优化wiki文档上传,增加消息提醒功能
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package com.zyplayer.doc.manage.web.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.UserMessage;
|
||||
import com.zyplayer.doc.data.service.manage.UserMessageService;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 用户消息控制器
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2020年6月25日
|
||||
*/
|
||||
@AuthMan
|
||||
@RestController
|
||||
@RequestMapping("/user/message")
|
||||
public class UserMessageController {
|
||||
|
||||
@Resource
|
||||
UserMessageService userMessageService;
|
||||
|
||||
/**
|
||||
* 消息列表
|
||||
*
|
||||
* @param pageNum 当前页
|
||||
* @param pageSize 每页条数
|
||||
* @param msgStatus 消息状态
|
||||
* @return 数据列表
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseJson<Object> list(Long pageNum, Long pageSize, Integer msgStatus) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
IPage<UserMessage> page = new Page<>(pageNum, pageSize);
|
||||
QueryWrapper<UserMessage> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("accept_user_id", currentUser.getUserId());
|
||||
if (msgStatus != null && msgStatus >= 0) {
|
||||
wrapper.eq("msg_status", msgStatus);
|
||||
}
|
||||
userMessageService.page(page, wrapper);
|
||||
return DocResponseJson.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新消息已读状态
|
||||
*
|
||||
* @param ids 消息IDS
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping("/read")
|
||||
public ResponseJson<Object> read(String ids) {
|
||||
this.update(ids, 1);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除消息
|
||||
*
|
||||
* @param ids 消息IDS
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseJson<Object> delete(String ids) {
|
||||
this.update(ids, 2);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新消息状态
|
||||
*
|
||||
* @param ids 消息IDS
|
||||
* @param status 状态
|
||||
*/
|
||||
public void update(String ids, Integer status) {
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
QueryWrapper<UserMessage> wrapper = new QueryWrapper<>();
|
||||
wrapper.in("id", Arrays.asList(ids.split(",")));
|
||||
wrapper.eq("accept_user_id", currentUser.getUserId());
|
||||
UserMessage msgUp = new UserMessage();
|
||||
msgUp.setMsgStatus(status);
|
||||
userMessageService.update(msgUp, wrapper);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,23 @@ ADD COLUMN `group_name` varchar(50) NULL COMMENT '数据源分组名';
|
||||
ALTER TABLE `wiki_page`
|
||||
ADD COLUMN `editor_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '编辑框类型 1=HTML 2=Markdown';
|
||||
|
||||
CREATE TABLE `user_message` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`sys_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '系统类型 1=manage 2=wiki 3=db',
|
||||
`msg_type` int NOT NULL DEFAULT 1 COMMENT '消息类型 1=普通文本消息 2=wiki文档创建 3=wiki文档删除 4=wiki文档编辑 5=wiki文档权限修改 6=wiki文档评论 7=wiki文档删除评论 8=wiki文档上传附件',
|
||||
`data_id` bigint(20) NULL DEFAULT NULL COMMENT '消息关联的数据ID',
|
||||
`data_desc` varchar(100) NULL DEFAULT NULL COMMENT '消息关联的数据说明',
|
||||
`msg_content` varchar(255) NULL DEFAULT NULL COMMENT '消息内容',
|
||||
`msg_status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '消息状态 0=未读 1=已读 2=已删除',
|
||||
`operator_user_id` bigint(20) NULL DEFAULT NULL COMMENT '操作人用户ID',
|
||||
`operator_user_name` varchar(20) NULL DEFAULT NULL COMMENT '操作人用户名',
|
||||
`affect_user_id` bigint(20) NULL DEFAULT NULL COMMENT '影响人用户ID',
|
||||
`affect_user_name` varchar(20) NULL DEFAULT NULL COMMENT '影响人用户名',
|
||||
`accept_user_id` bigint(20) NULL DEFAULT NULL COMMENT '接收人用户ID',
|
||||
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户消息表' ROW_FORMAT = Compact;
|
||||
|
||||
-- ------------------------全新的库:------------------------
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
@@ -226,6 +243,7 @@ CREATE TABLE `wiki_page` (
|
||||
`del_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '0=有效 1=删除',
|
||||
`view_num` int(11) NOT NULL DEFAULT 0 COMMENT '阅读数',
|
||||
`seq_no` int(11) NOT NULL DEFAULT 0 COMMENT '顺序',
|
||||
`editor_type` tinyint(4) NOT NULL DEFAULT 1 COMMENT '编辑框类型 1=HTML 2=Markdown',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user