diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index b6e2b73907..d78c96140e 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -61,6 +61,7 @@ spring: - Path=${server.servlet.context-path}/message/** filters: - StripPrefix=1 + - CpAuth=true #工作流服务 - id: epmet-activiti-server uri: @gateway.routes.epmet-activiti-server.uri@ diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxMsgAuthInfoFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxMsgAuthInfoFormDTO.java new file mode 100644 index 0000000000..11d70e506d --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxMsgAuthInfoFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class WxMsgAuthInfoFormDTO { + + public interface SaveSysAuthInfoGroup {} + + @NotBlank(message = "客户id不能为空", groups = { SaveSysAuthInfoGroup.class }) + private String customerId; + + @NotBlank(message = "客户端类型不能为空", groups = { SaveSysAuthInfoGroup.class }) + private String clientType; + + @NotBlank(message = "是否总是字段不能为空", groups = { SaveSysAuthInfoGroup.class }) + private String alwaysVisit; + + @NotBlank(message = "是否去订阅字段不能为空", groups = { SaveSysAuthInfoGroup.class }) + private String subscribeStatus; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/WxMsgAuthInfoResultDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/WxMsgAuthInfoResultDTO.java new file mode 100644 index 0000000000..13988b5411 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/WxMsgAuthInfoResultDTO.java @@ -0,0 +1,41 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class WxMsgAuthInfoResultDTO { + /** + * 客户Id 客户Id + */ + private String customerId; + + /** + * 所属端类型 居民端:resi 工作端:work + */ + private String clientType; + + /** + * 用户Id 用户Id + */ + private String userId; + + /** + * 是否总是访问 是:yes 否:no + */ + private String alwaysVisit; + + /** + * 订阅状态 订阅状态(订阅:subscribe 取消订阅:unsubscribe) + */ + private String subscribeStatus; + + /** + * wx是否总是访问 是:yes 否:no + */ + private String wxAlwaysVisit; + + /** + * wx订阅状态 订阅状态(订阅:subscribe 取消订阅:unsubscribe) + */ + private String wxSubscribeStatus; +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java index 294f0f5d36..57441016b3 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java @@ -17,10 +17,13 @@ package com.epmet.controller; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.WxMsgAuthInfoFormDTO; import com.epmet.service.WxmpMessageService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** @@ -36,4 +39,27 @@ public class WxmpMessageController { @Autowired private WxmpMessageService wxmpMessageService; + @Autowired + private LoginUserUtil loginUserUtil; + + /** + * @Description 保存系统自身的弹框授权信息 + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2020.10.21 17:32 + */ + @PostMapping("save-sys-authorizeinfo") + public Result saveSysAuthorizationInfo(@RequestBody WxMsgAuthInfoFormDTO form) { + ValidatorUtils.validateEntity(form, WxMsgAuthInfoFormDTO.SaveSysAuthInfoGroup.class); + + String alwaysVisit = form.getAlwaysVisit(); + String clientType = form.getClientType(); + String customerId = form.getCustomerId(); + String subscribeStatus = form.getSubscribeStatus(); + + wxmpMessageService.saveSysAuthorizeInfo(customerId, clientType, alwaysVisit, subscribeStatus, loginUserUtil.getLoginUserId()); + + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpTemplateMsgSubscribeStatusDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpTemplateMsgSubscribeStatusDao.java index 9f99225746..df2764868c 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpTemplateMsgSubscribeStatusDao.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpTemplateMsgSubscribeStatusDao.java @@ -18,8 +18,10 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.WxMsgAuthInfoResultDTO; import com.epmet.entity.WxmpTemplateMsgSubscribeStatusEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 用户模板消息订阅授权状态表(记录我们自己和微信的授权页用户勾选的状态) @@ -29,5 +31,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface WxmpTemplateMsgSubscribeStatusDao extends BaseDao { - + + WxMsgAuthInfoResultDTO getUserSubscribeStatusDTO(@Param("userId") String userId, + @Param("customerId") String customerId, + @Param("clientType") String clientType); + + WxmpTemplateMsgSubscribeStatusEntity getUserSubscribeStatusEntity(@Param("userId") String userId, + @Param("customerId") String customerId, + @Param("clientType") String clientType); } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java index ab96dd6f0d..25d631e1c9 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java @@ -25,4 +25,5 @@ package com.epmet.service; */ public interface WxmpMessageService { + void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId); } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java index 75b784b5e6..7192a0e1bf 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java @@ -17,9 +17,12 @@ package com.epmet.service.impl; +import com.epmet.dao.WxmpTemplateMsgSubscribeStatusDao; +import com.epmet.entity.WxmpTemplateMsgSubscribeStatusEntity; import com.epmet.service.WxmpMessageService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -32,4 +35,31 @@ import org.springframework.stereotype.Service; public class WxmpMessageServiceImpl implements WxmpMessageService { private Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired + private WxmpTemplateMsgSubscribeStatusDao msgSubscribeStatusDao; + + /** + * @Description 保存系统授权信息 + * @return void + * @author wxz + * @date 2020.10.21 17:29 + */ + @Override + public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId) { + WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType); + if (userSubscribeStatusEntity != null) { + userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit); + userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus); + msgSubscribeStatusDao.updateById(userSubscribeStatusEntity); + return; + } + + userSubscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity(); + userSubscribeStatusEntity.setCustomerId(customerId); + userSubscribeStatusEntity.setClientType(clientType); + userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit); + userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus); + userSubscribeStatusEntity.setUserId(userId); + msgSubscribeStatusDao.insert(userSubscribeStatusEntity); + } } \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpTemplateMsgSubscribeStatusDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpTemplateMsgSubscribeStatusDao.xml index b226ddb20a..d1fde2360a 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpTemplateMsgSubscribeStatusDao.xml +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpTemplateMsgSubscribeStatusDao.xml @@ -3,6 +3,45 @@ + - + \ No newline at end of file