refactor: 公告管理 Announcement => Notice

This commit is contained in:
Charles7c 2024-04-27 17:03:22 +08:00
parent abf1e651e9
commit dbe93df8bc
22 changed files with 98 additions and 100 deletions

View File

@ -29,7 +29,7 @@ import top.continew.starter.data.mybatis.plus.base.IBaseEnum;
*/
@Getter
@RequiredArgsConstructor
public enum AnnouncementStatusEnum implements IBaseEnum<Integer> {
public enum NoticeStatusEnum implements IBaseEnum<Integer> {
/**
* 待发布

View File

@ -16,8 +16,8 @@
package top.continew.admin.system.mapper;
import top.continew.admin.system.model.entity.AnnouncementDO;
import top.continew.admin.system.model.resp.DashboardAnnouncementResp;
import top.continew.admin.system.model.entity.NoticeDO;
import top.continew.admin.system.model.resp.DashboardNoticeResp;
import top.continew.starter.data.mybatis.plus.base.BaseMapper;
import java.util.List;
@ -28,12 +28,12 @@ import java.util.List;
* @author Charles7c
* @since 2023/8/20 10:55
*/
public interface AnnouncementMapper extends BaseMapper<AnnouncementDO> {
public interface NoticeMapper extends BaseMapper<NoticeDO> {
/**
* 查询仪表盘公告列表
*
* @return 仪表盘公告列表
*/
List<DashboardAnnouncementResp> selectDashboardList();
List<DashboardNoticeResp> selectDashboardList();
}

View File

@ -30,8 +30,8 @@ import java.time.LocalDateTime;
* @since 2023/8/20 10:55
*/
@Data
@TableName("sys_announcement")
public class AnnouncementDO extends BaseDO {
@TableName("sys_notice")
public class NoticeDO extends BaseDO {
@Serial
private static final long serialVersionUID = 1L;

View File

@ -32,7 +32,7 @@ import java.io.Serializable;
*/
@Data
@Schema(description = "公告查询条件")
public class AnnouncementQuery implements Serializable {
public class NoticeQuery implements Serializable {
@Serial
private static final long serialVersionUID = 1L;

View File

@ -50,7 +50,7 @@ public class DictReq extends BaseReq {
/**
* 编码
*/
@Schema(description = "编码", example = "announcement_type")
@Schema(description = "编码", example = "notice_type")
@NotBlank(message = "编码不能为空")
@Pattern(regexp = RegexConstants.GENERAL_CODE, message = "编码长度为 2 到 30 位,可以包含字母、数字,下划线,以字母开头")
private String code;

View File

@ -34,7 +34,7 @@ import java.time.LocalDateTime;
*/
@Data
@Schema(description = "创建或修改公告信息")
public class AnnouncementReq extends BaseReq {
public class NoticeReq extends BaseReq {
@Serial
private static final long serialVersionUID = 1L;
@ -55,9 +55,9 @@ public class AnnouncementReq extends BaseReq {
private String content;
/**
* 类型取值于字典 announcement_type
* 类型取值于字典 notice_type
*/
@Schema(description = "类型(取值于字典 announcement_type", example = "1")
@Schema(description = "类型(取值于字典 notice_type", example = "1")
@NotBlank(message = "类型不能为空")
@Length(max = 30, message = "类型长度不能超过 {max} 个字符")
private String type;

View File

@ -30,7 +30,7 @@ import java.io.Serializable;
*/
@Data
@Schema(description = "仪表盘-公告信息")
public class DashboardAnnouncementResp implements Serializable {
public class DashboardNoticeResp implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@ -48,8 +48,8 @@ public class DashboardAnnouncementResp implements Serializable {
private String title;
/**
* 类型取值于字典 announcement_type
* 类型取值于字典 notice_type
*/
@Schema(description = "类型(取值于字典 announcement_type", example = "1")
@Schema(description = "类型(取值于字典 notice_type", example = "1")
private String type;
}

View File

@ -44,7 +44,7 @@ public class DictResp extends BaseDetailResp {
/**
* 编码
*/
@Schema(description = "编码", example = "announcement_type")
@Schema(description = "编码", example = "notice_type")
private String code;
/**

View File

@ -34,7 +34,7 @@ import java.time.LocalDateTime;
@Data
@ExcelIgnoreUnannotated
@Schema(description = "公告详情信息")
public class AnnouncementDetailResp extends BaseDetailResp {
public class NoticeDetailResp extends BaseDetailResp {
@Serial
private static final long serialVersionUID = 1L;
@ -54,9 +54,9 @@ public class AnnouncementDetailResp extends BaseDetailResp {
private String content;
/**
* 类型取值于字典 announcement_type
* 类型取值于字典 notice_type
*/
@Schema(description = "类型(取值于字典 announcement_type", example = "1")
@Schema(description = "类型(取值于字典 notice_type", example = "1")
@ExcelProperty(value = "类型")
private String type;

View File

@ -18,7 +18,7 @@ package top.continew.admin.system.model.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.system.enums.AnnouncementStatusEnum;
import top.continew.admin.system.enums.NoticeStatusEnum;
import top.continew.starter.extension.crud.model.resp.BaseResp;
import java.io.Serial;
@ -32,7 +32,7 @@ import java.time.LocalDateTime;
*/
@Data
@Schema(description = "公告信息")
public class AnnouncementResp extends BaseResp {
public class NoticeResp extends BaseResp {
@Serial
private static final long serialVersionUID = 1L;
@ -44,9 +44,9 @@ public class AnnouncementResp extends BaseResp {
private String title;
/**
* 类型取值于字典 announcement_type
* 类型取值于字典 notice_type
*/
@Schema(description = "类型(取值于字典 announcement_type", example = "1")
@Schema(description = "类型(取值于字典 notice_type", example = "1")
private String type;
/**
@ -67,13 +67,13 @@ public class AnnouncementResp extends BaseResp {
* @return 公告状态
*/
@Schema(description = "状态1待发布2已发布3已过期", type = "Integer", allowableValues = {"1", "2", "3"}, example = "1")
public AnnouncementStatusEnum getStatus() {
public NoticeStatusEnum getStatus() {
if (null != this.effectiveTime && this.effectiveTime.isAfter(LocalDateTime.now())) {
return AnnouncementStatusEnum.PENDING_RELEASE;
return NoticeStatusEnum.PENDING_RELEASE;
}
if (null != this.terminateTime && this.terminateTime.isBefore(LocalDateTime.now())) {
return AnnouncementStatusEnum.EXPIRED;
return NoticeStatusEnum.EXPIRED;
}
return AnnouncementStatusEnum.PUBLISHED;
return NoticeStatusEnum.PUBLISHED;
}
}

View File

@ -62,5 +62,5 @@ public interface DashboardService {
*
* @return 公告列表
*/
List<DashboardAnnouncementResp> listAnnouncement();
List<DashboardNoticeResp> listNotice();
}

View File

@ -16,12 +16,12 @@
package top.continew.admin.system.service;
import top.continew.admin.system.model.entity.AnnouncementDO;
import top.continew.admin.system.model.query.AnnouncementQuery;
import top.continew.admin.system.model.req.AnnouncementReq;
import top.continew.admin.system.model.resp.AnnouncementDetailResp;
import top.continew.admin.system.model.resp.AnnouncementResp;
import top.continew.admin.system.model.resp.DashboardAnnouncementResp;
import top.continew.admin.system.model.entity.NoticeDO;
import top.continew.admin.system.model.query.NoticeQuery;
import top.continew.admin.system.model.req.NoticeReq;
import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.NoticeResp;
import top.continew.admin.system.model.resp.DashboardNoticeResp;
import top.continew.starter.extension.crud.service.BaseService;
import top.continew.starter.data.mybatis.plus.service.IService;
@ -33,12 +33,12 @@ import java.util.List;
* @author Charles7c
* @since 2023/8/20 10:55
*/
public interface AnnouncementService extends BaseService<AnnouncementResp, AnnouncementDetailResp, AnnouncementQuery, AnnouncementReq>, IService<AnnouncementDO> {
public interface NoticeService extends BaseService<NoticeResp, NoticeDetailResp, NoticeQuery, NoticeReq>, IService<NoticeDO> {
/**
* 查询仪表盘公告列表
*
* @return 仪表盘公告列表
*/
List<DashboardAnnouncementResp> listDashboard();
List<DashboardNoticeResp> listDashboard();
}

View File

@ -20,7 +20,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.continew.admin.system.service.AnnouncementService;
import top.continew.admin.system.service.NoticeService;
import top.continew.admin.system.service.DashboardService;
import top.continew.admin.system.service.LogService;
import top.continew.admin.system.model.resp.*;
@ -40,7 +40,7 @@ import java.util.Map;
public class DashboardServiceImpl implements DashboardService {
private final LogService logService;
private final AnnouncementService announcementService;
private final NoticeService noticeService;
@Override
public DashboardTotalResp getTotal() {
@ -85,7 +85,7 @@ public class DashboardServiceImpl implements DashboardService {
}
@Override
public List<DashboardAnnouncementResp> listAnnouncement() {
return announcementService.listDashboard();
public List<DashboardNoticeResp> listNotice() {
return noticeService.listDashboard();
}
}

View File

@ -16,22 +16,20 @@
package top.continew.admin.system.service.impl;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.continew.admin.system.mapper.AnnouncementMapper;
import top.continew.admin.system.model.entity.AnnouncementDO;
import top.continew.admin.system.model.query.AnnouncementQuery;
import top.continew.admin.system.model.req.AnnouncementReq;
import top.continew.admin.system.model.resp.AnnouncementDetailResp;
import top.continew.admin.system.model.resp.AnnouncementResp;
import top.continew.admin.system.model.resp.DashboardAnnouncementResp;
import top.continew.admin.system.service.AnnouncementService;
import top.continew.admin.system.mapper.NoticeMapper;
import top.continew.admin.system.model.entity.NoticeDO;
import top.continew.admin.system.model.query.NoticeQuery;
import top.continew.admin.system.model.req.NoticeReq;
import top.continew.admin.system.model.resp.DashboardNoticeResp;
import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.NoticeResp;
import top.continew.admin.system.service.NoticeService;
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
import java.util.List;
/**
* 公告业务实现
*
@ -40,10 +38,10 @@ import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
*/
@Service
@RequiredArgsConstructor
public class AnnouncementServiceImpl extends BaseServiceImpl<AnnouncementMapper, AnnouncementDO, AnnouncementResp, AnnouncementDetailResp, AnnouncementQuery, AnnouncementReq> implements AnnouncementService {
public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, NoticeDO, NoticeResp, NoticeDetailResp, NoticeQuery, NoticeReq> implements NoticeService {
@Override
public List<DashboardAnnouncementResp> listDashboard() {
public List<DashboardNoticeResp> listDashboard() {
return baseMapper.selectDashboardList();
}
}

View File

@ -1,12 +1,12 @@
<?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="top.continew.admin.system.mapper.AnnouncementMapper">
<mapper namespace="top.continew.admin.system.mapper.NoticeMapper">
<select id="selectDashboardList"
resultType="top.continew.admin.system.model.resp.DashboardAnnouncementResp">
resultType="top.continew.admin.system.model.resp.DashboardNoticeResp">
SELECT
id, title, type
FROM sys_announcement
FROM sys_notice
WHERE (effective_time IS NULL OR NOW() > effective_time)
AND (terminate_time IS NULL OR terminate_time > NOW())
ORDER BY sort ASC, effective_time DESC

View File

@ -102,7 +102,7 @@ public class CommonController {
}
@Operation(summary = "查询字典", description = "查询字典列表")
@Parameter(name = "code", description = "字典编码", example = "announcement_type", in = ParameterIn.PATH)
@Parameter(name = "code", description = "字典编码", example = "notice_type", in = ParameterIn.PATH)
@GetMapping("/dict/{code}")
public R<List<LabelValueResp<Serializable>>> listDict(@PathVariable String code) {
Optional<Class<?>> enumClassOptional = this.getEnumClassByName(code);

View File

@ -36,7 +36,7 @@ import top.continew.admin.system.model.resp.DashboardGeoDistributionResp;
import top.continew.admin.system.model.resp.DashboardPopularModuleResp;
import top.continew.admin.system.model.resp.DashboardTotalResp;
import top.continew.admin.system.service.DashboardService;
import top.continew.admin.system.model.resp.DashboardAnnouncementResp;
import top.continew.admin.system.model.resp.DashboardNoticeResp;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.web.model.R;
import top.continew.starter.log.core.annotation.Log;
@ -89,8 +89,8 @@ public class DashboardController {
}
@Operation(summary = "查询公告列表", description = "查询公告列表")
@GetMapping("/announcement")
public R<List<DashboardAnnouncementResp>> listAnnouncement() {
return R.ok(dashboardService.listAnnouncement());
@GetMapping("/notice")
public R<List<DashboardNoticeResp>> listNotice() {
return R.ok(dashboardService.listNotice());
}
}

View File

@ -16,26 +16,26 @@
package top.continew.admin.webapi.system;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import top.continew.admin.system.model.query.AnnouncementQuery;
import top.continew.admin.system.model.req.AnnouncementReq;
import top.continew.admin.system.model.resp.AnnouncementDetailResp;
import top.continew.admin.system.model.resp.AnnouncementResp;
import top.continew.admin.system.service.AnnouncementService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import top.continew.admin.system.model.query.NoticeQuery;
import top.continew.admin.system.model.req.NoticeReq;
import top.continew.admin.system.model.resp.NoticeDetailResp;
import top.continew.admin.system.model.resp.NoticeResp;
import top.continew.admin.system.service.NoticeService;
import top.continew.starter.core.util.validate.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.controller.BaseController;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.crud.util.ValidateGroup;
import top.continew.starter.web.model.R;
import java.time.LocalDateTime;
/**
* 公告管理 API
*
@ -44,19 +44,19 @@ import top.continew.starter.web.model.R;
*/
@Tag(name = "公告管理 API")
@RestController
@CrudRequestMapping("/system/announcement")
public class AnnouncementController extends BaseController<AnnouncementService, AnnouncementResp, AnnouncementDetailResp, AnnouncementQuery, AnnouncementReq> {
@CrudRequestMapping(value = "/system/notice", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE})
public class NoticeController extends BaseController<NoticeService, NoticeResp, NoticeDetailResp, NoticeQuery, NoticeReq> {
@Override
@SaCheckPermission("system:announcement:add")
public R<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody AnnouncementReq req) {
@SaCheckPermission("system:notice:add")
public R<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody NoticeReq req) {
this.checkTime(req);
return super.add(req);
}
@Override
@SaCheckPermission("system:announcement:update")
public R<Void> update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody AnnouncementReq req,
@SaCheckPermission("system:notice:update")
public R<Void> update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody NoticeReq req,
@PathVariable Long id) {
this.checkTime(req);
return super.update(req, id);
@ -67,7 +67,7 @@ public class AnnouncementController extends BaseController<AnnouncementService,
*
* @param req 创建或修改信息
*/
private void checkTime(AnnouncementReq req) {
private void checkTime(NoticeReq req) {
LocalDateTime effectiveTime = req.getEffectiveTime();
LocalDateTime terminateTime = req.getTerminateTime();
if (null != effectiveTime && null != terminateTime) {

View File

@ -120,7 +120,7 @@ VALUES
INSERT INTO `sys_dict`
(`id`, `name`, `code`, `description`, `is_system`, `create_user`, `create_time`, `update_user`, `update_time`)
VALUES
(547889614262632491, '公告类型', 'announcement_type', NULL, b'1', 1, NOW(), NULL, NULL);
(547889614262632491, '公告类型', 'notice_type', NULL, b'1', 1, NOW(), NULL, NULL);
INSERT INTO `sys_dict_item`
(`id`, `label`, `value`, `color`, `sort`, `description`, `status`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`)

View File

@ -215,7 +215,7 @@ CREATE TABLE IF NOT EXISTS `sys_message_user` (
PRIMARY KEY (`message_id`, `user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息和用户关联表';
CREATE TABLE IF NOT EXISTS `sys_announcement` (
CREATE TABLE IF NOT EXISTS `sys_notice` (
`id` bigint(20) NOT NULL COMMENT 'ID',
`title` varchar(150) NOT NULL COMMENT '标题',
`content` mediumtext NOT NULL COMMENT '内容',

View File

@ -120,7 +120,7 @@ VALUES
INSERT INTO "sys_dict"
("id", "name", "code", "description", "is_system", "create_user", "create_time", "update_user", "update_time")
VALUES
(547889614262632491, '公告类型', 'announcement_type', NULL, true, 1, NOW(), NULL, NULL);
(547889614262632491, '公告类型', 'notice_type', NULL, true, 1, NOW(), NULL, NULL);
INSERT INTO "sys_dict_item"
("id", "label", "value", "color", "sort", "description", "status", "dict_id", "create_user", "create_time", "update_user", "update_time")

View File

@ -360,7 +360,7 @@ COMMENT ON COLUMN "sys_message_user"."is_read" IS '是否已读';
COMMENT ON COLUMN "sys_message_user"."read_time" IS '读取时间';
COMMENT ON TABLE "sys_message_user" IS '消息和用户关联表';
CREATE TABLE IF NOT EXISTS "sys_announcement" (
CREATE TABLE IF NOT EXISTS "sys_notice" (
"id" int8 NOT NULL,
"title" varchar(150) NOT NULL,
"content" text NOT NULL,
@ -374,20 +374,20 @@ CREATE TABLE IF NOT EXISTS "sys_announcement" (
"update_time" timestamp DEFAULT NULL,
PRIMARY KEY ("id")
);
CREATE INDEX "idx_announcement_create_user" ON "sys_announcement" ("create_user");
CREATE INDEX "idx_announcement_update_user" ON "sys_announcement" ("update_user");
COMMENT ON COLUMN "sys_announcement"."id" IS 'ID';
COMMENT ON COLUMN "sys_announcement"."title" IS '标题';
COMMENT ON COLUMN "sys_announcement"."content" IS '内容';
COMMENT ON COLUMN "sys_announcement"."type" IS '类型';
COMMENT ON COLUMN "sys_announcement"."effective_time" IS '生效时间';
COMMENT ON COLUMN "sys_announcement"."terminate_time" IS '终止时间';
COMMENT ON COLUMN "sys_announcement"."sort" IS '排序';
COMMENT ON COLUMN "sys_announcement"."create_user" IS '创建人';
COMMENT ON COLUMN "sys_announcement"."create_time" IS '创建时间';
COMMENT ON COLUMN "sys_announcement"."update_user" IS '修改人';
COMMENT ON COLUMN "sys_announcement"."update_time" IS '修改时间';
COMMENT ON TABLE "sys_announcement" IS '公告表';
CREATE INDEX "idx_notice_create_user" ON "sys_notice" ("create_user");
CREATE INDEX "idx_notice_update_user" ON "sys_notice" ("update_user");
COMMENT ON COLUMN "sys_notice"."id" IS 'ID';
COMMENT ON COLUMN "sys_notice"."title" IS '标题';
COMMENT ON COLUMN "sys_notice"."content" IS '内容';
COMMENT ON COLUMN "sys_notice"."type" IS '类型';
COMMENT ON COLUMN "sys_notice"."effective_time" IS '生效时间';
COMMENT ON COLUMN "sys_notice"."terminate_time" IS '终止时间';
COMMENT ON COLUMN "sys_notice"."sort" IS '排序';
COMMENT ON COLUMN "sys_notice"."create_user" IS '创建人';
COMMENT ON COLUMN "sys_notice"."create_time" IS '创建时间';
COMMENT ON COLUMN "sys_notice"."update_user" IS '修改人';
COMMENT ON COLUMN "sys_notice"."update_time" IS '修改时间';
COMMENT ON TABLE "sys_notice" IS '公告表';
CREATE TABLE IF NOT EXISTS "sys_storage" (
"id" int8 NOT NULL,