zs 8 月之前
父節點
當前提交
b60a38108a
共有 2 個文件被更改,包括 57 次插入3 次删除
  1. 8 0
      src/controller/system/role.controller.ts
  2. 49 3
      src/service/system/role.service.ts

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

@@ -32,6 +32,14 @@ export class RoleController implements BaseController {
     return { data: list, total };
   }
 
+  @Get('/prove')
+  @ApiTags('用户认证')
+  @ApiResponse({ type: QVO_role })
+  async prove(@Query() query: object) {
+    const data = await this.service.prove(query);
+    return data;
+  }
+
   @Get('/:id')
   @ApiTags('单查询')
   @ApiResponse({ type: FVO_role })

+ 49 - 3
src/service/system/role.service.ts

@@ -1,14 +1,22 @@
 import { Inject, Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { In, Repository } from 'typeorm';
+import { Equal, Repository } from 'typeorm';
 import { Role } from '../../entity/system/role.entity';
 import { Context } from '@midwayjs/koa';
 import { AdminService } from './admin.service';
-import { compact, flattenDeep, get, isArray, last, lowerFirst, uniq, upperFirst } from 'lodash';
+import { compact, flattenDeep, get, last, lowerFirst, uniq, upperFirst } from 'lodash';
 import { DeptService } from './dept.service';
 import { MenusService } from './menus.service';
 import { BaseServiceV2 } from '../../frame/BaseServiceV2';
 import { UserMenusService } from './userMenus.service';
+import { Investment } from '../../entity/users/investment.entity';
+import { State } from '../../entity/users/state.entity';
+import { Association } from '../../entity/users/association.entity';
+import { Competition } from '../../entity/users/competition.entity';
+import { Incubator } from '../../entity/users/incubator.entity';
+import { Company } from '../../entity/users/company.entity';
+import { Unit } from '../../entity/users/unit.entity';
+import { Expert } from '../../entity/users/expert.entity';
 @Provide()
 export class RoleService extends BaseServiceV2 {
   @InjectEntityModel(Role)
@@ -26,11 +34,49 @@ export class RoleService extends BaseServiceV2 {
   @Inject()
   userMenusService: UserMenusService;
 
+  @InjectEntityModel(Investment)
+  Investment: Repository<Investment>;
+  @InjectEntityModel(State)
+  State: Repository<State>;
+  @InjectEntityModel(Association)
+  Association: Repository<Association>;
+  @InjectEntityModel(Competition)
+  Competition: Repository<Competition>;
+  @InjectEntityModel(Incubator)
+  Incubator: Repository<Incubator>;
+  @InjectEntityModel(Company)
+  Company: Repository<Company>;
+  @InjectEntityModel(Expert)
+  Expert: Repository<Expert>;
+  @InjectEntityModel(Unit)
+  Unit: Repository<Unit>;
+
   @Inject()
   ctx: Context;
   getQueryColumnsOpera(): object {
     return {};
   }
+
+  // 用户认证
+  async prove(query) {
+    const { user } = query;
+    const roleList = await this.model.find({ where: { is_use: Equal('0') } });
+    const list = [];
+    for (const val of roleList) {
+      const tModel = this[val.code];
+      if (tModel) {
+        const info: any = val;
+        if (val.code !== 'Admin' && val.code !== 'User') {
+          const result = await tModel.findOne({ where: { user: Equal(user), status: Equal('1') } });
+          if (result) info.title = `${val.name}(已认证)`;
+          else info.title = `${val.name}(未认证)`;
+          list.push(val);
+        }
+      }
+    }
+    return list;
+  }
+
   //是否是超级管理员
   async isSuperAdmin() {
     const user = this.ctx.user;
@@ -85,7 +131,7 @@ export class RoleService extends BaseServiceV2 {
   /**
    * 获取用户菜单
    * @param needCode 是否只需要编码
-   * @returns 
+   * @returns
    */
   async getUserMenus(needCode = false) {
     const user = this.ctx.user;