mirror of https://gitee.com/stylefeng/roses
【8.0.5】【message】更新我的通知相关的类
parent
6f94500659
commit
9996e3a834
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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>
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue