Commit 5b686d57 by danmo

企业群发记录功能重构

1 parent b4cc912c
Showing 27 changed files with 489 additions and 181 deletions
package com.linkwechat.web.controller.wecom;
import com.github.pagehelper.PageInfo;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import com.linkwechat.wecom.domain.vo.WeGroupMessageListVo;
import com.linkwechat.wecom.service.IWeGroupMessageListService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 群发消息列Controller
*
* @author ruoyi
* @date 2021-10-19
*/
@Api(tags = "群发消息管理")
@RestController
@RequestMapping("/wecom/group/message")
public class WeGroupMessageListController extends BaseController {
@Autowired
private IWeGroupMessageListService iWeGroupMessageListService;
/**
* 查询群发消息列列表
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:group:message:list')")
@GetMapping("/list")
public TableDataInfo<WeGroupMessageListVo> list(WeGroupMessageList weGroupMessageList) {
startPage();
PageInfo<WeGroupMessageListVo> listPageInfo = iWeGroupMessageListService.queryList(weGroupMessageList);
return getDataTable(listPageInfo);
}
/**
* 导出群发消息列列表
*/
@PreAuthorize("@ss.hasPermi('linkwechat:group:message:list:export')")
@Log(title = "群发消息列", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeGroupMessageList weGroupMessageList) {
PageInfo<WeGroupMessageListVo> listPageInfo = iWeGroupMessageListService.queryList(weGroupMessageList);
ExcelUtil<WeGroupMessageListVo> util = new ExcelUtil<>(WeGroupMessageListVo.class);
return util.exportExcel(listPageInfo.getList(), "list");
}
/**
* 获取群发消息列详细信息
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:group:message:list:query')")
@GetMapping(value = "/{msgId}")
public AjaxResult<WeGroupMessageDetailVo> getInfo(@PathVariable("msgId") String msgId) {
return AjaxResult.success(iWeGroupMessageListService.getGroupMsgDetail(msgId));
}
/**
* 新增群发消息列
*/
@PreAuthorize("@ss.hasPermi('linkwechat:group:message:list:add')")
@Log(title = "群发消息列", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WeGroupMessageList weGroupMessageList) {
return toAjax(iWeGroupMessageListService.save(weGroupMessageList) ? 1 : 0);
}
/**
* 修改群发消息列
*/
@PreAuthorize("@ss.hasPermi('linkwechat:group:message:list:edit')")
@Log(title = "群发消息列", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WeGroupMessageList weGroupMessageList) {
return toAjax(iWeGroupMessageListService.updateById(weGroupMessageList) ? 1 : 0);
}
/**
* 删除群发消息列
*/
@PreAuthorize("@ss.hasPermi('linkwechat:group:message:list:remove')")
@Log(title = "群发消息列", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(iWeGroupMessageListService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
}
}
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import com.linkwechat.wecom.domain.vo.WeGroupMessageListVo;
import com.linkwechat.wecom.service.IWeGroupMessageTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 群发消息模板Controller
*
* @author ruoyi
* @date 2021-10-27
*/
@Api(tags = "群发消息管理")
@RestController
@RequestMapping("/wecom/groupmsg/template")
public class WeGroupMessageTemplateController extends BaseController {
@Autowired
private IWeGroupMessageTemplateService iWeGroupMessageTemplateService;
/**
* 查询群发消息模板列表
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:list')")
@ApiOperation(value = "查询群发消息模板列表", httpMethod = "GET")
@GetMapping("/list")
public TableDataInfo<WeGroupMessageTemplate> list(WeGroupMessageTemplate weGroupMessageTemplate) {
startPage();
List<WeGroupMessageTemplate> list = iWeGroupMessageTemplateService.queryList(weGroupMessageTemplate);
return getDataTable(list);
}
/**
* 获取群发消息模板详细信息
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:query')")
@ApiOperation(value = "获取群发消息模板详细信息", httpMethod = "GET")
@GetMapping(value = "/{id}")
public AjaxResult<WeGroupMessageDetailVo> getGroupMsgTemplateDetail(@PathVariable("id") Long id) {
return AjaxResult.success(iWeGroupMessageTemplateService.getGroupMsgTemplateDetail(id));
}
/**
* 新增群发消息模板
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:add')")
@ApiOperation(value = "新增群发消息模板", httpMethod = "POST")
@Log(title = "群发消息模板", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult addGroupMsgTemplate(@RequestBody WeAddGroupMessageQuery query) {
iWeGroupMessageTemplateService.addGroupMsgTemplate(query);
return AjaxResult.success();
}
/**
* 删除群发消息模板
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:remove')")
@ApiOperation(value = "删除群发消息模板", httpMethod = "DELETE")
@Log(title = "群发消息模板", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(iWeGroupMessageTemplateService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
}
}
......@@ -408,4 +408,7 @@ public class WeConstans {
* 会话消息订阅的频道
*/
public static final String CONVERSATION_MSG_CHANNEL = "CONVERSATION_MSG_CHANNEL";
public static final String WEGROUPMSGTIMEDTASK_KEY = "weGroupMessageTimedTask";
}
......@@ -5,24 +5,28 @@ import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.enums.MessageType;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.message.SendMessageResultDto;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.query.WeAddMsgTemplateQuery;
import com.linkwechat.wecom.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author danmo
......@@ -48,6 +52,12 @@ public class PullGroupMessageTask {
@Autowired
private IWeMaterialService weMaterialService;
@Autowired
private WeCustomerMessagePushClient customerMessagePushClient;
@Autowired
private RedisCache redisCache;
/**
* 同步开始时间
*/
......@@ -245,4 +255,48 @@ public class PullGroupMessageTask {
groupMessageTaskService.addOrUpdateBatchByCondition(taskList);
sendResultService.addOrUpdateBatchByCondition(sendResultlist);
}
public void groupMessageTaskHandler(){
Long cacheZSetSize = redisCache.getCacheZSetSize(WeConstans.WEGROUPMSGTIMEDTASK_KEY);
if(cacheZSetSize > 0){
Set<ZSetOperations.TypedTuple<String>> typedTuples = redisCache.rangeWithScore(WeConstans.WEGROUPMSGTIMEDTASK_KEY, 0, 0);
typedTuples.forEach(item -> {
long score = Objects.requireNonNull(item.getScore()).longValue();
if(score < System.currentTimeMillis()){
//当时间小于当前时间时删除第一个记录,并发送群发消息
log.info("获取到消息,执行群发任务: {}",item.getValue());
redisCache.removeCacheZSet(WeConstans.WEGROUPMSGTIMEDTASK_KEY,item.getValue());
WeAddGroupMessageQuery query = JSONObject.parseObject(item.getValue(), WeAddGroupMessageQuery.class);
List<WeAddGroupMessageQuery.SenderInfo> senderList = query.getSenderList();
List<WeGroupMessageList> weGroupMessageLists = new ArrayList<>();
senderList.forEach(sender ->{
WeAddMsgTemplateQuery templateQuery = new WeAddMsgTemplateQuery();
templateQuery.setChat_type(query.getChatType());
templateQuery.setSender(sender.getUserId());
if(ObjectUtil.equal(1,query.getChatType())){
templateQuery.setExternal_userid(sender.getCustomerList());
}
templateQuery.setAttachments(query.getAttachmentsList());
if(StringUtils.isNotEmpty(query.getContent())){
WeAddMsgTemplateQuery.Text text = new WeAddMsgTemplateQuery.Text();
text.setContent(query.getContent());
templateQuery.setText(text);
}
SendMessageResultDto resultDto = customerMessagePushClient.addMsgTemplate(templateQuery);
if(resultDto != null && ObjectUtil.equal(WeConstans.WE_SUCCESS_CODE,resultDto.getErrcode())){
String msgid = resultDto.getMsgid();
Long msgTemplateId = query.getId();
WeGroupMessageList messageList = new WeGroupMessageList();
messageList.setMsgId(msgid);
weGroupMessageLists.add(messageList);
groupMessageListService.update(messageList,new LambdaQueryWrapper<WeGroupMessageList>()
.eq(WeGroupMessageList::getMsgTemplateId,msgTemplateId)
.eq(WeGroupMessageList::getUserId,sender.getUserId()));
}
});
}
});
}
}
}
......@@ -57,6 +57,15 @@ public interface WeUserClient {
* @param fetchChild
* @return
*/
@Request(url="/user/simplelist")
WeUserListDto simpleList(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
/**
* 获取部门成员
* @param departmentId
* @param fetchChild
* @return
*/
@Request(url="/user/list")
WeUserListDto list(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
......
......@@ -28,6 +28,13 @@ public class WeGroupMessageAttachments extends BaseEntity{
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/** 企业群发消息的id */
@ApiModelProperty("企业群发消息的id")
@Excel(name = "企业群发消息的id")
......
......@@ -35,6 +35,14 @@ public class WeGroupMessageList extends BaseEntity{
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/**
* 企业群发消息的id
*/
......@@ -52,7 +60,7 @@ public class WeGroupMessageList extends BaseEntity{
/**
* 群发消息创建者userid
*/
@ApiModelProperty("群发消息创建者userid")
@ApiModelProperty(value = "群发消息创建者userid", hidden = true)
@Excel(name = "群发消息创建者userid")
private String userId;
......@@ -67,28 +75,14 @@ public class WeGroupMessageList extends BaseEntity{
/**
* 群发消息创建来源。0:企业 1:个人
*/
@ApiModelProperty("群发消息创建来源。0:企业 1:个人")
@ApiModelProperty(value = "群发消息创建来源。0:企业 1:个人",hidden = true)
@Excel(name = "群发消息创建来源。0:企业 1:个人")
private Integer createType;
/**
* 是否定时任务 0 常规 1 定时发送
*/
@ApiModelProperty("是否定时任务 0 常规 1 定时发送")
@Excel(name = "是否定时任务 0 常规 1 定时发送")
private Integer isTask;
/**
* 是否执行 0 未执行 1 已执行
*/
@ApiModelProperty("是否执行 0 未执行 1 已执行")
@Excel(name = "是否执行 0 未执行 1 已执行")
private Integer isExecute;
private Integer createType = 0;
/**
* 群发消息创建者
*/
@ApiModelProperty("群发消息创建者")
@ApiModelProperty(value = "群发消息创建者",hidden = true)
@TableField(exist = false)
private String userName;
}
......@@ -35,6 +35,14 @@ public class WeGroupMessageSendResult extends BaseEntity{
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/**
* 企业群发消息的id
*/
......
......@@ -36,6 +36,13 @@ public class WeGroupMessageTask extends BaseEntity{
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/**
* 企业群发消息的id
*/
@ApiModelProperty("企业群发消息的id")
......
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 群发消息模板对象 we_group_message_template
*
* @author ruoyi
* @date 2021-10-27
*/
@ApiModel
@Data
@TableName("we_group_message_template")
public class WeGroupMessageTemplate extends BaseEntity {
/**
* 主键id
*/
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发任务的类,1:表示发送给客户,2:表示发送给客户群
*/
@ApiModelProperty("群发任务的类,1:表示发送给客户,2:表示发送给客户群")
@Excel(name = "群发任务的类,1:表示发送给客户,2:表示发送给客户群")
private Integer chatType;
/**
* 群发内容
*/
@ApiModelProperty("群发内容")
@Excel(name = "群发内容")
private String content;
/**
* 发送时间
*/
@ApiModelProperty("发送时间")
@Excel(name = "发送时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
/**
* 条件筛选
*/
@ApiModelProperty("条件筛选")
@Excel(name = "条件筛选")
private String filterCondition;
/**
* 是否定时任务 0 立即发送 1 定时发送
*/
@ApiModelProperty("是否定时任务 0 立即发送 1 定时发送")
@Excel(name = "是否定时任务 0 立即发送 1 定时发送")
private Integer isTask;
/**
* 状态 -1:失败 0:未执行 1:完成 2:取消
*/
@ApiModelProperty("状态 -1:失败 0:未执行 1:完成 2:取消")
@Excel(name = "是否执行 -1:失败 0:未执行 1:完成 2:取消")
private Integer status;
}
package com.linkwechat.wecom.domain.query;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author sxw
* @description 添加群发消息入参
* @date 2021/10/24 12:14
**/
@ApiModel
@Data
public class WeAddGroupMessageQuery extends WeGroupMessageTemplate {
/**
* 指定接收消息的成员及对应客户列表
*/
@ApiModelProperty("指定接收消息的成员及对应客户列表")
private List<SenderInfo> senderList;
@ApiModelProperty("附件列表")
private List<WeMessageTemplate> attachmentsList;
@ApiModel
@Data
public static class SenderInfo {
@ApiModelProperty("成员id")
private String userId;
@ApiModelProperty("客户列表")
private List<String> customerList;
@ApiModelProperty("群组列表")
private List<String> chatList;
}
}
......@@ -36,6 +36,17 @@ public class WeAddMsgTemplateQuery {
@ApiModelProperty("附件,最多支持添加9个附件 ru")
private List<Attachments> attachments;
public void setChat_type(String chat_type) {
this.chat_type = chat_type;
}
public void setChat_type(Integer chatType) {
if(ObjectUtil.equal(2,chatType)){
this.chat_type = "group";
}else {
this.chat_type = "single";
}
}
public void setAttachments(List<WeMessageTemplate> messageTemplates) {
final int size = 9;
......
package com.linkwechat.wecom.domain.vo;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import io.swagger.annotations.ApiModel;
......@@ -17,7 +16,7 @@ import java.util.List;
**/
@ApiModel
@Data
public class WeGroupMessageDetailVo extends WeGroupMessageList {
public class WeGroupMessageDetailVo {
/**
* 附件
*/
......@@ -25,14 +24,14 @@ public class WeGroupMessageDetailVo extends WeGroupMessageList {
private List<WeGroupMessageAttachments> attachments;
/**
* 发送者
* 待发送者列表
*/
@ApiModelProperty("发送者信息")
private List<WeGroupMessageTask> senders;
@ApiModelProperty("待发送者列表")
private List<WeGroupMessageTaskVo> toBeSentList;
/**
* 发送客户
* 已发送者列表
*/
@ApiModelProperty("接收者信息")
private List<WeGroupMessageSendResult> extralInfos;
@ApiModelProperty("已发送者列表")
private List<WeGroupMessageTaskVo> alreadySentList;
}
package com.linkwechat.wecom.domain.vo;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -11,28 +11,31 @@ import java.util.List;
/**
* @author sxw
* @description 群发列表出参
* @date 2021/10/23 15:27
* @description 群发详情出参
* @date 2021/10/23 15:09
**/
@ApiModel
@Data
public class WeGroupMessageListVo extends WeGroupMessageList {
@ApiModelProperty("发送成员总数")
@Excel(name = "发送成员总数")
private Integer senderTotalNums;
public class WeGroupMessageListVo {
@ApiModelProperty("待发送成员数")
@Excel(name = "待发送成员数")
private Integer senderNums;
private String msgTemplateId;
@ApiModelProperty("待发送客户数")
@Excel(name = "待发送客户数")
private Integer serviceMember;
@ApiModelProperty("发送客户总数")
@Excel(name = "发送客户总数")
private Integer serviceTotalMember;
/**
* 附件
*/
@ApiModelProperty("附件")
private List<WeGroupMessageAttachments> attachments;
/**
* 发送者
*/
@ApiModelProperty("发送者信息")
private List<WeGroupMessageTask> senders;
/**
* 发送客户
*/
@ApiModelProperty("接收者信息")
private List<WeGroupMessageSendResult> extralInfos;
}
package com.linkwechat.wecom.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author sxw
* @description 群发成员任务出参
* @date 2021/10/23 15:09
**/
@ApiModel
@Data
public class WeGroupMessageTaskVo {
/**
* 企业服务人员的userid
*/
@ApiModelProperty("企业服务人员的userid")
private String userId;
/**
* 企业服务人员的名称
*/
@ApiModelProperty("企业服务人员的名称")
private String userName;
/**
* 发送时间
*/
@ApiModelProperty("发送时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date sendTime;
/**
* 发送客户列表
*/
@ApiModelProperty("发送客户列表")
private List<String> customerList;
/**
* 发送群列表
*/
@ApiModelProperty("发送群列表")
private List<String> groupList;
}
......@@ -2,7 +2,7 @@ package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import com.linkwechat.wecom.domain.vo.WeGroupMessageListVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -18,10 +18,8 @@ public interface WeGroupMessageListMapper extends BaseMapper<WeGroupMessageList>
/**
* 查询群发消息详情
* @param msgIds
* @param msgTemplateIds 消息模板id列表
* @return
*/
List<WeGroupMessageDetailVo> getGroupMsgDetails(@Param("msgIds") List<String> msgIds);
WeGroupMessageDetailVo getGroupMsgDetail(@Param("msgId") String msgId);
List<WeGroupMessageListVo> getGroupMsgDetails(@Param("msgTemplateIds") List<Long> msgTemplateIds);
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
/**
* 群发消息模板Mapper接口
*
* @author ruoyi
* @date 2021-10-27
*/
public interface WeGroupMessageTemplateMapper extends BaseMapper<WeGroupMessageTemplate> {
}
package com.linkwechat.wecom.service;
import com.github.pagehelper.PageInfo;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import com.linkwechat.wecom.domain.vo.WeGroupMessageListVo;
import java.util.List;
......@@ -16,12 +14,6 @@ import java.util.List;
* @date 2021-10-19
*/
public interface IWeGroupMessageListService extends IService<WeGroupMessageList> {
/**
* 查询列表
*/
PageInfo<WeGroupMessageListVo> queryList(WeGroupMessageList weGroupMessageList);
/**
* 获取群发记录列表
*
......@@ -34,9 +26,9 @@ public interface IWeGroupMessageListService extends IService<WeGroupMessageList>
WeGroupMsgListDto getGroupMsgList(String chatType, Long startTime, Long endTime, String cursor);
/**
* 群发消息详情
* @param msgId 消息id
* @return 详情
* 查询群发消息详情
* @param msgTemplateId 模板id
* @return
*/
WeGroupMessageDetailVo getGroupMsgDetail(String msgId);
List<WeGroupMessageListVo> getGroupMsgDetail(Long msgTemplateId);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import java.util.List;
/**
* 群发消息模板Service接口
*
* @author ruoyi
* @date 2021-10-27
*/
public interface IWeGroupMessageTemplateService extends IService<WeGroupMessageTemplate> {
/**
* 查询列表
*/
List<WeGroupMessageTemplate> queryList(WeGroupMessageTemplate weGroupMessageTemplate);
/**
* 获取群发消息详情
* @param id 模板id
* @return
*/
WeGroupMessageDetailVo getGroupMsgTemplateDetail(Long id);
/**
* 创建群发消息
* @param query
*/
void addGroupMsgTemplate(WeAddGroupMessageQuery query);
}
......@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageAttachments" id="WeGroupMessageAttachmentsResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="msgType" column="msg_type" />
<result property="content" column="content" />
......
......@@ -6,21 +6,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageList" id="WeGroupMessageListResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="chatType" column="chat_type" />
<result property="userId" column="user_id" />
<result property="sendTime" column="send_time" />
<result property="createType" column="create_type" />
<result property="isTask" column="is_task" />
<result property="isExecute" column="is_execute" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap id="groupMsgDetailResult" type="WeGroupMessageDetailVo">
<result property="msgId" column="msg_id" />
<resultMap id="groupMsgDetailResult" type="WeGroupMessageListVo">
<result property="msgTemplateId" column="msg_template_id" />
<collection property="attachments" ofType="com.linkwechat.wecom.domain.WeGroupMessageAttachments">
<result property="msgType" column="msg_type"/>
<result property="content" column="content"/>
......@@ -50,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="getDetailVo">
select
wgml.msg_id,
wgml.msg_template_id,
wgma.msg_type,
wgma.content,
wgma.app_id ,
......@@ -74,11 +73,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from
we_group_message_list wgml
left join we_group_message_attachments wgma on
wgma.msg_id = wgml.msg_id
wgma.msg_template_id = wgml.msg_template_id
left join we_group_message_task wgmt on
wgmt.msg_id = wgml.msg_id
wgmt.msg_template_id = wgml.msg_template_id
left join we_group_message_send_result wgmsr on
wgmsr.msg_id = wgml.msg_id
wgmsr.msg_template_id = wgml.msg_template_id
where
1 = 1
</sql>
......@@ -86,18 +85,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getGroupMsgDetails" resultMap="groupMsgDetailResult">
<include refid="getDetailVo"/>
<if test="msgIds != null and msgIds.size > 0">
and wgml.msg_id in
<foreach collection="msgIds" index="index" item="msgId" open="(" separator="," close=")">
#{msgId}
and wgml.msg_template_id in
<foreach collection="msgTemplateIds" index="index" item="msgTemplateId" open="(" separator="," close=")">
#{msgTemplateId}
</foreach>
</if>
</select>
<select id="getGroupMsgDetail" resultMap="groupMsgDetailResult">
<include refid="getDetailVo"/>
<if test="msgId != null and msgId != ''">
and wgml.msg_id = #{msgId}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageSendResult" id="WeGroupMessageSendResultResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="userId" column="user_id" />
<result property="externalUserid" column="external_userid" />
......
......@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageTask" id="WeGroupMessageTaskResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="userId" column="user_id" />
<result property="status" column="status" />
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeGroupMessageTemplateMapper">
<resultMap type="WeGroupMessageTemplate" id="WeGroupMessageTemplateResult">
<result property="id" column="id" />
<result property="chatType" column="chat_type" />
<result property="content" column="context" />
<result property="sendTime" column="send_time" />
<result property="filterCondition" column="filter_condition" />
<result property="isTask" column="is_task" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!