【8.0.5】【message】更新我的通知相关的类

pull/60/head
fengshuonan 2024-01-12 17:32:34 +08:00
parent 6f94500659
commit 9996e3a834
9 changed files with 752 additions and 0 deletions

View File

@ -0,0 +1,114 @@
package cn.stylefeng.roses.kernel.sys.modular.message.controller;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
import cn.stylefeng.roses.kernel.sys.modular.message.service.SysMessageService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@RestController
@ApiResource(name = "系统消息")
public class SysMessageController {
@Resource
private SysMessageService sysMessageService;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@PostResource(name = "添加系统消息", path = "/sysMessage/add")
public ResponseData<SysMessage> add(@RequestBody @Validated(SysMessageRequest.add.class) SysMessageRequest sysMessageRequest) {
sysMessageService.add(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@PostResource(name = "删除系统消息", path = "/sysMessage/delete")
public ResponseData<?> delete(@RequestBody @Validated(SysMessageRequest.delete.class) SysMessageRequest sysMessageRequest) {
sysMessageService.del(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@PostResource(name = "批量删除系统消息", path = "/sysMessage/batchDelete")
public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) SysMessageRequest sysMessageRequest) {
sysMessageService.batchDelete(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@PostResource(name = "编辑系统消息", path = "/sysMessage/edit")
public ResponseData<?> edit(@RequestBody @Validated(SysMessageRequest.edit.class) SysMessageRequest sysMessageRequest) {
sysMessageService.edit(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@GetResource(name = "查看系统消息详情", path = "/sysMessage/detail")
public ResponseData<SysMessage> detail(@Validated(SysMessageRequest.detail.class) SysMessageRequest sysMessageRequest) {
return new SuccessResponseData<>(sysMessageService.detail(sysMessageRequest));
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@GetResource(name = "获取系统消息列表", path = "/sysMessage/list")
public ResponseData<List<SysMessage>> list(SysMessageRequest sysMessageRequest) {
return new SuccessResponseData<>(sysMessageService.findList(sysMessageRequest));
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@GetResource(name = "获取系统消息列表(带分页)", path = "/sysMessage/page")
public ResponseData<PageResult<SysMessage>> page(SysMessageRequest sysMessageRequest) {
return new SuccessResponseData<>(sysMessageService.findPage(sysMessageRequest));
}
}

View File

@ -0,0 +1,113 @@
package cn.stylefeng.roses.kernel.sys.modular.message.entity;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseBusinessEntity;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@TableName("sys_message")
@Data
@EqualsAndHashCode(callSuper = true)
public class SysMessage extends BaseBusinessEntity {
/**
*
*/
@TableId(value = "message_id", type = IdType.ASSIGN_ID)
@ChineseDescription("主键")
private Long messageId;
/**
* id
*/
@TableField("receive_user_id")
@ChineseDescription("接收用户id")
private Long receiveUserId;
/**
* id
*/
@TableField("send_user_id")
@ChineseDescription("发送用户id")
private Long sendUserId;
/**
*
*/
@TableField("message_title")
@ChineseDescription("消息标题")
private String messageTitle;
/**
*
*/
@TableField("message_content")
@ChineseDescription("消息内容")
private String messageContent;
/**
* NORMAL-URL-
*/
@TableField("message_type")
@ChineseDescription("消息类型NORMAL-普通类型URL-带链接跳转")
private String messageType;
/**
* URL
*/
@TableField("message_url")
@ChineseDescription("消息跳转的URL")
private String messageUrl;
/**
* high-middle-low-
*/
@TableField("priority_level")
@ChineseDescription("优先级high-高优先级middle-中low-低")
private String priorityLevel;
/**
*
*/
@TableField("message_send_time")
@ChineseDescription("消息发送时间")
private Date messageSendTime;
/**
* id
*/
@TableField("business_id")
@ChineseDescription("关联业务id")
private String businessId;
/**
* (id)
*/
@TableField("business_type")
@ChineseDescription("业务类型(根据业务id和业务类型可以确定业务数据)")
private String businessType;
/**
* 0-1-
*/
@TableField("read_flag")
@ChineseDescription("阅读状态0-未读1-已读")
private Integer readFlag;
/**
*
*/
@TableField(value = "tenant_id", fill = FieldFill.INSERT)
@ChineseDescription("租户号")
private Long tenantId;
}

View File

@ -0,0 +1,36 @@
package cn.stylefeng.roses.kernel.sys.modular.message.enums;
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import lombok.Getter;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@Getter
public enum SysMessageExceptionEnum implements AbstractExceptionEnum {
/**
*
*/
SYS_MESSAGE_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
/**
*
*/
private final String errorCode;
/**
*
*/
private final String userTip;
SysMessageExceptionEnum(String errorCode, String userTip) {
this.errorCode = errorCode;
this.userTip = userTip;
}
}

View File

@ -0,0 +1,28 @@
package cn.stylefeng.roses.kernel.sys.modular.message.mapper;
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.response.SysMessageVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
public interface SysMessageMapper extends BaseMapper<SysMessage> {
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
List<SysMessageVo> customFindList(@Param("page") Page page, @Param("param")SysMessageRequest request);
}

View File

@ -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" >
<mapper namespace="cn.stylefeng.roses.kernel.sys.modular.message.mapper.SysMessageMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage">
<id column="message_id" property="messageId" />
<result column="receive_user_id" property="receiveUserId" />
<result column="send_user_id" property="sendUserId" />
<result column="message_title" property="messageTitle" />
<result column="message_content" property="messageContent" />
<result column="message_type" property="messageType" />
<result column="message_url" property="messageUrl" />
<result column="priority_level" property="priorityLevel" />
<result column="message_send_time" property="messageSendTime" />
<result column="business_id" property="businessId" />
<result column="business_type" property="businessType" />
<result column="read_flag" property="readFlag" />
<result column="version_flag" property="versionFlag" />
<result column="del_flag" property="delFlag" />
<result column="create_user" property="createUser" />
<result column="create_time" property="createTime" />
<result column="update_user" property="updateUser" />
<result column="update_time" property="updateTime" />
<result column="tenant_id" property="tenantId" />
</resultMap>
<sql id="Base_Column_List">
message_id,receive_user_id,send_user_id,message_title,message_content,message_type,message_url,priority_level,message_send_time,business_id,business_type,read_flag,version_flag,del_flag,create_user,create_time,update_user,update_time,tenant_id
</sql>
<resultMap id="customResultMap" type="cn.stylefeng.roses.kernel.sys.modular.message.pojo.response.SysMessageVo" extends="BaseResultMap">
</resultMap>
<select id="customFindList" resultMap="customResultMap">
SELECT
*
FROM
sys_message tbl
WHERE
<where>
<if test="param.messageId != null and param.messageId != ''">
and tbl.message_id like concat('%',#{param.messageId},'%')
</if>
<if test="param.receiveUserId != null and param.receiveUserId != ''">
and tbl.receive_user_id like concat('%',#{param.receiveUserId},'%')
</if>
<if test="param.sendUserId != null and param.sendUserId != ''">
and tbl.send_user_id like concat('%',#{param.sendUserId},'%')
</if>
<if test="param.messageTitle != null and param.messageTitle != ''">
and tbl.message_title like concat('%',#{param.messageTitle},'%')
</if>
<if test="param.messageContent != null and param.messageContent != ''">
and tbl.message_content like concat('%',#{param.messageContent},'%')
</if>
<if test="param.messageType != null and param.messageType != ''">
and tbl.message_type like concat('%',#{param.messageType},'%')
</if>
<if test="param.messageUrl != null and param.messageUrl != ''">
and tbl.message_url like concat('%',#{param.messageUrl},'%')
</if>
<if test="param.priorityLevel != null and param.priorityLevel != ''">
and tbl.priority_level like concat('%',#{param.priorityLevel},'%')
</if>
<if test="param.messageSendTime != null and param.messageSendTime != ''">
and tbl.message_send_time like concat('%',#{param.messageSendTime},'%')
</if>
<if test="param.businessId != null and param.businessId != ''">
and tbl.business_id like concat('%',#{param.businessId},'%')
</if>
<if test="param.businessType != null and param.businessType != ''">
and tbl.business_type like concat('%',#{param.businessType},'%')
</if>
<if test="param.readFlag != null and param.readFlag != ''">
and tbl.read_flag like concat('%',#{param.readFlag},'%')
</if>
<if test="param.versionFlag != null and param.versionFlag != ''">
and tbl.version_flag like concat('%',#{param.versionFlag},'%')
</if>
<if test="param.delFlag != null and param.delFlag != ''">
and tbl.del_flag like concat('%',#{param.delFlag},'%')
</if>
<if test="param.createUser != null and param.createUser != ''">
and tbl.create_user like concat('%',#{param.createUser},'%')
</if>
<if test="param.createTime != null and param.createTime != ''">
and tbl.create_time like concat('%',#{param.createTime},'%')
</if>
<if test="param.updateUser != null and param.updateUser != ''">
and tbl.update_user like concat('%',#{param.updateUser},'%')
</if>
<if test="param.updateTime != null and param.updateTime != ''">
and tbl.update_time like concat('%',#{param.updateTime},'%')
</if>
<if test="param.tenantId != null and param.tenantId != ''">
and tbl.tenant_id like concat('%',#{param.tenantId},'%')
</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,126 @@
package cn.stylefeng.roses.kernel.sys.modular.message.pojo.request;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SysMessageRequest extends BaseRequest {
/**
*
*/
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class})
@ChineseDescription("主键")
private Long messageId;
/**
* id
*/
@NotNull(message = "接收用户id不能为空", groups = {add.class, edit.class})
@ChineseDescription("接收用户id")
private Long receiveUserId;
/**
* id
*/
@ChineseDescription("发送用户id")
private Long sendUserId;
/**
*
*/
@NotBlank(message = "消息标题不能为空", groups = {add.class, edit.class})
@ChineseDescription("消息标题")
private String messageTitle;
/**
*
*/
@ChineseDescription("消息内容")
private String messageContent;
/**
* NORMAL-URL-
*/
@NotBlank(message = "消息类型NORMAL-普通类型URL-带链接跳转不能为空", groups = {add.class, edit.class})
@ChineseDescription("消息类型NORMAL-普通类型URL-带链接跳转")
private String messageType;
/**
* URL
*/
@ChineseDescription("消息跳转的URL")
private String messageUrl;
/**
* high-middle-low-
*/
@NotBlank(message = "优先级high-高优先级middle-中low-低不能为空", groups = {add.class, edit.class})
@ChineseDescription("优先级high-高优先级middle-中low-低")
private String priorityLevel;
/**
*
*/
@ChineseDescription("消息发送时间")
private String messageSendTime;
/**
* id
*/
@ChineseDescription("关联业务id")
private String businessId;
/**
* (id)
*/
@ChineseDescription("业务类型(根据业务id和业务类型可以确定业务数据)")
private String businessType;
/**
* 0-1-
*/
@ChineseDescription("阅读状态0-未读1-已读")
private Integer readFlag;
/**
*
*/
@ChineseDescription("乐观锁")
private Long versionFlag;
/**
* Y-N-
*/
@NotBlank(message = "是否删除Y-被删除N-未删除不能为空", groups = {add.class, edit.class})
@ChineseDescription("是否删除Y-被删除N-未删除")
private String delFlag;
/**
*
*/
@ChineseDescription("租户号")
private Long tenantId;
/**
* id
*/
@NotNull(message = "批量删除id集合不能为空", groups = batchDelete.class)
@ChineseDescription("批量删除用的id集合")
private List<Long> batchDeleteIdList;
}

View File

@ -0,0 +1,17 @@
package cn.stylefeng.roses.kernel.sys.modular.message.pojo.response;
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class SysMessageVo extends SysMessage {
}

View File

@ -0,0 +1,83 @@
package cn.stylefeng.roses.kernel.sys.modular.message.service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
public interface SysMessageService extends IService<SysMessage> {
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void add(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void del(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void batchDelete(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void edit(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
SysMessage detail(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @return List<SysMessage>
* @author fengshuonan
* @since 2024/01/12 17:31
*/
List<SysMessage> findList(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @return PageResult<SysMessage>
* @author fengshuonan
* @since 2024/01/12 17:31
*/
PageResult<SysMessage> findPage(SysMessageRequest sysMessageRequest);
}

View File

@ -0,0 +1,133 @@
package cn.stylefeng.roses.kernel.sys.modular.message.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
import cn.stylefeng.roses.kernel.sys.modular.message.enums.SysMessageExceptionEnum;
import cn.stylefeng.roses.kernel.sys.modular.message.mapper.SysMessageMapper;
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
import cn.stylefeng.roses.kernel.sys.modular.message.service.SysMessageService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@Service
public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMessage> implements SysMessageService {
@Override
public void add(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = new SysMessage();
BeanUtil.copyProperties(sysMessageRequest, sysMessage);
this.save(sysMessage);
}
@Override
public void del(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = this.querySysMessage(sysMessageRequest);
this.removeById(sysMessage.getMessageId());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchDelete(SysMessageRequest sysMessageRequest) {
this.removeByIds(sysMessageRequest.getBatchDeleteIdList());
}
@Override
public void edit(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = this.querySysMessage(sysMessageRequest);
BeanUtil.copyProperties(sysMessageRequest, sysMessage);
this.updateById(sysMessage);
}
@Override
public SysMessage detail(SysMessageRequest sysMessageRequest) {
return this.querySysMessage(sysMessageRequest);
}
@Override
public PageResult<SysMessage> findPage(SysMessageRequest sysMessageRequest) {
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(sysMessageRequest);
Page<SysMessage> pageList = this.page(PageFactory.defaultPage(), wrapper);
return PageResultFactory.createPageResult(pageList);
}
@Override
public List<SysMessage> findList(SysMessageRequest sysMessageRequest) {
LambdaQueryWrapper<SysMessage> wrapper = this.createWrapper(sysMessageRequest);
return this.list(wrapper);
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
private SysMessage querySysMessage(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = this.getById(sysMessageRequest.getMessageId());
if (ObjectUtil.isEmpty(sysMessage)) {
throw new ServiceException(SysMessageExceptionEnum.SYS_MESSAGE_NOT_EXISTED);
}
return sysMessage;
}
/**
* wrapper
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
private LambdaQueryWrapper<SysMessage> createWrapper(SysMessageRequest sysMessageRequest) {
LambdaQueryWrapper<SysMessage> queryWrapper = new LambdaQueryWrapper<>();
Long messageId = sysMessageRequest.getMessageId();
Long receiveUserId = sysMessageRequest.getReceiveUserId();
Long sendUserId = sysMessageRequest.getSendUserId();
String messageTitle = sysMessageRequest.getMessageTitle();
String messageContent = sysMessageRequest.getMessageContent();
String messageType = sysMessageRequest.getMessageType();
String messageUrl = sysMessageRequest.getMessageUrl();
String priorityLevel = sysMessageRequest.getPriorityLevel();
String messageSendTime = sysMessageRequest.getMessageSendTime();
String businessId = sysMessageRequest.getBusinessId();
String businessType = sysMessageRequest.getBusinessType();
Integer readFlag = sysMessageRequest.getReadFlag();
Long versionFlag = sysMessageRequest.getVersionFlag();
String delFlag = sysMessageRequest.getDelFlag();
Long tenantId = sysMessageRequest.getTenantId();
queryWrapper.eq(ObjectUtil.isNotNull(messageId), SysMessage::getMessageId, messageId);
queryWrapper.eq(ObjectUtil.isNotNull(receiveUserId), SysMessage::getReceiveUserId, receiveUserId);
queryWrapper.eq(ObjectUtil.isNotNull(sendUserId), SysMessage::getSendUserId, sendUserId);
queryWrapper.like(ObjectUtil.isNotEmpty(messageTitle), SysMessage::getMessageTitle, messageTitle);
queryWrapper.like(ObjectUtil.isNotEmpty(messageContent), SysMessage::getMessageContent, messageContent);
queryWrapper.like(ObjectUtil.isNotEmpty(messageType), SysMessage::getMessageType, messageType);
queryWrapper.like(ObjectUtil.isNotEmpty(messageUrl), SysMessage::getMessageUrl, messageUrl);
queryWrapper.like(ObjectUtil.isNotEmpty(priorityLevel), SysMessage::getPriorityLevel, priorityLevel);
queryWrapper.eq(ObjectUtil.isNotNull(messageSendTime), SysMessage::getMessageSendTime, messageSendTime);
queryWrapper.like(ObjectUtil.isNotEmpty(businessId), SysMessage::getBusinessId, businessId);
queryWrapper.like(ObjectUtil.isNotEmpty(businessType), SysMessage::getBusinessType, businessType);
queryWrapper.eq(ObjectUtil.isNotNull(readFlag), SysMessage::getReadFlag, readFlag);
queryWrapper.eq(ObjectUtil.isNotNull(versionFlag), SysMessage::getVersionFlag, versionFlag);
queryWrapper.like(ObjectUtil.isNotEmpty(delFlag), SysMessage::getDelFlag, delFlag);
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), SysMessage::getTenantId, tenantId);
return queryWrapper;
}
}