wks hace 2 años
padre
commit
c1e57d7053

+ 4 - 0
src/main/java/com/ydtech/modules/protocol/entity/vo/PtlInsAttributionTemplateQueryVo.java

@@ -17,4 +17,8 @@ public class PtlInsAttributionTemplateQueryVo extends BasePageVO {
     @ApiModelProperty("保险公司ID")
     private String insCompanyId;
 
+    @ApiModelProperty("接口类型")
+    private String apiType;
+
+
 }

+ 14 - 2
src/main/java/com/ydtech/modules/protocol/service/impl/PtlInsAttributionTemplateServiceImpl.java

@@ -13,6 +13,7 @@ import com.ydtech.modules.protocol.entity.constants.PtlApiType;
 import com.ydtech.modules.protocol.entity.dto.PtlInsAttributionTemplateQueryDto;
 import com.ydtech.modules.protocol.entity.po.PtlCrawlerApi;
 import com.ydtech.modules.protocol.entity.po.PtlInsAttributionTemplate;
+import com.ydtech.modules.protocol.entity.vo.PtlCrawlerApiSaveVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateQueryVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateSaveVo;
 import com.ydtech.modules.protocol.entity.vo.PtlInsAttributionTemplateVo;
@@ -104,7 +105,8 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
     public HttpResult<BasePageResult<PtlInsAttributionTemplate>> getAll(PtlInsAttributionTemplateQueryVo queryVo) {
         Page<PtlInsAttributionTemplate> pageQuery = new Page<>(queryVo.getPageNum(), queryVo.getPageSize());
         LambdaQueryWrapper<PtlInsAttributionTemplate> queryWrapper = new LambdaQueryWrapper<PtlInsAttributionTemplate>()
-                .eq(!StringUtils.isNullOrEmpty(queryVo.getInsCompanyId()), PtlInsAttributionTemplate::getInsCompanyId, queryVo.getInsCompanyId());
+                .eq(!StringUtils.isNullOrEmpty(queryVo.getInsCompanyId()), PtlInsAttributionTemplate::getInsCompanyId, queryVo.getInsCompanyId())
+                .eq(!StringUtils.isNullOrEmpty(queryVo.getApiType()), PtlInsAttributionTemplate::getApiType, queryVo.getApiType());
         Page<PtlInsAttributionTemplate> page = page(pageQuery, queryWrapper);
         BasePageResult<PtlInsAttributionTemplate> pageResult = new BasePageResult<>(queryVo.getPageNum(), page.getSize(), page.getTotal(), page.getPages(), page.getRecords());
         return HttpResult.ok("succeed", pageResult);
@@ -127,13 +129,23 @@ public class PtlInsAttributionTemplateServiceImpl extends ServiceImpl<PtlInsAttr
         EsmInsCompany esmInsCompany = esmInsCompanyService.isExists(ptlInsAttributionTemplateSaveVo.getInsCompanyId());
         PtlInsAttributionTemplate ptlInsAttributionTemplate = new PtlInsAttributionTemplate(ptlInsAttributionTemplateSaveVo, esmInsCompany.getNamesimple());
         ptlInsAttributionTemplate.setId(id);
-
         LambdaQueryWrapper<PtlInsAttributionTemplate> wrapper = byInsCompanyIdAndApiType(ptlInsAttributionTemplateSaveVo.getInsCompanyId(), ptlInsAttributionTemplateSaveVo.getApiType());
         PtlInsAttributionTemplate ptlInsAttributionTemplateOne = getOne(wrapper);
         if (!ObjectUtils.isEmpty(ptlInsAttributionTemplateOne) && !Objects.equals(ptlInsAttributionTemplateOne.getId(), id)) {
             throw new SystemException("一个保险公司,一种api方式只能配置一种");
         }
 
+        if (PtlApiType.PTL_API_2.getCode() == ptlInsAttributionTemplateSaveVo.getApiType()) {
+            LambdaQueryWrapper<PtlCrawlerApi> crawlerApiWrapper = new LambdaQueryWrapper<>();
+            crawlerApiWrapper.eq(PtlCrawlerApi::getTemplateId, ptlInsAttributionTemplate.getId());
+            ptlCrawlerApiService.remove(crawlerApiWrapper);
+
+            // 保存请求链接
+            List<PtlCrawlerApi> ptlCrawlerApiList = PtlCrawlerApi.toPtlCrawlerApiList(ptlInsAttributionTemplate.getId(), ptlInsAttributionTemplateSaveVo.getApi());
+            boolean b = ptlCrawlerApiService.saveBatch(ptlCrawlerApiList);
+            AssertionUtils.isSucceed(b, "保险公司api请求插入失败");
+        }
+
         boolean b = updateById(ptlInsAttributionTemplate);
         AssertionUtils.isSucceed(b, "保险公司归属信息模板修改失败");
         return HttpResult.ok("修改成功");