11 changed files with 168 additions and 2 deletions
@ -0,0 +1,59 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @description: 微信订阅消息FormDTO |
|||
* @author: liushaowen |
|||
* @date: 2020/10/21 14:29 |
|||
*/ |
|||
@Data |
|||
public class WxmpMessagePushFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
@NotBlank(message = "客户id不能为空") |
|||
private String customerId; |
|||
/** |
|||
* 客户端类型 居民端:resi 工作端:work |
|||
*/ |
|||
@NotBlank(message = "客户端类型不能为空") |
|||
private String clientType; |
|||
|
|||
/** |
|||
* 接收者(用户)的 userId |
|||
*/ |
|||
@NotBlank(message = "接收用户id不能为空") |
|||
private String userId; |
|||
|
|||
/** |
|||
* 行为类型(存title字段的中间值) 入组申请、党员认证等 |
|||
*/ |
|||
@NotBlank(message = "行为类型不能为空") |
|||
private String behaviorType; |
|||
|
|||
/** |
|||
* 消息内容 |
|||
*/ |
|||
@NotBlank(message = "消息内容不能为空") |
|||
private String messageContent; |
|||
|
|||
/** |
|||
* 网格id-居民端用 |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 调用方 |
|||
*/ |
|||
@NotBlank(message = "调用方不能为空") |
|||
private String referer; |
|||
|
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.form.WxmpMessagePushFormDTO; |
|||
import com.epmet.service.WxmpMessageExtService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: 外部调用微信订阅controller |
|||
* @author: liushaowen |
|||
* @date: 2020/11/2 14:51 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("template") |
|||
public class WxmpMessageExtController { |
|||
@Autowired |
|||
private WxmpMessageExtService wxmpMessageExtService; |
|||
|
|||
@PostMapping("wxmpmsgpush") |
|||
public Result wxmpMsgPush(@RequestBody List<WxmpMessagePushFormDTO> dtos){ |
|||
for (WxmpMessagePushFormDTO dto : dtos) { |
|||
ValidatorUtils.validateEntity(dto); |
|||
} |
|||
return wxmpMessageExtService.pushWxmpMessage(dtos); |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.WxmpMessagePushFormDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface WxmpMessageExtService { |
|||
Result pushWxmpMessage(List<WxmpMessagePushFormDTO> dto); |
|||
} |
@ -0,0 +1,43 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.form.WxSubscribeMessageFormDTO; |
|||
import com.epmet.dto.form.WxmpMessagePushFormDTO; |
|||
import com.epmet.service.WxmpMessageExtService; |
|||
import com.epmet.service.WxmpMessageService; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: liushaowen |
|||
* @date: 2020/11/2 14:54 |
|||
*/ |
|||
@Service |
|||
public class WxmpMessageExtServiceImpl implements WxmpMessageExtService { |
|||
@Autowired |
|||
private WxmpMessageService wxmpMessageService; |
|||
|
|||
@Override |
|||
public Result pushWxmpMessage(List<WxmpMessagePushFormDTO> dtos) { |
|||
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>(); |
|||
for (WxmpMessagePushFormDTO dto : dtos) { |
|||
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO(); |
|||
try{ |
|||
BeanUtils.copyProperties(dto,wxSubscribeMessageFormDTO); |
|||
wxSubscribeMessageFormDTO.setMessageTime(new Date()); |
|||
msgList.add(wxSubscribeMessageFormDTO); |
|||
}catch (Exception e){ |
|||
throw new RenException("转换bean失败"); |
|||
} |
|||
} |
|||
wxmpMessageService.sendWxSubscribeMessage(msgList); |
|||
return new Result(); |
|||
} |
|||
} |
@ -0,0 +1 @@ |
|||
ALTER TABLE wxmp_msg_send_record ADD REFERER VARCHAR(20) COMMENT '调用者'; |
Loading…
Reference in new issue