zs 8 месяцев назад
Родитель
Сommit
c4df6e4082
2 измененных файлов с 35 добавлено и 0 удалено
  1. 15 0
      src/controller/system/user.controller.ts
  2. 20 0
      src/service/system/role.service.ts

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

@@ -6,6 +6,7 @@ import { omit, pick } from 'lodash';
 import { ErrorCode, ServiceError } from '../../error/service.error';
 import { UserService } from '../../service/system/user.service';
 import { CVO_user, FVO_user, QVO_user, UVAO_user } from '../../interface/system/user.interface';
+import { RoleService } from '../../service/system/role.service';
 const namePrefix = '平台用户';
 @ApiTags(['平台用户'])
 @Controller('/user', { tagName: namePrefix })
@@ -14,6 +15,9 @@ export class UserController implements BaseController {
   @Inject()
   service: UserService;
 
+  @Inject()
+  roleService: RoleService;
+
   @Get('/')
   @ApiTags('列表查询')
   @ApiQuery({ name: 'query' })
@@ -25,6 +29,17 @@ export class UserController implements BaseController {
     return result;
   }
 
+  @Get('/list')
+  async list(@Query() query: object) {
+    const qobj = omit(query, ['skip', 'limit']);
+    const others = pick(query, ['skip', 'limit']);
+    const { data, total } = await this.service.query(qobj, others);
+    for (let i of data) {
+      i = await this.roleService.Isaudit(i);
+    }
+    return { data, total };
+  }
+
   @Get('/:id')
   @ApiTags('单查询')
   @ApiResponse({ type: FVO_user })

+ 20 - 0
src/service/system/role.service.ts

@@ -80,6 +80,26 @@ export class RoleService extends BaseServiceV2 {
     return list;
   }
 
+  // 判断用户角色是否审核成功
+  async Isaudit(data) {
+    const { id, role } = data;
+    const list = [];
+    for (const val of role) {
+      const tModel = this[val];
+      const roleInfo = await this.model.findOne({ where: { code: Equal(val), is_use: Equal('0') } });
+      if (tModel) {
+        const info: any = {};
+        if (val !== 'Admin' && val !== 'User') {
+          const result = await tModel.findOne({ where: { user: Equal(id), status: Equal('1') } });
+          if (!result) info.title = `${roleInfo.name}(未审核)`;
+          list.push(info);
+        }
+      }
+    }
+    data.is_audit = list;
+    return data;
+  }
+
   //是否是超级管理员
   async isSuperAdmin() {
     const user = this.ctx.user;