zs 1 year ago
parent
commit
7cf8b5cd86

+ 5 - 0
src/controller/users/association.controller.ts

@@ -4,12 +4,16 @@ import { AssociationService } from '../../service/users/association.service';
 import { CDTO_association, CVO_association, FVO_association, QDTO_association, QVO_association, UDTO_association, UVAO_association } from '../../interface/users/association.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['商协会'])
 @Controller('/association')
 export class AssociationController extends BaseController {
   @Inject()
   service: AssociationService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_association })
@@ -45,6 +49,7 @@ export class AssociationController extends BaseController {
   @ApiResponse({ type: UVAO_association })
   async update(@Param('id') id: string, @Body() body: UDTO_association) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Association');
     return result;
   }
 

+ 5 - 0
src/controller/users/company.controller.ts

@@ -4,12 +4,16 @@ import { CompanyService } from '../../service/users/company.service';
 import { CDTO_company, CVO_company, FVO_company, QDTO_company, QVO_company, UDTO_company, UVAO_company } from '../../interface/users/company.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['企业'])
 @Controller('/company')
 export class CompanyController extends BaseController {
   @Inject()
   service: CompanyService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_company })
@@ -52,6 +56,7 @@ export class CompanyController extends BaseController {
   @ApiResponse({ type: UVAO_company })
   async update(@Param('id') id: string, @Body() body: UDTO_company) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Company');
     return result;
   }
 

+ 5 - 0
src/controller/users/competition.controller.ts

@@ -4,12 +4,16 @@ import { CompetitionService } from '../../service/users/competition.service';
 import { CDTO_competition, CVO_competition, FVO_competition, QDTO_competition, QVO_competition, UDTO_competition, UVAO_competition } from '../../interface/users/competition.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['创业大赛'])
 @Controller('/competition')
 export class CompetitionController extends BaseController {
   @Inject()
   service: CompetitionService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_competition })
@@ -45,6 +49,7 @@ export class CompetitionController extends BaseController {
   @ApiResponse({ type: UVAO_competition })
   async update(@Param('id') id: string, @Body() body: UDTO_competition) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Competition');
     return result;
   }
 

+ 5 - 0
src/controller/users/expert.controller.ts

@@ -4,12 +4,16 @@ import { ExpertService } from '../../service/users/expert.service';
 import { CDTO_expert, CVO_expert, FVO_expert, QDTO_expert, QVO_expert, UDTO_expert, UVAO_expert } from '../../interface/users/expert.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['专家'])
 @Controller('/expert')
 export class ExpertController extends BaseController {
   @Inject()
   service: ExpertService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_expert })
@@ -52,6 +56,7 @@ export class ExpertController extends BaseController {
   @ApiResponse({ type: UVAO_expert })
   async update(@Param('id') id: string, @Body() body: UDTO_expert) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Expert');
     return result;
   }
 

+ 5 - 0
src/controller/users/incubator.controller.ts

@@ -4,12 +4,16 @@ import { IncubatorService } from '../../service/users/incubator.service';
 import { CDTO_incubator, CVO_incubator, FVO_incubator, QDTO_incubator, QVO_incubator, UDTO_incubator, UVAO_incubator } from '../../interface/users/incubator.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['孵化器'])
 @Controller('/incubator')
 export class IncubatorController extends BaseController {
   @Inject()
   service: IncubatorService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_incubator })
@@ -45,6 +49,7 @@ export class IncubatorController extends BaseController {
   @ApiResponse({ type: UVAO_incubator })
   async update(@Param('id') id: string, @Body() body: UDTO_incubator) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Incubator');
     return result;
   }
 

+ 5 - 0
src/controller/users/investment.controller.ts

@@ -4,12 +4,16 @@ import { InvestmentService } from '../../service/users/investment.service';
 import { CDTO_investment, CVO_investment, FVO_investment, QDTO_investment, QVO_investment, UDTO_investment, UVAO_investment } from '../../interface/users/investment.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['投资人'])
 @Controller('/investment')
 export class InvestmentController extends BaseController {
   @Inject()
   service: InvestmentService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_investment })
@@ -45,6 +49,7 @@ export class InvestmentController extends BaseController {
   @ApiResponse({ type: UVAO_investment })
   async update(@Param('id') id: string, @Body() body: UDTO_investment) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Investment');
     return result;
   }
 

+ 5 - 0
src/controller/users/state.controller.ts

@@ -4,12 +4,16 @@ import { StateService } from '../../service/users/state.service';
 import { CDTO_state, CVO_state, FVO_state, QDTO_state, QVO_state, UDTO_state, UVAO_state } from '../../interface/users/state.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['政府部门'])
 @Controller('/state')
 export class StateController extends BaseController {
   @Inject()
   service: StateService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_state })
@@ -45,6 +49,7 @@ export class StateController extends BaseController {
   @ApiResponse({ type: UVAO_state })
   async update(@Param('id') id: string, @Body() body: UDTO_state) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'State');
     return result;
   }
 

+ 5 - 0
src/controller/users/unit.controller.ts

@@ -4,12 +4,16 @@ import { UnitService } from '../../service/users/unit.service';
 import { CDTO_unit, CVO_unit, FVO_unit, QDTO_unit, QVO_unit, UDTO_unit, UVAO_unit } from '../../interface/users/unit.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { UtilService } from '../../service/util.service';
 @ApiTags(['科研机构'])
 @Controller('/unit')
 export class UnitController extends BaseController {
   @Inject()
   service: UnitService;
 
+  @Inject()
+  utilService: UtilService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_unit })
@@ -45,6 +49,7 @@ export class UnitController extends BaseController {
   @ApiResponse({ type: UVAO_unit })
   async update(@Param('id') id: string, @Body() body: UDTO_unit) {
     const result = await this.service.updateOne(id, body);
+    await this.utilService.updateUserAfter(id, body, 'Unit');
     return result;
   }
 

+ 18 - 0
src/service/util.service.ts

@@ -1,7 +1,25 @@
 import { Provide } from '@midwayjs/decorator';
+import { GetModel } from 'free-midway-component';
+import { InjectEntityModel } from '@midwayjs/typegoose';
+import { ReturnModelType } from '@typegoose/typegoose';
+import { upperFirst } from 'lodash';
+import { User } from '../entity/system/user.entity';
 @Provide()
 export class UtilService {
+  @InjectEntityModel(User)
+  uModel: ReturnModelType<typeof User>;
+
   randomStr(len = 6) {
     return Math.random().toString(36).slice(-len);
   }
+
+  // 修改后信息后用户重新审核
+  async updateUserAfter(id, body, role_type) {
+    const { status } = body;
+    if (status === '0') {
+      const model = GetModel(upperFirst(role_type));
+      const data = await model.findById(id).lean();
+      await this.uModel.updateOne({ _id: data.user }, { status: '0' });
+    }
+  }
 }