Browse Source

联系申请,无目标用户也可以申请,由管理员填写,相似度匹配添加来源数据id

lrf 7 tháng trước cách đây
mục cha
commit
583e8ca4f2

+ 7 - 4
src/controller/users/contactApply.controller.ts

@@ -101,10 +101,12 @@ export class ContactApplyController {
     /**组织数据,填充联系方式申请表:将被申请方的id填充 */
     const userData = get(otherData, 'userData');
     // 如果是在跳过检查列表中的申请,则不需要target_user.直接由管理员审核
+    // 09-20修改: 没有target_user也允许,由管理员去填写内容
     if (!skipCheckList.includes(source)) {
-      if (!userData) throw new ServiceError(ErrorCode.CONTACTAPPLY_TARGET_USER_NOT_FOUND);
-      const target_user = get(userData, 'id');
-      data['target_user'] = target_user;
+      if (userData) {
+        const target_user = get(userData, 'id');
+        data['target_user'] = target_user;
+      }
     }
     // 检查是否有未审核的申请
     await this.service.checkHasApply(data);
@@ -115,8 +117,9 @@ export class ContactApplyController {
       // 没有keyword,无法计算匹配度,不用继续往下了.
       if (!keyword) throw new ServiceError(ErrorCode.CONTACTAPPLY_NO_KEYWORD); //抛出异常: 无关键词,无法进行匹配计算
       // 查询匹配度
-      const result = await this.esService.getCS(keyword, source);
+      const result = await this.esService.getCS(keyword, source, source_id);
       if (!result) throw new ServiceError(ErrorCode.CONTACTAPPLY_MATCHING_NOT_ENOUGH); // 抛出异常,无匹配度到4星,无法进行预约
+      return;
     }
     /**创建申请数据 */
     const dbData = await this.service.create(data);

+ 3 - 2
src/service/elasticsearch/es.service.ts

@@ -89,9 +89,10 @@ export class ESService {
    * 计算匹配度
    * @param keyword 查询关键词
    * @param index 表
+   * @param source_id 数据id
    */
-  async getCS(keyword, index) {
-    const csUrl = `${this.esServiceHttpPrefix}/cs/${index}?keyword=${keyword}`;
+  async getCS(keyword, index, source_id) {
+    const csUrl = `${this.esServiceHttpPrefix}/cs/${index}?keyword=${keyword}&id=${source_id}`;
     let res;
     const token = get(this.ctx.request, 'header.token')
     try {