feat:实现通知公告的基础功能
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package ai.remi.sys.domain.converter;
|
||||
|
||||
|
||||
import ai.remi.sys.domain.dto.post.NoticePostDTO;
|
||||
import ai.remi.sys.domain.dto.put.NoticePutDTO;
|
||||
import ai.remi.sys.domain.entity.Notice;
|
||||
import ai.remi.sys.domain.query.NoticeQuery;
|
||||
import ai.remi.sys.domain.vo.NoticeVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告 NoticeConverter转换接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface NoticeConverter {
|
||||
|
||||
NoticeConverter INSTANT = Mappers.getMapper(NoticeConverter.class);
|
||||
|
||||
@Mapping(target = "id", ignore = true)
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
@Mapping(target = "revision", ignore = true)
|
||||
@Mapping(target = "deptTenantId", ignore = true)
|
||||
@Mapping(target = "companyTenantId", ignore = true)
|
||||
@Mapping(target = "createdBy", ignore = true)
|
||||
@Mapping(target = "createdAt", ignore = true)
|
||||
@Mapping(target = "updatedBy", ignore = true)
|
||||
@Mapping(target = "updatedAt", ignore = true)
|
||||
Notice postDtoToEntity(NoticePostDTO noticeDTO);
|
||||
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
@Mapping(target = "revision", ignore = true)
|
||||
@Mapping(target = "deptTenantId", ignore = true)
|
||||
@Mapping(target = "companyTenantId", ignore = true)
|
||||
@Mapping(target = "createdBy", ignore = true)
|
||||
@Mapping(target = "createdAt", ignore = true)
|
||||
@Mapping(target = "updatedBy", ignore = true)
|
||||
@Mapping(target = "updatedAt", ignore = true)
|
||||
Notice putDtoToEntity(NoticePutDTO noticeDTO);
|
||||
|
||||
@Mapping(target = "deleted", ignore = true)
|
||||
@Mapping(target = "revision", ignore = true)
|
||||
@Mapping(target = "deptTenantId", ignore = true)
|
||||
@Mapping(target = "companyTenantId", ignore = true)
|
||||
@Mapping(target = "createdBy", ignore = true)
|
||||
@Mapping(target = "createdAt", ignore = true)
|
||||
@Mapping(target = "updatedBy", ignore = true)
|
||||
@Mapping(target = "updatedAt", ignore = true)
|
||||
Notice queryToEntity(NoticeQuery noticeQuery);
|
||||
|
||||
NoticeVO entityToVO(Notice notice);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package ai.remi.sys.domain.dto.post;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告 NoticeDTO对象
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
@Schema(description = "通知公告")
|
||||
public class NoticePostDTO implements Serializable {
|
||||
private static final long serialVersionUID = -85705948237810052L;
|
||||
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@Schema(description = "通知类型")
|
||||
private Integer noticeType;
|
||||
|
||||
/**
|
||||
* 通知图标
|
||||
*/
|
||||
@Schema(description = "通知图标")
|
||||
private String noticeIcon;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
@Schema(description = "通知内容")
|
||||
private String noticeContent;
|
||||
|
||||
/**
|
||||
* 通知英文内容
|
||||
*/
|
||||
@Schema(description = "通知英文内容")
|
||||
private String noticeContentEn;
|
||||
|
||||
/**
|
||||
* 链接地址
|
||||
*/
|
||||
@Schema(description = "链接地址")
|
||||
private String linkUrl;
|
||||
|
||||
/**
|
||||
* 是否启用(0停用 1启用)
|
||||
*/
|
||||
@Schema(description = "是否启用(0停用 1启用)")
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package ai.remi.sys.domain.dto.put;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告 NoticeDTO对象
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
@Schema(description = "通知公告")
|
||||
public class NoticePutDTO implements Serializable {
|
||||
private static final long serialVersionUID = -60057424548731388L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@Schema(description = "ID")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@Schema(description = "通知类型")
|
||||
private Integer noticeType;
|
||||
|
||||
/**
|
||||
* 通知图标
|
||||
*/
|
||||
@Schema(description = "通知图标")
|
||||
private String noticeIcon;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
@Schema(description = "通知内容")
|
||||
private String noticeContent;
|
||||
|
||||
/**
|
||||
* 通知英文内容
|
||||
*/
|
||||
@Schema(description = "通知英文内容")
|
||||
private String noticeContentEn;
|
||||
|
||||
/**
|
||||
* 链接地址
|
||||
*/
|
||||
@Schema(description = "链接地址")
|
||||
private String linkUrl;
|
||||
|
||||
/**
|
||||
* 是否启用(0停用 1启用)
|
||||
*/
|
||||
@Schema(description = "是否启用(0停用 1启用)")
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package ai.remi.sys.domain.entity;
|
||||
|
||||
import ai.remi.comm.domain.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告 NoticeDTO对象
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("sys_notice")
|
||||
public class Notice extends BaseEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
private Integer noticeType;
|
||||
|
||||
/**
|
||||
* 通知图标
|
||||
*/
|
||||
private String noticeIcon;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
private String noticeContent;
|
||||
|
||||
/**
|
||||
* 通知英文内容
|
||||
*/
|
||||
private String noticeContentEn;
|
||||
|
||||
/**
|
||||
* 链接地址
|
||||
*/
|
||||
private String linkUrl;
|
||||
|
||||
/**
|
||||
* 是否启用(0停用 1启用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package ai.remi.sys.domain.query;
|
||||
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告 NoticeQuery对象
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
@Schema(description = "通知公告")
|
||||
public class NoticeQuery implements Serializable {
|
||||
private static final long serialVersionUID = 184487597326354695L;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@Schema(description = "ID")
|
||||
private String id;
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@Schema(description = "通知类型")
|
||||
private Integer noticeType;
|
||||
/**
|
||||
* 通知图标
|
||||
*/
|
||||
@Schema(description = "通知图标")
|
||||
private String noticeIcon;
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
@Schema(description = "通知内容")
|
||||
private String noticeContent;
|
||||
/**
|
||||
* 通知英文内容
|
||||
*/
|
||||
@Schema(description = "通知英文内容")
|
||||
private String noticeContentEn;
|
||||
/**
|
||||
* 链接地址
|
||||
*/
|
||||
@Schema(description = "链接地址")
|
||||
private String linkUrl;
|
||||
/**
|
||||
* 是否启用(0停用 1启用)
|
||||
*/
|
||||
@Schema(description = "是否启用(0停用 1启用)")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package ai.remi.sys.domain.vo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告 NoticeVO对象
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString(callSuper = true)
|
||||
@Schema(description = "通知公告")
|
||||
public class NoticeVO implements Serializable {
|
||||
private static final long serialVersionUID = 695350673723880666L;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@Schema(description = "ID")
|
||||
private String id;
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
@Schema(description = "通知类型")
|
||||
private Integer noticeType;
|
||||
/**
|
||||
* 通知图标
|
||||
*/
|
||||
@Schema(description = "通知图标")
|
||||
private String noticeIcon;
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
@Schema(description = "通知内容")
|
||||
private String noticeContent;
|
||||
/**
|
||||
* 通知英文内容
|
||||
*/
|
||||
@Schema(description = "通知英文内容")
|
||||
private String noticeContentEn;
|
||||
/**
|
||||
* 链接地址
|
||||
*/
|
||||
@Schema(description = "链接地址")
|
||||
private String linkUrl;
|
||||
/**
|
||||
* 是否启用(0停用 1启用)
|
||||
*/
|
||||
@Schema(description = "是否启用(0停用 1启用)")
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否删除(0正常 1删除)
|
||||
*/
|
||||
@Schema(description = "是否删除(0正常 1删除)")
|
||||
private Integer deleted;
|
||||
/**
|
||||
* 乐观锁
|
||||
*/
|
||||
@Schema(description = "乐观锁")
|
||||
private Integer revision;
|
||||
/**
|
||||
* 部门租户ID
|
||||
*/
|
||||
@Schema(description = "部门租户ID")
|
||||
private String deptTenantId;
|
||||
/**
|
||||
* 公司租户ID
|
||||
*/
|
||||
@Schema(description = "公司租户ID")
|
||||
private String companyTenantId;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Schema(description = "创建人")
|
||||
private String createdBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Schema(description = "更新人")
|
||||
private String updatedBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package ai.remi.sys.infra.mapper;
|
||||
|
||||
import ai.remi.sys.domain.entity.Notice;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告(Notice)数据层
|
||||
*/
|
||||
@Mapper
|
||||
public interface NoticeMapper extends BaseMapper<Notice> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package ai.remi.sys.server.service;
|
||||
|
||||
import ai.remi.sys.domain.entity.Notice;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告(Notice)服务定义层
|
||||
*/
|
||||
public interface NoticeService extends IService<Notice> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package ai.remi.sys.server.service.impl;
|
||||
|
||||
import ai.remi.sys.domain.entity.Notice;
|
||||
import ai.remi.sys.infra.mapper.NoticeMapper;
|
||||
import ai.remi.sys.server.service.NoticeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告(Notice)服务实现层
|
||||
*/
|
||||
@Service("noticeService")
|
||||
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package ai.remi.sys.web.controller;
|
||||
|
||||
|
||||
import ai.remi.comm.core.result.PagerBean;
|
||||
import ai.remi.comm.core.result.ResultBean;
|
||||
import ai.remi.comm.domain.query.PageQuery;
|
||||
import ai.remi.comm.util.bean.BeanCopyUtils;
|
||||
import ai.remi.sys.domain.converter.NoticeConverter;
|
||||
import ai.remi.sys.domain.dto.post.NoticePostDTO;
|
||||
import ai.remi.sys.domain.dto.put.NoticePutDTO;
|
||||
import ai.remi.sys.domain.entity.Notice;
|
||||
import ai.remi.sys.domain.query.NoticeQuery;
|
||||
import ai.remi.sys.domain.vo.NoticeVO;
|
||||
import ai.remi.sys.server.service.NoticeService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSort;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DianJiu
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通知公告(Notice)控制层
|
||||
*/
|
||||
@Validated
|
||||
@RestController
|
||||
@ApiSort(value = 1)
|
||||
@Tag(name = "通知公告")
|
||||
@RequestMapping("notice")
|
||||
public class NoticeController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private NoticeService noticeService;
|
||||
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "查询单条")
|
||||
public ResultBean<NoticeVO> get(@PathVariable @Validated @NotBlank(message = "ID不能为空") String id) {
|
||||
Notice notice = noticeService.getById(id);
|
||||
//处理格式转换
|
||||
NoticeVO noticeVO = NoticeConverter.INSTANT.entityToVO(notice);
|
||||
return ResultBean.success(noticeVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过实体不为空的属性作为筛选条件查询对象列表
|
||||
*
|
||||
* @param noticeQuery 实例对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
@PostMapping(value = "/list")
|
||||
@Operation(summary = "查询所有")
|
||||
public ResultBean<List<NoticeVO>> list(@RequestBody NoticeQuery noticeQuery) {
|
||||
//处理格式转换
|
||||
Notice notice = NoticeConverter.INSTANT.queryToEntity(noticeQuery);
|
||||
//执行分页查询
|
||||
List<Notice> listResult = noticeService.list(new QueryWrapper<>(notice));
|
||||
return ResultBean.success(BeanCopyUtils.coverList(listResult, NoticeVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
*
|
||||
* @param pageQuery 分页对象
|
||||
* @param noticeQuery 查询实体
|
||||
* @return 分页对象
|
||||
*/
|
||||
@PostMapping(value = "/page")
|
||||
@Operation(summary = "分页查询")
|
||||
public ResultBean<PagerBean<NoticeVO>> page(PageQuery pageQuery, NoticeQuery noticeQuery) {
|
||||
//处理分页条件
|
||||
Page<Notice> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||
//处理格式转换
|
||||
Notice notice = NoticeConverter.INSTANT.queryToEntity(noticeQuery);
|
||||
//执行分页查询
|
||||
Page<Notice> pageResult = noticeService.page(page, new QueryWrapper<>(notice));
|
||||
PagerBean<NoticeVO> pageBean = new PagerBean<>(pageResult.getTotal(), pageResult.getCurrent(),
|
||||
pageResult.getSize(), BeanCopyUtils.coverList(pageResult.getRecords(), NoticeVO.class));
|
||||
return ResultBean.success(pageBean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param noticeDTO 实体对象
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "新增数据")
|
||||
public ResultBean<Boolean> insert(@RequestBody @Validated NoticePostDTO noticeDTO) {
|
||||
//处理格式转换
|
||||
Notice notice = NoticeConverter.INSTANT.postDtoToEntity(noticeDTO);
|
||||
//执行数据保存
|
||||
return ResultBean.success(noticeService.save(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param noticeDTO 实体对象
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改数据")
|
||||
public ResultBean<Boolean> update(@RequestBody @Validated NoticePutDTO noticeDTO) {
|
||||
//处理格式转换
|
||||
Notice notice = NoticeConverter.INSTANT.putDtoToEntity(noticeDTO);
|
||||
//执行数据更新
|
||||
return ResultBean.success(noticeService.updateById(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param ids 主键结合
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除数据")
|
||||
public ResultBean<Boolean> delete(@RequestParam("ids") List<String> ids) {
|
||||
return ResultBean.success(noticeService.removeByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user