新增 日志评论回复 发送小程序信息提醒
This commit is contained in:
parent
a8d9072a40
commit
96b6d2102a
@ -26,4 +26,8 @@ public interface SubscribeMessageSendApi {
|
|||||||
@PostMapping(PREFIX + "/send-company-notice")
|
@PostMapping(PREFIX + "/send-company-notice")
|
||||||
@Operation(summary = "发送公司公告通知")
|
@Operation(summary = "发送公司公告通知")
|
||||||
CommonResult<Long> sendCompanyNotice(@RequestBody SubscribeMessageReqDTO reqDTO);
|
CommonResult<Long> sendCompanyNotice(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/send-worklog-comment")
|
||||||
|
@Operation(summary = "发送日志评论、回复通知")
|
||||||
|
CommonResult<Long> sendWorkLogComment(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,13 @@ public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi {
|
|||||||
return success(1L);
|
return success(1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public CommonResult<Long> sendWorkLogComment(SubscribeMessageReqDTO reqDTO) {
|
||||||
|
socialClientService.getWxMaService().getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||||
|
return success(1L);
|
||||||
|
}
|
||||||
|
|
||||||
private WxMaSubscribeMessage initWxMaSubscribeMessage(SubscribeMessageReqDTO reqDTO) {
|
private WxMaSubscribeMessage initWxMaSubscribeMessage(SubscribeMessageReqDTO reqDTO) {
|
||||||
WxMaSubscribeMessage message = WxMaSubscribeMessage.builder()
|
WxMaSubscribeMessage message = WxMaSubscribeMessage.builder()
|
||||||
.toUser(reqDTO.getToUser())
|
.toUser(reqDTO.getToUser())
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.convert.worklog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.api.subscribe.dto.MsgData;
|
||||||
|
import cn.iocoder.yudao.module.system.api.subscribe.dto.SubscribeMessageReqDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.comment.WorkLogCommentDO;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface LogCommentConvert {
|
||||||
|
|
||||||
|
LogCommentConvert INSTANCE = Mappers.getMapper(LogCommentConvert.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param openId 微信小程序唯一id
|
||||||
|
* @param logCommentDO 评论对象
|
||||||
|
* @param nickname 发布人姓名
|
||||||
|
* @param miniProgramState 小程序的状态
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default SubscribeMessageReqDTO convertLogComment(String openId, WorkLogCommentDO logCommentDO, String nickname, String miniProgramState) {
|
||||||
|
|
||||||
|
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||||
|
message.setToUser(openId);
|
||||||
|
message.setTemplateId("fH29xjNb8pe-7onQ-wE3QrBAC-y8aaC_oosYZKNMtzM");
|
||||||
|
|
||||||
|
//消息类型
|
||||||
|
MsgData noticeType = new MsgData();
|
||||||
|
noticeType.setName("phrase8");
|
||||||
|
if (logCommentDO.getType()) {
|
||||||
|
noticeType.setValue("评论回复");
|
||||||
|
}else {
|
||||||
|
noticeType.setValue("日志评论");
|
||||||
|
}
|
||||||
|
message.addData(noticeType);
|
||||||
|
|
||||||
|
//发送人
|
||||||
|
MsgData publishMan = new MsgData();
|
||||||
|
publishMan.setName("thing16");
|
||||||
|
publishMan.setValue(nickname);
|
||||||
|
message.addData(publishMan);
|
||||||
|
|
||||||
|
//发送时间
|
||||||
|
MsgData createTime = new MsgData();
|
||||||
|
createTime.setName("time3");
|
||||||
|
createTime.setValue(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
|
||||||
|
message.addData(createTime);
|
||||||
|
|
||||||
|
//消息内容
|
||||||
|
MsgData content = new MsgData();
|
||||||
|
String comment = logCommentDO.getComment();
|
||||||
|
content.setName("thing2");
|
||||||
|
if (comment.length() > 10) {
|
||||||
|
comment = comment.substring(0,10) + ". . . . ";
|
||||||
|
}
|
||||||
|
content.setValue(comment);
|
||||||
|
message.addData(content);
|
||||||
|
|
||||||
|
message.setMiniprogramState(miniProgramState);
|
||||||
|
message.setPage("/subPages/notice/detail?id=");
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
@ -5,15 +5,21 @@ import cn.hutool.json.JSONObject;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.api.subscribe.SubscribeMessageSendApi;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
|
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentPageListVO;
|
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentPageListVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentTypeCountVO;
|
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentTypeCountVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.convert.worklog.LogCommentConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.comment.WorkLogCommentDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.comment.WorkLogCommentDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogFormDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogFormDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.comment.WorkLogCommentMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.comment.WorkLogCommentMapper;
|
||||||
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import cn.iocoder.yudao.module.system.service.worklog.LogFormService;
|
import cn.iocoder.yudao.module.system.service.worklog.LogFormService;
|
||||||
|
import cn.iocoder.yudao.module.system.service.worklog.LogInstanceService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -21,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -39,6 +46,15 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
|
|||||||
@Resource
|
@Resource
|
||||||
private LogFormService logFormService;
|
private LogFormService logFormService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LogInstanceService logInstanceService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SubscribeMessageSendApi subscribeMessageSendApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createWorkLogComment(WorkLogCommentSaveReqVO createReqVO) {
|
public Long createWorkLogComment(WorkLogCommentSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@ -46,6 +62,10 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
|
|||||||
Long userId = WebFrameworkUtils.getLoginUserId();
|
Long userId = WebFrameworkUtils.getLoginUserId();
|
||||||
workLogComment.setUserId(userId);
|
workLogComment.setUserId(userId);
|
||||||
workLogCommentMapper.insert(workLogComment);
|
workLogCommentMapper.insert(workLogComment);
|
||||||
|
|
||||||
|
//创建评论、回复后, 发送消息通知
|
||||||
|
sendMessage(workLogComment);
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return workLogComment.getId();
|
return workLogComment.getId();
|
||||||
}
|
}
|
||||||
@ -134,4 +154,26 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
|
|||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论或回复 发送消息通知
|
||||||
|
*/
|
||||||
|
private void sendMessage(WorkLogCommentDO workLogComment) {
|
||||||
|
|
||||||
|
//获得日志详情
|
||||||
|
LogInstanceRespVO instanceDO = logInstanceService.getLogInstance(workLogComment.getWorkLogId());
|
||||||
|
|
||||||
|
//获得 用户信息Map
|
||||||
|
Map<Long, AdminUserDO> userMap = userService.getUserMap(Arrays.asList(instanceDO.getStartUserId(), workLogComment.getUserId()));
|
||||||
|
|
||||||
|
String openId = userMap.get(instanceDO.getStartUserId()).getOpenId();
|
||||||
|
|
||||||
|
if (openId != null) {
|
||||||
|
|
||||||
|
//发送消息通知
|
||||||
|
subscribeMessageSendApi.sendCompanyNotice(LogCommentConvert.INSTANCE.convertLogComment(
|
||||||
|
openId, workLogComment, userMap.get(workLogComment.getUserId()).getNickname(),
|
||||||
|
"formal"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user