feat: 消息管理页面CURD
This commit is contained in:
parent
a423552a2f
commit
044056a7f2
|
@ -3,10 +3,10 @@ package cn.bunny.common.generator.generator;
|
|||
import cn.bunny.common.generator.entity.BaseField;
|
||||
import cn.bunny.common.generator.entity.BaseResultMap;
|
||||
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
||||
import cn.bunny.dao.dto.system.message.MessageTypeDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageTypeUpdateDto;
|
||||
import cn.bunny.dao.entity.system.MessageType;
|
||||
import cn.bunny.dao.vo.system.message.MessageTypeVo;
|
||||
import cn.bunny.dao.dto.system.message.MessageDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Message;
|
||||
import cn.bunny.dao.vo.system.message.MessageVo;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -50,11 +50,11 @@ public class WebGeneratorCode {
|
|||
public static String resourceMapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class<?> originalClass = MessageType.class;
|
||||
Class<?> dtoClass = MessageTypeDto.class;
|
||||
Class<?> addDtoClass = MessageTypeDto.class;
|
||||
Class<?> updateDtoClass = MessageTypeUpdateDto.class;
|
||||
Class<?> voClass = MessageTypeVo.class;
|
||||
Class<?> originalClass = Message.class;
|
||||
Class<?> dtoClass = MessageDto.class;
|
||||
Class<?> addDtoClass = MessageDto.class;
|
||||
Class<?> updateDtoClass = MessageUpdateDto.class;
|
||||
Class<?> voClass = MessageVo.class;
|
||||
|
||||
// 设置velocity资源加载器
|
||||
Properties prop = new Properties();
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
<include refid="Base_Column_List"/>
|
||||
from $tableName
|
||||
<where>
|
||||
is_deleted = 0
|
||||
#foreach($field in $pageQueryMap)
|
||||
is_deleted = 0
|
||||
<if test="dto.${field.property} != null and dto.${field.property} != ''">
|
||||
and $field.column like CONCAT('%',#{dto.${field.property}},'%')
|
||||
</if>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { reactive, ref } from 'vue';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
// 表格列
|
||||
export const columns: TableColumnList = [
|
||||
|
|
|
@ -6,16 +6,15 @@ import { h, ref } from 'vue';
|
|||
import { messageBox } from '@/utils/message';
|
||||
import type { FormItemProps } from '${typesPath}';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import type { FormRules } from 'element-plus';
|
||||
import { message, messageBox } from "@/utils/message";
|
||||
import DeleteBatchDialog from "@/components/Table/DeleteBatchDialog.vue";
|
||||
|
||||
export const formRef = ref();
|
||||
// 删除ids
|
||||
export const deleteIds = ref([]);
|
||||
const ${lowercaseName}Store = use${originalName}Store();
|
||||
|
||||
/**
|
||||
* * 搜索初始化${classTitle}
|
||||
*/
|
||||
/** 搜索初始化${classTitle} */
|
||||
export async function onSearch() {
|
||||
${lowercaseName}Store.loading = true;
|
||||
await ${lowercaseName}Store.get${originalName}List();
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package cn.bunny.dao.dto.system.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "MessageAddDto对象", title = "系统消息", description = "系统消息")
|
||||
public class MessageAddDto {
|
||||
|
||||
@Schema(name = "title", title = "消息标题")
|
||||
@NotNull(message = "消息标题 不能为空")
|
||||
@NotBlank(message = "消息标题 不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(name = "receivedUserId", title = "接收人用户ID")
|
||||
private List<Long> receivedUserId;
|
||||
|
||||
@Schema(name = "sendUserId", title = "发送人用户ID")
|
||||
@NotNull(message = "发送人用户ID 不能为空")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(name = "sendNickName", title = "发送人昵称")
|
||||
@NotBlank(message = "发送人昵称 不能为空")
|
||||
@NotNull(message = "发送人昵称 不能为空")
|
||||
private String sendNickName;
|
||||
|
||||
@Schema(name = "messageType", title = "消息类型")
|
||||
@NotBlank(message = "消息类型 不能为空")
|
||||
@NotNull(message = "消息类型 不能为空")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
@NotBlank(message = "消息内容 不能为空")
|
||||
@NotNull(message = "消息内容 不能为空")
|
||||
private String content;
|
||||
|
||||
@Schema(name = "editorType", title = "编辑器类型")
|
||||
@NotBlank(message = "编辑器类型 不能为空")
|
||||
@NotNull(message = "编辑器类型 不能为空")
|
||||
private String editorType;
|
||||
|
||||
@Schema(name = "status", title = "0:未读 1:已读")
|
||||
private Boolean status = false;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package cn.bunny.dao.dto.system.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "MessageDto对象", title = "系统消息", description = "系统消息")
|
||||
public class MessageDto {
|
||||
|
||||
@Schema(name = "title", title = "消息标题")
|
||||
private String title;
|
||||
|
||||
@Schema(name = "receivedUserId", title = "接收人用户ID")
|
||||
private Long receivedUserId;
|
||||
|
||||
@Schema(name = "sendUserId", title = "发送人用户ID")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(name = "sendNickName", title = "发送人昵称")
|
||||
private String sendNickName;
|
||||
|
||||
@Schema(name = "messageType", title = "消息类型")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
private String content;
|
||||
|
||||
@Schema(name = "editorType", title = "编辑器类型")
|
||||
private String editorType;
|
||||
|
||||
@Schema(name = "status", title = "0:未读 1:已读")
|
||||
private Boolean status;
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package cn.bunny.dao.dto.system.message;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "MessageUpdateDto对象", title = "系统消息", description = "系统消息")
|
||||
public class MessageUpdateDto {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "title", title = "消息标题")
|
||||
@NotNull(message = "消息标题 不能为空")
|
||||
@NotBlank(message = "消息标题 不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(name = "receivedUserId", title = "接收人用户ID")
|
||||
private List<Long> receivedUserId;
|
||||
|
||||
@Schema(name = "sendUserId", title = "发送人用户ID")
|
||||
@NotNull(message = "发送人用户ID 不能为空")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(name = "sendNickName", title = "发送人昵称")
|
||||
@NotBlank(message = "发送人昵称 不能为空")
|
||||
@NotNull(message = "发送人昵称 不能为空")
|
||||
private String sendNickName;
|
||||
|
||||
@Schema(name = "messageType", title = "消息类型")
|
||||
@NotBlank(message = "消息类型 不能为空")
|
||||
@NotNull(message = "消息类型 不能为空")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
@NotBlank(message = "消息内容 不能为空")
|
||||
@NotNull(message = "消息内容 不能为空")
|
||||
private String content;
|
||||
|
||||
@Schema(name = "editorType", title = "编辑器类型")
|
||||
@NotBlank(message = "编辑器类型 不能为空")
|
||||
@NotNull(message = "编辑器类型 不能为空")
|
||||
private String editorType;
|
||||
|
||||
@Schema(name = "status", title = "0:未读 1:已读")
|
||||
private Boolean status;
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,9 @@ import lombok.experimental.Accessors;
|
|||
@Schema(name = "Message对象", title = "系统消息", description = "系统消息")
|
||||
public class Message extends BaseEntity {
|
||||
|
||||
@Schema(name = "title", title = "消息标题")
|
||||
private String title;
|
||||
|
||||
@Schema(name = "receivedUserId", title = "接收人用户ID")
|
||||
private Long receivedUserId;
|
||||
|
||||
|
@ -44,3 +47,5 @@ public class Message extends BaseEntity {
|
|||
private Boolean status;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package cn.bunny.dao.vo.system.message;
|
||||
|
||||
import cn.bunny.dao.vo.common.BaseVo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "MessageVo对象", title = "系统消息返回内容", description = "系统消息返回内容")
|
||||
public class MessageVo extends BaseVo {
|
||||
|
||||
@Schema(name = "title", title = "消息标题")
|
||||
private String title;
|
||||
|
||||
@Schema(name = "receivedUserId", title = "接收人用户ID")
|
||||
private Long receivedUserId;
|
||||
|
||||
@Schema(name = "sendUserId", title = "发送人用户ID")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(name = "sendNickName", title = "发送人昵称")
|
||||
private String sendNickName;
|
||||
|
||||
@Schema(name = "messageType", title = "sys:系统消息,user用户消息")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
private String content;
|
||||
|
||||
@Schema(name = "editorType", title = "编辑器类型")
|
||||
private String editorType;
|
||||
|
||||
@Schema(name = "status", title = "0:未读 1:已读")
|
||||
private Boolean status;
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ import lombok.*;
|
|||
@Builder
|
||||
@Schema(name = "AdminUserVo对象", title = "用户信息", description = "用户信息")
|
||||
public class AdminUserVo extends BaseVo {
|
||||
|
||||
@Schema(name = "username", title = "用户名")
|
||||
private String username;
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package cn.bunny.dao.vo.system.user;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "AdminUserVo对象", title = "用户信息", description = "用户信息")
|
||||
public class SearchUserinfoVo {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
@JsonProperty("id")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "username", title = "用户名")
|
||||
private String username;
|
||||
|
||||
@Schema(name = "nickname", title = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@Schema(name = "email", title = "邮箱")
|
||||
private String email;
|
||||
|
||||
@Schema(name = "phone", title = "手机号")
|
||||
private String phone;
|
||||
|
||||
}
|
|
@ -1,18 +1,72 @@
|
|||
package cn.bunny.services.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import cn.bunny.dao.dto.system.message.MessageAddDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Message;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.message.MessageVo;
|
||||
import cn.bunny.services.service.MessageService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统消息 前端控制器
|
||||
* 系统消息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-30
|
||||
* @since 2024-10-30 15:19:56
|
||||
*/
|
||||
@Tag(name = "系统消息", description = "系统消息相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/admin/message")
|
||||
@RequestMapping("admin/message")
|
||||
public class MessageController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Operation(summary = "分页查询系统消息", description = "分页查询系统消息")
|
||||
@GetMapping("getMessageList/{page}/{limit}")
|
||||
public Mono<Result<PageResult<MessageVo>>> getMessageList(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
MessageDto dto) {
|
||||
Page<Message> pageParams = new Page<>(page, limit);
|
||||
PageResult<MessageVo> pageResult = messageService.getMessageList(pageParams, dto);
|
||||
return Mono.just(Result.success(pageResult));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加系统消息", description = "添加系统消息")
|
||||
@PostMapping("addMessage")
|
||||
public Mono<Result<String>> addMessage(@Valid @RequestBody MessageAddDto dto) {
|
||||
messageService.addMessage(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新系统消息", description = "更新系统消息")
|
||||
@PutMapping("updateMessage")
|
||||
public Mono<Result<String>> updateMessage(@Valid @RequestBody MessageUpdateDto dto) {
|
||||
messageService.updateMessage(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除系统消息", description = "删除系统消息")
|
||||
@DeleteMapping("deleteMessage")
|
||||
public Mono<Result<String>> deleteMessage(@RequestBody List<Long> ids) {
|
||||
messageService.deleteMessage(ids);
|
||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,7 @@ import cn.bunny.dao.entity.system.AdminUser;
|
|||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.pojo.result.Result;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.user.AdminUserVo;
|
||||
import cn.bunny.dao.vo.system.user.LoginVo;
|
||||
import cn.bunny.dao.vo.system.user.RefreshTokenVo;
|
||||
import cn.bunny.dao.vo.system.user.UserVo;
|
||||
import cn.bunny.dao.vo.system.user.*;
|
||||
import cn.bunny.services.service.UserService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
@ -59,8 +56,8 @@ public class UserController {
|
|||
|
||||
@Operation(summary = "多条件查询用户", description = "多条件查询用户")
|
||||
@GetMapping("noManage/queryUser")
|
||||
public Mono<Result<List<AdminUserVo>>> queryUser(String keyword) {
|
||||
List<AdminUserVo> voList = userService.queryUser(keyword);
|
||||
public Mono<Result<List<SearchUserinfoVo>>> queryUser(String keyword) {
|
||||
List<SearchUserinfoVo> voList = userService.queryUser(keyword);
|
||||
return Mono.just(Result.success(voList));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
package cn.bunny.services.factory;
|
||||
|
||||
import cn.bunny.common.service.context.BaseContext;
|
||||
import cn.bunny.common.service.exception.BunnyException;
|
||||
import cn.bunny.common.service.utils.FileUtil;
|
||||
import cn.bunny.common.service.utils.minio.MinioUtil;
|
||||
import cn.bunny.dao.entity.system.Files;
|
||||
import cn.bunny.dao.pojo.common.MinioFilePath;
|
||||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||
import cn.bunny.services.mapper.FilesMapper;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Component
|
||||
public class FileFactory {
|
||||
@Value("${spring.servlet.multipart.max-file-size}")
|
||||
private String maxFileSize;
|
||||
|
||||
@Autowired
|
||||
private FilesMapper filesMapper;
|
||||
|
||||
@Autowired
|
||||
private MinioUtil minioUtil;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 文件
|
||||
* @param type 文件类型(MinioConstant)
|
||||
* @return 返回文件信息
|
||||
*/
|
||||
@SneakyThrows
|
||||
public FileInfoVo uploadFile(MultipartFile file, String type) {
|
||||
// 管理员Id
|
||||
Long userId = BaseContext.getUserId();
|
||||
// 文件大小
|
||||
long fileSize = file.getSize();
|
||||
// 文件类型
|
||||
String contentType = file.getContentType();
|
||||
// 文件名
|
||||
String filename = file.getOriginalFilename();
|
||||
|
||||
// 上传文件
|
||||
MinioFilePath minioFIlePath = minioUtil.uploadObject4FilePath(file, type);
|
||||
String bucketNameFilepath = minioFIlePath.getBucketNameFilepath();
|
||||
|
||||
// 盘读研数据是否过大
|
||||
String mb = maxFileSize.replace("MB", "");
|
||||
if (fileSize / 1024 / 1024 > Long.parseLong(mb)) throw new BunnyException(ResultCodeEnum.DATA_TOO_LARGE);
|
||||
|
||||
// 插入文件信息
|
||||
Files adminFiles = new Files();
|
||||
adminFiles.setFileSize(fileSize);
|
||||
adminFiles.setFileType(contentType);
|
||||
adminFiles.setFilename(filename);
|
||||
adminFiles.setFilepath(bucketNameFilepath);
|
||||
adminFiles.setCreateUser(userId);
|
||||
filesMapper.insert(adminFiles);
|
||||
|
||||
// 返回信息内容化
|
||||
return FileInfoVo.builder()
|
||||
.size(FileUtil.getSize(fileSize))
|
||||
.filepath(bucketNameFilepath)
|
||||
.fileSize(fileSize)
|
||||
.fileType(contentType)
|
||||
.filename(filename)
|
||||
.url(minioUtil.getObjectNameFullPath(bucketNameFilepath))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,14 @@
|
|||
package cn.bunny.services.mapper;
|
||||
|
||||
import cn.bunny.dao.dto.system.message.MessageDto;
|
||||
import cn.bunny.dao.entity.system.Message;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -10,9 +16,24 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-30
|
||||
* @since 2024-10-30 15:19:56
|
||||
*/
|
||||
@Mapper
|
||||
public interface MessageMapper extends BaseMapper<Message> {
|
||||
|
||||
/**
|
||||
* * 分页查询系统消息内容
|
||||
*
|
||||
* @param pageParams 系统消息分页参数
|
||||
* @param dto 系统消息查询表单
|
||||
* @return 系统消息分页结果
|
||||
*/
|
||||
IPage<Message> selectListByPage(@Param("page") Page<Message> pageParams, @Param("dto") MessageDto dto);
|
||||
|
||||
/**
|
||||
* 物理删除系统消息
|
||||
*
|
||||
* @param ids 删除 id 列表
|
||||
*/
|
||||
void deleteBatchIdsWithPhysics(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
package cn.bunny.services.service;
|
||||
|
||||
import cn.bunny.dao.dto.system.message.MessageAddDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Message;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.message.MessageVo;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -9,8 +18,35 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-30
|
||||
* @since 2024-10-30 15:19:56
|
||||
*/
|
||||
public interface MessageService extends IService<Message> {
|
||||
|
||||
/**
|
||||
* * 获取系统消息列表
|
||||
*
|
||||
* @return 系统消息返回列表
|
||||
*/
|
||||
PageResult<MessageVo> getMessageList(Page<Message> pageParams, MessageDto dto);
|
||||
|
||||
/**
|
||||
* * 添加系统消息
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
void addMessage(@Valid MessageAddDto dto);
|
||||
|
||||
/**
|
||||
* * 更新系统消息
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
void updateMessage(@Valid MessageUpdateDto dto);
|
||||
|
||||
/**
|
||||
* * 删除|批量删除系统消息类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteMessage(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -3,10 +3,7 @@ package cn.bunny.services.service;
|
|||
import cn.bunny.dao.dto.system.user.*;
|
||||
import cn.bunny.dao.entity.system.AdminUser;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.user.AdminUserVo;
|
||||
import cn.bunny.dao.vo.system.user.LoginVo;
|
||||
import cn.bunny.dao.vo.system.user.RefreshTokenVo;
|
||||
import cn.bunny.dao.vo.system.user.UserVo;
|
||||
import cn.bunny.dao.vo.system.user.*;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
@ -108,7 +105,7 @@ public interface UserService extends IService<AdminUser> {
|
|||
* @param keyword 查询用户信息关键字
|
||||
* @return 用户信息列表
|
||||
*/
|
||||
List<AdminUserVo> queryUser(String keyword);
|
||||
List<SearchUserinfoVo> queryUser(String keyword);
|
||||
|
||||
/**
|
||||
* * 修改用户状态
|
||||
|
|
|
@ -1,20 +1,92 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.dao.dto.system.message.MessageAddDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageDto;
|
||||
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
|
||||
import cn.bunny.dao.entity.system.Message;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.message.MessageVo;
|
||||
import cn.bunny.services.mapper.MessageMapper;
|
||||
import cn.bunny.services.service.MessageService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统消息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-10-30
|
||||
* @since 2024-10-30 15:19:56
|
||||
*/
|
||||
@Service
|
||||
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {
|
||||
|
||||
/**
|
||||
* * 系统消息 服务实现类
|
||||
*
|
||||
* @param pageParams 系统消息分页查询page对象
|
||||
* @param dto 系统消息分页查询对象
|
||||
* @return 查询分页系统消息返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<MessageVo> getMessageList(Page<Message> pageParams, MessageDto dto) {
|
||||
// 分页查询菜单图标
|
||||
IPage<Message> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
List<MessageVo> voList = page.getRecords().stream().map(message -> {
|
||||
MessageVo messageVo = new MessageVo();
|
||||
BeanUtils.copyProperties(message, messageVo);
|
||||
return messageVo;
|
||||
}).toList();
|
||||
|
||||
return PageResult.<MessageVo>builder()
|
||||
.list(voList)
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统消息
|
||||
*
|
||||
* @param dto 系统消息添加
|
||||
*/
|
||||
@Override
|
||||
public void addMessage(@Valid MessageAddDto dto) {
|
||||
// 保存数据
|
||||
Message message = new Message();
|
||||
BeanUtils.copyProperties(dto, message);
|
||||
save(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新系统消息
|
||||
*
|
||||
* @param dto 系统消息更新
|
||||
*/
|
||||
@Override
|
||||
public void updateMessage(@Valid MessageUpdateDto dto) {
|
||||
// 更新内容
|
||||
Message message = new Message();
|
||||
BeanUtils.copyProperties(dto, message);
|
||||
updateById(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除系统消息
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteMessage(List<Long> ids) {
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,7 @@ import cn.bunny.dao.pojo.result.PageResult;
|
|||
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||
import cn.bunny.dao.view.ViewUserDept;
|
||||
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||
import cn.bunny.dao.vo.system.user.AdminUserVo;
|
||||
import cn.bunny.dao.vo.system.user.LoginVo;
|
||||
import cn.bunny.dao.vo.system.user.RefreshTokenVo;
|
||||
import cn.bunny.dao.vo.system.user.UserVo;
|
||||
import cn.bunny.dao.vo.system.user.*;
|
||||
import cn.bunny.services.factory.EmailFactory;
|
||||
import cn.bunny.services.factory.UserFactory;
|
||||
import cn.bunny.services.mapper.*;
|
||||
|
@ -46,7 +43,6 @@ import org.springframework.util.DigestUtils;
|
|||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -284,12 +280,18 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
|||
* @return 用户信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<AdminUserVo> queryUser(String keyword) {
|
||||
if (!StringUtils.hasText(keyword)) return new ArrayList<>();
|
||||
public List<SearchUserinfoVo> queryUser(String keyword) {
|
||||
if (!StringUtils.hasText(keyword)) {
|
||||
return list(Page.of(1, 20), Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getStatus, false)).stream().map(adminUser -> {
|
||||
SearchUserinfoVo adminUserVo = new SearchUserinfoVo();
|
||||
BeanUtils.copyProperties(adminUser, adminUserVo);
|
||||
return adminUserVo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
List<AdminUser> list = baseMapper.queryUser(keyword);
|
||||
return list.stream().map(adminUser -> {
|
||||
AdminUserVo adminUserVo = new AdminUserVo();
|
||||
SearchUserinfoVo adminUserVo = new SearchUserinfoVo();
|
||||
BeanUtils.copyProperties(adminUser, adminUserVo);
|
||||
return adminUserVo;
|
||||
}).toList();
|
||||
|
|
|
@ -5,22 +5,68 @@
|
|||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.system.Message">
|
||||
<id column="id" property="id"/>
|
||||
<result column="received_user_id" property="receivedUserId"/>
|
||||
<result column="send_user_id" property="sendUserId"/>
|
||||
<result column="send_nick_name" property="sendNickName"/>
|
||||
<result column="message_type" property="messageType"/>
|
||||
<result column="content" property="content"/>
|
||||
<result column="editor_type" property="editorType"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="title" property="title"/>
|
||||
<id column="received_user_id" property="receivedUserId"/>
|
||||
<id column="send_user_id" property="sendUserId"/>
|
||||
<id column="send_nick_name" property="sendNickName"/>
|
||||
<id column="message_type" property="messageType"/>
|
||||
<id column="content" property="content"/>
|
||||
<id column="editor_type" property="editorType"/>
|
||||
<id column="status" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, received_user_id, send_user_id, send_nick_name, message_type, content, editor_type, status, create_time, update_time, update_user, is_deleted
|
||||
id, create_time, update_time, create_user, update_user, is_deleted, title, received_user_id, send_user_id, send_nick_name, message_type, content, editor_type, status
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询系统消息内容 -->
|
||||
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.Message">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from sys_message
|
||||
<where>
|
||||
is_deleted = 0
|
||||
<if test="dto.title != null and dto.title != ''">
|
||||
and title like CONCAT('%',#{dto.title},'%')
|
||||
</if>
|
||||
<if test="dto.receivedUserId != null and dto.receivedUserId != ''">
|
||||
and received_user_id like CONCAT('%',#{dto.receivedUserId},'%')
|
||||
</if>
|
||||
<if test="dto.sendUserId != null and dto.sendUserId != ''">
|
||||
and send_user_id like CONCAT('%',#{dto.sendUserId},'%')
|
||||
</if>
|
||||
<if test="dto.sendNickName != null and dto.sendNickName != ''">
|
||||
and send_nick_name like CONCAT('%',#{dto.sendNickName},'%')
|
||||
</if>
|
||||
<if test="dto.messageType != null and dto.messageType != ''">
|
||||
and message_type like CONCAT('%',#{dto.messageType},'%')
|
||||
</if>
|
||||
<if test="dto.content != null and dto.content != ''">
|
||||
and content like CONCAT('%',#{dto.content},'%')
|
||||
</if>
|
||||
<if test="dto.editorType != null and dto.editorType != ''">
|
||||
and editor_type like CONCAT('%',#{dto.editorType},'%')
|
||||
</if>
|
||||
<if test="dto.status != null and dto.status != ''">
|
||||
and status like CONCAT('%',#{dto.status},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 物理删除系统消息 -->
|
||||
<delete id="deleteBatchIdsWithPhysics">
|
||||
delete
|
||||
from sys_message
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue