Revert "✨ feat(db): 修改role表数据库操作方式"

This reverts commit e39af3649288cc5802739cfe862c818fe56e194e.
This commit is contained in:
luying
2023-05-22 19:43:21 +08:00
parent 2d45b2c66c
commit 7bc9e1fe49
79 changed files with 423 additions and 423 deletions
+8 -8
View File
@@ -1,6 +1,6 @@
import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, BLOCK_TYPE, DEBUG_MAGIC_WORD } from '@consts';
import Role, { RoleModel, WarStar } from '@db/Role';
import { RoleModel, WarStar } from '@db/Role';
import { UserModel, UserType } from '@db/User';
import { STATUS, GET_SMS_TYPE, ADDICTION_PREVENTION_CODE } from '@consts';
import { smsModel } from '@db/Sms';
@@ -307,7 +307,7 @@ export default class Auth extends Service {
let canLogin = await this.ctx.service.utils.validateCanLogin();
if(!canLogin) return this.ctx.service.utils.resResult(STATUS.ONLINE_USER_MAX);
const role = await Role.findByUid(uid, serverId, 'roleId blockType +closeTime');
const role = await RoleModel.findByUid(uid, serverId, 'roleId blockType +closeTime');
if (role) {
if(role.blockType == BLOCK_TYPE.BLOCK) {
return ctx.service.utils.resResult(STATUS.BLOCKED);
@@ -336,7 +336,7 @@ export default class Auth extends Service {
const code = ctx.service.utils.genCode(6);
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
const role = await Role.createRole(uid, serverId, { roleId, code, roleName: "默认玩家名", seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 }, distinctId);
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName: "默认玩家名", seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 }, distinctId);
if (role) {
if(server.isReview) { // 审核服跳关卡
await this.skipPrologueWhenReview(roleId);
@@ -356,7 +356,7 @@ export default class Auth extends Service {
if(i < toWarId) warStars.push({ id: dicWar.war_id, warType: dicWar.warType, star: 0, stars: [] });
}
await RScriptRecordModel.insertScripts(roleId, insertParams, [toWarId]);
await Role.updateRoleInfo(roleId, { warStar: warStars, mainWarId: toWarId - 1 })
await RoleModel.updateRoleInfo(roleId, { warStar: warStars, mainWarId: toWarId - 1 })
}
/**
@@ -485,12 +485,12 @@ export default class Auth extends Service {
public async closeAccount(roleId: string) {
const ctx = this.ctx;
let role = await Role.findByRoleId(roleId, '+closeTime +cancelCloseTime userInfo');
let role = await RoleModel.findByRoleId(roleId, '+closeTime +cancelCloseTime userInfo');
if(!role || role.userInfo.uid != ctx.uid ) return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
if(role.cancelCloseTime > 0 && role.cancelCloseTime + 24 * 60 * 60 > nowSeconds() )
return ctx.service.utils.resResult(STATUS.ROLE_CLOSE_COOL_DOWN, `注销冷却中,请${this.getCdTimeStr(role.cancelCloseTime)}后再试`);
if(role.closeTime > 0) return ctx.service.utils.resResult(STATUS.ROLE_CLOSED);
role = await Role.closeAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
role = await RoleModel.closeAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
}
@@ -504,10 +504,10 @@ export default class Auth extends Service {
public async cancelCloseAccount(roleId: string) {
const ctx = this.ctx;
let role = await Role.findByRoleId(roleId, '+cancelCloseTime userInfo');
let role = await RoleModel.findByRoleId(roleId, '+cancelCloseTime userInfo');
if(!role || role.userInfo.uid != ctx.uid ) return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
role = await Role.cancelCloseAccount(roleId, nowSeconds());
role = await RoleModel.cancelCloseAccount(roleId, nowSeconds());
if(!role) return ctx.service.utils.resResult(STATUS.ROLE_CLOSE_TIME_OVER);
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
}