提交
This commit is contained in:
36
ruoyi-main/ruoyi-message/pom.xml
Normal file
36
ruoyi-main/ruoyi-message/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-main</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-message</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-custom</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.16.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.ruoyi.message.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.controller.resp.GoeasyResult;
|
||||
import com.ruoyi.enums.user.UserEnums;
|
||||
import com.ruoyi.frequency.customer.entity.Customer;
|
||||
import com.ruoyi.frequency.customer.mapper.CustomerMapper;
|
||||
import com.ruoyi.frequency.store.entity.Store;
|
||||
import com.ruoyi.frequency.store.mapper.StoreMapper;
|
||||
import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage;
|
||||
import com.ruoyi.message.frequency.goeasymessage.service.GoeasyMessageService;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* goeasy消息
|
||||
*
|
||||
* @author liwenlong
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/goeasy")
|
||||
@Slf4j
|
||||
@Api(tags = "goeasy消息")
|
||||
public class ApiGoeasyMessageController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private GoeasyMessageService goeasyMessageService;
|
||||
|
||||
|
||||
@RequestMapping("/goeasyMessage")
|
||||
@ApiOperation(value = "数据同步Webhook", notes = "数据同步Webhook")
|
||||
public GoeasyResult goeasyMessage(HttpServletRequest request) {
|
||||
log.info("进入goeasy历史消息通知");
|
||||
|
||||
String content = request.getParameter("content");
|
||||
System.out.println(content);
|
||||
|
||||
if (content == null || "".equals(content)) {
|
||||
return GoeasyResult.success();
|
||||
}
|
||||
|
||||
//判断请求签名是否合法
|
||||
String goeasy_signature = request.getHeader("x-goeasy-signature");
|
||||
log.info("goeasy_signature:" + goeasy_signature);
|
||||
String signature = goeasyWebhookSignature(secretKey, content);
|
||||
log.info("signature:" + signature);
|
||||
if (!signature.equals(goeasy_signature)) {
|
||||
return GoeasyResult.success();
|
||||
}
|
||||
|
||||
JSONArray jsonArray = JSONObject.parseArray(content);
|
||||
System.out.println(jsonArray);
|
||||
|
||||
List<GoeasyMessage> goeasyMessages = jsonArray.stream().filter(s -> {
|
||||
JSONObject messageJson = JSONObject.parseObject(s.toString());
|
||||
return !messageJson.containsKey("channel");
|
||||
}).map(s -> {
|
||||
JSONObject messageJson = JSONObject.parseObject(s.toString());
|
||||
GoeasyMessage goeasyMessage = new GoeasyMessage();
|
||||
//每条消息唯一标识,可用于去重操作
|
||||
goeasyMessage.setMessageId((String) messageJson.get("messageId"));
|
||||
//消息类型
|
||||
goeasyMessage.setType((String) messageJson.get("type"));
|
||||
//发送方userId
|
||||
goeasyMessage.setSenderId((String) messageJson.get("senderId"));
|
||||
//解析发送用户
|
||||
String[] sender = goeasyMessage.getSenderId().split("_");
|
||||
if (sender.length == 2) {
|
||||
goeasyMessage.setSenderUserType(UserEnums.valueOf(sender[0]).getCode());
|
||||
goeasyMessage.setSenderUserId(Long.valueOf(sender[1]));
|
||||
}
|
||||
//接收方userId
|
||||
goeasyMessage.setReceiverId((String) messageJson.get("receiverId"));
|
||||
//解析接收用户
|
||||
String[] receiver = goeasyMessage.getReceiverId().split("_");
|
||||
if (receiver.length == 2) {
|
||||
goeasyMessage.setReceiverUserType(UserEnums.valueOf(receiver[0]).getCode());
|
||||
goeasyMessage.setReceiverUserId(Long.valueOf(receiver[1]));
|
||||
}
|
||||
//消息体
|
||||
goeasyMessage.setPayload((String) messageJson.get("payload"));
|
||||
//发送的时间,可用于排序
|
||||
goeasyMessage.setGoeasyTime(DateUtil.date((Long) messageJson.get("timestamp")));
|
||||
System.out.println(goeasyMessage);
|
||||
|
||||
if (goeasyMessage.getSenderUserType().equals(UserEnums.customer.getCode())) {
|
||||
Customer customer = customerMapper.selectById(goeasyMessage.getSenderUserId());
|
||||
if (customer != null) {
|
||||
return goeasyMessage;
|
||||
}
|
||||
} else if (goeasyMessage.getSenderUserType().equals(UserEnums.store.getCode())) {
|
||||
Store store = storeMapper.selectById(goeasyMessage.getSenderUserId());
|
||||
if (store != null) {
|
||||
return goeasyMessage;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
goeasyMessageService.goeasyMessage(goeasyMessages);
|
||||
|
||||
|
||||
log.info("goeasy历史消息通知结束");
|
||||
|
||||
return GoeasyResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private CustomerMapper customerMapper;
|
||||
@Autowired
|
||||
private StoreMapper storeMapper;
|
||||
|
||||
|
||||
@Value("${push.goeasy.secretKey}")
|
||||
private String secretKey;
|
||||
|
||||
public String goeasyWebhookSignature(String secretKey, String content) {
|
||||
try {
|
||||
SecretKeySpec signinKey = new SecretKeySpec(secretKey.getBytes(), "HmacSHA1");
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
mac.init(signinKey);
|
||||
byte[] rawHmac = mac.doFinal(content.getBytes("UTF8"));
|
||||
|
||||
return new BASE64Encoder().encode(rawHmac);
|
||||
} catch (Exception e) {
|
||||
log.error("HMACSHA1 failed for key:{} and content:{}", secretKey, content, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.message.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.annotations.UserLoginToken;
|
||||
import com.ruoyi.common.page.PageResult;
|
||||
import com.ruoyi.controller.req.MessageReadOrDeleteReq;
|
||||
import com.ruoyi.message.controller.resp.InteractionMessagePageResp;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.PageBasic;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 互动消息
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/message")
|
||||
@Api(tags = "互动消息")
|
||||
public class ApiInteractionMessageController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private InteractionMessageRecordService interactionMessageRecordService;
|
||||
|
||||
@UserLoginToken
|
||||
@PostMapping("/interactionMessagePage")
|
||||
@ApiOperation(value = "互动消息列表", notes = "互动消息列表")
|
||||
public ResponseData<PageResult<Page<InteractionMessagePageResp>>> interactionMessagePage(@RequestBody PageBasic req) {
|
||||
return interactionMessageRecordService.interactionMessagePage(req,getUserVo());
|
||||
}
|
||||
|
||||
@UserLoginToken
|
||||
@PostMapping("/interactionMessageReadOrDelete")
|
||||
@ApiOperation(value = "互动消息列表_已读,删除消息", notes = "互动消息列表_已读,删除消息")
|
||||
public ResponseData interactionMessageReadOrDelete(@RequestBody MessageReadOrDeleteReq req) {
|
||||
return interactionMessageRecordService.interactionMessageReadOrDelete(req, getUserVo());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.message.controller.resp;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author a
|
||||
* @date 2023/10/17 9:44
|
||||
*/
|
||||
@Data
|
||||
public class InteractionMessagePageResp {
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志;1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户id;设计师和表现师")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
private Integer messageType;
|
||||
|
||||
@ApiModelProperty("标语")
|
||||
@Excel(name = "标语")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("是否已读;1未读 2 已读")
|
||||
private String isRead;
|
||||
|
||||
@ApiModelProperty("是否清空;1 不清空 2 清空")
|
||||
private String isShow;
|
||||
|
||||
@ApiModelProperty("跳转主体id")
|
||||
private Long skipId;
|
||||
|
||||
@ApiModelProperty("对应的主体id")
|
||||
private Long objectId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("来源类型 1帖子 2作品 3关注 4新闻")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
private UserInfo userInfo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage;
|
||||
import com.ruoyi.message.frequency.goeasymessage.service.GoeasyMessageService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* goeasy消息Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/goeasymessage")
|
||||
public class GoeasyMessageController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private GoeasyMessageService goeasyMessageService;
|
||||
|
||||
/**
|
||||
* 查询goeasy消息列表
|
||||
*/
|
||||
//@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<GoeasyMessage> list(@RequestBody GoeasyMessage goeasyMessage)
|
||||
{
|
||||
startPage();
|
||||
List<GoeasyMessage> list = goeasyMessageService.selectGoeasyMessageList(goeasyMessage);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出goeasy消息列表
|
||||
*/
|
||||
//@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:export')")
|
||||
@Log(title = "goeasy消息", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(GoeasyMessage goeasyMessage)
|
||||
{
|
||||
List<GoeasyMessage> list = goeasyMessageService.selectGoeasyMessageList(goeasyMessage);
|
||||
ExcelUtil<GoeasyMessage> util = new ExcelUtil<GoeasyMessage>(GoeasyMessage.class);
|
||||
return util.exportExcel(list, "goeasy消息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取goeasy消息详细信息
|
||||
*/
|
||||
//@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<GoeasyMessage> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(goeasyMessageService.selectGoeasyMessageById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增goeasy消息
|
||||
*/
|
||||
//@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:add')")
|
||||
@Log(title = "goeasy消息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody GoeasyMessage goeasyMessage)
|
||||
{
|
||||
return toAjax(goeasyMessageService.insertGoeasyMessage(goeasyMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改goeasy消息
|
||||
*/
|
||||
//@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:edit')")
|
||||
@Log(title = "goeasy消息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody GoeasyMessage goeasyMessage)
|
||||
{
|
||||
return toAjax(goeasyMessageService.updateGoeasyMessage(goeasyMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除goeasy消息
|
||||
*/
|
||||
//@PreAuthorize("@ss.hasPermi('frequency:goeasymessage:remove')")
|
||||
@Log(title = "goeasy消息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}/{delFlag}")
|
||||
public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
|
||||
{
|
||||
return toAjax(goeasyMessageService.deleteGoeasyMessageByIds(ids,delFlag));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* goeasy消息对象 t_goeasy_message
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_goeasy_message")
|
||||
public class GoeasyMessage extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("goeasy返回消息id")
|
||||
@Excel(name = "goeasy返回消息id")
|
||||
private String messageId;
|
||||
|
||||
@ApiModelProperty("goeasy消息类型")
|
||||
@Excel(name = "goeasy消息类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("发送用户")
|
||||
@Excel(name = "发送用户")
|
||||
private String senderId;
|
||||
|
||||
@ApiModelProperty("发送用户类型 1 用户 ")
|
||||
@Excel(name = "发送用户类型 1 用户 ")
|
||||
private Integer senderUserType;
|
||||
|
||||
@ApiModelProperty("发送用户id")
|
||||
@Excel(name = "发送用户id")
|
||||
private Long senderUserId;
|
||||
|
||||
|
||||
@ApiModelProperty("接收用户")
|
||||
@Excel(name = "接收用户")
|
||||
private String receiverId;
|
||||
|
||||
@ApiModelProperty("接收用户类型 1 用户 ")
|
||||
@Excel(name = "接收用户类型 1 用户 ")
|
||||
private Integer receiverUserType;
|
||||
|
||||
@ApiModelProperty("接收用户id")
|
||||
@Excel(name = "接收用户id")
|
||||
private Long receiverUserId;
|
||||
|
||||
@ApiModelProperty("消息(json字符串)")
|
||||
@Excel(name = "消息(json字符串)")
|
||||
private String payload;
|
||||
|
||||
@ApiModelProperty("goeasy消息发送时间")
|
||||
@Excel(name = "goeasy消息发送时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date goeasyTime;
|
||||
|
||||
@ApiModelProperty("发送用户消息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo sendUserInfo;
|
||||
|
||||
@ApiModelProperty("接收用户消息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo receiveUserInfo;
|
||||
|
||||
/**
|
||||
* 最早一條消息的时间
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Date lasttimestamp;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage;
|
||||
|
||||
/**
|
||||
* goeasy消息Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
public interface GoeasyMessageMapper extends BaseMapper<GoeasyMessage>
|
||||
{
|
||||
/**
|
||||
* 查询goeasy消息
|
||||
*
|
||||
* @param id goeasy消息主键
|
||||
* @return goeasy消息
|
||||
*/
|
||||
public GoeasyMessage selectGoeasyMessageById(Long id);
|
||||
|
||||
/**
|
||||
* 查询goeasy消息列表
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return goeasy消息集合
|
||||
*/
|
||||
public List<GoeasyMessage> selectGoeasyMessageList(GoeasyMessage goeasyMessage);
|
||||
|
||||
/**
|
||||
* 新增goeasy消息
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGoeasyMessage(GoeasyMessage goeasyMessage);
|
||||
|
||||
/**
|
||||
* 修改goeasy消息
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGoeasyMessage(GoeasyMessage goeasyMessage);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?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.ruoyi.message.frequency.goeasymessage.mapper.GoeasyMessageMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage" id="GoeasyMessageResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="messageId" column="message_id" />
|
||||
<result property="type" column="type" />
|
||||
<result property="senderId" column="sender_id" />
|
||||
<result property="receiverId" column="receiver_id" />
|
||||
<result property="payload" column="payload" />
|
||||
<result property="goeasyTime" column="goeasy_time" />
|
||||
<result property="senderUserId" column="sender_user_id" />
|
||||
<result property="senderUserType" column="sender_user_type" />
|
||||
<result property="receiverUserId" column="receiver_user_id" />
|
||||
<result property="receiverUserType" column="receiver_user_type" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
<sql id="selectGoeasyMessageVo">
|
||||
select
|
||||
t.id ,
|
||||
t.create_by ,
|
||||
t.create_time ,
|
||||
t.update_by ,
|
||||
t.update_time ,
|
||||
t.del_flag ,
|
||||
t.message_id ,
|
||||
t.type ,
|
||||
t.sender_id ,
|
||||
t.receiver_id ,
|
||||
t.payload ,
|
||||
t.goeasy_time ,
|
||||
t.sender_user_id ,
|
||||
t.sender_user_type ,
|
||||
t.receiver_user_id ,
|
||||
t.receiver_user_type
|
||||
from t_goeasy_message AS t
|
||||
|
||||
</sql>
|
||||
|
||||
<select id="selectGoeasyMessageList" parameterType="com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage" resultMap="GoeasyMessageResult">
|
||||
<include refid="selectGoeasyMessageVo"/>
|
||||
<where>AND t.del_flag != 2
|
||||
<if test="messageId != null and messageId != ''">and t.message_id = #{messageId}</if>
|
||||
<if test="type != null and type != ''">and t.type = #{type}</if>
|
||||
<if test="senderId != null and senderId != ''">and t.sender_id = #{senderId}</if>
|
||||
<if test="receiverId != null and receiverId != ''">and t.receiver_id = #{receiverId}</if>
|
||||
<if test="payload != null and payload != ''">and t.payload = #{payload}</if>
|
||||
<if test="goeasyTime != null ">and t.goeasy_time = #{goeasyTime}</if>
|
||||
<if test="delFlag != null and delFlag != ''">and t.del_flag = #{delFlag}</if>
|
||||
<if test="senderUserId != null and senderUserType != null and receiverUserId != null and receiverUserType != null">
|
||||
AND (
|
||||
( t.sender_user_type = #{senderUserType} AND t.sender_user_id = #{senderUserId} AND t.receiver_user_type
|
||||
= #{receiverUserType} AND t.receiver_user_id = #{receiverUserId} )
|
||||
OR ( t.sender_user_type = #{receiverUserType} AND t.sender_user_id = #{receiverUserId} AND
|
||||
t.receiver_user_type = #{senderUserType} AND t.receiver_user_id = #{senderUserId} )
|
||||
)
|
||||
</if>
|
||||
<if test="lasttimestamp != null">and t.goeasy_time <= #{lasttimestamp}</if>
|
||||
</where>
|
||||
order by t.goeasy_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectGoeasyMessageById" parameterType="Long" resultMap="GoeasyMessageResult">
|
||||
<include refid="selectGoeasyMessageVo"/>
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertGoeasyMessage" parameterType="com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage">
|
||||
insert into t_goeasy_message
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="messageId != null">message_id,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="senderId != null">sender_id,</if>
|
||||
<if test="receiverId != null">receiver_id,</if>
|
||||
<if test="payload != null">payload,</if>
|
||||
<if test="goeasyTime != null">goeasy_time,</if>
|
||||
<if test="senderUserId != null">sender_user_id,</if>
|
||||
<if test="senderUserType != null">sender_user_type,</if>
|
||||
<if test="receiverUserId != null">receiver_user_id,</if>
|
||||
<if test="receiverUserType != null">receiver_user_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="messageId != null">#{messageId},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="senderId != null">#{senderId},</if>
|
||||
<if test="receiverId != null">#{receiverId},</if>
|
||||
<if test="payload != null">#{payload},</if>
|
||||
<if test="goeasyTime != null">#{goeasyTime},</if>
|
||||
<if test="senderUserId != null">#{senderUserId},</if>
|
||||
<if test="senderUserType != null">#{senderUserType},</if>
|
||||
<if test="receiverUserId != null">#{receiverUserId},</if>
|
||||
<if test="receiverUserType != null">#{receiverUserType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateGoeasyMessage" parameterType="com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage">
|
||||
update t_goeasy_message
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="messageId != null">message_id = #{messageId},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="senderId != null">sender_id = #{senderId},</if>
|
||||
<if test="receiverId != null">receiver_id = #{receiverId},</if>
|
||||
<if test="payload != null">payload = #{payload},</if>
|
||||
<if test="goeasyTime != null">goeasy_time = #{goeasyTime},</if>
|
||||
<if test="senderUserId != null">sender_user_id = #{senderUserId},</if>
|
||||
<if test="senderUserType != null">sender_user_type = #{senderUserType},</if>
|
||||
<if test="receiverUserId != null">receiver_user_id = #{receiverUserId},</if>
|
||||
<if test="receiverUserType != null">receiver_user_type = #{receiverUserType},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.model.param;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* goeasy消息对象 t_goeasy_message
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GoeasyMessageParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("goeasy返回消息id")
|
||||
@Excel(name = "goeasy返回消息id")
|
||||
private String messageId;
|
||||
|
||||
@ApiModelProperty("goeasy消息类型")
|
||||
@Excel(name = "goeasy消息类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("发送用户")
|
||||
@Excel(name = "发送用户")
|
||||
private String senderId;
|
||||
|
||||
@ApiModelProperty("接收用户")
|
||||
@Excel(name = "接收用户")
|
||||
private String receiverId;
|
||||
|
||||
@ApiModelProperty("消息(json字符串)")
|
||||
@Excel(name = "消息(json字符串)")
|
||||
private String payload;
|
||||
|
||||
@ApiModelProperty("goeasy消息发送时间")
|
||||
@Excel(name = "goeasy消息发送时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date goeasyTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.model.result;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* goeasy消息对象 t_goeasy_message
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GoeasyMessageResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("goeasy返回消息id")
|
||||
@Excel(name = "goeasy返回消息id")
|
||||
private String messageId;
|
||||
|
||||
@ApiModelProperty("goeasy消息类型")
|
||||
@Excel(name = "goeasy消息类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("发送用户")
|
||||
@Excel(name = "发送用户")
|
||||
private String senderId;
|
||||
|
||||
@ApiModelProperty("接收用户")
|
||||
@Excel(name = "接收用户")
|
||||
private String receiverId;
|
||||
|
||||
@ApiModelProperty("消息(json字符串)")
|
||||
@Excel(name = "消息(json字符串)")
|
||||
private String payload;
|
||||
|
||||
@ApiModelProperty("goeasy消息发送时间")
|
||||
@Excel(name = "goeasy消息发送时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date goeasyTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* goeasy消息Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
public interface GoeasyMessageService extends IService<GoeasyMessage>
|
||||
{
|
||||
/**
|
||||
* 查询goeasy消息
|
||||
*
|
||||
* @param id goeasy消息主键
|
||||
* @return goeasy消息
|
||||
*/
|
||||
public GoeasyMessage selectGoeasyMessageById(Long id);
|
||||
|
||||
/**
|
||||
* 查询goeasy消息列表
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return goeasy消息集合
|
||||
*/
|
||||
public List<GoeasyMessage> selectGoeasyMessageList(GoeasyMessage goeasyMessage);
|
||||
|
||||
/**
|
||||
* 新增goeasy消息
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGoeasyMessage(GoeasyMessage goeasyMessage);
|
||||
|
||||
/**
|
||||
* 修改goeasy消息
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGoeasyMessage(GoeasyMessage goeasyMessage);
|
||||
|
||||
/**
|
||||
* 批量删除goeasy消息
|
||||
*
|
||||
* @param ids 需要删除的goeasy消息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGoeasyMessageByIds(Long[] ids,Integer delFlag);
|
||||
|
||||
void goeasyMessage(List<GoeasyMessage> goeasyMessages);
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.ruoyi.message.frequency.goeasymessage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.frequency.customer.service.UserService;
|
||||
import com.ruoyi.message.frequency.goeasymessage.entity.GoeasyMessage;
|
||||
import com.ruoyi.message.frequency.goeasymessage.mapper.GoeasyMessageMapper;
|
||||
import com.ruoyi.message.frequency.goeasymessage.service.GoeasyMessageService;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.mapper.GoeasyMessageNewMapper;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* goeasy消息Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-17
|
||||
*/
|
||||
@Service
|
||||
public class GoeasyMessageServiceImpl extends ServiceImpl<GoeasyMessageMapper, GoeasyMessage> implements GoeasyMessageService {
|
||||
@Autowired
|
||||
private GoeasyMessageMapper goeasyMessageMapper;
|
||||
|
||||
/**
|
||||
* 查询goeasy消息
|
||||
*
|
||||
* @param id goeasy消息主键
|
||||
* @return goeasy消息
|
||||
*/
|
||||
@Override
|
||||
public GoeasyMessage selectGoeasyMessageById(Long id) {
|
||||
GoeasyMessage goeasyMessage = goeasyMessageMapper.selectGoeasyMessageById(id);
|
||||
if (goeasyMessage != null) {
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
userVoSet.add(new UserVo(goeasyMessage.getSenderUserType(), goeasyMessage.getSenderUserId()));
|
||||
userVoSet.add(new UserVo(goeasyMessage.getReceiverUserType(), goeasyMessage.getReceiverUserId()));
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
goeasyMessage.setSendUserInfo(userMap.get(new UserVo(goeasyMessage.getSenderUserType(), goeasyMessage.getSenderUserId())));
|
||||
goeasyMessage.setReceiveUserInfo(userMap.get(new UserVo(goeasyMessage.getReceiverUserType(), goeasyMessage.getReceiverUserId())));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return goeasyMessage;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 查询goeasy消息列表
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return goeasy消息
|
||||
*/
|
||||
@Override
|
||||
public List<GoeasyMessage> selectGoeasyMessageList(GoeasyMessage goeasyMessage) {
|
||||
List<GoeasyMessage> goeasyMessages = goeasyMessageMapper.selectGoeasyMessageList(goeasyMessage);
|
||||
//根據goeasy_time 來正序排列
|
||||
goeasyMessages.sort(Comparator.comparing(GoeasyMessage::getGoeasyTime));
|
||||
if (goeasyMessages.size() > 0) {
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
goeasyMessages.stream().forEach(s -> {
|
||||
userVoSet.add(new UserVo(s.getSenderUserType(), s.getSenderUserId()));
|
||||
userVoSet.add(new UserVo(s.getReceiverUserType(), s.getReceiverUserId()));
|
||||
});
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
goeasyMessages.stream().forEach(s -> {
|
||||
s.setSendUserInfo(userMap.get(new UserVo(s.getSenderUserType(), s.getSenderUserId())));
|
||||
s.setReceiveUserInfo(userMap.get(new UserVo(s.getReceiverUserType(), s.getReceiverUserId())));
|
||||
});
|
||||
}
|
||||
|
||||
return goeasyMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增goeasy消息
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertGoeasyMessage(GoeasyMessage goeasyMessage) {
|
||||
goeasyMessage.setCreateData();
|
||||
return goeasyMessageMapper.insert(goeasyMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改goeasy消息
|
||||
*
|
||||
* @param goeasyMessage goeasy消息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGoeasyMessage(GoeasyMessage goeasyMessage) {
|
||||
goeasyMessage.setUpdateData();
|
||||
return goeasyMessageMapper.updateGoeasyMessage(goeasyMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除goeasy消息
|
||||
*
|
||||
* @param ids 需要删除的goeasy消息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGoeasyMessageByIds(Long[] ids, Integer delFlag) {
|
||||
this.lambdaUpdate().set(GoeasyMessage::getDelFlag, delFlag).in(GoeasyMessage::getId, ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private GoeasyMessageNewService goeasyMessageNewService;
|
||||
|
||||
@Autowired
|
||||
private GoeasyMessageNewMapper goeasyMessageNewMapper;
|
||||
|
||||
@Override
|
||||
public void goeasyMessage(List<GoeasyMessage> goeasyMessages) {
|
||||
|
||||
// 使用 Map 存储唯一的 GoeasyMessage,键为 messageId,值为 GoeasyMessage 对象
|
||||
Map<String, GoeasyMessage> uniqueMessages = new HashMap<>();
|
||||
|
||||
// 遍历列表,将每个消息按 messageId 存储到 Map 中
|
||||
for (GoeasyMessage message : goeasyMessages) {
|
||||
if (message == null) {
|
||||
continue;
|
||||
}
|
||||
uniqueMessages.put(message.getMessageId(), message);
|
||||
}
|
||||
|
||||
Collection<GoeasyMessage> onlyList = uniqueMessages.values();
|
||||
try {
|
||||
this.saveBatch(onlyList);
|
||||
|
||||
//更新 goeasy_message_new
|
||||
List<GoeasyMessageNew> goeasyMessageNewList = new ArrayList<>();
|
||||
|
||||
onlyList.stream().forEach(x -> {
|
||||
Long userId = x.getSenderUserId();
|
||||
Long otherUserId = x.getReceiverUserId();
|
||||
|
||||
GoeasyMessageNew goeasyMessageNew = goeasyMessageNewMapper.getMessage(userId, otherUserId);
|
||||
|
||||
if (goeasyMessageNew == null) {
|
||||
goeasyMessageNew = new GoeasyMessageNew();
|
||||
goeasyMessageNew.setGoeasyTime(x.getGoeasyTime());
|
||||
goeasyMessageNew.setUserId(userId);
|
||||
goeasyMessageNew.setOtherUserId(otherUserId);
|
||||
goeasyMessageNew.setType(x.getType());
|
||||
goeasyMessageNew.setPayload(x.getPayload());
|
||||
goeasyMessageNew.setDelFlag(PublicCommon.启用);
|
||||
} else {
|
||||
goeasyMessageNew.setGoeasyTime(x.getGoeasyTime());
|
||||
goeasyMessageNew.setPayload(x.getPayload());
|
||||
goeasyMessageNew.setType(x.getType());
|
||||
}
|
||||
|
||||
goeasyMessageNewList.add(goeasyMessageNew);
|
||||
});
|
||||
|
||||
if (goeasyMessageNewList.size() > 0) {
|
||||
goeasyMessageNewService.saveOrUpdateBatch(goeasyMessageNewList);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("goeasy消息发送失败", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* goeasy最新消息Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/goeasymessagenew")
|
||||
public class GoeasyMessageNewController extends BaseController {
|
||||
@Autowired
|
||||
private GoeasyMessageNewService goeasyMessageNewService;
|
||||
|
||||
/**
|
||||
* 查询goeasy最新消息列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<GoeasyMessageNew> list(@RequestBody GoeasyMessageNew goeasyMessageNew) {
|
||||
startPage();
|
||||
List<GoeasyMessageNew> list = goeasyMessageNewService.selectGoeasyMessageNewList(goeasyMessageNew);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出goeasy最新消息列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:export')")
|
||||
@Log(title = "goeasy最新消息", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(GoeasyMessageNew goeasyMessageNew) {
|
||||
List<GoeasyMessageNew> list = goeasyMessageNewService.selectGoeasyMessageNewList(goeasyMessageNew);
|
||||
ExcelUtil<GoeasyMessageNew> util = new ExcelUtil<GoeasyMessageNew>(GoeasyMessageNew.class);
|
||||
return util.exportExcel(list, "goeasy最新消息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取goeasy最新消息详细信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<GoeasyMessageNew> getInfo(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(goeasyMessageNewService.selectGoeasyMessageNewById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增goeasy最新消息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:add')")
|
||||
@Log(title = "goeasy最新消息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody GoeasyMessageNew goeasyMessageNew) {
|
||||
return toAjax(goeasyMessageNewService.insertGoeasyMessageNew(goeasyMessageNew));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改goeasy最新消息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:edit')")
|
||||
@Log(title = "goeasy最新消息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody GoeasyMessageNew goeasyMessageNew) {
|
||||
return toAjax(goeasyMessageNewService.updateGoeasyMessageNew(goeasyMessageNew));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除goeasy最新消息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:remove')")
|
||||
@Log(title = "goeasy最新消息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}/{delFlag}")
|
||||
public AjaxResult remove(@PathVariable("ids") Long[] ids, @PathVariable("delFlag") Integer delFlag) {
|
||||
return toAjax(goeasyMessageNewService.deleteGoeasyMessageNewByIds(ids, delFlag));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.entity;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* goeasy最新消息对象 t_goeasy_message_new
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_goeasy_message_new")
|
||||
public class GoeasyMessageNew extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("消息(json字符串)")
|
||||
@Excel(name = "消息(json字符串)")
|
||||
private String payload;
|
||||
|
||||
@ApiModelProperty("goeasy最新消息发送时间")
|
||||
@Excel(name = "goeasy最新消息发送时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date goeasyTime;
|
||||
|
||||
@ApiModelProperty("goeasy消息类型")
|
||||
@Excel(name = "goeasy消息类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("用户ID")
|
||||
@Excel(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("聊天对象用户ID")
|
||||
@Excel(name = "聊天对象用户ID")
|
||||
private Long otherUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long senderUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer senderUserType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long receiverUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer receiverUserType;
|
||||
|
||||
|
||||
@ApiModelProperty("发送用户消息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo sendUserInfo;
|
||||
|
||||
@ApiModelProperty("接收用户消息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo receiveUserInfo;
|
||||
|
||||
|
||||
@ApiModelProperty("传参")
|
||||
@TableField(exist = false)
|
||||
private UserInfo userInfo;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* goeasy最新消息Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface GoeasyMessageNewMapper extends BaseMapper<GoeasyMessageNew>
|
||||
{
|
||||
/**
|
||||
* 查询goeasy最新消息
|
||||
*
|
||||
* @param id goeasy最新消息主键
|
||||
* @return goeasy最新消息
|
||||
*/
|
||||
public GoeasyMessageNew selectGoeasyMessageNewById(Long id);
|
||||
|
||||
/**
|
||||
* 查询goeasy最新消息列表
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return goeasy最新消息集合
|
||||
*/
|
||||
public List<GoeasyMessageNew> selectGoeasyMessageNewList(GoeasyMessageNew goeasyMessageNew);
|
||||
|
||||
/**
|
||||
* 新增goeasy最新消息
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew);
|
||||
|
||||
/**
|
||||
* 修改goeasy最新消息
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew);
|
||||
|
||||
GoeasyMessageNew getMessage(@Param("userId") Long userId, @Param("otherUserId") Long otherUserId);
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
<?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.ruoyi.message.frequency.goeasymessagenew.mapper.GoeasyMessageNewMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew" id="GoeasyMessageNewResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="otherUserId" column="other_user_id" />
|
||||
<result property="payload" column="payload" />
|
||||
<result property="goeasyTime" column="goeasy_time" />
|
||||
<result property="type" column="type" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
<sql id="selectGoeasyMessageNewVo">
|
||||
select
|
||||
t.id ,
|
||||
t.create_by ,
|
||||
t.create_time ,
|
||||
t.update_by ,
|
||||
t.update_time ,
|
||||
t.del_flag ,
|
||||
t.user_id ,
|
||||
t.other_user_id ,
|
||||
t.payload ,
|
||||
t.goeasy_time ,
|
||||
t.type
|
||||
from t_goeasy_message_new AS t
|
||||
|
||||
</sql>
|
||||
|
||||
<select id="selectGoeasyMessageNewList" parameterType="com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew" resultMap="GoeasyMessageNewResult">
|
||||
<include refid="selectGoeasyMessageNewVo"/>
|
||||
<where>AND t.del_flag != 2
|
||||
AND (
|
||||
t.user_id in (select id from t_customer UNION ALL select id from t_store)
|
||||
)
|
||||
<if test="payload != null and payload != ''">and t.payload = #{payload}</if>
|
||||
<if test="goeasyTime != null ">and t.goeasy_time = #{goeasyTime}</if>
|
||||
<if test="type != null and type != ''">and t.type = #{type}</if>
|
||||
<if test="delFlag != null and delFlag != ''">and t.del_flag = #{delFlag}</if>
|
||||
|
||||
<if test="userInfo != null ">
|
||||
<if test="userInfo.nickname != null and userInfo.nickname != ''">
|
||||
AND (
|
||||
(
|
||||
t.user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_customer
|
||||
WHERE
|
||||
nickname LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
)
|
||||
OR t.user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_store
|
||||
WHERE
|
||||
nickname LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
)
|
||||
) or
|
||||
(
|
||||
t.other_user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_customer
|
||||
WHERE
|
||||
nickname LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
)
|
||||
OR t.other_user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_store
|
||||
WHERE
|
||||
nickname LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
)
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="userInfo.mobile != null and userInfo.mobile != ''">
|
||||
AND (
|
||||
(
|
||||
t.user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_customer
|
||||
WHERE
|
||||
mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
)
|
||||
OR t.user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_store
|
||||
WHERE
|
||||
mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
)
|
||||
) or
|
||||
(
|
||||
t.other_user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_customer
|
||||
WHERE
|
||||
mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
)
|
||||
OR t.other_user_id IN (
|
||||
SELECT
|
||||
id
|
||||
FROM
|
||||
t_store
|
||||
WHERE
|
||||
mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
)
|
||||
)
|
||||
)
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
order by t.goeasy_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectGoeasyMessageNewById" parameterType="Long" resultMap="GoeasyMessageNewResult">
|
||||
<include refid="selectGoeasyMessageNewVo"/>
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
<select id="getMessage" resultType="com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew">
|
||||
SELECT *
|
||||
FROM t_goeasy_message_new
|
||||
WHERE (
|
||||
user_id = #{userId}
|
||||
AND other_user_id = #{otherUserId}
|
||||
)
|
||||
OR (
|
||||
user_id = #{otherUserId}
|
||||
AND other_user_id = #{userId}
|
||||
)
|
||||
</select>
|
||||
|
||||
<insert id="insertGoeasyMessageNew" parameterType="com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew">
|
||||
insert into t_goeasy_message_new
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="otherUserId != null">other_user_id,</if>
|
||||
<if test="payload != null">payload,</if>
|
||||
<if test="goeasyTime != null">goeasy_time,</if>
|
||||
<if test="type != null">type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="otherUserId != null">#{otherUserId},</if>
|
||||
<if test="payload != null">#{payload},</if>
|
||||
<if test="goeasyTime != null">#{goeasyTime},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateGoeasyMessageNew" parameterType="com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew">
|
||||
update t_goeasy_message_new
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="otherUserId != null">other_user_id = #{otherUserId},</if>
|
||||
<if test="payload != null">payload = #{payload},</if>
|
||||
<if test="goeasyTime != null">goeasy_time = #{goeasyTime},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.model.param;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* goeasy最新消息对象 t_goeasy_message_new
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GoeasyMessageNewParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("聊天对象用户ID")
|
||||
@Excel(name = "聊天对象用户ID")
|
||||
private Long otherUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long senderUserId;
|
||||
|
||||
@ApiModelProperty("消息(json字符串)")
|
||||
@Excel(name = "消息(json字符串)")
|
||||
private String payload;
|
||||
|
||||
@ApiModelProperty("goeasy最新消息发送时间")
|
||||
@Excel(name = "goeasy最新消息发送时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date goeasyTime;
|
||||
|
||||
@ApiModelProperty("goeasy消息类型")
|
||||
@Excel(name = "goeasy消息类型")
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.model.result;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* goeasy最新消息对象 t_goeasy_message_new
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GoeasyMessageNewResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("聊天对象用户ID")
|
||||
@Excel(name = "聊天对象用户ID")
|
||||
private Long otherUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long senderUserId;
|
||||
|
||||
@ApiModelProperty("消息(json字符串)")
|
||||
@Excel(name = "消息(json字符串)")
|
||||
private String payload;
|
||||
|
||||
@ApiModelProperty("goeasy最新消息发送时间")
|
||||
@Excel(name = "goeasy最新消息发送时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date goeasyTime;
|
||||
|
||||
@ApiModelProperty("goeasy消息类型")
|
||||
@Excel(name = "goeasy消息类型")
|
||||
private String type;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* goeasy最新消息Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
public interface GoeasyMessageNewService extends IService<GoeasyMessageNew>
|
||||
{
|
||||
/**
|
||||
* 查询goeasy最新消息
|
||||
*
|
||||
* @param id goeasy最新消息主键
|
||||
* @return goeasy最新消息
|
||||
*/
|
||||
public GoeasyMessageNew selectGoeasyMessageNewById(Long id);
|
||||
|
||||
/**
|
||||
* 查询goeasy最新消息列表
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return goeasy最新消息集合
|
||||
*/
|
||||
public List<GoeasyMessageNew> selectGoeasyMessageNewList(GoeasyMessageNew goeasyMessageNew);
|
||||
|
||||
/**
|
||||
* 新增goeasy最新消息
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew);
|
||||
|
||||
/**
|
||||
* 修改goeasy最新消息
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew);
|
||||
|
||||
/**
|
||||
* 批量删除goeasy最新消息
|
||||
*
|
||||
* @param ids 需要删除的goeasy最新消息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteGoeasyMessageNewByIds(Long[] ids,Integer delFlag);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.ruoyi.message.frequency.goeasymessagenew.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.enums.user.UserEnums;
|
||||
import com.ruoyi.frequency.customer.entity.Customer;
|
||||
import com.ruoyi.frequency.customer.service.CustomerService;
|
||||
import com.ruoyi.frequency.customer.service.UserService;
|
||||
import com.ruoyi.frequency.store.entity.Store;
|
||||
import com.ruoyi.frequency.store.service.StoreService;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.entity.GoeasyMessageNew;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.mapper.GoeasyMessageNewMapper;
|
||||
import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* goeasy最新消息Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2024-04-20
|
||||
*/
|
||||
@Service
|
||||
public class GoeasyMessageNewServiceImpl extends ServiceImpl<GoeasyMessageNewMapper, GoeasyMessageNew> implements GoeasyMessageNewService {
|
||||
@Autowired
|
||||
private GoeasyMessageNewMapper goeasyMessageNewMapper;
|
||||
|
||||
/**
|
||||
* 查询goeasy最新消息
|
||||
*
|
||||
* @param id goeasy最新消息主键
|
||||
* @return goeasy最新消息
|
||||
*/
|
||||
@Override
|
||||
public GoeasyMessageNew selectGoeasyMessageNewById(Long id) {
|
||||
return goeasyMessageNewMapper.selectGoeasyMessageNewById(id);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
/**
|
||||
* 查询goeasy最新消息列表
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return goeasy最新消息
|
||||
*/
|
||||
@Override
|
||||
public List<GoeasyMessageNew> selectGoeasyMessageNewList(GoeasyMessageNew goeasyMessageNew) {
|
||||
List<GoeasyMessageNew> goeasyMessageNewList = goeasyMessageNewMapper.selectGoeasyMessageNewList(goeasyMessageNew);
|
||||
|
||||
if (goeasyMessageNewList.size() > 0) {
|
||||
List<Long> userId = new ArrayList<>();
|
||||
goeasyMessageNewList.stream().forEach(s -> {
|
||||
userId.add(s.getUserId());
|
||||
userId.add(s.getOtherUserId());
|
||||
});
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
List<Customer> customerList = customerService.listByIds(userId);
|
||||
|
||||
Map<Long, Long> customerMap = new HashMap<>();
|
||||
customerList.stream().forEach(x -> {
|
||||
customerMap.put(x.getId(), x.getId());
|
||||
userVoSet.add(new UserVo(UserEnums.customer.getCode(), x.getId()));
|
||||
|
||||
});
|
||||
|
||||
List<Store> storeList = storeService.listByIds(userId);
|
||||
|
||||
Map<Long, Long> storeMap = new HashMap<>();
|
||||
storeList.stream().forEach(x -> {
|
||||
storeMap.put(x.getId(), x.getId());
|
||||
userVoSet.add(new UserVo(UserEnums.store.getCode(), x.getId()));
|
||||
|
||||
});
|
||||
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
goeasyMessageNewList.stream().forEach(s -> {
|
||||
// 取 userId
|
||||
if (customerMap.containsKey(s.getUserId())) {
|
||||
s.setSendUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), s.getUserId())));
|
||||
s.setSenderUserId(s.getSendUserInfo().getUserId());
|
||||
s.setSenderUserType(UserEnums.customer.getCode());
|
||||
} else if (storeMap.containsKey(s.getUserId())) {
|
||||
s.setSendUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getUserId())));
|
||||
s.setSenderUserId(s.getSendUserInfo().getUserId());
|
||||
s.setSenderUserType(UserEnums.store.getCode());
|
||||
}
|
||||
|
||||
|
||||
if (customerMap.containsKey(s.getOtherUserId())) {
|
||||
s.setReceiveUserInfo(userMap.get(new UserVo(UserEnums.customer.getCode(), s.getOtherUserId())));
|
||||
s.setReceiverUserId(s.getReceiveUserInfo().getUserId());
|
||||
s.setReceiverUserType(UserEnums.customer.getCode());
|
||||
} else if (storeMap.containsKey(s.getOtherUserId())) {
|
||||
s.setReceiveUserInfo(userMap.get(new UserVo(UserEnums.store.getCode(), s.getOtherUserId())));
|
||||
s.setReceiverUserId(s.getReceiveUserInfo().getUserId());
|
||||
s.setReceiverUserType(UserEnums.store.getCode());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return goeasyMessageNewList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增goeasy最新消息
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew) {
|
||||
goeasyMessageNew.setCreateData();
|
||||
return goeasyMessageNewMapper.insert(goeasyMessageNew);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改goeasy最新消息
|
||||
*
|
||||
* @param goeasyMessageNew goeasy最新消息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateGoeasyMessageNew(GoeasyMessageNew goeasyMessageNew) {
|
||||
goeasyMessageNew.setUpdateData();
|
||||
return goeasyMessageNewMapper.updateGoeasyMessageNew(goeasyMessageNew);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除goeasy最新消息
|
||||
*
|
||||
* @param ids 需要删除的goeasy最新消息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteGoeasyMessageNewByIds(Long[] ids, Integer delFlag) {
|
||||
this.lambdaUpdate().set(GoeasyMessageNew::getDelFlag, delFlag).in(GoeasyMessageNew::getId, ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 互动消息记录Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/interactionmessagerecord")
|
||||
public class InteractionMessageRecordController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private InteractionMessageRecordService interactionMessageRecordService;
|
||||
|
||||
/**
|
||||
* 查询互动消息记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<InteractionMessageRecord> list(InteractionMessageRecord interactionMessageRecord)
|
||||
{
|
||||
startPage();
|
||||
List<InteractionMessageRecord> list = interactionMessageRecordService.selectInteractionMessageRecordList(interactionMessageRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出互动消息记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:export')")
|
||||
@Log(title = "互动消息记录", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(InteractionMessageRecord interactionMessageRecord)
|
||||
{
|
||||
List<InteractionMessageRecord> list = interactionMessageRecordService.selectInteractionMessageRecordList(interactionMessageRecord);
|
||||
ExcelUtil<InteractionMessageRecord> util = new ExcelUtil<InteractionMessageRecord>(InteractionMessageRecord.class);
|
||||
return util.exportExcel(list, "互动消息记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取互动消息记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<InteractionMessageRecord> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(interactionMessageRecordService.selectInteractionMessageRecordById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增互动消息记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:add')")
|
||||
@Log(title = "互动消息记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody InteractionMessageRecord interactionMessageRecord)
|
||||
{
|
||||
return toAjax(interactionMessageRecordService.insertInteractionMessageRecord(interactionMessageRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改互动消息记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:edit')")
|
||||
@Log(title = "互动消息记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody InteractionMessageRecord interactionMessageRecord)
|
||||
{
|
||||
return toAjax(interactionMessageRecordService.updateInteractionMessageRecord(interactionMessageRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除互动消息记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:remove')")
|
||||
@Log(title = "互动消息记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(interactionMessageRecordService.deleteInteractionMessageRecordByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 互动消息记录对象 t_interaction_message_record
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_interaction_message_record")
|
||||
public class InteractionMessageRecord extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志;1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户id;设计师和表现师")
|
||||
@Excel(name = "用户id;设计师和表现师")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
@Excel(name = "消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
private Integer messageType;
|
||||
|
||||
@ApiModelProperty("标语")
|
||||
@Excel(name = "标语")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("是否已读;1未读 2 已读")
|
||||
@Excel(name = "是否已读;1未读 2 已读")
|
||||
private String isRead;
|
||||
|
||||
@ApiModelProperty("是否清空;1 不清空 2 清空")
|
||||
@Excel(name = "是否清空;1 不清空 2 清空")
|
||||
private String isShow;
|
||||
|
||||
@ApiModelProperty("跳转主体id")
|
||||
@Excel(name = "跳转主体id")
|
||||
private Long skipId;
|
||||
|
||||
@ApiModelProperty("用户类型 ")
|
||||
@Excel(name = "用户类型 ")
|
||||
private Integer interactionUserType;
|
||||
|
||||
@ApiModelProperty("互动消息用户id")
|
||||
@Excel(name = "互动消息用户id")
|
||||
private Long interactionUserId;
|
||||
|
||||
@ApiModelProperty("对应的主体id")
|
||||
@Excel(name = "对应的主体id")
|
||||
private Long objectId;
|
||||
|
||||
@ApiModelProperty("具体类型看 InteractionMessageEnums 枚举")
|
||||
private Integer type;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.message.controller.resp.InteractionMessagePageResp;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 互动消息记录Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
public interface InteractionMessageRecordMapper extends BaseMapper<InteractionMessageRecord>
|
||||
{
|
||||
/**
|
||||
* 查询互动消息记录
|
||||
*
|
||||
* @param id 互动消息记录主键
|
||||
* @return 互动消息记录
|
||||
*/
|
||||
public InteractionMessageRecord selectInteractionMessageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 查询互动消息记录列表
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 互动消息记录集合
|
||||
*/
|
||||
public List<InteractionMessageRecord> selectInteractionMessageRecordList(InteractionMessageRecord interactionMessageRecord);
|
||||
|
||||
/**
|
||||
* 新增互动消息记录
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord);
|
||||
|
||||
/**
|
||||
* 修改互动消息记录
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord);
|
||||
|
||||
/**
|
||||
* 删除互动消息记录
|
||||
*
|
||||
* @param id 互动消息记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInteractionMessageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除互动消息记录
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInteractionMessageRecordByIds(Long[] ids);
|
||||
|
||||
Page<InteractionMessagePageResp> interactionMessagePage(@Param("page") Page<Object> objectPage, @Param("userVo") UserVo userVo);
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?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.ruoyi.message.frequency.interactionmessagerecord.mapper.InteractionMessageRecordMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord" id="InteractionMessageRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="messageType" column="message_type" />
|
||||
<result property="title" column="title" />
|
||||
<result property="content" column="content" />
|
||||
<result property="isRead" column="is_read" />
|
||||
<result property="isShow" column="is_show" />
|
||||
<result property="skipId" column="skip_id" />
|
||||
<result property="interactionUserType" column="interaction_user_type" />
|
||||
<result property="interactionUserId" column="interaction_user_id" />
|
||||
<result property="objectId" column="object_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInteractionMessageRecordVo">
|
||||
select id, create_by, create_time, update_by, update_time, del_flag, user_id, user_type, message_type, title, content, is_read, is_show, skip_id, interaction_user_type, interaction_user_id, object_id from t_interaction_message_record
|
||||
</sql>
|
||||
|
||||
<select id="selectInteractionMessageRecordList" parameterType="com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord" resultMap="InteractionMessageRecordResult">
|
||||
<include refid="selectInteractionMessageRecordVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userType != null "> and user_type = #{userType}</if>
|
||||
<if test="messageType != null "> and message_type = #{messageType}</if>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="content != null and content != ''"> and content = #{content}</if>
|
||||
<if test="isRead != null and isRead != ''"> and is_read = #{isRead}</if>
|
||||
<if test="isShow != null and isShow != ''"> and is_show = #{isShow}</if>
|
||||
<if test="skipId != null "> and skip_id = #{skipId}</if>
|
||||
<if test="interactionUserType != null "> and interaction_user_type = #{interactionUserType}</if>
|
||||
<if test="interactionUserId != null "> and interaction_user_id = #{interactionUserId}</if>
|
||||
<if test="objectId != null "> and object_id = #{objectId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectInteractionMessageRecordById" parameterType="Long" resultMap="InteractionMessageRecordResult">
|
||||
<include refid="selectInteractionMessageRecordVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertInteractionMessageRecord" parameterType="com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord">
|
||||
insert into t_interaction_message_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="messageType != null">message_type,</if>
|
||||
<if test="title != null">title,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="isRead != null">is_read,</if>
|
||||
<if test="isShow != null">is_show,</if>
|
||||
<if test="skipId != null">skip_id,</if>
|
||||
<if test="interactionUserType != null">interaction_user_type,</if>
|
||||
<if test="interactionUserId != null">interaction_user_id,</if>
|
||||
<if test="objectId != null">object_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="messageType != null">#{messageType},</if>
|
||||
<if test="title != null">#{title},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="isRead != null">#{isRead},</if>
|
||||
<if test="isShow != null">#{isShow},</if>
|
||||
<if test="skipId != null">#{skipId},</if>
|
||||
<if test="interactionUserType != null">#{interactionUserType},</if>
|
||||
<if test="interactionUserId != null">#{interactionUserId},</if>
|
||||
<if test="objectId != null">#{objectId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateInteractionMessageRecord" parameterType="com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord">
|
||||
update t_interaction_message_record
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="userType != null">user_type = #{userType},</if>
|
||||
<if test="messageType != null">message_type = #{messageType},</if>
|
||||
<if test="title != null">title = #{title},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="isRead != null">is_read = #{isRead},</if>
|
||||
<if test="isShow != null">is_show = #{isShow},</if>
|
||||
<if test="skipId != null">skip_id = #{skipId},</if>
|
||||
<if test="interactionUserType != null">interaction_user_type = #{interactionUserType},</if>
|
||||
<if test="interactionUserId != null">interaction_user_id = #{interactionUserId},</if>
|
||||
<if test="objectId != null">object_id = #{objectId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteInteractionMessageRecordById" parameterType="Long">
|
||||
delete from t_interaction_message_record where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteInteractionMessageRecordByIds" parameterType="String">
|
||||
delete from t_interaction_message_record where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="interactionMessagePage" resultType="com.ruoyi.message.controller.resp.InteractionMessagePageResp">
|
||||
SELECT
|
||||
t.id,
|
||||
t.create_time,
|
||||
t.message_type,
|
||||
t.title,
|
||||
t.content,
|
||||
t.is_read,
|
||||
t.is_show,
|
||||
t.skip_id,
|
||||
t.interaction_user_type user_type,
|
||||
t.interaction_user_id user_id,
|
||||
t.object_id,
|
||||
CASE
|
||||
|
||||
WHEN t.type IN ( 1, 3, 4, 7 ) THEN
|
||||
1
|
||||
WHEN t.type in (2,5,8,11) THEN
|
||||
2
|
||||
WHEN t.type = 6 THEN
|
||||
3
|
||||
WHEN t.type in (9,10) THEN
|
||||
4
|
||||
ELSE 0
|
||||
END type,
|
||||
CASE
|
||||
|
||||
WHEN t.type IN ( 1, 3, 4, 7 ) THEN
|
||||
IFNULL( p.del_flag, 2 )
|
||||
WHEN t.type in (2,5,8,11) THEN
|
||||
w.del_flag
|
||||
WHEN t.type in (9,10) THEN
|
||||
n.del_flag
|
||||
WHEN t.type = 6 THEN
|
||||
1 ELSE 0
|
||||
END del_flag
|
||||
FROM
|
||||
t_interaction_message_record AS t
|
||||
LEFT JOIN t_post p ON t.object_id = p.id
|
||||
AND t.type IN ( 1, 3, 4, 7 )
|
||||
LEFT JOIN t_works w ON t.object_id = w.id
|
||||
AND t.type in (2,5,8,11)
|
||||
LEFT JOIN t_news n ON t.object_id = n.id
|
||||
AND t.type in (9,10)
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.is_show = 1
|
||||
AND t.user_type = #{userVo.userType}
|
||||
AND t.user_id = #{userVo.userId}
|
||||
ORDER BY
|
||||
t.create_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 互动消息记录对象 t_interaction_message_record
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class InteractionMessageRecordParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志;1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户id;设计师和表现师")
|
||||
@Excel(name = "用户id;设计师和表现师")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
@Excel(name = "消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
private Integer messageType;
|
||||
|
||||
@ApiModelProperty("标语")
|
||||
@Excel(name = "标语")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("是否已读;1未读 2 已读")
|
||||
@Excel(name = "是否已读;1未读 2 已读")
|
||||
private String isRead;
|
||||
|
||||
@ApiModelProperty("是否清空;1 不清空 2 清空")
|
||||
@Excel(name = "是否清空;1 不清空 2 清空")
|
||||
private String isShow;
|
||||
|
||||
@ApiModelProperty("跳转主体id")
|
||||
@Excel(name = "跳转主体id")
|
||||
private Long skipId;
|
||||
|
||||
@ApiModelProperty("用户类型 ")
|
||||
@Excel(name = "用户类型 ")
|
||||
private Integer interactionUserType;
|
||||
|
||||
@ApiModelProperty("互动消息用户id")
|
||||
@Excel(name = "互动消息用户id")
|
||||
private Long interactionUserId;
|
||||
|
||||
@ApiModelProperty("对应的主体id")
|
||||
@Excel(name = "对应的主体id")
|
||||
private Long objectId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 互动消息记录对象 t_interaction_message_record
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class InteractionMessageRecordResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志;1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户id;设计师和表现师")
|
||||
@Excel(name = "用户id;设计师和表现师")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
@Excel(name = "消息类型;1点赞消息 2评论消息 3关注消息")
|
||||
private Integer messageType;
|
||||
|
||||
@ApiModelProperty("标语")
|
||||
@Excel(name = "标语")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("是否已读;1未读 2 已读")
|
||||
@Excel(name = "是否已读;1未读 2 已读")
|
||||
private String isRead;
|
||||
|
||||
@ApiModelProperty("是否清空;1 不清空 2 清空")
|
||||
@Excel(name = "是否清空;1 不清空 2 清空")
|
||||
private String isShow;
|
||||
|
||||
@ApiModelProperty("跳转主体id")
|
||||
@Excel(name = "跳转主体id")
|
||||
private Long skipId;
|
||||
|
||||
@ApiModelProperty("用户类型 ")
|
||||
@Excel(name = "用户类型 ")
|
||||
private Integer interactionUserType;
|
||||
|
||||
@ApiModelProperty("互动消息用户id")
|
||||
@Excel(name = "互动消息用户id")
|
||||
private Long interactionUserId;
|
||||
|
||||
@ApiModelProperty("对应的主体id")
|
||||
@Excel(name = "对应的主体id")
|
||||
private Long objectId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.enums.message.InteractionMessageEnums;
|
||||
import com.ruoyi.controller.req.MessageReadOrDeleteReq;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.PageBasic;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 互动消息记录Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
public interface InteractionMessageRecordService extends IService<InteractionMessageRecord>
|
||||
{
|
||||
/**
|
||||
* 查询互动消息记录
|
||||
*
|
||||
* @param id 互动消息记录主键
|
||||
* @return 互动消息记录
|
||||
*/
|
||||
public InteractionMessageRecord selectInteractionMessageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 查询互动消息记录列表
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 互动消息记录集合
|
||||
*/
|
||||
public List<InteractionMessageRecord> selectInteractionMessageRecordList(InteractionMessageRecord interactionMessageRecord);
|
||||
|
||||
/**
|
||||
* 新增互动消息记录
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord);
|
||||
|
||||
/**
|
||||
* 修改互动消息记录
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord);
|
||||
|
||||
/**
|
||||
* 批量删除互动消息记录
|
||||
*
|
||||
* @param ids 需要删除的互动消息记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInteractionMessageRecordByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除互动消息记录信息
|
||||
*
|
||||
* @param id 互动消息记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInteractionMessageRecordById(Long id);
|
||||
|
||||
/**
|
||||
* 互动消息列表
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData interactionMessagePage(PageBasic req, UserVo userVo);
|
||||
|
||||
/**
|
||||
* 互动消息列表_已读,删除消息
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData interactionMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 生成互动消息
|
||||
* @param userVo 当前用户
|
||||
* @param sendUserVo 目标用户
|
||||
* @param messageType 消息类型;1点赞消息 2评论消息 3关注消息
|
||||
* @param enums 具体类型看 InteractionMessageEnums 枚举
|
||||
* @param objectId
|
||||
*
|
||||
*/
|
||||
void addInteractionMessage(UserVo userVo,UserVo sendUserVo, Integer messageType, Long objectId, Boolean isPush, InteractionMessageEnums enums);
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package com.ruoyi.message.frequency.interactionmessagerecord.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.page.PageResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.controller.req.MessageReadOrDeleteReq;
|
||||
import com.ruoyi.enums.message.InteractionMessageEnums;
|
||||
import com.ruoyi.enums.user.UserEnums;
|
||||
import com.ruoyi.frequency.customer.service.UserService;
|
||||
import com.ruoyi.frequency.store.entity.Store;
|
||||
import com.ruoyi.frequency.store.service.StoreService;
|
||||
import com.ruoyi.message.controller.resp.InteractionMessagePageResp;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.entity.InteractionMessageRecord;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.mapper.InteractionMessageRecordMapper;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService;
|
||||
import com.ruoyi.push.service.PushService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.utils.BusinessUtil;
|
||||
import com.ruoyi.utils.wx.wecom.WecomUtil;
|
||||
import com.ruoyi.vo.PageBasic;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 互动消息记录Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-17
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class InteractionMessageRecordServiceImpl extends ServiceImpl<InteractionMessageRecordMapper, InteractionMessageRecord> implements InteractionMessageRecordService {
|
||||
@Autowired
|
||||
private InteractionMessageRecordMapper interactionMessageRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询互动消息记录
|
||||
*
|
||||
* @param id 互动消息记录主键
|
||||
* @return 互动消息记录
|
||||
*/
|
||||
@Override
|
||||
public InteractionMessageRecord selectInteractionMessageRecordById(Long id) {
|
||||
return interactionMessageRecordMapper.selectInteractionMessageRecordById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询互动消息记录列表
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 互动消息记录
|
||||
*/
|
||||
@Override
|
||||
public List<InteractionMessageRecord> selectInteractionMessageRecordList(InteractionMessageRecord interactionMessageRecord) {
|
||||
return interactionMessageRecordMapper.selectInteractionMessageRecordList(interactionMessageRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增互动消息记录
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord) {
|
||||
interactionMessageRecord.setCreateTime(DateUtils.getNowDate());
|
||||
return interactionMessageRecordMapper.insertInteractionMessageRecord(interactionMessageRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改互动消息记录
|
||||
*
|
||||
* @param interactionMessageRecord 互动消息记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateInteractionMessageRecord(InteractionMessageRecord interactionMessageRecord) {
|
||||
interactionMessageRecord.setUpdateTime(DateUtils.getNowDate());
|
||||
return interactionMessageRecordMapper.updateInteractionMessageRecord(interactionMessageRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除互动消息记录
|
||||
*
|
||||
* @param ids 需要删除的互动消息记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteInteractionMessageRecordByIds(Long[] ids) {
|
||||
this.lambdaUpdate().set(InteractionMessageRecord::getDelFlag, PublicCommon.删除).in(InteractionMessageRecord::getId, ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除互动消息记录信息
|
||||
*
|
||||
* @param id 互动消息记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteInteractionMessageRecordById(Long id) {
|
||||
this.lambdaUpdate().set(InteractionMessageRecord::getDelFlag, PublicCommon.删除).eq(InteractionMessageRecord::getId, id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public ResponseData interactionMessagePage(PageBasic req, UserVo userVo) {
|
||||
Page<InteractionMessagePageResp> page = this.baseMapper.interactionMessagePage(new Page<>(req.getPageNo(), req.getPageSize()), userVo);
|
||||
|
||||
if (!page.getRecords().isEmpty()) {
|
||||
Set<UserVo> userVoSet = page.getRecords().stream().map(resp -> new UserVo(resp.getUserType(), resp.getUserId())).collect(Collectors.toSet());
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
page.getRecords().stream().forEach(resp -> {
|
||||
resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId())));
|
||||
});
|
||||
}
|
||||
|
||||
return ResponseData.success(new PageResult<>(page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData interactionMessageReadOrDelete(MessageReadOrDeleteReq req, UserVo userVo) {
|
||||
//1 标记已读 2 删除消息
|
||||
switch (req.getType()) {
|
||||
case 1:
|
||||
this.update().set("is_read", PublicCommon.Message.已读)
|
||||
.eq("user_type", userVo.getUserType())
|
||||
.eq("user_id", userVo.getUserId())
|
||||
.eq("is_read", PublicCommon.Message.未读)
|
||||
.in(CollectionUtil.isNotEmpty(req.getIds()), "id", req.getIds()).update();
|
||||
break;
|
||||
case 2:
|
||||
|
||||
this.update().set("is_show", PublicCommon.Message.清空)
|
||||
.set("is_read", PublicCommon.Message.已读)
|
||||
.eq("user_type", userVo.getUserType())
|
||||
.eq("user_id", userVo.getUserId())
|
||||
.eq("is_show", PublicCommon.Message.未清空)
|
||||
.in(CollectionUtil.isNotEmpty(req.getIds()), "id", req.getIds()).update();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + req.getType());
|
||||
}
|
||||
return ResponseData.success();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private PushService pushService;
|
||||
|
||||
@Autowired
|
||||
private WecomUtil wecomUtil;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private BusinessUtil businessUtil;
|
||||
|
||||
|
||||
@Override
|
||||
public void addInteractionMessage(UserVo userVo, UserVo sendUserVo, Integer messageType, Long objectId, Boolean isPush, InteractionMessageEnums enums) {
|
||||
|
||||
if (!isPush) {
|
||||
return;
|
||||
}
|
||||
if (BusinessUtil.isSelf(userVo, sendUserVo)) {
|
||||
return;
|
||||
}
|
||||
if (sendUserVo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Boolean canPushMessage = businessUtil.canPushMessage(userVo, sendUserVo);
|
||||
if (!canPushMessage) {
|
||||
return;
|
||||
}
|
||||
//互动消息
|
||||
InteractionMessageRecord messageRecord = new InteractionMessageRecord()
|
||||
.setMessageType(messageType)
|
||||
.setInteractionUserId(userVo.getUserId())
|
||||
.setInteractionUserType(userVo.getUserType())
|
||||
.setSkipId(objectId)
|
||||
.setObjectId(objectId);
|
||||
|
||||
String title = enums.getTitle();
|
||||
String content = enums.getContent();
|
||||
|
||||
messageRecord.setTitle(title);
|
||||
messageRecord.setContent(content);
|
||||
|
||||
messageRecord.setType(enums.getCode());
|
||||
|
||||
messageRecord.setUserType(sendUserVo.getUserType())
|
||||
.setUserId(sendUserVo.getUserId());
|
||||
|
||||
this.save(messageRecord);
|
||||
|
||||
pushService.push(sendUserVo, objectId, messageRecord.getId(), enums);
|
||||
|
||||
//给表现师发送企业微信消息
|
||||
if (ObjectUtil.equal(UserEnums.store.getCode(), sendUserVo.getUserType())) {
|
||||
|
||||
Store store = storeService.getById(sendUserVo.getUserId());
|
||||
|
||||
if (store != null) {
|
||||
|
||||
if (ObjectUtil.isNotEmpty(store.getWecomUserid())) {
|
||||
wecomUtil.sendTextMessage(content, store.getWecomUserid());
|
||||
} else {
|
||||
//获取表现师在企业微信中的userid
|
||||
if (ObjectUtil.isNotEmpty(store.getMobile())) {
|
||||
String userid = wecomUtil.getUserid(store.getMobile());
|
||||
if (ObjectUtil.isNotEmpty(userid)) {
|
||||
storeService.lambdaUpdate().set(Store::getWecomUserid, userid).eq(Store::getId, store.getId()).update();
|
||||
wecomUtil.sendTextMessage(content, store.getWecomUserid());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user