16 changed files with 601 additions and 7 deletions
@ -0,0 +1,29 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 政府端wxmp-未读消息查询入参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:17 |
|||
*/ |
|||
@Data |
|||
public class StaffMessageCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = 6926536123515417293L; |
|||
|
|||
/** |
|||
* 当前登录的工作人员,从token中获取 |
|||
*/ |
|||
@NotBlank(message="用户id不能为空") |
|||
private String userId; |
|||
|
|||
/** |
|||
* 用户当前访问的网格对应的客户id |
|||
*/ |
|||
@NotBlank(message="客户id不能为空") |
|||
private String customerId; |
|||
} |
|||
|
@ -0,0 +1,39 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.Min; |
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 政府端wxmp-查询我的消息 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:50 |
|||
*/ |
|||
@Data |
|||
public class StaffMessageFormDTO implements Serializable { |
|||
/** |
|||
* 当前登录的工作人员,从token中获取 |
|||
*/ |
|||
@NotBlank(message="用户id不能为空") |
|||
private String userId; |
|||
|
|||
/** |
|||
* 用户当前访问的网格对应的客户id |
|||
*/ |
|||
@NotBlank(message="客户id不能为空") |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 页码 |
|||
*/ |
|||
@Min(1) |
|||
private Integer pageNo; |
|||
|
|||
/** |
|||
* 每页显示条数 |
|||
*/ |
|||
private Integer pageSize = 20; |
|||
} |
|||
|
@ -0,0 +1,39 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 政府端wxmp-查询我的消息返参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:52 |
|||
*/ |
|||
@Data |
|||
public class StaffMessageResultDTO implements Serializable { |
|||
/** |
|||
* 消息id |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 消息标题 |
|||
*/ |
|||
private String title; |
|||
|
|||
/** |
|||
* 消息内容 |
|||
*/ |
|||
private String messageContent; |
|||
|
|||
/** |
|||
* read已读、unread未读 |
|||
*/ |
|||
private String readFlag; |
|||
|
|||
/** |
|||
* 通知时间 |
|||
*/ |
|||
private Long createdTime; |
|||
} |
|||
|
@ -0,0 +1,19 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 政府端wxmp-未读消息查询返参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:19 |
|||
*/ |
|||
@Data |
|||
public class StaffUnReadMsgResultDTO implements Serializable { |
|||
/** |
|||
* 未读消息总数 |
|||
*/ |
|||
private Integer unReadCount; |
|||
} |
|||
|
@ -0,0 +1,19 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description 单条消息标记为已读入参 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 15:56 |
|||
*/ |
|||
@Data |
|||
public class StaffReadMsgFormDTO implements Serializable { |
|||
@NotBlank(message = "消息id不能为空") |
|||
private String messageId; |
|||
|
|||
} |
|||
|
@ -0,0 +1,98 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.form.StaffMessageCommonFormDTO; |
|||
import com.epmet.dto.form.StaffMessageFormDTO; |
|||
import com.epmet.dto.form.StaffReadMsgFormDTO; |
|||
import com.epmet.dto.result.StaffMessageResultDTO; |
|||
import com.epmet.dto.result.StaffUnReadMsgResultDTO; |
|||
import com.epmet.service.StaffMessageService; |
|||
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 政府端小程序首页,我的消息 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:11 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("message") |
|||
public class StaffMessageController { |
|||
|
|||
@Autowired |
|||
private StaffMessageService staffMessageService; |
|||
|
|||
/** |
|||
* @param tokenDto |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.StaffUnReadMsgResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 未读消息查询 |
|||
* @Date 2020/5/17 15:48 |
|||
**/ |
|||
@PostMapping("unreadmsg") |
|||
public Result<StaffUnReadMsgResultDTO> unReadMsg(@LoginUser TokenDto tokenDto, |
|||
@RequestBody StaffMessageCommonFormDTO formDTO) { |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
StaffUnReadMsgResultDTO staffUnReadMsgResultDTO = staffMessageService.queryUnReadMsg(formDTO); |
|||
return new Result<StaffUnReadMsgResultDTO>().ok(staffUnReadMsgResultDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param tokenDto |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.StaffMessageResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 查询我的消息 |
|||
* @Date 2020/5/17 15:48 |
|||
**/ |
|||
@PostMapping("mymessage") |
|||
public Result<List<StaffMessageResultDTO>> myMessage(@LoginUser TokenDto tokenDto, |
|||
@RequestBody StaffMessageFormDTO formDTO) { |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
List<StaffMessageResultDTO> staffMessageResultDTO = staffMessageService.queryStaffMessage(formDTO); |
|||
return new Result<List<StaffMessageResultDTO>>().ok(staffMessageResultDTO); |
|||
} |
|||
|
|||
/** |
|||
* @param tokenDto |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 全部已读(清楚未读) |
|||
* @Date 2020/5/17 15:52 |
|||
**/ |
|||
@PostMapping("readall") |
|||
public Result readAll(@LoginUser TokenDto tokenDto, |
|||
@RequestBody StaffMessageCommonFormDTO formDTO) { |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
staffMessageService.readAllMessage(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result |
|||
* @Author yinzuomei |
|||
* @Description 单条消息标记为已读 |
|||
* @Date 2020/5/17 15:57 |
|||
**/ |
|||
@PostMapping("readmsg") |
|||
public Result readMessage(@RequestBody StaffReadMsgFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO); |
|||
staffMessageService.readMessage(formDTO); |
|||
return new Result(); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,64 @@ |
|||
package com.epmet.feign; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.UserMessageDTO; |
|||
import com.epmet.dto.form.StaffMessageCommonFormDTO; |
|||
import com.epmet.dto.form.StaffMessageFormDTO; |
|||
import com.epmet.dto.result.StaffMessageResultDTO; |
|||
import com.epmet.dto.result.StaffUnReadMsgResultDTO; |
|||
import com.epmet.feign.fallback.EpmetMessageFeignClientFallBack; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/4/7 14:55 |
|||
*/ |
|||
@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageFeignClientFallBack.class) |
|||
public interface EpmetMessageFeignClient { |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.result.StaffUnReadMsgResultDTO> |
|||
* @Author yinzuomei |
|||
* @Description 查询未读消息 |
|||
* @Date 2020/5/17 16:10 |
|||
**/ |
|||
@PostMapping("/message/usermessage/staff/queryunreadmsg") |
|||
Result<StaffUnReadMsgResultDTO> queryUnReadMsg(@RequestBody StaffMessageCommonFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.StaffMessageResultDTO>> |
|||
* @Author yinzuomei |
|||
* @Description 查询我的消息列表 |
|||
* @Date 2020/5/17 16:10 |
|||
**/ |
|||
@PostMapping("/message/usermessage/staff/querystaffmessage") |
|||
Result<List<StaffMessageResultDTO>> queryStaffMessage(@RequestBody StaffMessageFormDTO formDTO); |
|||
|
|||
/** |
|||
* 单条消息已读 |
|||
* |
|||
* @param messageDTO 参数 |
|||
* @return Result |
|||
*/ |
|||
@PostMapping("/message/usermessage/readmsg") |
|||
Result readMessage(@RequestBody UserMessageDTO messageDTO); |
|||
|
|||
/** |
|||
* 消息全部已读 |
|||
* |
|||
* @param messageDTO 参数 |
|||
* @return Result |
|||
*/ |
|||
@PostMapping("/message/usermessage/readall") |
|||
Result readAllMessage(@RequestBody UserMessageDTO messageDTO); |
|||
|
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
package com.epmet.feign.fallback; |
|||
|
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.utils.ModuleUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.UserMessageDTO; |
|||
import com.epmet.dto.form.StaffMessageCommonFormDTO; |
|||
import com.epmet.dto.form.StaffMessageFormDTO; |
|||
import com.epmet.dto.result.StaffMessageResultDTO; |
|||
import com.epmet.dto.result.StaffUnReadMsgResultDTO; |
|||
import com.epmet.feign.EpmetMessageFeignClient; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2020/4/7 14:58 |
|||
*/ |
|||
@Component |
|||
public class EpmetMessageFeignClientFallBack implements EpmetMessageFeignClient { |
|||
|
|||
@Override |
|||
public Result<StaffUnReadMsgResultDTO> queryUnReadMsg(StaffMessageCommonFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "queryUnReadMsg", formDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result<List<StaffMessageResultDTO>> queryStaffMessage(StaffMessageFormDTO formDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "queryStaffMessage", formDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result readMessage(UserMessageDTO messageDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "readMessage", messageDTO); |
|||
} |
|||
|
|||
@Override |
|||
public Result readAllMessage(UserMessageDTO messageDTO) { |
|||
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "allRead", messageDTO); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.form.StaffMessageCommonFormDTO; |
|||
import com.epmet.dto.form.StaffMessageFormDTO; |
|||
import com.epmet.dto.form.StaffReadMsgFormDTO; |
|||
import com.epmet.dto.result.StaffMessageResultDTO; |
|||
import com.epmet.dto.result.StaffUnReadMsgResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 政府端小程序首页,我的消息 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:12 |
|||
*/ |
|||
public interface StaffMessageService { |
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.dto.result.StaffUnReadMsgResultDTO |
|||
* @Author yinzuomei |
|||
* @Description 查询未读消息 |
|||
* @Date 2020/5/17 15:58 |
|||
**/ |
|||
StaffUnReadMsgResultDTO queryUnReadMsg(StaffMessageCommonFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.dto.result.StaffMessageResultDTO |
|||
* @Author yinzuomei |
|||
* @Description 查询我的消息 |
|||
* @Date 2020/5/17 15:58 |
|||
**/ |
|||
List<StaffMessageResultDTO> queryStaffMessage(StaffMessageFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return void |
|||
* @Author yinzuomei |
|||
* @Description 清除未读 |
|||
* @Date 2020/5/17 15:58 |
|||
**/ |
|||
void readAllMessage(StaffMessageCommonFormDTO formDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return void |
|||
* @Author yinzuomei |
|||
* @Description 单条已读 |
|||
* @Date 2020/5/17 15:58 |
|||
**/ |
|||
void readMessage(StaffReadMsgFormDTO formDTO); |
|||
} |
@ -0,0 +1,73 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dto.UserMessageDTO; |
|||
import com.epmet.dto.form.StaffMessageCommonFormDTO; |
|||
import com.epmet.dto.form.StaffMessageFormDTO; |
|||
import com.epmet.dto.form.StaffReadMsgFormDTO; |
|||
import com.epmet.dto.result.StaffMessageResultDTO; |
|||
import com.epmet.dto.result.StaffUnReadMsgResultDTO; |
|||
import com.epmet.feign.EpmetMessageFeignClient; |
|||
import com.epmet.service.StaffMessageService; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Description 政府端小程序首页,我的消息 |
|||
* @Author yinzuomei |
|||
* @Date 2020/5/17 14:12 |
|||
*/ |
|||
@Service |
|||
public class StaffMessageServiceImpl implements StaffMessageService { |
|||
private Logger logger = LoggerFactory.getLogger(getClass()); |
|||
@Autowired |
|||
private EpmetMessageFeignClient epmetMessageFeignClient; |
|||
|
|||
|
|||
@Override |
|||
public StaffUnReadMsgResultDTO queryUnReadMsg(StaffMessageCommonFormDTO formDTO) { |
|||
StaffUnReadMsgResultDTO staffUnReadMsgResultDTO = new StaffUnReadMsgResultDTO(); |
|||
staffUnReadMsgResultDTO.setUnReadCount(0); |
|||
Result<StaffUnReadMsgResultDTO> result = epmetMessageFeignClient.queryUnReadMsg(formDTO); |
|||
if (result.success() && null != result.getData()) { |
|||
return result.getData(); |
|||
} |
|||
return staffUnReadMsgResultDTO; |
|||
} |
|||
|
|||
@Override |
|||
public List<StaffMessageResultDTO> queryStaffMessage(StaffMessageFormDTO formDTO) { |
|||
Result<List<StaffMessageResultDTO>> result = epmetMessageFeignClient.queryStaffMessage(formDTO); |
|||
if (result.success() && null != result.getData() && result.getData().size() > 0) { |
|||
return result.getData(); |
|||
} |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
@Override |
|||
public void readAllMessage(StaffMessageCommonFormDTO formDTO) { |
|||
UserMessageDTO userMessageDTO = new UserMessageDTO(); |
|||
userMessageDTO.setUserId(formDTO.getUserId()); |
|||
userMessageDTO.setCustomerId(formDTO.getCustomerId()); |
|||
Result result = epmetMessageFeignClient.readAllMessage(userMessageDTO); |
|||
if (result.success()) { |
|||
logger.info(String.format("客户id:%s,staffId:%s清除未读消息成功", formDTO.getCustomerId(), formDTO.getUserId())); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void readMessage(StaffReadMsgFormDTO formDTO) { |
|||
UserMessageDTO userMessageDTO = new UserMessageDTO(); |
|||
userMessageDTO.setId(formDTO.getMessageId()); |
|||
Result result = epmetMessageFeignClient.readMessage(userMessageDTO); |
|||
if (result.success()) { |
|||
logger.info(String.format("消息id:%s置为已读", formDTO.getMessageId())); |
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue