新增消息中心功能

This commit is contained in:
xiezhijun 2021-04-27 19:48:22 +08:00
parent d5e9933fe7
commit bbbc4f2753
14 changed files with 742 additions and 3 deletions

View File

@ -13,6 +13,7 @@ import com.stdiet.common.utils.poi.ExcelUtil;
import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.domain.SysWxUserLog;
import com.stdiet.custom.page.WxLogInfo;
import com.stdiet.custom.service.ISysMessageNoticeService;
import com.stdiet.custom.service.ISysOrderService;
import com.stdiet.custom.service.ISysWxUserInfoService;
import com.stdiet.custom.service.ISysWxUserLogService;
@ -40,8 +41,12 @@ public class SysWxUserLogController extends BaseController {
@Autowired
private ISysWxUserInfoService sysWxUserInfoService;
@Autowired
private ISysOrderService sysOrderService;
@Autowired
private ISysMessageNoticeService sysMessageNoticeService;
/**
* 查询微信用户记录列表
*/
@ -211,6 +216,11 @@ public class SysWxUserLogController extends BaseController {
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:query')")
@PostMapping("/commentPunchContent")
public AjaxResult commentPunchContent(@RequestBody SysWxUserLog sysWxUserLog) {
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
int row = sysWxUserLogService.updateSysWxUserLog(sysWxUserLog);
if(row > 0){
SysWxUserLog log = sysWxUserLogService.selectSysWxUserLogById(sysWxUserLog.getId()+"");
sysMessageNoticeService.sendPunchCommentMessage(log);
}
return toAjax(row);
}
}

View File

@ -14,8 +14,10 @@ import com.stdiet.common.utils.oss.AliyunOSSUtils;
import com.stdiet.common.utils.sign.AesUtils;
import com.stdiet.custom.domain.*;
import com.stdiet.custom.dto.response.CustomerCaseResponse;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
import com.stdiet.custom.page.WxLogInfo;
import com.stdiet.custom.service.*;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@ -51,6 +53,12 @@ public class WechatAppletController extends BaseController {
@Autowired
private ISysAskNutritionQuestionService sysAskNutritionQuestionService;
@Autowired
private ISysMessageNoticeService sysMessageNoticeService;
@Autowired
private ISysCustomerService sysCustomerService;
/**
* 查询微信小程序中展示的客户案例
*/
@ -89,7 +97,7 @@ public class WechatAppletController extends BaseController {
}
/**
* 同步客户信息返回订单数量
* 同步客户信息
* @param sysWxUserInfo
* @return
*/
@ -106,7 +114,17 @@ public class WechatAppletController extends BaseController {
}else{
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
}
return AjaxResult.success();
Map<String,Object> result = new HashMap<>();
//根据手机号查询返回用户加密ID
SysCustomer customer = sysCustomerService.getCustomerByPhone(sysWxUserInfo.getPhone());
result.put("customerId", customer != null ? AesUtils.encrypt(customer.getId()+"", null) : null);
//查询未读消息数量
SysMessageNotice messageParam = new SysMessageNotice();
messageParam.setReadType(0);
messageParam.setMessageCustomer(customer != null ? customer.getId() : 0);
int unReadNoticeTotal = sysMessageNoticeService.getCustomerMessageCount(messageParam);
result.put("unReadNoticeTotal", unReadNoticeTotal);
return AjaxResult.success(result);
}
/**
@ -309,4 +327,30 @@ public class WechatAppletController extends BaseController {
}
return toAjax(sysAskNutritionQuestionService.insertSysAskNutritionQuestion(sysAskNutritionQuestion));
}
/**
* 获取用户通知消息
*/
@GetMapping(value = "/getCustomerMessage")
public TableDataInfo getCustomerMessage(SysMessageNotice sysMessageNotice) {
startPage();
if(StringUtils.isNotEmpty(sysMessageNotice.getCustomerId())){
sysMessageNotice.setMessageCustomer(Long.parseLong(AesUtils.decrypt(sysMessageNotice.getCustomerId(), null)));
}else{
sysMessageNotice.setMessageCustomer(0L);
}
List<MessageNoticeResponse> list = sysMessageNoticeService.getCustomerMessage(sysMessageNotice);
return getDataTable(list);
}
/**
* 更新用户通知消息已读状态
*/
@GetMapping(value = "/updateMessageReadStatus")
public AjaxResult updateMessageReadStatus(@RequestParam("id")Long id) {
SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setReadType(1);
sysMessageNotice.setId(id);
return toAjax(sysMessageNoticeService.updateSysMessageNotice(sysMessageNotice));
}
}

View File

@ -0,0 +1,54 @@
package com.stdiet.custom.domain;
import lombok.Data;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.core.domain.BaseEntity;
/**
* 客户消息通知对象 sys_message_notice
*
* @author xzj
* @date 2021-04-26
*/
@Data
public class SysMessageNotice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 消息属性0 公共消息 1 私有消息 */
@Excel(name = "消息属性0 公共消息 1 私有消息")
private Integer messageProperty;
/** 消息对应客户ID (公共消息时该字段为0) */
@Excel(name = "消息对应客户ID (公共消息时该字段为0)")
private Long messageCustomer;
//用户加密ID非持久化字段
private String customerId;
/** 消息类型 */
@Excel(name = "消息类型")
private Integer messageType;
/** 消息标题 */
@Excel(name = "消息标题")
private String messageTitle;
/** 消息内容 */
@Excel(name = "消息内容")
private String messageContent;
/** 是否已读 0未读 1已读 */
@Excel(name = "是否已读 0未读 1已读")
private Integer readType;
/** 当前消息对应关键参数多个参数可保存json字符串 */
@Excel(name = "当前消息对应关键参数多个参数可保存json字符串")
private String messageKey;
/** 删除标识 0未删除 1已删除 */
private Integer delFlag;
}

View File

@ -0,0 +1,75 @@
package com.stdiet.custom.domain.entityEnum;
public enum MessageNoticeEnum{
systemMessage("系统通知", 0, 0, "系统通知"),
punchComment("打卡点评", 1, 1, "%s打卡点评"); //%s 为打卡时间
//消息名称
private String name;
//消息属性 0公共 1私有
private Integer property;
//消息类型
private Integer type;
//消息标题模板
private String titleTemplate;
MessageNoticeEnum(String name, Integer property, Integer type, String titleTemplate){
this.name = name;
this.property = property;
this.type = type;
this.titleTemplate = titleTemplate;
}
/**
* 根据type类型获取枚举对象
* @param type
* @return
*/
public static MessageNoticeEnum getNoticeEnumByType(Integer type){
for (MessageNoticeEnum messageEnum : MessageNoticeEnum.values()) {
if(messageEnum.getType().intValue() == type.intValue()){
return messageEnum;
}
}
return systemMessage;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getProperty() {
return property;
}
public void setProperty(Integer property) {
this.property = property;
}
public String getTitleTemplate() {
return titleTemplate;
}
public void setTitleTemplate(String titleTemplate) {
this.titleTemplate = titleTemplate;
}
}

View File

@ -0,0 +1,43 @@
package com.stdiet.custom.dto.response;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class MessageNoticeResponse implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
/** 消息属性0 公共消息 1 私有消息 */
private Integer messageProperty;
/** 消息对应客户ID (公共消息时该字段为0) */
private Long messageCustomer;
/** 消息类型 */
private Integer messageType;
//消息类型名称
private String messageTypeName;
/** 消息标题 */
private String messageTitle;
/** 消息内容 */
private String messageContent;
/** 是否已读 0未读 1已读 */
private Integer readType;
/** 当前消息对应关键参数多个参数可保存json字符串 */
private String messageKey;
/** 创建时间 **/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date createTime;
}

View File

@ -67,4 +67,11 @@ public interface SysCustomerMapper
* @return 结果
*/
SysCustomer getCustomerByPhone(@Param("phone")String phone);
/**
* 根据openid查询客户信息
* @param openid
* @return
*/
SysCustomer getCustomerByOpenId(@Param("openid")String openid);
}

View File

@ -0,0 +1,76 @@
package com.stdiet.custom.mapper;
import java.util.List;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
/**
* 客户消息通知Mapper接口
*
* @author xzj
* @date 2021-04-26
*/
public interface SysMessageNoticeMapper
{
/**
* 查询客户消息通知
*
* @param id 客户消息通知ID
* @return 客户消息通知
*/
public SysMessageNotice selectSysMessageNoticeById(Long id);
/**
* 查询客户消息通知列表
*
* @param sysMessageNotice 客户消息通知
* @return 客户消息通知集合
*/
public List<SysMessageNotice> selectSysMessageNoticeList(SysMessageNotice sysMessageNotice);
/**
* 新增客户消息通知
*
* @param sysMessageNotice 客户消息通知
* @return 结果
*/
public int insertSysMessageNotice(SysMessageNotice sysMessageNotice);
/**
* 修改客户消息通知
*
* @param sysMessageNotice 客户消息通知
* @return 结果
*/
public int updateSysMessageNotice(SysMessageNotice sysMessageNotice);
/**
* 删除客户消息通知
*
* @param id 客户消息通知ID
* @return 结果
*/
public int deleteSysMessageNoticeById(Long id);
/**
* 批量删除客户消息通知
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteSysMessageNoticeByIds(Long[] ids);
/**
* 根据客户ID查询客户信息包含私有信息以及公共消息
* @param sysMessageNotice
* @return
*/
public List<MessageNoticeResponse> getCustomerMessage(SysMessageNotice sysMessageNotice);
/**
* 根据客户ID查询客户消息数量
* @param sysMessageNotice
* @return
*/
public int getCustomerMessageCount(SysMessageNotice sysMessageNotice);
}

View File

@ -81,4 +81,11 @@ public interface ISysCustomerService
Map<String,Object> getPhysicalSignsByOutId(String id);
/**
* 根据openid查询客户信息
* @param openid
* @return
*/
SysCustomer getCustomerByOpenId(String openid);
}

View File

@ -0,0 +1,92 @@
package com.stdiet.custom.service;
import java.util.List;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.domain.SysWxUserLog;
import com.stdiet.custom.domain.entityEnum.MessageNoticeEnum;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
/**
* 客户消息通知Service接口
*
* @author xzj
* @date 2021-04-26
*/
public interface ISysMessageNoticeService
{
/**
* 查询客户消息通知
*
* @param id 客户消息通知ID
* @return 客户消息通知
*/
public SysMessageNotice selectSysMessageNoticeById(Long id);
/**
* 查询客户消息通知列表
*
* @param sysMessageNotice 客户消息通知
* @return 客户消息通知集合
*/
public List<SysMessageNotice> selectSysMessageNoticeList(SysMessageNotice sysMessageNotice);
/**
* 新增客户消息通知
*
* @param sysMessageNotice 客户消息通知
* @return 结果
*/
public int insertSysMessageNotice(SysMessageNotice sysMessageNotice);
/**
* 修改客户消息通知
*
* @param sysMessageNotice 客户消息通知
* @return 结果
*/
public int updateSysMessageNotice(SysMessageNotice sysMessageNotice);
/**
* 批量删除客户消息通知
*
* @param ids 需要删除的客户消息通知ID
* @return 结果
*/
public int deleteSysMessageNoticeByIds(Long[] ids);
/**
* 删除客户消息通知信息
*
* @param id 客户消息通知ID
* @return 结果
*/
public int deleteSysMessageNoticeById(Long id);
/**
* 根据客户ID查询客户信息包含私有信息以及公共消息
* @param sysMessageNotice
* @return
*/
public List<MessageNoticeResponse> getCustomerMessage(SysMessageNotice sysMessageNotice);
/**
* 消息发送
* @param messageNoticeEnum
* @param sysMessageNotice
* @return
*/
public int sendMessageNoticeToCustomer(MessageNoticeEnum messageNoticeEnum, SysMessageNotice sysMessageNotice);
/**
* 根据客户ID查询客户消息数量
* @param sysMessageNotice
* @return
*/
public int getCustomerMessageCount(SysMessageNotice sysMessageNotice);
/**
* 发送打卡点评消息
* @param sysWxUserLog
*/
public void sendPunchCommentMessage(SysWxUserLog sysWxUserLog);
}

View File

@ -168,4 +168,13 @@ public class SysCustomerServiceImpl implements ISysCustomerService {
public Map<String, Object> getPhysicalSignsByOutId(String id) {
return null;
}
/**
* 根据openid查询客户信息
* @param openid
* @return
*/
public SysCustomer getCustomerByOpenId(String openid){
return sysCustomerMapper.getCustomerByOpenId(openid);
}
}

View File

@ -0,0 +1,169 @@
package com.stdiet.custom.service.impl;
import java.util.Date;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysWxUserLog;
import com.stdiet.custom.domain.entityEnum.MessageNoticeEnum;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
import com.stdiet.custom.service.ISysCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysMessageNoticeMapper;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.service.ISysMessageNoticeService;
/**
* 客户消息通知Service业务层处理
*
* @author xzj
* @date 2021-04-26
*/
@Service
public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
{
@Autowired
private SysMessageNoticeMapper sysMessageNoticeMapper;
@Autowired
private ISysCustomerService sysCustomerService;
/**
* 查询客户消息通知
*
* @param id 客户消息通知ID
* @return 客户消息通知
*/
@Override
public SysMessageNotice selectSysMessageNoticeById(Long id)
{
return sysMessageNoticeMapper.selectSysMessageNoticeById(id);
}
/**
* 查询客户消息通知列表
*
* @param sysMessageNotice 客户消息通知
* @return 客户消息通知
*/
@Override
public List<SysMessageNotice> selectSysMessageNoticeList(SysMessageNotice sysMessageNotice)
{
return sysMessageNoticeMapper.selectSysMessageNoticeList(sysMessageNotice);
}
/**
* 新增客户消息通知
*
* @param sysMessageNotice 客户消息通知
* @return 结果
*/
@Override
public int insertSysMessageNotice(SysMessageNotice sysMessageNotice)
{
sysMessageNotice.setCreateTime(DateUtils.getNowDate());
return sysMessageNoticeMapper.insertSysMessageNotice(sysMessageNotice);
}
/**
* 修改客户消息通知
*
* @param sysMessageNotice 客户消息通知
* @return 结果
*/
@Override
public int updateSysMessageNotice(SysMessageNotice sysMessageNotice)
{
sysMessageNotice.setUpdateTime(DateUtils.getNowDate());
return sysMessageNoticeMapper.updateSysMessageNotice(sysMessageNotice);
}
/**
* 批量删除客户消息通知
*
* @param ids 需要删除的客户消息通知ID
* @return 结果
*/
@Override
public int deleteSysMessageNoticeByIds(Long[] ids)
{
return sysMessageNoticeMapper.deleteSysMessageNoticeByIds(ids);
}
/**
* 删除客户消息通知信息
*
* @param id 客户消息通知ID
* @return 结果
*/
@Override
public int deleteSysMessageNoticeById(Long id)
{
return sysMessageNoticeMapper.deleteSysMessageNoticeById(id);
}
/**
* 根据客户ID查询客户信息包含私有信息以及公共消息
* @param sysMessageNotice
* @return
*/
@Override
public List<MessageNoticeResponse> getCustomerMessage(SysMessageNotice sysMessageNotice){
List<MessageNoticeResponse> responsesList = sysMessageNoticeMapper.getCustomerMessage(sysMessageNotice);
if(responsesList != null && responsesList.size() > 0){
for (MessageNoticeResponse messageNoticeResponse : responsesList) {
messageNoticeResponse.setMessageTypeName(MessageNoticeEnum.getNoticeEnumByType(messageNoticeResponse.getMessageType()).getName());
}
}
return responsesList;
}
/**
* 消息发送
* @param messageNoticeEnum
* @param sysMessageNotice
* @return
*/
@Override
public int sendMessageNoticeToCustomer(MessageNoticeEnum messageNoticeEnum, SysMessageNotice sysMessageNotice){
sysMessageNotice.setMessageProperty(messageNoticeEnum.getProperty());
sysMessageNotice.setMessageType(messageNoticeEnum.getType());
return sysMessageNoticeMapper.insertSysMessageNotice(sysMessageNotice);
}
/**
* 根据客户ID查询客户消息数量
* @param sysMessageNotice
* @return
*/
@Override
public int getCustomerMessageCount(SysMessageNotice sysMessageNotice){
return sysMessageNoticeMapper.getCustomerMessageCount(sysMessageNotice);
}
/**
* 发送打卡点评消息
* @param sysWxUserLog
*/
@Override
@Async
public void sendPunchCommentMessage(SysWxUserLog sysWxUserLog){
if(sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid())){
return;
}
SysCustomer sysCustomer = sysCustomerService.getCustomerByOpenId(sysWxUserLog.getOpenid());
if(sysCustomer != null){
SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setMessageProperty(1);
sysMessageNotice.setMessageType(MessageNoticeEnum.punchComment.getType());
sysMessageNotice.setReadType(0);
sysMessageNotice.setMessageCustomer(sysCustomer.getId());
sysMessageNotice.setMessageTitle(String.format(MessageNoticeEnum.punchComment.getTitleTemplate(), DateUtils.dateTime(sysWxUserLog.getLogTime())));
sysMessageNotice.setMessageContent(sysWxUserLog.getComment());
sendMessageNoticeToCustomer(MessageNoticeEnum.punchComment, sysMessageNotice);
}
}
}

View File

@ -8,8 +8,11 @@ import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.file.FileUploadUtils;
import com.stdiet.common.utils.file.MimeTypeUtils;
import com.stdiet.common.utils.oss.AliyunOSSUtils;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.domain.entityEnum.MessageNoticeEnum;
import com.stdiet.custom.page.WxLogInfo;
import com.stdiet.custom.service.ISysMessageNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysWxUserLogMapper;

View File

@ -156,6 +156,12 @@
where phone = #{phone} and del_flag = 0
</select>
<!-- 根据openId查询客户 -->
<select id="getCustomerByOpenId" parameterType="String" resultMap="SysCustomerResult">
select sc.id from sys_customer sc
left join sys_wx_user_info wu on wu.phone = sc.phone
where wu.openid = #{openid} and sc.del_flag = 0 order by sc.id desc limit 1
</select>
</mapper>

View File

@ -0,0 +1,144 @@
<?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.stdiet.custom.mapper.SysMessageNoticeMapper">
<resultMap type="SysMessageNotice" id="SysMessageNoticeResult">
<result property="id" column="id" />
<result property="messageProperty" column="message_property" />
<result property="messageCustomer" column="message_customer" />
<result property="messageType" column="message_type" />
<result property="messageTitle" column="message_title" />
<result property="messageContent" column="message_content" />
<result property="readType" column="read_type" />
<result property="messageKey" column="message_key" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" />
</resultMap>
<resultMap type="com.stdiet.custom.dto.response.MessageNoticeResponse" id="SysMessageNoticeResponse">
<result property="id" column="id" />
<result property="messageProperty" column="message_property" />
<result property="messageCustomer" column="message_customer" />
<result property="messageType" column="message_type" />
<result property="messageTitle" column="message_title" />
<result property="messageContent" column="message_content" />
<result property="readType" column="read_type" />
<result property="messageKey" column="message_key" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectSysMessageNoticeVo">
id, message_property, message_customer, message_type, message_title, message_content, read_type, message_key, create_time, create_by, update_time, update_by, del_flag
</sql>
<select id="selectSysMessageNoticeList" parameterType="SysMessageNotice" resultMap="SysMessageNoticeResult">
select
<include refid="selectSysMessageNoticeVo"/>
from sys_message_notice
where del_flag = 0
</select>
<select id="selectSysMessageNoticeById" parameterType="Long" resultMap="SysMessageNoticeResult">
select
<include refid="selectSysMessageNoticeVo"/>
from sys_message_notice
where id = #{id} and del_flag = 0 order by id desc
</select>
<insert id="insertSysMessageNotice" parameterType="SysMessageNotice">
insert into sys_message_notice
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="messageProperty != null">message_property,</if>
<if test="messageCustomer != null">message_customer,</if>
<if test="messageType != null">message_type,</if>
<if test="messageTitle != null">message_title,</if>
<if test="messageContent != null">message_content,</if>
<if test="readType != null">read_type,</if>
<if test="messageKey != null">message_key,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="messageProperty != null">#{messageProperty},</if>
<if test="messageCustomer != null">#{messageCustomer},</if>
<if test="messageType != null">#{messageType},</if>
<if test="messageTitle != null">#{messageTitle},</if>
<if test="messageContent != null">#{messageContent},</if>
<if test="readType != null">#{readType},</if>
<if test="messageKey != null">#{messageKey},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysMessageNotice" parameterType="SysMessageNotice">
update sys_message_notice
<trim prefix="SET" suffixOverrides=",">
<if test="messageProperty != null">message_property = #{messageProperty},</if>
<if test="messageCustomer != null">message_customer = #{messageCustomer},</if>
<if test="messageType != null">message_type = #{messageType},</if>
<if test="messageTitle != null">message_title = #{messageTitle},</if>
<if test="messageContent != null">message_content = #{messageContent},</if>
<if test="readType != null">read_type = #{readType},</if>
<if test="messageKey != null">message_key = #{messageKey},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<update id="deleteSysMessageNoticeById" parameterType="Long">
update sys_message_notice set del_flag = 1 where id = #{id}
</update>
<update id="deleteSysMessageNoticeByIds" parameterType="String">
update sys_message_notice set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- 根据客户ID获取用户的消息 -->
<select id="getCustomerMessage" parameterType="SysMessageNotice" resultMap="SysMessageNoticeResponse">
select
smn.id, smn.message_property, smn.message_customer, smn.message_type, smn.message_title, smn.message_content, smn.read_type, smn.message_key, smn.create_time
from sys_message_notice smn
where smn.del_flag = 0 and (smn.message_property = 0 or smn.message_customer = #{messageCustomer})
<if test="readType != null">
and smn.read_type = #{readType}
</if>
<if test="messageType != null">
and smn.message_type = #{messageType}
</if>
order by smn.id desc
</select>
<!-- 根据客户ID获取用户的消息数量 -->
<select id="getCustomerMessageCount" parameterType="SysMessageNotice" resultType="int">
select count(smn.id)
from sys_message_notice smn
where smn.del_flag = 0 and (smn.message_property = 0 or smn.message_customer = #{messageCustomer})
<if test="readType != null">
and smn.read_type = #{readType}
</if>
<if test="messageType != null">
and smn.message_type = #{messageType}
</if>
</select>
</mapper>