|
@@ -1,10 +1,8 @@
|
|
|
import { Provide } from '@midwayjs/decorator';
|
|
|
-import { GetModel } from 'free-midway-component';
|
|
|
import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
|
import { BaseService } from 'free-midway-component';
|
|
|
import { User } from '../../entity/system/user.entity';
|
|
|
-import { upperFirst } from 'lodash';
|
|
|
type modelType = ReturnModelType<typeof User>;
|
|
|
@Provide()
|
|
|
export class UserService extends BaseService<modelType> {
|
|
@@ -14,27 +12,8 @@ export class UserService extends BaseService<modelType> {
|
|
|
// 创建前判断是否是普通用户 普通用户不用审核直接通过
|
|
|
async createBefore(data) {
|
|
|
const { role } = data;
|
|
|
- if (role && role.length > 1) data.status = '0';
|
|
|
+ if (role && role === 'User') data.status = '0';
|
|
|
else data.status = '1';
|
|
|
return data;
|
|
|
}
|
|
|
-
|
|
|
- // 修改后判断是否有身份 如何审核通过将有身份的数据也审核成功
|
|
|
- async updateAfter(id, body) {
|
|
|
- const arr = await this.detail(id);
|
|
|
- const { status } = body;
|
|
|
- if (status === '1' && arr.role_type !== 'User') {
|
|
|
- const model = GetModel(upperFirst(arr.role_type));
|
|
|
- const user = await model.findOne({user:id}).lean();
|
|
|
- await model.updateOne({ _id: user._id }, { status: '1' });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- async detail(id) {
|
|
|
- const arr = await this.model.findById(id).lean();
|
|
|
- let role_type;
|
|
|
- if (arr && arr.role && arr.role.length > 1) role_type = arr.role[1];
|
|
|
- else role_type = arr.role[0];
|
|
|
- return { ...arr, role_type };
|
|
|
- }
|
|
|
}
|