zs před 1 rokem
rodič
revize
c2fff2ff8d

+ 0 - 8
src/controller/system/user.controller.ts

@@ -41,20 +41,12 @@ export class UserController extends BaseController {
     return result;
   }
 
-  @Get('/detail/:id')
-  @ApiResponse({ type: FVO_user })
-  async detail(@Param('id') id: string) {
-    const data = await this.service.detail(id);
-    const result = new FVO_user(data);
-    return result;
-  }
 
   @Post('/:id')
   @Validate()
   @ApiResponse({ type: UVAO_user })
   async update(@Param('id') id: string, @Body() body: UDTO_user) {
     const result = await this.service.updateOne(id, body);
-    await this.service.updateAfter(id, body);
     return result;
   }
 

+ 1 - 1
src/entity/system/user.entity.ts

@@ -30,7 +30,7 @@ export class User extends BaseModel {
   @prop({ required: false, index: true, zh: '电子邮箱' })
   email: string;
   @prop({ required: false, index: false, zh: '角色' })
-  role: Array<any>;
+  role: string;
   @prop({ required: false, index: true, zh: '状态', default: '1' })
   status: string;
 }

+ 3 - 3
src/interface/system/user.interface.ts

@@ -29,7 +29,7 @@ export class FVO_user {
   @ApiProperty({ description: '角色类型' })
   'role_type': string = undefined;
   @ApiProperty({ description: '角色' })
-  'role': Array<any> = undefined;
+  'role': string = undefined;
   @ApiProperty({ description: '状态' })
   'status': string = undefined;
 }
@@ -80,8 +80,8 @@ export class CDTO_user {
   @Rule(RuleType['string']().empty(''))
   'email': string = undefined;
   @ApiProperty({ description: '角色' })
-  @Rule(RuleType['array']().empty(''))
-  'role': Array<any> = undefined;
+  @Rule(RuleType['string']().empty(''))
+  'role': string = undefined;
   @ApiProperty({ description: '状态' })
   @Rule(RuleType['string']().empty(''))
   'status': string = undefined;

+ 1 - 22
src/service/system/user.service.ts

@@ -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 };
-  }
 }