feature:
修改账号接口返回结构 修改部分账号接口逻辑
This commit is contained in:
@@ -2,6 +2,7 @@ import { COUNTER } from './../consts/consts';
|
||||
import { CounterModel } from './Counter';
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
import { genCode } from 'app/pubUtils/util';
|
||||
|
||||
/**
|
||||
* 用户字段接口
|
||||
@@ -16,6 +17,9 @@ export default class User extends BaseModel {
|
||||
@prop({ required: true })
|
||||
username: string;
|
||||
|
||||
@prop({ required: true })
|
||||
userCode: string; // 用户唯一字符串标识
|
||||
|
||||
@prop({ required: true })
|
||||
token: string;
|
||||
|
||||
@@ -65,8 +69,9 @@ export default class User extends BaseModel {
|
||||
let update = {};
|
||||
if (!user) {
|
||||
const uid = await CounterModel.getNewCounter(COUNTER.UID);
|
||||
const userCode = genCode(8);
|
||||
const doc = new UserModel();
|
||||
update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, username: `用户${uid}` }, doc.toJSON());
|
||||
update = Object.assign(update, { platform, pkgName, serverType, createTime: curTime, uid, userCode, username: `用户${uid}` }, doc.toJSON());
|
||||
}
|
||||
update = Object.assign(update, { token, lastLoginTime: curTime });
|
||||
user = await UserModel.findOneAndUpdate({ tel }, update, { upsert: true, new: true }).lean(lean);
|
||||
|
||||
Reference in New Issue
Block a user