feat: 新增系统管理/公告管理(列表、查看详情、新增、修改、删除、导出)

This commit is contained in:
2023-08-23 00:00:41 +08:00
parent 46a75d0297
commit 46e125d8c9
22 changed files with 2225 additions and 151 deletions

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.charles7c.cnadmin.common.base.BaseEnum;
/**
* 公告类型枚举(计划 v1.2.0 增加字典管理,用于维护此类信息)
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Getter
@RequiredArgsConstructor
public enum AnnouncementTypeEnum implements BaseEnum<Integer, String> {
/** 活动 */
ACTIVITY(1, "活动"),
/** 消息 */
MESSAGE(2, "消息"),
/** 通知 */
NOTICE(3, "通知"),;
private final Integer value;
private final String description;
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.mapper;
import top.charles7c.cnadmin.common.base.BaseMapper;
import top.charles7c.cnadmin.system.model.entity.AnnouncementDO;
/**
* 公告 Mapper
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
public interface AnnouncementMapper extends BaseMapper<AnnouncementDO> {}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.model.entity;
import java.time.LocalDateTime;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import top.charles7c.cnadmin.common.base.BaseDO;
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
/**
* 公告实体
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Data
@TableName("sys_announcement")
public class AnnouncementDO extends BaseDO {
private static final long serialVersionUID = 1L;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
/**
* 类型
*/
private AnnouncementTypeEnum type;
/**
* 生效时间
*/
private LocalDateTime effectiveTime;
/**
* 终止时间
*/
private LocalDateTime terminateTime;
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.model.query;
import java.io.Serializable;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.charles7c.cnadmin.common.annotation.Query;
import top.charles7c.cnadmin.common.enums.QueryTypeEnum;
/**
* 公告查询条件
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Data
@Schema(description = "公告查询条件")
public class AnnouncementQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 标题
*/
@Schema(description = "标题")
@Query(type = QueryTypeEnum.INNER_LIKE)
private String title;
/**
* 类型1活动2消息3通知
*/
@Schema(description = "类型1活动2消息3通知")
@Query(type = QueryTypeEnum.EQUAL)
private Integer type;
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.model.request;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import org.hibernate.validator.constraints.Length;
import top.charles7c.cnadmin.common.base.BaseRequest;
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
/**
* 创建或修改公告信息
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Data
@Schema(description = "创建或修改公告信息")
public class AnnouncementRequest extends BaseRequest {
private static final long serialVersionUID = 1L;
/**
* 标题
*/
@Schema(description = "标题")
@NotBlank(message = "标题不能为空")
@Length(max = 255, message = "标题长度不能超过 {max} 个字符")
private String title;
/**
* 内容
*/
@Schema(description = "内容")
@NotBlank(message = "内容不能为空")
private String content;
/**
* 类型
*/
@Schema(description = "类型")
@NotNull(message = "类型非法")
private AnnouncementTypeEnum type;
/**
* 生效时间
*/
@Schema(description = "生效时间")
private LocalDateTime effectiveTime;
/**
* 终止时间
*/
@Schema(description = "终止时间")
@Future(message = "终止时间必须是未来时间")
private LocalDateTime terminateTime;
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.model.vo;
import java.time.LocalDateTime;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import top.charles7c.cnadmin.common.base.BaseDetailVO;
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
/**
* 公告详情信息
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "公告详情信息")
public class AnnouncementDetailVO extends BaseDetailVO {
private static final long serialVersionUID = 1L;
/**
* 标题
*/
@Schema(description = "标题")
@ExcelProperty(value = "标题")
private String title;
/**
* 内容
*/
@Schema(description = "内容")
@ExcelProperty(value = "内容")
private String content;
/**
* 类型
*/
@Schema(description = "类型")
private AnnouncementTypeEnum type;
/**
* 生效时间
*/
@Schema(description = "生效时间")
@ExcelProperty(value = "生效时间")
private LocalDateTime effectiveTime;
/**
* 终止时间
*/
@Schema(description = "终止时间")
@ExcelProperty(value = "终止时间")
private LocalDateTime terminateTime;
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.model.vo;
import java.time.LocalDateTime;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import top.charles7c.cnadmin.common.base.BaseVO;
import top.charles7c.cnadmin.system.enums.AnnouncementTypeEnum;
/**
* 公告信息
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Data
@Schema(description = "公告信息")
public class AnnouncementVO extends BaseVO {
private static final long serialVersionUID = 1L;
/**
* 标题
*/
@Schema(description = "标题")
private String title;
/**
* 类型
*/
@Schema(description = "类型")
private AnnouncementTypeEnum type;
/**
* 生效时间
*/
@Schema(description = "生效时间")
private LocalDateTime effectiveTime;
/**
* 终止时间
*/
@Schema(description = "终止时间")
private LocalDateTime terminateTime;
public Integer getStatus() {
int status = 1;
if (null != this.effectiveTime) {
if (this.effectiveTime.isAfter(LocalDateTime.now())) {
status = 2;
}
}
if (null != this.terminateTime) {
if (this.terminateTime.isBefore(LocalDateTime.now())) {
status = 2;
}
}
return status;
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.service;
import top.charles7c.cnadmin.common.base.BaseService;
import top.charles7c.cnadmin.system.model.query.AnnouncementQuery;
import top.charles7c.cnadmin.system.model.request.AnnouncementRequest;
import top.charles7c.cnadmin.system.model.vo.AnnouncementDetailVO;
import top.charles7c.cnadmin.system.model.vo.AnnouncementVO;
/**
* 公告业务接口
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
public interface AnnouncementService
extends BaseService<AnnouncementVO, AnnouncementDetailVO, AnnouncementQuery, AnnouncementRequest> {}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package top.charles7c.cnadmin.system.service.impl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.charles7c.cnadmin.common.base.BaseServiceImpl;
import top.charles7c.cnadmin.system.mapper.AnnouncementMapper;
import top.charles7c.cnadmin.system.model.entity.AnnouncementDO;
import top.charles7c.cnadmin.system.model.query.AnnouncementQuery;
import top.charles7c.cnadmin.system.model.request.AnnouncementRequest;
import top.charles7c.cnadmin.system.model.vo.AnnouncementDetailVO;
import top.charles7c.cnadmin.system.model.vo.AnnouncementVO;
import top.charles7c.cnadmin.system.service.AnnouncementService;
/**
* 公告业务实现
*
* @author Charles7c
* @since 2023/8/20 10:55
*/
@Service
@RequiredArgsConstructor
public class AnnouncementServiceImpl extends BaseServiceImpl<AnnouncementMapper, AnnouncementDO, AnnouncementVO,
AnnouncementDetailVO, AnnouncementQuery, AnnouncementRequest> implements AnnouncementService {}