diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java index 9dbabbfdbe..2fb11064f0 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java @@ -22,6 +22,10 @@ public class CustomerTemplateListFormDTO implements Serializable { */ @NotBlank(message="公共模板Id不能为空", groups = {AddUserInternalGroup.class}) private String publicId; + /** + * 模板关键词Id + */ + private String keyIds; public interface AddUserInternalGroup {} } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java index 09fb259376..8bde81adf2 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java @@ -26,6 +26,10 @@ public class GetTemplateListFormDTO implements Serializable { * 模板类型(站内信提醒) */ private String templateType; + /** + * 模板关键词Id + */ + private String keyIds; public interface AddUserInternalGroup {} } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java index 6e229dc052..c89ed2aeba 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java @@ -94,4 +94,15 @@ public interface PersonalTemplateDao extends BaseDao { * @author sun */ List selectCustomerTemplateList(CustomerTemplateListFormDTO formDTO); + + /** + * 根据tid和keyIds查询是否已存在该模板类型数据 + * @author zhaoqifeng + * @date 2020/11/2 10:31 + * @param appId + * @param tid + * @param keyIds + * @return java.util.List + */ + List selectListByKey(@Param("appId") String appId, @Param("tid") String tid, @Param("keyIds") String keyIds); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java index f3f0da9b49..1d69a7b16a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java @@ -141,4 +141,15 @@ public interface PersonalTemplateService extends BaseService customerTemplateList(CustomerTemplateListFormDTO formDTO); + + /** + * 根据tid和keyIds查询是否已存在该模板类型数据 + * @author zhaoqifeng + * @date 2020/11/2 10:29 + * @param appId + * @param tid + * @param keyIds + * @return java.util.List + */ + List getListByKey(String appId, String tid, String keyIds); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java index 154cca9082..6aac8fdc8f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java @@ -127,6 +127,7 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl templateList(GetTemplateListFormDTO formDTO) { + formDTO.setKeyIds("5,4,2"); //根据客户Id、appId、模板类型查询小程序订阅消息模板列表 return baseDao.selectTemplateList(formDTO); } @@ -138,7 +139,23 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl customerTemplateList(CustomerTemplateListFormDTO formDTO) { + formDTO.setKeyIds("5,4,2"); return baseDao.selectCustomerTemplateList(formDTO); } + /** + * 根据tid和keyIds查询是否已存在该模板类型数据 + * + * @param appId + * @param tid + * @param keyIds + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/2 10:29 + */ + @Override + public List getListByKey(String appId, String tid, String keyIds) { + return baseDao.selectListByKey(appId, tid, keyIds); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java index 1521aa508a..4596bcf589 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java @@ -180,6 +180,11 @@ public class SubscribeServiceImpl implements SubscribeService { String keywords = String.join(",", formDTO.getNameList()); List keyIdList = formDTO.getKidList().stream().map(Object::toString).collect(Collectors.toList()); String keyIds = String.join(",", keyIdList); + //根据tid和keyIds查询是否已存在该模板类型数据 + List list = personalTemplateService.getListByKey(formDTO.getAppId(), formDTO.getTid(), keyIds); + if (null != list && list.size() > NumConstant.ZERO) { + throw new RenException(formDTO.getTitle() + "已存在所选关键词[" + keywords + "]的模板"); + } //将公共模板存入数据库 PersonalTemplateDTO personalTemplateDTO = new PersonalTemplateDTO(); personalTemplateDTO.setCustomerId(authInfo.getCustomerId()); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml index 7eab9a2e63..97452fa3b9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml @@ -86,7 +86,8 @@ AND customer_id = #{customerId} AND app_id = #{appId} AND title = #{templateType} - ORDER BY CREATED_TIME DESC + AND key_ids = '5,4,2' + ORDER BY created_time ASC + \ No newline at end of file