站内消息服务.

This commit is contained in:
lijiahang
2024-05-14 11:32:17 +08:00
parent 4b17d7b4ab
commit 1ae47f8ab9
23 changed files with 964 additions and 20 deletions

View File

@@ -26,7 +26,7 @@ public class CodeGenerators {
// 作者
String author = Const.ORION_AUTHOR;
// 模块
String module = "asset";
String module = "infra";
// 生成的表
Table[] tables = {
// Template.create("dict_key", "字典配置项", "dict")
@@ -49,24 +49,22 @@ public class CodeGenerators {
// .disableUnitTest()
// .vue("exec", "exec-template-host")
// .build(),
Template.create("upload_task", "上传任务", "upload")
Template.create("system_message", "系统消息", "message")
.disableUnitTest()
.vue("exec", "upload-task")
.enableRowSelection()
.dict("uploadTaskStatus", "status")
.comment("上传任务状态")
.fields("WAITING", "UPLOADING", "FINISHED", "FAILED", "CANCELED")
.labels("等待中", "上传中", "已完成", "已失败", "已取消")
.enableProviderApi()
.vue("system", "message")
.dict("messageClassify", "classify", "messageClassify")
.comment("消息分类")
.fields("NOTICE", "TODO")
.labels("通知", "待办")
.valueUseFields()
.build(),
Template.create("upload_task_file", "上传任务文件", "upload")
.disableUnitTest()
.vue("exec", "upload-task-file")
.enableRowSelection()
.dict("uploadTaskFileStatus", "status")
.comment("上传任务文件状态")
.fields("WAITING", "UPLOADING", "FINISHED", "FAILED", "CANCELED")
.labels("等待中", "上传中", "已完成", "已失败", "已取消")
.dict("messageType", "type", "messageType")
.comment("消息类型")
.fields("EXEC_FAILED", "UPLOAD_FAILED")
.labels("执行失败", "上传失败")
.extra("tagLabel", "执行失败", "上传失败")
.extra("tagVisible", true, true)
.extra("tagColor", "red", "red")
.valueUseFields()
.build(),
};

View File

@@ -14,6 +14,17 @@ import java.util.LinkedHashMap;
*/
public class DictTemplate extends Template {
// // $comment
// export const $field = {
// // labels[0]
// fields[0]: 'values[0]',
// // labels[1]
// fields[0]: 'values[1]',
// };
//
// // $comment 字典项
// export const $keyField = '$keyName';
private final DictMeta dictMeta;
public DictTemplate(Table table, String keyName, String variable) {

View File

@@ -0,0 +1,24 @@
package com.orion.ops.module.infra.api;
import com.orion.ops.module.infra.entity.dto.message.SystemMessageCreateDTO;
import com.orion.ops.module.infra.enums.MessageClassifyEnum;
/**
* 系统消息 对外服务类
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
public interface SystemMessageApi {
/**
* 创建系统消息
*
* @param classify classify
* @param dto dto
* @return id
*/
Long createSystemMessage(MessageClassifyEnum classify, SystemMessageCreateDTO dto);
}

View File

@@ -0,0 +1,56 @@
package com.orion.ops.module.infra.entity.dto.message;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* 系统消息 创建请求业务对象
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "SystemMessageCreateDTO", description = "系统消息 创建请求业务对象")
public class SystemMessageCreateDTO implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank
@Size(max = 32)
@Schema(description = "消息类型")
private String type;
@NotBlank
@Size(max = 64)
@Schema(description = "消息关联")
private String relKey;
@NotBlank
@Size(max = 128)
@Schema(description = "标题")
private String title;
@NotBlank
@Schema(description = "消息内容")
private String content;
@NotNull
@Schema(description = "接收人id")
private Long receiverId;
@Schema(description = "接收人用户名")
private String receiverUsername;
}

View File

@@ -0,0 +1,24 @@
package com.orion.ops.module.infra.enums;
/**
* 消息分类
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024/5/11 16:38
*/
public enum MessageClassifyEnum {
/**
* 通知
*/
NOTICE,
/**
* 待办
*/
TODO,
;
}

View File

@@ -0,0 +1,41 @@
package com.orion.ops.module.infra.api.impl;
import com.alibaba.fastjson.JSON;
import com.orion.ops.framework.common.utils.Valid;
import com.orion.ops.module.infra.api.SystemMessageApi;
import com.orion.ops.module.infra.convert.SystemMessageProviderConvert;
import com.orion.ops.module.infra.entity.dto.message.SystemMessageCreateDTO;
import com.orion.ops.module.infra.entity.request.message.SystemMessageCreateRequest;
import com.orion.ops.module.infra.enums.MessageClassifyEnum;
import com.orion.ops.module.infra.service.SystemMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 系统消息 对外服务实现类
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Slf4j
@Service
public class SystemMessageApiImpl implements SystemMessageApi {
@Resource
private SystemMessageService systemMessageService;
@Override
public Long createSystemMessage(MessageClassifyEnum classify, SystemMessageCreateDTO dto) {
log.info("SystemMessageApi.createSystemMessage dto: {}", JSON.toJSONString(dto));
Valid.valid(dto);
// 转换
SystemMessageCreateRequest request = SystemMessageProviderConvert.MAPPER.toRequest(dto);
request.setClassify(classify.name());
// 创建
return systemMessageService.createSystemMessage(request);
}
}

View File

@@ -0,0 +1,39 @@
### 查询系统消息列表
POST {{baseUrl}}/infra/system-message/list
Content-Type: application/json
Authorization: {{token}}
{
"limit": 10,
"maxId": null,
"classify": "NOTICE",
"queryCount": true,
"queryUnread": true
}
### 查询是否有未读消息
GET {{baseUrl}}/infra/system-message/has-unread
Authorization: {{token}}
### 查询是否有未读消息
PUT {{baseUrl}}/infra/system-message/read?id=1
Authorization: {{token}}
### 更新全部系统消息为已读
PUT {{baseUrl}}/infra/system-message/read-all?classify=NOTICE
Authorization: {{token}}
### 删除系统消息
DELETE {{baseUrl}}/infra/system-message/delete?id=1
Authorization: {{token}}
### 清理已读的系统消息
DELETE {{baseUrl}}/infra/system-message/clear?classify=NOTICE
Authorization: {{token}}
###

View File

@@ -0,0 +1,90 @@
package com.orion.ops.module.infra.controller;
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
import com.orion.ops.framework.web.core.annotation.RestWrapper;
import com.orion.ops.module.infra.entity.request.message.SystemMessageQueryRequest;
import com.orion.ops.module.infra.entity.vo.SystemMessageVO;
import com.orion.ops.module.infra.service.SystemMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* 系统消息 api
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Tag(name = "infra - 系统消息服务")
@Slf4j
@Validated
@RestWrapper
@RestController
@RequestMapping("/infra/system-message")
@SuppressWarnings({"ELValidationInJSP", "SpringElInspection"})
public class SystemMessageController {
@Resource
private SystemMessageService systemMessageService;
@IgnoreLog(IgnoreLogMode.ALL)
@PostMapping("/list")
@Operation(summary = "查询系统消息列表")
public List<SystemMessageVO> getSystemMessageList(@RequestBody SystemMessageQueryRequest request) {
return systemMessageService.getSystemMessageList(request);
}
@IgnoreLog(IgnoreLogMode.ALL)
@GetMapping("/count")
@Operation(summary = "查询系统消息数量")
@Parameter(name = "queryUnread", description = "queryUnread", required = true)
public Map<String, Integer> getSystemMessageCount(@RequestParam("queryUnread") Boolean queryUnread) {
return systemMessageService.getSystemMessageCount(queryUnread);
}
@IgnoreLog(IgnoreLogMode.ALL)
@GetMapping("/has-unread")
@Operation(summary = "查询是否有未读消息")
public Boolean checkHasUnreadMessage() {
return systemMessageService.checkHasUnreadMessage();
}
@PutMapping("/read")
@Operation(summary = "更新系统消息为已读")
@Parameter(name = "id", description = "id", required = true)
public Integer readSystemMessage(@RequestParam("id") Long id) {
return systemMessageService.readSystemMessage(id);
}
@PutMapping("/read-all")
@Operation(summary = "更新全部系统消息为已读")
@Parameter(name = "classify", description = "classify", required = true)
public Integer readAllSystemMessage(@RequestParam("classify") String classify) {
return systemMessageService.readAllSystemMessage(classify);
}
@DeleteMapping("/delete")
@Operation(summary = "删除系统消息")
@Parameter(name = "id", description = "id", required = true)
public Integer deleteSystemMessage(@RequestParam("id") Long id) {
return systemMessageService.deleteSystemMessageById(id);
}
@DeleteMapping("/clear")
@Operation(summary = "清理已读的系统消息")
@Parameter(name = "classify", description = "classify", required = true)
public Integer clearSystemMessage(@RequestParam("classify") String classify) {
return systemMessageService.clearSystemMessage(classify);
}
}

View File

@@ -0,0 +1,32 @@
package com.orion.ops.module.infra.convert;
import com.orion.ops.module.infra.entity.domain.SystemMessageDO;
import com.orion.ops.module.infra.entity.request.message.SystemMessageCreateRequest;
import com.orion.ops.module.infra.entity.request.message.SystemMessageQueryRequest;
import com.orion.ops.module.infra.entity.vo.SystemMessageVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* 系统消息 内部对象转换器
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Mapper
public interface SystemMessageConvert {
SystemMessageConvert MAPPER = Mappers.getMapper(SystemMessageConvert.class);
SystemMessageDO to(SystemMessageCreateRequest request);
SystemMessageDO to(SystemMessageQueryRequest request);
SystemMessageVO to(SystemMessageDO domain);
List<SystemMessageVO> to(List<SystemMessageDO> list);
}

View File

@@ -0,0 +1,22 @@
package com.orion.ops.module.infra.convert;
import com.orion.ops.module.infra.entity.dto.message.SystemMessageCreateDTO;
import com.orion.ops.module.infra.entity.request.message.SystemMessageCreateRequest;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 系统消息 对外服务对象转换器
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Mapper
public interface SystemMessageProviderConvert {
SystemMessageProviderConvert MAPPER = Mappers.getMapper(SystemMessageProviderConvert.class);
SystemMessageCreateRequest toRequest(SystemMessageCreateDTO request);
}

View File

@@ -0,0 +1,31 @@
package com.orion.ops.module.infra.dao;
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
import com.orion.ops.module.infra.entity.domain.SystemMessageDO;
import com.orion.ops.module.infra.entity.dto.SystemMessageCountDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 系统消息 Mapper 接口
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Mapper
public interface SystemMessageDAO extends IMapper<SystemMessageDO> {
/**
* 查询消息数量
*
* @param receiverId receiverId
* @param status status
* @return count
*/
List<SystemMessageCountDTO> selectSystemMessageCount(@Param("receiverId") Long receiverId,
@Param("status") Integer status);
}

View File

@@ -0,0 +1,73 @@
package com.orion.ops.module.infra.entity.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
/**
* 系统消息 实体对象
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName(value = "system_message", autoResultMap = true)
@Schema(name = "SystemMessageDO", description = "系统消息 实体对象")
public class SystemMessageDO extends BaseDO {
private static final long serialVersionUID = 1L;
@Schema(description = "id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@Schema(description = "消息分类")
@TableField("classify")
private String classify;
@Schema(description = "消息类型")
@TableField("type")
private String type;
@Schema(description = "消息状态")
@TableField("status")
private Integer status;
@Schema(description = "消息关联")
@TableField("rel_key")
private String relKey;
@Schema(description = "标题")
@TableField("title")
private String title;
@Schema(description = "消息内容")
@TableField("content")
private String content;
@Schema(description = "接收人id")
@TableField("receiver_id")
private Long receiverId;
@Schema(description = "接收人用户名")
@TableField("receiver_username")
private String receiverUsername;
@Schema(description = "创建人")
@TableField(exist = false)
private String creator;
@Schema(description = "修改人")
@TableField(exist = false)
private String updater;
}

View File

@@ -0,0 +1,33 @@
package com.orion.ops.module.infra.entity.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 系统消息数量对象
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024/5/11 18:15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "SystemMessageCountDTO", description = "系统消息数量对象")
public class SystemMessageCountDTO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "消息分类")
private String classify;
@Schema(description = "数量")
private Integer count;
}

View File

@@ -0,0 +1,62 @@
package com.orion.ops.module.infra.entity.request.message;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
* 系统消息 创建请求对象
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "SystemMessageCreateRequest", description = "系统消息 创建请求对象")
public class SystemMessageCreateRequest implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank
@Size(max = 10)
@Schema(description = "消息分类")
private String classify;
@NotBlank
@Size(max = 32)
@Schema(description = "消息类型")
private String type;
@NotBlank
@Size(max = 64)
@Schema(description = "消息关联")
private String relKey;
@NotBlank
@Size(max = 128)
@Schema(description = "标题")
private String title;
@NotBlank
@Schema(description = "消息内容")
private String content;
@NotNull
@Schema(description = "接收人id")
private Long receiverId;
@Size(max = 32)
@Schema(description = "接收人用户名")
private String receiverUsername;
}

View File

@@ -0,0 +1,35 @@
package com.orion.ops.module.infra.entity.request.message;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 系统消息 查询请求对象
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "SystemMessageQueryRequest", description = "系统消息 查询请求对象")
public class SystemMessageQueryRequest {
@Schema(description = "大小")
private Integer limit;
@Schema(description = "maxId")
private Long maxId;
@Schema(description = "消息分类")
private String classify;
@Schema(description = "是否查询未读消息")
private Boolean queryUnread;
}

View File

@@ -0,0 +1,52 @@
package com.orion.ops.module.infra.entity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 系统消息 视图响应对象
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "SystemMessageVO", description = "系统消息 视图响应对象")
public class SystemMessageVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "id")
private Long id;
@Schema(description = "消息分类")
private String classify;
@Schema(description = "消息类型")
private String type;
@Schema(description = "消息状态")
private Integer status;
@Schema(description = "消息关联")
private String relKey;
@Schema(description = "标题")
private String title;
@Schema(description = "消息内容")
private String content;
@Schema(description = "创建时间")
private Date createTime;
}

View File

@@ -0,0 +1,31 @@
package com.orion.ops.module.infra.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 消息状态
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024/5/11 16:35
*/
@Getter
@AllArgsConstructor
public enum MessageStatusEnum {
/**
* 未读
*/
UNREAD(0),
/**
* 已读
*/
READ(1),
;
private final Integer status;
}

View File

@@ -0,0 +1,82 @@
package com.orion.ops.module.infra.service;
import com.orion.ops.module.infra.entity.request.message.SystemMessageCreateRequest;
import com.orion.ops.module.infra.entity.request.message.SystemMessageQueryRequest;
import com.orion.ops.module.infra.entity.vo.SystemMessageVO;
import java.util.List;
import java.util.Map;
/**
* 系统消息 服务类
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
public interface SystemMessageService {
/**
* 创建系统消息
*
* @param request request
* @return id
*/
Long createSystemMessage(SystemMessageCreateRequest request);
/**
* 查询系统消息列表
*
* @param request request
* @return rows
*/
List<SystemMessageVO> getSystemMessageList(SystemMessageQueryRequest request);
/**
* 查询系统消息数量
*
* @param queryUnread queryUnread
* @return rows
*/
Map<String, Integer> getSystemMessageCount(Boolean queryUnread);
/**
* 查询是否有未读消息
*
* @return has
*/
Boolean checkHasUnreadMessage();
/**
* 更新系统消息为已读
*
* @param id id
* @return effect
*/
Integer readSystemMessage(Long id);
/**
* 更新全部系统消息为已读
*
* @param classify classify
* @return effect
*/
Integer readAllSystemMessage(String classify);
/**
* 删除系统消息
*
* @param id id
* @return effect
*/
Integer deleteSystemMessageById(Long id);
/**
* 清理已读的系统消息
*
* @param classify classify
* @return effect
*/
Integer clearSystemMessage(String classify);
}

View File

@@ -0,0 +1,165 @@
package com.orion.ops.module.infra.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.orion.lang.function.Functions;
import com.orion.lang.utils.Booleans;
import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.security.core.utils.SecurityUtils;
import com.orion.ops.module.infra.convert.SystemMessageConvert;
import com.orion.ops.module.infra.dao.SystemMessageDAO;
import com.orion.ops.module.infra.dao.SystemUserDAO;
import com.orion.ops.module.infra.entity.domain.SystemMessageDO;
import com.orion.ops.module.infra.entity.domain.SystemUserDO;
import com.orion.ops.module.infra.entity.dto.SystemMessageCountDTO;
import com.orion.ops.module.infra.entity.request.message.SystemMessageCreateRequest;
import com.orion.ops.module.infra.entity.request.message.SystemMessageQueryRequest;
import com.orion.ops.module.infra.entity.vo.SystemMessageVO;
import com.orion.ops.module.infra.enums.MessageStatusEnum;
import com.orion.ops.module.infra.service.SystemMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 系统消息 服务实现类
*
* @author Jiahang Li
* @version 1.0.8
* @since 2024-5-11 16:29
*/
@Slf4j
@Service
public class SystemMessageServiceImpl implements SystemMessageService {
@Resource
private SystemMessageDAO systemMessageDAO;
@Resource
private SystemUserDAO systemUserDAO;
@Override
public Long createSystemMessage(SystemMessageCreateRequest request) {
// 设置接收人用户名
if (request.getReceiverUsername() == null) {
Optional.ofNullable(request.getReceiverId())
.map(systemUserDAO::selectById)
.map(SystemUserDO::getUsername)
.ifPresent(request::setReceiverUsername);
}
// 转换
SystemMessageDO record = SystemMessageConvert.MAPPER.to(request);
record.setStatus(MessageStatusEnum.UNREAD.getStatus());
// 插入
int effect = systemMessageDAO.insert(record);
Long id = record.getId();
log.info("SystemMessageService-createSystemMessage id: {}, effect: {}", id, effect);
return id;
}
@Override
public List<SystemMessageVO> getSystemMessageList(SystemMessageQueryRequest request) {
Long userId = SecurityUtils.getLoginUserId();
Integer status = Booleans.isTrue(request.getQueryUnread()) ? MessageStatusEnum.UNREAD.getStatus() : null;
// 查询列表
return systemMessageDAO.of()
.createValidateWrapper()
.eq(SystemMessageDO::getReceiverId, userId)
.eq(SystemMessageDO::getClassify, request.getClassify())
.lt(SystemMessageDO::getId, request.getMaxId())
.eq(SystemMessageDO::getStatus, status)
.last(Const.LIMIT + Const.SPACE + request.getLimit())
.orderByDesc(SystemMessageDO::getId)
.then()
.list(SystemMessageConvert.MAPPER::to);
}
@Override
public Map<String, Integer> getSystemMessageCount(Boolean queryUnread) {
Long userId = SecurityUtils.getLoginUserId();
Integer status = queryUnread ? MessageStatusEnum.UNREAD.getStatus() : null;
// 查询数量
List<SystemMessageCountDTO> countList = systemMessageDAO.selectSystemMessageCount(userId, status);
// 返回
return countList.stream()
.collect(Collectors.toMap(SystemMessageCountDTO::getClassify,
SystemMessageCountDTO::getCount,
Functions.right()));
}
@Override
public Boolean checkHasUnreadMessage() {
// 查询
return systemMessageDAO.of()
.createWrapper()
.select(SystemMessageDO::getId)
.eq(SystemMessageDO::getReceiverId, SecurityUtils.getLoginUserId())
.eq(SystemMessageDO::getStatus, MessageStatusEnum.UNREAD.getStatus())
.then()
.only()
.optional()
.isPresent();
}
@Override
public Integer readSystemMessage(Long id) {
Long userId = SecurityUtils.getLoginUserId();
log.info("SystemMessageService-readSystemMessage id: {}, userId: {}", id, userId);
// 修改状态
SystemMessageDO update = new SystemMessageDO();
update.setStatus(MessageStatusEnum.READ.getStatus());
LambdaQueryWrapper<SystemMessageDO> wrapper = systemMessageDAO.wrapper()
.eq(SystemMessageDO::getId, id)
.eq(SystemMessageDO::getReceiverId, userId);
int effect = systemMessageDAO.update(update, wrapper);
log.info("SystemMessageService-readSystemMessage id: {}, effect: {}", id, effect);
return effect;
}
@Override
public Integer readAllSystemMessage(String classify) {
Long userId = SecurityUtils.getLoginUserId();
log.info("SystemMessageService-readAllSystemMessage classify: {}, userId: {}", classify, userId);
// 修改状态
SystemMessageDO update = new SystemMessageDO();
update.setStatus(MessageStatusEnum.READ.getStatus());
LambdaQueryWrapper<SystemMessageDO> wrapper = systemMessageDAO.wrapper()
.eq(SystemMessageDO::getReceiverId, userId)
.eq(SystemMessageDO::getClassify, classify)
.eq(SystemMessageDO::getStatus, MessageStatusEnum.UNREAD.getStatus());
int effect = systemMessageDAO.update(update, wrapper);
log.info("SystemMessageService-readAllSystemMessage classify: {}, effect: {}", classify, effect);
return effect;
}
@Override
public Integer deleteSystemMessageById(Long id) {
log.info("SystemMessageService-deleteSystemMessageById id: {}", id);
// 删除
LambdaQueryWrapper<SystemMessageDO> wrapper = systemMessageDAO.wrapper()
.eq(SystemMessageDO::getId, id)
.eq(SystemMessageDO::getReceiverId, SecurityUtils.getLoginUserId());
int effect = systemMessageDAO.delete(wrapper);
log.info("SystemMessageService-deleteSystemMessageById id: {}, effect: {}", id, effect);
return effect;
}
@Override
public Integer clearSystemMessage(String classify) {
Long userId = SecurityUtils.getLoginUserId();
log.info("SystemMessageService-clearSystemMessage classify: {}, userId: {}", classify, userId);
// 删除
LambdaQueryWrapper<SystemMessageDO> wrapper = systemMessageDAO.wrapper()
.eq(SystemMessageDO::getReceiverId, userId)
.eq(SystemMessageDO::getClassify, classify)
.eq(SystemMessageDO::getStatus, MessageStatusEnum.READ.getStatus());
int effect = systemMessageDAO.delete(wrapper);
log.info("SystemMessageService-clearSystemMessage classify: {}, effect: {}", classify, effect);
return effect;
}
}

