lrf 7 ay önce
ebeveyn
işleme
b1d834ac94

+ 2 - 2
src/config/config.self.ts

@@ -1,7 +1,7 @@
 import { MidwayConfig } from '@midwayjs/core';
 import { DbSubscriber } from '../event/dbSubscriber';
 /**数据库ip */
-const ip = 'localhost'; //localhost
+const ip = '192.168.1.113'; //localhost
 /**数据库名 */
 const dbName = 'cxyy';
 /**日志数据库名 */
@@ -51,7 +51,7 @@ export default {
         port: 54321,
         entities: ['./entity'],
         type: 'postgres',
-        synchronize: true, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
+        synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
         logging: false,
         subscribers: [DbSubscriber],
       },

+ 33 - 0
src/controller/users/contactApply.controller.ts

@@ -80,6 +80,39 @@ export class ContactApplyController {
     return { data: nd, total };
   }
 
+  @Post('/sign', { routerName: `申请${namePrefix}-项目路演` })
+  @ApiTags('创建数据-申请路演')
+  async meetingCreate(@Body() data: any) {
+    /** 获取报名id(source_id),source为sign */
+    const source = get(data, 'source', 'sign');
+    let source_id: any = get(data, 'source_id');
+    const otherData = await this.service.searchCompleteData(source, source_id);
+    const sourceData = get(otherData, 'sourceData');
+    const source_user = get(sourceData, 'user');
+    const user_id = get(this.ctx, 'user.id');
+    if (user_id === source_user) throw new ServiceError(ErrorCode.CONTACTAPPLY_IS_THIS_USER_DATA); // 抛出异常: 来源数据是当前用户的数据
+    data.apply_user = user_id;
+    const userData = get(otherData, 'userData');
+    const target_user = get(userData, 'id');
+    data['target_user'] = target_user;
+    // 检查是否有未审核的申请
+    await this.service.checkHasApply(data);
+    /**创建申请数据 */
+    const dbData = await this.service.create(data);
+    const adminIds = await this.service.getSourceDept(source);
+    if (!adminIds) return; // 部门下无管理人员,请联系平台维护人员
+    try {
+      /**给这些管理员发送消息,通知他们去个人审核这个信息 */
+      const messageData = await this.service.getAdminToExamData(data, adminIds);
+      /**创建消息数据 */
+      const messageResult = await this.msgService.create(messageData);
+      const msgId = get(messageResult, 'id');
+      this.msgService.toSendMsg(msgId);
+    } catch (error) {
+      console.error('申请联系方式 消息创建失败');
+    }
+    return dbData;
+  }
   @Post('/', { routerName: `申请${namePrefix}` })
   @ApiTags('创建数据')
   @Validate()

+ 6 - 0
src/service/users/contactApply.service.ts

@@ -16,6 +16,7 @@ import { Incubator } from '../../entity/users/incubator.entity';
 import { Sector } from '../../entity/platform/sector.entity';
 import { Project } from '../../entity/platform/project.entity';
 import { Achievement } from '../../entity/platform/achievement.entity';
+import { Sign } from '../../entity/platform/sign.entity';
 
 @Provide()
 export class ContactApplyService extends BaseServiceV2 {
@@ -40,6 +41,8 @@ export class ContactApplyService extends BaseServiceV2 {
   incubator: Repository<Incubator>;
   @InjectEntityModel(Sector)
   sector: Repository<Sector>;
+  @InjectEntityModel(Sign)
+  sign: Repository<Sign>;
 
   @InjectEntityModel(Expert)
   expert: Repository<Expert>;
@@ -317,6 +320,9 @@ export class ContactApplyService extends BaseServiceV2 {
       case 'sector':
         str = '产业集群';
         break;
+      case 'sign':
+        str = '活动路演'
+        break;
       default:
         break;
     }