完成小程序端,用户给平台发送聊天信息接口
完成小程序端,查询用户与平台所发送的信息接口, 大致完成平台端,平台给用户发送留言接口, 添加日志,打印Mybatis过程信息。
This commit is contained in:
parent
fad1e6f7cc
commit
a8298d868a
@ -1,4 +1,4 @@
|
|||||||
package com.xhpc.board;
|
package com.xhpc;
|
||||||
|
|
||||||
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
import com.xhpc.common.security.annotation.EnableCustomConfig;
|
||||||
import com.xhpc.common.security.annotation.EnableRyFeignClients;
|
import com.xhpc.common.security.annotation.EnableRyFeignClients;
|
||||||
@ -1,13 +1,14 @@
|
|||||||
package com.xhpc.board.api;
|
package com.xhpc.board.api;
|
||||||
|
|
||||||
|
import com.xhpc.board.domain.QueryUserMassageResponse;
|
||||||
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
||||||
|
import com.xhpc.board.domain.UserQueryCondition;
|
||||||
import com.xhpc.board.service.XhpcMessageBoardService;
|
import com.xhpc.board.service.XhpcMessageBoardService;
|
||||||
import com.xhpc.common.core.web.controller.BaseController;
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import com.xhpc.common.log.annotation.Log;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import com.xhpc.common.log.enums.BusinessType;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ import javax.annotation.Resource;
|
|||||||
* @since version-1.0
|
* @since version-1.0
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/message-board/")
|
@RequestMapping("/api/message-board")
|
||||||
public class XhpcMessageBoardApiController extends BaseController {
|
public class XhpcMessageBoardApiController extends BaseController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -33,9 +34,18 @@ public class XhpcMessageBoardApiController extends BaseController {
|
|||||||
* @since version-1.0
|
* @since version-1.0
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/message")
|
@PostMapping("/user/message")
|
||||||
|
@Log(title = "留言板-用户发送聊天信息", businessType = BusinessType.INSERT)
|
||||||
public AjaxResult sendMessageToPlatform(@RequestBody SendMessageToPlatformRequest userMessage) {
|
public AjaxResult sendMessageToPlatform(@RequestBody SendMessageToPlatformRequest userMessage) {
|
||||||
|
|
||||||
|
xhpcMessageBoardService.writeUserMessageToDb(userMessage);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@GetMapping("/user/message")
|
||||||
|
public AjaxResult queryUserMessage(UserQueryCondition userQueryCondition) {
|
||||||
|
|
||||||
|
QueryUserMassageResponse queryUserMassageResponse = xhpcMessageBoardService.queryUserMessage(userQueryCondition);
|
||||||
|
return AjaxResult.success(queryUserMassageResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.xhpc.board.controller;
|
||||||
|
|
||||||
|
import com.xhpc.board.domain.PlatformSendMessageToUserRequest;
|
||||||
|
import com.xhpc.board.service.XhpcMessageBoardService;
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 留言板服务Controller
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/10 10:02
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/board")
|
||||||
|
public class XhpcMessageBoardController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
XhpcMessageBoardService xhpcMessageBoardService;
|
||||||
|
|
||||||
|
@PostMapping("/platform/message")
|
||||||
|
public AjaxResult platformSendMessageToUser(@RequestBody PlatformSendMessageToUserRequest platformRequest) {
|
||||||
|
|
||||||
|
xhpcMessageBoardService.platformSendMessageToUser(platformRequest);
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.xhpc.board.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台查询条件
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 15:23
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class PlatformQueryCondition {
|
||||||
|
|
||||||
|
@JsonProperty("senderAccount")
|
||||||
|
private String senderAccount;
|
||||||
|
@JsonProperty("senderType")
|
||||||
|
private Integer senderType;
|
||||||
|
@JsonProperty("tenantId")
|
||||||
|
private String tenantId;
|
||||||
|
@JsonProperty("tenantType")
|
||||||
|
private Integer tenantType;
|
||||||
|
@JsonProperty("sendMessageTime")
|
||||||
|
private String sendMessageTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.xhpc.board.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台向用户发送的信息包装类
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 13:47
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class PlatformSendMessageToUserRequest {
|
||||||
|
|
||||||
|
@JsonProperty("sendMessageTime")
|
||||||
|
private String sendMessageTime;
|
||||||
|
@JsonProperty("senderAccount")
|
||||||
|
private String senderAccount;
|
||||||
|
@JsonProperty("senderType")
|
||||||
|
private Integer senderType;
|
||||||
|
@JsonProperty("tenantId")
|
||||||
|
private String tenantId;
|
||||||
|
@JsonProperty("tenantType")
|
||||||
|
private Integer tenantType;
|
||||||
|
@JsonProperty("messageContent")
|
||||||
|
private String messageContent;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.xhpc.board.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户信息的返回封装数据类
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/13 10:23
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class QueryUserMassageResponse {
|
||||||
|
|
||||||
|
@JsonProperty("nextQueryTime")
|
||||||
|
private String nextQueryTime;
|
||||||
|
@JsonProperty("data")
|
||||||
|
private List<DataDTO> data;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class DataDTO {
|
||||||
|
|
||||||
|
@JsonProperty("senderType")
|
||||||
|
private Integer senderType;
|
||||||
|
@JsonProperty("senderAccount")
|
||||||
|
private String senderAccount;
|
||||||
|
@JsonProperty("sendMessageTime")
|
||||||
|
private String sendMessageTime;
|
||||||
|
@JsonProperty("messageContent")
|
||||||
|
private String messageContent;
|
||||||
|
@JsonProperty("tenantType")
|
||||||
|
private Integer tenantType;
|
||||||
|
@JsonProperty("tenantId")
|
||||||
|
private String tenantId;
|
||||||
|
@JsonProperty("have_new_info")
|
||||||
|
private Integer haveNewInfo;
|
||||||
|
@JsonProperty("sender")
|
||||||
|
private Integer sender;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -21,11 +21,11 @@ public class SendMessageToPlatformRequest {
|
|||||||
private String senderAccount;
|
private String senderAccount;
|
||||||
@JsonProperty("senderType")
|
@JsonProperty("senderType")
|
||||||
private Integer senderType;
|
private Integer senderType;
|
||||||
@JsonProperty("senderContent")
|
@JsonProperty("messageContent")
|
||||||
private String senderContent;
|
private String messageContent;
|
||||||
@JsonProperty("receiveId")
|
@JsonProperty("tenantId")
|
||||||
private String receiveId;
|
private String tenantId;
|
||||||
@JsonProperty("receiverType")
|
@JsonProperty("tenantType")
|
||||||
private Integer receiverType;
|
private Integer tenantType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.xhpc.board.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户查询条件
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 15:23
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class UserQueryCondition {
|
||||||
|
|
||||||
|
@JsonProperty("senderAccount")
|
||||||
|
private String senderAccount;
|
||||||
|
@JsonProperty("senderType")
|
||||||
|
private Integer senderType;
|
||||||
|
@JsonProperty("tenantId")
|
||||||
|
private String tenantId;
|
||||||
|
@JsonProperty("tenantType")
|
||||||
|
private Integer tenantType;
|
||||||
|
@JsonProperty("sendMessageTime")
|
||||||
|
private String sendMessageTime;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,97 @@
|
|||||||
|
package com.xhpc.board.mapper;
|
||||||
|
|
||||||
|
import com.xhpc.board.domain.PlatformSendMessageToUserRequest;
|
||||||
|
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
||||||
|
import com.xhpc.board.domain.UserQueryCondition;
|
||||||
|
import com.xhpc.board.pojo.XhpcMessageBoard;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface XhpcMessageBoardMapper {
|
||||||
|
|
||||||
|
int deleteByPrimaryKey(Long messageId);
|
||||||
|
|
||||||
|
int insert(XhpcMessageBoard record);
|
||||||
|
|
||||||
|
int insertSelective(XhpcMessageBoard record);
|
||||||
|
|
||||||
|
XhpcMessageBoard selectByPrimaryKey(Long messageId);
|
||||||
|
|
||||||
|
int updateByPrimaryKeySelective(XhpcMessageBoard record);
|
||||||
|
|
||||||
|
int updateByPrimaryKey(XhpcMessageBoard record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端存入时间记录
|
||||||
|
*
|
||||||
|
* @param userMessage 用户时间记录信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 17:46
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void insertUserTimeMessageRecord(SendMessageToPlatformRequest userMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端存入发送的消息
|
||||||
|
*
|
||||||
|
* @param userMessage 用户发送的消息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 18:16
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void insertUserMessage(SendMessageToPlatformRequest userMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台端存入发送的信息
|
||||||
|
*
|
||||||
|
* @param platformRequest 平台所要发送给用户的信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 11:30
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void insertPlatformMessage(PlatformSendMessageToUserRequest platformRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台端存入时间记录
|
||||||
|
*
|
||||||
|
* @param platformRequest 平台时间记录信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 11:49
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void insertPlatformTimeMessageRecord(PlatformSendMessageToUserRequest platformRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户一个月的记录
|
||||||
|
*
|
||||||
|
* @param userQueryCondition 用户查询条件
|
||||||
|
* @param nextTimeStr 上一个月的时间
|
||||||
|
* @return 返回一个装有一个月的数据的集合
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 16:03
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
List<XhpcMessageBoard> selectBy(@Param("userQueryCondition") UserQueryCondition userQueryCondition, @Param("nextTimeStr") String nextTimeStr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 给查询出来的记录,添加用户已读状态
|
||||||
|
*
|
||||||
|
* @param messageIdList 查询出来的记录的id集合
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/13 10:16
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void setUserReadedStatus(List<Long> messageIdList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户所有时间记录
|
||||||
|
*
|
||||||
|
* @param userQueryCondition 用户信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/13 10:56
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
List<XhpcMessageBoard> selectTimeRecords(UserQueryCondition userQueryCondition);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.xhpc.board.mapper;
|
||||||
|
|
||||||
|
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
||||||
|
import com.xhpc.board.pojo.XhpcMessageBoardReceiveUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the mapper of the xhpc_message_board_receive_user
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 10:26
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
public interface XhpcMessageBoardReceiveUserMapper {
|
||||||
|
|
||||||
|
int insert(XhpcMessageBoardReceiveUser record);
|
||||||
|
|
||||||
|
int insertSelective(XhpcMessageBoardReceiveUser record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户id,用户类型,租户id,租户类型,查询指定记录
|
||||||
|
*
|
||||||
|
* @param userMessage 储存条件的包装类
|
||||||
|
* @return 指定记录
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/10 18:03
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
XhpcMessageBoardReceiveUser findOneByCondition(SendMessageToPlatformRequest userMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将指定用户记录have_new_info字段的值,将其设置为0,即该用户发送了新消息
|
||||||
|
*
|
||||||
|
* @param userMessage 指定要更新哪个记录的条件
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 10:31
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void updateHaveNewInfoFiledByUserCondition(SendMessageToPlatformRequest userMessage);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.xhpc.board.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xhpc_message_board
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class XhpcMessageBoard implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息id
|
||||||
|
*/
|
||||||
|
private Long messageId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型
|
||||||
|
*/
|
||||||
|
private Integer senderType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账号
|
||||||
|
*/
|
||||||
|
private String senderAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息的时间
|
||||||
|
*/
|
||||||
|
private Date sendMessageTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
private String messageContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户类型
|
||||||
|
*/
|
||||||
|
private Integer tenantType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户id(平台id)
|
||||||
|
*/
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户发送的消息,用户是否已读,默认为null,表示未读,0表示已读
|
||||||
|
*/
|
||||||
|
private Integer haveNewInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑删除字段
|
||||||
|
*/
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者(0,用户,1,时间,2,平台(租户))
|
||||||
|
*/
|
||||||
|
private Integer sender;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.xhpc.board.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xhpc_message_board_receive_user
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class XhpcMessageBoardReceiveUser implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收者id(租户id)
|
||||||
|
*/
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接收者类型(租户类型)
|
||||||
|
*/
|
||||||
|
private Integer tenantType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者账号
|
||||||
|
*/
|
||||||
|
private String senderAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送者类型(0 C端用户 1 流量方用户 2社区用户 3B端用户)
|
||||||
|
*/
|
||||||
|
private Integer senderType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户头像地址
|
||||||
|
*/
|
||||||
|
private String userIcon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有新消息(null表示有新消息,0表示没有)
|
||||||
|
*/
|
||||||
|
private Integer haveNewInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 逻辑删除(0为删除)
|
||||||
|
*/
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,10 @@
|
|||||||
package com.xhpc.board.service;
|
package com.xhpc.board.service;
|
||||||
|
|
||||||
|
import com.xhpc.board.domain.PlatformSendMessageToUserRequest;
|
||||||
|
import com.xhpc.board.domain.QueryUserMassageResponse;
|
||||||
|
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
||||||
|
import com.xhpc.board.domain.UserQueryCondition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 留言板服务的Service
|
* 留言板服务的Service
|
||||||
*
|
*
|
||||||
@ -7,6 +12,38 @@ package com.xhpc.board.service;
|
|||||||
* @date 2022/1/7 17:57
|
* @date 2022/1/7 17:57
|
||||||
* @since version-1.0
|
* @since version-1.0
|
||||||
*/
|
*/
|
||||||
public class XhpcMessageBoardService {
|
public interface XhpcMessageBoardService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将用户发送的信息保存到数据库中
|
||||||
|
*
|
||||||
|
* @param userMessage 用户发送的信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/10 14:17
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void writeUserMessageToDb(SendMessageToPlatformRequest userMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将平台(租户)发送的信息保存到数据库中
|
||||||
|
*
|
||||||
|
* @param platformRequest 平台消息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 13:58
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
void platformSendMessageToUser(PlatformSendMessageToUserRequest platformRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户条件,查询指定的数据库中的记录
|
||||||
|
*
|
||||||
|
* @param userQueryCondition 用户传入的条件
|
||||||
|
* @return 用户在数据库中发送的记录
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 15:30
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
QueryUserMassageResponse queryUserMessage(UserQueryCondition userQueryCondition);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,228 @@
|
|||||||
package com.xhpc.board.service.impl;
|
package com.xhpc.board.service.impl;
|
||||||
|
|
||||||
public class XhpcMessageBoardServiceImpl {
|
import com.xhpc.board.domain.PlatformSendMessageToUserRequest;
|
||||||
|
import com.xhpc.board.domain.QueryUserMassageResponse;
|
||||||
|
import com.xhpc.board.domain.SendMessageToPlatformRequest;
|
||||||
|
import com.xhpc.board.domain.UserQueryCondition;
|
||||||
|
import com.xhpc.board.mapper.XhpcMessageBoardMapper;
|
||||||
|
import com.xhpc.board.mapper.XhpcMessageBoardReceiveUserMapper;
|
||||||
|
import com.xhpc.board.pojo.XhpcMessageBoard;
|
||||||
|
import com.xhpc.board.pojo.XhpcMessageBoardReceiveUser;
|
||||||
|
import com.xhpc.board.service.XhpcMessageBoardService;
|
||||||
|
import com.xhpc.common.api.UserTypeService;
|
||||||
|
import com.xhpc.common.core.domain.R;
|
||||||
|
import com.xhpc.common.core.utils.DateUtils;
|
||||||
|
import com.xhpc.common.core.utils.bean.BeanUtils;
|
||||||
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
|
import com.xhpc.common.security.service.TokenService;
|
||||||
|
import com.xhpc.common.util.DateUtil;
|
||||||
|
import com.xhpc.system.api.domain.SysUser;
|
||||||
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 留言板实现类
|
||||||
|
*
|
||||||
|
* @author WH
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
TokenService tokenService;
|
||||||
|
@Resource
|
||||||
|
XhpcMessageBoardMapper messageBoardMapper;
|
||||||
|
@Resource
|
||||||
|
XhpcMessageBoardReceiveUserMapper xhpcMessageBoardReceiveUserMapper;
|
||||||
|
@Resource
|
||||||
|
RedisService redisService;
|
||||||
|
@Resource
|
||||||
|
UserTypeService userTypeService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将用户发送的信息保存到数据库中
|
||||||
|
*
|
||||||
|
* @param userMessage 用户发送的信息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/10 14:17
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void writeUserMessageToDb(SendMessageToPlatformRequest userMessage) {
|
||||||
|
//解析Token,获取用户与平台用户信息
|
||||||
|
LoginUser loginUser = tokenService.getLoginUser();
|
||||||
|
String userRedisKey = "userMessageValidTime:" + loginUser.getUserType() + ":" + loginUser.getUserid() + ":" + userMessage.getTenantType() + ":" + userMessage.getTenantId();
|
||||||
|
//使用Redis判断消息发送是否大于5分钟:
|
||||||
|
Object cacheObject = redisService.getCacheObject(userRedisKey);
|
||||||
|
String currentTime;
|
||||||
|
if (cacheObject == null) {
|
||||||
|
//设置当前时间
|
||||||
|
currentTime = DateUtil.getYyyyMmDdHhMmSs();
|
||||||
|
redisService.setCacheObject(userRedisKey, currentTime);
|
||||||
|
redisService.expire(userRedisKey, 60 * 5);
|
||||||
|
//设置平台RedisKey的有效时间,保证双方时间数据同步
|
||||||
|
String platformRedisKey = "PlatformMessageValidTime:" + userMessage.getTenantType() + ":" + userMessage.getTenantId() + ":" + loginUser.getUserType() + ":" + loginUser.getUsername();
|
||||||
|
redisService.setCacheObject(platformRedisKey, currentTime);
|
||||||
|
redisService.expire(platformRedisKey, 60 * 5);
|
||||||
|
userMessage.setSendMessageTime(currentTime);
|
||||||
|
userMessage.setSenderAccount(loginUser.getUsername());
|
||||||
|
userMessage.setSenderType(loginUser.getUserType());
|
||||||
|
messageBoardMapper.insertUserTimeMessageRecord(userMessage);
|
||||||
|
messageBoardMapper.insertUserMessage(userMessage);
|
||||||
|
XhpcMessageBoardReceiveUser receiverUser = xhpcMessageBoardReceiveUserMapper.findOneByCondition(userMessage);
|
||||||
|
if (receiverUser == null) {
|
||||||
|
XhpcMessageBoardReceiveUser xhpcMessageBoardReceiveUser = new XhpcMessageBoardReceiveUser();
|
||||||
|
BeanUtils.copyProperties(userMessage, xhpcMessageBoardReceiveUser);
|
||||||
|
//发送请求所返回的响应信息
|
||||||
|
R<Map<String, Object>> result = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null, userMessage.getTenantId());
|
||||||
|
Map<String, Object> userInfo = result.getData();
|
||||||
|
String avatar = (String) userInfo.get("avatar");
|
||||||
|
xhpcMessageBoardReceiveUser.setUserIcon(avatar);
|
||||||
|
xhpcMessageBoardReceiveUser.setHaveNewInfo(0);
|
||||||
|
xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser);
|
||||||
|
} else {
|
||||||
|
xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//reset redis key valid time
|
||||||
|
redisService.expire(userRedisKey, 60 * 5);
|
||||||
|
currentTime = (String) cacheObject;
|
||||||
|
userMessage.setSendMessageTime(currentTime);
|
||||||
|
//设置用户账号,用户类型
|
||||||
|
userMessage.setSenderAccount(loginUser.getUsername());
|
||||||
|
userMessage.setSenderType(loginUser.getUserType());
|
||||||
|
messageBoardMapper.insertUserMessage(userMessage);
|
||||||
|
//向租户显示的列表中添加该用户信息,表示该用户来新消息了,如果列表中已经有该用户了,则只更新状态即可。
|
||||||
|
XhpcMessageBoardReceiveUser receiverUser = xhpcMessageBoardReceiveUserMapper.findOneByCondition(userMessage);
|
||||||
|
if (receiverUser == null) {
|
||||||
|
XhpcMessageBoardReceiveUser xhpcMessageBoardReceiveUser = new XhpcMessageBoardReceiveUser();
|
||||||
|
BeanUtils.copyProperties(userMessage, xhpcMessageBoardReceiveUser);
|
||||||
|
//发送请求所返回的响应信息
|
||||||
|
R<Map<String, Object>> result = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null, userMessage.getTenantId());
|
||||||
|
Map<String, Object> userInfo = result.getData();
|
||||||
|
String avatar = (String) userInfo.get("avatar");
|
||||||
|
xhpcMessageBoardReceiveUser.setUserIcon(avatar);
|
||||||
|
xhpcMessageBoardReceiveUser.setHaveNewInfo(0);
|
||||||
|
xhpcMessageBoardReceiveUserMapper.insertSelective(xhpcMessageBoardReceiveUser);
|
||||||
|
} else {
|
||||||
|
xhpcMessageBoardReceiveUserMapper.updateHaveNewInfoFiledByUserCondition(userMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将平台(租户)发送的信息保存到数据库中
|
||||||
|
*
|
||||||
|
* @param platformRequest 平台消息
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/11 13:58
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void platformSendMessageToUser(PlatformSendMessageToUserRequest platformRequest) {
|
||||||
|
|
||||||
|
//获取平台用户信息
|
||||||
|
SysUser sysUser = tokenService.getLoginUser().getSysUser();
|
||||||
|
//使用redis控制发送时间
|
||||||
|
String platformRedisKey = "PlatformMessageValidTime:" + "0:" + sysUser.getTenantId() + ":" + platformRequest.getSenderType() + ":" + platformRequest.getSenderAccount();
|
||||||
|
Object cacheObject = redisService.getCacheObject(platformRedisKey);
|
||||||
|
String currentTime;
|
||||||
|
if (cacheObject == null) {
|
||||||
|
//设置当前时间
|
||||||
|
currentTime = DateUtil.getYyyyMmDdHhMmSs();
|
||||||
|
redisService.setCacheObject(platformRedisKey, currentTime);
|
||||||
|
redisService.expire(platformRedisKey, 60 * 5);
|
||||||
|
//设置用户RedisKey的有效时间,保证双方时间数据同步
|
||||||
|
String userRedisKey = "userMessageValidTime:" + platformRequest.getSenderType() + ":" + platformRequest.getSenderAccount() + ":" + "0:" + sysUser.getTenantId();
|
||||||
|
redisService.setCacheObject(userRedisKey, currentTime);
|
||||||
|
redisService.expire(userRedisKey, 60 * 5);
|
||||||
|
platformRequest.setSendMessageTime(currentTime);
|
||||||
|
platformRequest.setTenantId(sysUser.getTenantId());
|
||||||
|
platformRequest.setTenantType(0);
|
||||||
|
messageBoardMapper.insertPlatformTimeMessageRecord(platformRequest);
|
||||||
|
messageBoardMapper.insertPlatformMessage(platformRequest);
|
||||||
|
}
|
||||||
|
//reset redis key valid time
|
||||||
|
redisService.expire(platformRedisKey, 60 * 5);
|
||||||
|
platformRequest.setSendMessageTime((String) cacheObject);
|
||||||
|
platformRequest.setTenantId(sysUser.getTenantId());
|
||||||
|
platformRequest.setTenantType(0);
|
||||||
|
messageBoardMapper.insertPlatformMessage(platformRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户条件,查询指定的数据库中的记录
|
||||||
|
*
|
||||||
|
* @param userQueryCondition 用户传入的条件
|
||||||
|
* @author WH
|
||||||
|
* @date 2022/1/12 15:30
|
||||||
|
* @since version-1.0
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public QueryUserMassageResponse queryUserMessage(UserQueryCondition userQueryCondition) {
|
||||||
|
//完善条件集合
|
||||||
|
LoginUser loginUser = tokenService.getLoginUser();
|
||||||
|
userQueryCondition.setSenderAccount(loginUser.getUsername());
|
||||||
|
userQueryCondition.setSenderType(loginUser.getUserType());
|
||||||
|
String nextTimeStr = null;
|
||||||
|
if ("".equals(userQueryCondition.getSendMessageTime()) || userQueryCondition.getSendMessageTime() == null || "null".equals(userQueryCondition.getSendMessageTime())) {
|
||||||
|
userQueryCondition.setSendMessageTime(DateUtil.getYyyyMmDdHhMmSs());
|
||||||
|
//查询用户是否有数据,即查询该用户的所有时间记录(有时间记录表示该用户发送过信息)
|
||||||
|
List<XhpcMessageBoard> allTimeRecords = messageBoardMapper.selectTimeRecords(userQueryCondition);
|
||||||
|
QueryUserMassageResponse queryUserMassageResponse = new QueryUserMassageResponse();
|
||||||
|
if (allTimeRecords.size() == 0) {
|
||||||
|
return queryUserMassageResponse;
|
||||||
|
}
|
||||||
|
//获取最后一个时间记录,将其减去一个月,放入查询条件中
|
||||||
|
XhpcMessageBoard xhpcMessageBoard = allTimeRecords.get(allTimeRecords.size() - 1);
|
||||||
|
Date finalTime = xhpcMessageBoard.getSendMessageTime();
|
||||||
|
userQueryCondition.setSendMessageTime(DateUtils.parseDateToStr(finalTime));
|
||||||
|
Calendar finalTimeCalendar = DateUtil.getCalendar(finalTime);
|
||||||
|
finalTimeCalendar.add(Calendar.MONTH, -1);
|
||||||
|
Date nextTime = finalTimeCalendar.getTime();
|
||||||
|
nextTimeStr = DateUtils.parseDateToStr(nextTime);
|
||||||
|
} else {
|
||||||
|
//如果有值过来,说明有之前的记录,计算上一个月的值,作为查询条件,并返回
|
||||||
|
String sendMessageTimeStr = userQueryCondition.getSendMessageTime();
|
||||||
|
Date sendMessageTimeDate = DateUtils.parseDate(sendMessageTimeStr);
|
||||||
|
Calendar nextTimeCalendar = DateUtil.getCalendar(sendMessageTimeDate);
|
||||||
|
nextTimeCalendar.add(Calendar.MONTH, -1);
|
||||||
|
Date nextTime = nextTimeCalendar.getTime();
|
||||||
|
nextTimeStr = DateUtils.parseDateToStr(nextTime);
|
||||||
|
}
|
||||||
|
//根据用户信息中所保存的时间,与上个月时间进行区间查询
|
||||||
|
List<XhpcMessageBoard> aMonthRecords = messageBoardMapper.selectBy(userQueryCondition, nextTimeStr);
|
||||||
|
//如果没有数据,则返回空实体类对象
|
||||||
|
QueryUserMassageResponse response = new QueryUserMassageResponse();
|
||||||
|
if (aMonthRecords.size() == 0) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
List<Long> messageIdList = new ArrayList<>();
|
||||||
|
for (int index = 0; index <= aMonthRecords.size() - 1; index++) {
|
||||||
|
Long messageId = aMonthRecords.get(index).getMessageId();
|
||||||
|
messageIdList.add(messageId);
|
||||||
|
}
|
||||||
|
//设置查询出来的记录为已读状态
|
||||||
|
messageBoardMapper.setUserReadedStatus(messageIdList);
|
||||||
|
//封装数据
|
||||||
|
ArrayList<QueryUserMassageResponse.DataDTO> dataDTOS = new ArrayList<>();
|
||||||
|
for (XhpcMessageBoard aMonthRecord : aMonthRecords) {
|
||||||
|
QueryUserMassageResponse.DataDTO dataDTO = new QueryUserMassageResponse.DataDTO();
|
||||||
|
BeanUtils.copyProperties(aMonthRecord, dataDTO);
|
||||||
|
dataDTO.setSendMessageTime(DateUtils.parseDateToStr(aMonthRecord.getSendMessageTime()));
|
||||||
|
dataDTOS.add(dataDTO);
|
||||||
|
}
|
||||||
|
//处理下次查询时间
|
||||||
|
//todo 截取时间
|
||||||
|
response.setNextQueryTime(nextTimeStr);
|
||||||
|
response.setData(dataDTOS);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,4 +22,7 @@ spring:
|
|||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.xhpc.board.mapper: debug
|
||||||
@ -0,0 +1,292 @@
|
|||||||
|
<?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">
|
||||||
|
<!--suppress ALL -->
|
||||||
|
<mapper namespace="com.xhpc.board.mapper.XhpcMessageBoardMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.xhpc.board.pojo.XhpcMessageBoard">
|
||||||
|
<id column="message_id" jdbcType="BIGINT" property="messageId"/>
|
||||||
|
<result column="sender_type" jdbcType="TINYINT" property="senderType"/>
|
||||||
|
<result column="sender_account" jdbcType="VARCHAR" property="senderAccount"/>
|
||||||
|
<result column="send_message_time" jdbcType="TIMESTAMP" property="sendMessageTime"/>
|
||||||
|
<result column="message_content" jdbcType="VARCHAR" property="messageContent"/>
|
||||||
|
<result column="tenant_type" jdbcType="TINYINT" property="tenantType"/>
|
||||||
|
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
|
||||||
|
<result column="have_new_info" jdbcType="TINYINT" property="haveNewInfo"/>
|
||||||
|
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
|
||||||
|
<result column="sender" jdbcType="TINYINT" property="sender"/>
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
message_id
|
||||||
|
, sender_type, sender_account, send_message_time, message_content, tenant_type,
|
||||||
|
tenant_id, have_new_info, del_flag, sender
|
||||||
|
</sql>
|
||||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from xhpc_message_board
|
||||||
|
where message_id = #{messageId,jdbcType=BIGINT}
|
||||||
|
</select>
|
||||||
|
<select id="selectBy" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM
|
||||||
|
xhpc_message_board
|
||||||
|
WHERE
|
||||||
|
del_flag is NULL
|
||||||
|
AND sender_type = #{userQueryCondition.senderType}
|
||||||
|
AND sender_account = #{userQueryCondition.senderAccount}
|
||||||
|
AND send_message_time <= #{userQueryCondition.sendMessageTime}
|
||||||
|
<if test="nextTimeStr!=null">
|
||||||
|
AND send_message_time > #{nextTimeStr}
|
||||||
|
</if>
|
||||||
|
AND tenant_type = #{userQueryCondition.tenantType}
|
||||||
|
AND tenant_id = #{userQueryCondition.tenantId}
|
||||||
|
</select>
|
||||||
|
<select id="selectTimeRecords" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM
|
||||||
|
xhpc_message_board
|
||||||
|
WHERE
|
||||||
|
sender_type = #{senderType}
|
||||||
|
AND sender_account = #{senderAccount}
|
||||||
|
AND del_flag IS NULL
|
||||||
|
AND message_content IS NULL
|
||||||
|
</select>
|
||||||
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||||
|
delete
|
||||||
|
from xhpc_message_board
|
||||||
|
where message_id = #{messageId,jdbcType=BIGINT}
|
||||||
|
</delete>
|
||||||
|
<insert id="insert" keyColumn="message_id" keyProperty="messageId"
|
||||||
|
parameterType="com.xhpc.board.pojo.XhpcMessageBoard" useGeneratedKeys="true">
|
||||||
|
insert into xhpc_message_board (sender_type, sender_account, send_message_time,
|
||||||
|
message_content, tenant_type, tenant_id,
|
||||||
|
have_new_info, del_flag, sender)
|
||||||
|
values (#{senderType,jdbcType=TINYINT}, #{senderAccount,jdbcType=VARCHAR},
|
||||||
|
#{sendMessageTime,jdbcType=TIMESTAMP},
|
||||||
|
#{messageContent,jdbcType=VARCHAR}, #{tenantType,jdbcType=TINYINT}, #{tenantId,jdbcType=VARCHAR},
|
||||||
|
#{haveNewInfo,jdbcType=BOOLEAN}, #{delFlag,jdbcType=BOOLEAN}, #{sender,jdbcType=BOOLEAN})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" keyColumn="message_id" keyProperty="messageId"
|
||||||
|
parameterType="com.xhpc.board.pojo.XhpcMessageBoard" useGeneratedKeys="true">
|
||||||
|
insert into xhpc_message_board
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="senderType != null">
|
||||||
|
sender_type,
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
sender_account,
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
send_message_time,
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
message_content,
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
tenant_type,
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id,
|
||||||
|
</if>
|
||||||
|
<if test="haveNewInfo != null">
|
||||||
|
have_new_info,
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
del_flag,
|
||||||
|
</if>
|
||||||
|
<if test="sender != null">
|
||||||
|
sender,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="senderType != null">
|
||||||
|
#{senderType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
#{senderAccount,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
#{sendMessageTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
#{messageContent,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
#{tenantType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
#{tenantId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="haveNewInfo != null">
|
||||||
|
#{haveNewInfo,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
#{delFlag,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
<if test="sender != null">
|
||||||
|
#{sender,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<insert id="insertUserTimeMessageRecord">
|
||||||
|
insert into xhpc_message_board
|
||||||
|
(sender_type, sender_account, send_message_time, tenant_type, tenant_id, sender)
|
||||||
|
values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 1)
|
||||||
|
</insert>
|
||||||
|
<insert id="insertUserMessage">
|
||||||
|
insert into xhpc_message_board
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="senderType != null">
|
||||||
|
sender_type,
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
sender_account,
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
send_message_time,
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
message_content,
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
tenant_type,
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id,
|
||||||
|
</if>
|
||||||
|
have_new_info,
|
||||||
|
sender,
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="senderType != null">
|
||||||
|
#{senderType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
#{senderAccount,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
#{sendMessageTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
#{messageContent,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
#{tenantType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
#{tenantId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<insert id="insertPlatformMessage">
|
||||||
|
insert into xhpc_message_board
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="senderType != null">
|
||||||
|
sender_type,
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
sender_account,
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
send_message_time,
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
message_content,
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
tenant_type,
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id,
|
||||||
|
</if>
|
||||||
|
have_new_info,
|
||||||
|
sender,
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="senderType != null">
|
||||||
|
#{senderType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
#{senderAccount,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
#{sendMessageTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
#{messageContent,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
#{tenantType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
#{tenantId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<insert id="insertPlatformTimeMessageRecord">
|
||||||
|
insert into xhpc_message_board
|
||||||
|
(sender_type, sender_account, send_message_time, tenant_type, tenant_id, sender)
|
||||||
|
values (#{senderType}, #{senderAccount}, #{sendMessageTime}, #{tenantType}, #{tenantId}, 1)
|
||||||
|
</insert>
|
||||||
|
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.board.pojo.XhpcMessageBoard">
|
||||||
|
update xhpc_message_board
|
||||||
|
<set>
|
||||||
|
<if test="senderType != null">
|
||||||
|
sender_type = #{senderType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
sender_account = #{senderAccount,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="sendMessageTime != null">
|
||||||
|
send_message_time = #{sendMessageTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="messageContent != null">
|
||||||
|
message_content = #{messageContent,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
tenant_type = #{tenantType,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id = #{tenantId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="haveNewInfo != null">
|
||||||
|
have_new_info = #{haveNewInfo,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
del_flag = #{delFlag,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
<if test="sender != null">
|
||||||
|
sender = #{sender,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where message_id = #{messageId,jdbcType=BIGINT}
|
||||||
|
</update>
|
||||||
|
<update id="updateByPrimaryKey" parameterType="com.xhpc.board.pojo.XhpcMessageBoard">
|
||||||
|
update xhpc_message_board
|
||||||
|
set sender_type = #{senderType,jdbcType=TINYINT},
|
||||||
|
sender_account = #{senderAccount,jdbcType=VARCHAR},
|
||||||
|
send_message_time = #{sendMessageTime,jdbcType=TIMESTAMP},
|
||||||
|
message_content = #{messageContent,jdbcType=VARCHAR},
|
||||||
|
tenant_type = #{tenantType,jdbcType=TINYINT},
|
||||||
|
tenant_id = #{tenantId,jdbcType=VARCHAR},
|
||||||
|
have_new_info = #{haveNewInfo,jdbcType=BOOLEAN},
|
||||||
|
del_flag = #{delFlag,jdbcType=BOOLEAN},
|
||||||
|
sender = #{sender,jdbcType=BOOLEAN}
|
||||||
|
where message_id = #{messageId,jdbcType=BIGINT}
|
||||||
|
</update>
|
||||||
|
<update id="setUserReadedStatus">
|
||||||
|
UPDATE `xhpc_message_board`
|
||||||
|
SET have_new_info = 1
|
||||||
|
WHERE
|
||||||
|
message_id IN
|
||||||
|
<foreach collection="list" separator="," item="messageId" open="(" close=")">
|
||||||
|
#{messageId}
|
||||||
|
</foreach>
|
||||||
|
AND del_flag IS NULL
|
||||||
|
</update>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,102 @@
|
|||||||
|
<?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">
|
||||||
|
<!--suppress ALL -->
|
||||||
|
<mapper namespace="com.xhpc.board.mapper.XhpcMessageBoardReceiveUserMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.xhpc.board.pojo.XhpcMessageBoardReceiveUser">
|
||||||
|
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
|
||||||
|
<result column="tenant_type" jdbcType="INTEGER" property="tenantType"/>
|
||||||
|
<result column="sender_account" jdbcType="VARCHAR" property="senderAccount"/>
|
||||||
|
<result column="sender_type" jdbcType="INTEGER" property="senderType"/>
|
||||||
|
<result column="user_icon" jdbcType="VARCHAR" property="userIcon"/>
|
||||||
|
<result column="have_new_info" jdbcType="BOOLEAN" property="haveNewInfo"/>
|
||||||
|
<result column="del_flag" jdbcType="BOOLEAN" property="delFlag"/>
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
tenant_id
|
||||||
|
,
|
||||||
|
tenant_type,
|
||||||
|
sender_account,
|
||||||
|
sender_type,
|
||||||
|
user_icon,
|
||||||
|
have_new_info,
|
||||||
|
del_flag
|
||||||
|
</sql>
|
||||||
|
<insert id="insert" parameterType="com.xhpc.board.pojo.XhpcMessageBoardReceiveUser">
|
||||||
|
insert into xhpc_message_board_receive_user (tenant_id, tenant_type, sender_account,
|
||||||
|
sender_type, user_icon, have_new_info,
|
||||||
|
del_flag)
|
||||||
|
values (#{tenantId,jdbcType=VARCHAR}, #{tenantType,jdbcType=INTEGER}, #{senderAccount,jdbcType=VARCHAR},
|
||||||
|
#{senderType,jdbcType=INTEGER}, #{userIcon,jdbcType=VARCHAR}, #{haveNewInfo,jdbcType=BOOLEAN},
|
||||||
|
#{delFlag,jdbcType=BOOLEAN})
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" parameterType="com.xhpc.board.pojo.XhpcMessageBoardReceiveUser">
|
||||||
|
insert into xhpc_message_board_receive_user
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="tenantId != null">
|
||||||
|
tenant_id,
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
tenant_type,
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
sender_account,
|
||||||
|
</if>
|
||||||
|
<if test="senderType != null">
|
||||||
|
sender_type,
|
||||||
|
</if>
|
||||||
|
<if test="userIcon != null">
|
||||||
|
user_icon,
|
||||||
|
</if>
|
||||||
|
<if test="haveNewInfo != null">
|
||||||
|
have_new_info,
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
del_flag,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="tenantId != null">
|
||||||
|
#{tenantId,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="tenantType != null">
|
||||||
|
#{tenantType,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="senderAccount != null">
|
||||||
|
#{senderAccount,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="senderType != null">
|
||||||
|
#{senderType,jdbcType=INTEGER},
|
||||||
|
</if>
|
||||||
|
<if test="userIcon != null">
|
||||||
|
#{userIcon,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="haveNewInfo != null">
|
||||||
|
#{haveNewInfo,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
<if test="delFlag != null">
|
||||||
|
#{delFlag,jdbcType=BOOLEAN},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
<update id="updateHaveNewInfoFiledByUserCondition">
|
||||||
|
UPDATE xhpc_message_board_receive_user
|
||||||
|
SET have_new_info = 0
|
||||||
|
WHERE tenant_type = #{tenantType}
|
||||||
|
AND tenant_id = #{tenantId}
|
||||||
|
AND sender_account = #{senderAccount}
|
||||||
|
AND sender_type = #{senderType}
|
||||||
|
AND del_flag IS NULL;
|
||||||
|
</update>
|
||||||
|
<select id="findOneByCondition" resultMap="BaseResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM
|
||||||
|
xhpc_message_board_receive_user
|
||||||
|
WHERE
|
||||||
|
tenant_id = #{tenantId}
|
||||||
|
AND tenant_type = #{tenantType}
|
||||||
|
AND sender_account = #{senderAccount}
|
||||||
|
AND sender_type = #{senderType}
|
||||||
|
AND del_flag IS NULL
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user