View File

@@ -0,0 +1,43 @@
<?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.orion.ops.module.infra.dao.SystemMessageDAO">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.orion.ops.module.infra.entity.domain.SystemMessageDO">
<id column="id" property="id"/>
<result column="classify" property="classify"/>
<result column="type" property="type"/>
<result column="status" property="status"/>
<result column="rel_key" property="relKey"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
<result column="receiver_id" property="receiverId"/>
<result column="receiver_username" property="receiverUsername"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="deleted" property="deleted"/>
</resultMap>
<resultMap id="CountResultMap" type="com.orion.ops.module.infra.entity.dto.SystemMessageCountDTO">
<result column="classify" property="classify"/>
<result column="count" property="count"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, classify, type, status, rel_key, title, content, receiver_id, receiver_username, create_time, update_time, deleted
</sql>
<!-- 查询消息数量 -->
<select id="selectSystemMessageCount" resultMap="CountResultMap">
SELECT classify, count(1) count
FROM system_message
WHERE deleted = 0
AND receiver_id = #{receiverId}
<if test="status != null">
AND status = #{status}
</if>
GROUP BY classify
</select>
</mapper>

View File

@@ -1,4 +1,4 @@
VITE_API_BASE_URL= 'http://127.0.0.1:9200/orion/api'
VITE_WS_BASE_URL= 'ws://127.0.0.1:9200/orion/keep-alive'
VITE_APP_VERSION= '1.0.7'
VITE_APP_VERSION= '1.0.8'
VITE_SFTP_PREVIEW_MB= 2

View File

@@ -1,4 +1,4 @@
VITE_API_BASE_URL= '/orion/api'
VITE_WS_BASE_URL= '/orion/keep-alive'
VITE_APP_VERSION= '1.0.7'
VITE_APP_VERSION= '1.0.8'
VITE_SFTP_PREVIEW_MB= 2

View File

@@ -1,7 +1,7 @@
{
"name": "orion-ops-pro-ui",
"description": "Orion Ops Pro for Vue",
"version": "1.0.7",
"version": "1.0.8",
"private": true,
"author": "Jiahang Li",
"license": "Apache 2.0",