Skip to content

Commit

Permalink
refactor: 公告管理 Announcement => Notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Apr 27, 2024
1 parent abf1e65 commit dbe93df
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
@Getter
@RequiredArgsConstructor
public enum AnnouncementStatusEnum implements IBaseEnum<Integer> {
public enum NoticeStatusEnum implements IBaseEnum<Integer> {

/**
* 待发布
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,12 +28,12 @@
* @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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* @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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
@Data
@Schema(description = "公告查询条件")
public class AnnouncementQuery implements Serializable {
public class NoticeQuery implements Serializable {

@Serial
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
@Data
@Schema(description = "创建或修改公告信息")
public class AnnouncementReq extends BaseReq {
public class NoticeReq extends BaseReq {

@Serial
private static final long serialVersionUID = 1L;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
@Data
@Schema(description = "仪表盘-公告信息")
public class DashboardAnnouncementResp implements Serializable {
public class DashboardNoticeResp implements Serializable {

@Serial
private static final long serialVersionUID = 1L;
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class DictResp extends BaseDetailResp {
/**
* 编码
*/
@Schema(description = "编码", example = "announcement_type")
@Schema(description = "编码", example = "notice_type")
private String code;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Data
@ExcelIgnoreUnannotated
@Schema(description = "公告详情信息")
public class AnnouncementDetailResp extends BaseDetailResp {
public class NoticeDetailResp extends BaseDetailResp {

@Serial
private static final long serialVersionUID = 1L;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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;
Expand All @@ -32,7 +32,7 @@
*/
@Data
@Schema(description = "公告信息")
public class AnnouncementResp extends BaseResp {
public class NoticeResp extends BaseResp {

@Serial
private static final long serialVersionUID = 1L;
Expand All @@ -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;

/**
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ public interface DashboardService {
*
* @return 公告列表
*/
List<DashboardAnnouncementResp> listAnnouncement();
List<DashboardNoticeResp> listNotice();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -33,12 +33,12 @@
* @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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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.*;
Expand All @@ -40,7 +40,7 @@
public class DashboardServiceImpl implements DashboardService {

private final LogService logService;
private final AnnouncementService announcementService;
private final NoticeService noticeService;

@Override
public DashboardTotalResp getTotal() {
Expand Down Expand Up @@ -85,7 +85,7 @@ public DashboardGeoDistributionResp getGeoDistribution() {
}

@Override
public List<DashboardAnnouncementResp> listAnnouncement() {
return announcementService.listDashboard();
public List<DashboardNoticeResp> listNotice() {
return noticeService.listDashboard();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* 公告业务实现
*
Expand All @@ -40,10 +38,10 @@
*/
@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();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http:https://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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public R<List<LabelValueResp<Long>>> listRoleDict(RoleQuery query, SortQuery sor
}

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
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;
Expand Down Expand Up @@ -89,8 +89,8 @@ public R<DashboardGeoDistributionResp> getGeoDistribution() {
}

@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());
}
}
Loading

0 comments on commit dbe93df

Please sign in to comment.