feat: 新增 Excel 字典数据转换器

This commit is contained in:
2025-04-09 22:33:45 +08:00
parent aed27533a6
commit 449478b188
6 changed files with 209 additions and 18 deletions

View File

@@ -16,10 +16,16 @@
package top.continew.admin.system.model.resp;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.model.resp.BaseDetailResp;
import top.continew.admin.common.config.excel.DictExcelProperty;
import top.continew.admin.common.config.excel.ExcelDictConverter;
import top.continew.admin.common.enums.DisEnableStatusEnum;
import top.continew.admin.common.model.resp.BaseDetailResp;
import top.continew.starter.file.excel.converter.ExcelBaseEnumConverter;
import top.continew.starter.file.excel.converter.ExcelListConverter;
import java.io.Serial;
import java.util.List;
@@ -32,6 +38,7 @@ import java.util.List;
* @since 2024/12/03 16:04
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "终端信息")
public class ClientResp extends BaseDetailResp {
@@ -42,12 +49,14 @@ public class ClientResp extends BaseDetailResp {
* 终端 ID
*/
@Schema(description = "终端 ID", example = "ef51c9a3e9046c4f2ea45142c8a8344a")
@ExcelProperty(value = "终端 ID", order = 2)
private String clientId;
/**
* 终端 Key
*/
@Schema(description = "终端 Key", example = "PC")
@ExcelProperty(value = "终端 Key", order = 3)
private String clientKey;
/**
@@ -60,29 +69,35 @@ public class ClientResp extends BaseDetailResp {
* 认证类型
*/
@Schema(description = "认证类型", example = "ACCOUNT")
@ExcelProperty(value = "认证类型", converter = ExcelListConverter.class, order = 4)
private List<String> authType;
/**
* 终端类型
* 终端类型(取值于字典 client_type
*/
@Schema(description = "终端类型", example = "PC")
@Schema(description = "终端类型(取值于字典 client_type", example = "PC")
@ExcelProperty(value = "终端类型", converter = ExcelDictConverter.class, order = 5)
@DictExcelProperty("client_type")
private String clientType;
/**
* Token 最低活跃频率(单位:秒,-1不限制永不冻结
*/
@Schema(description = "Token 最低活跃频率(单位:秒,-1不限制永不冻结", example = "1800")
@ExcelProperty(value = "Token 最低活跃频率", order = 6)
private Long activeTimeout;
/**
* Token 有效期(单位:秒,-1永不过期
*/
@Schema(description = "Token 有效期(单位:秒,-1永不过期", example = "86400")
@ExcelProperty(value = "Token 有效期", order = 7)
private Long timeout;
/**
* 状态
*/
@Schema(description = "状态", example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class, order = 8)
private DisEnableStatusEnum status;
}

View File

@@ -20,8 +20,12 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.continew.admin.common.config.excel.DictExcelProperty;
import top.continew.admin.common.config.excel.ExcelDictConverter;
import top.continew.admin.common.model.resp.BaseDetailResp;
import top.continew.admin.system.enums.NoticeScopeEnum;
import top.continew.admin.system.enums.NoticeStatusEnum;
import top.continew.starter.file.excel.converter.ExcelBaseEnumConverter;
import java.io.Serial;
import java.time.LocalDateTime;
@@ -45,35 +49,42 @@ public class NoticeDetailResp extends BaseDetailResp {
* 标题
*/
@Schema(description = "标题", example = "这是公告标题")
@ExcelProperty(value = "标题")
@ExcelProperty(value = "标题", order = 2)
private String title;
/**
* 内容
*/
@Schema(description = "内容", example = "这是公告内容")
@ExcelProperty(value = "内容")
private String content;
/**
* 类型(取值于字典 notice_type
*/
@Schema(description = "类型(取值于字典 notice_type", example = "1")
@ExcelProperty(value = "类型")
@ExcelProperty(value = "类型", converter = ExcelDictConverter.class, order = 3)
@DictExcelProperty("notice_type")
private String type;
/**
* 状态
*/
@Schema(description = "状态", example = "1")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class, order = 4)
private NoticeStatusEnum status;
/**
* 生效时间
*/
@Schema(description = "生效时间", example = "2023-08-08 00:00:00", type = "string")
@ExcelProperty(value = "生效时间")
@ExcelProperty(value = "生效时间", order = 5)
private LocalDateTime effectiveTime;
/**
* 终止时间
*/
@Schema(description = "终止时间", example = "2023-08-08 23:59:59", type = "string")
@ExcelProperty(value = "终止时间")
@ExcelProperty(value = "终止时间", order = 6)
private LocalDateTime terminateTime;
/**
@@ -87,4 +98,8 @@ public class NoticeDetailResp extends BaseDetailResp {
*/
@Schema(description = "指定用户", example = "[1,2,3]")
private List<String> noticeUsers;
public NoticeStatusEnum getStatus() {
return NoticeStatusEnum.getStatus(effectiveTime, terminateTime);
}
}

View File

@@ -16,12 +16,12 @@
package top.continew.admin.system.service;
import top.continew.admin.common.service.CommonDictItemService;
import top.continew.admin.system.model.entity.DictItemDO;
import top.continew.admin.system.model.query.DictItemQuery;
import top.continew.admin.system.model.req.DictItemReq;
import top.continew.admin.system.model.resp.DictItemResp;
import top.continew.starter.data.mp.service.IService;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.service.BaseService;
import java.util.List;
@@ -32,15 +32,7 @@ import java.util.List;
* @author Charles7c
* @since 2023/9/11 21:29
*/
public interface DictItemService extends BaseService<DictItemResp, DictItemResp, DictItemQuery, DictItemReq>, IService<DictItemDO> {
/**
* 根据字典编码查询
*
* @param dictCode 字典编码
* @return 字典项列表
*/
List<LabelValueResp> listByDictCode(String dictCode);
public interface DictItemService extends BaseService<DictItemResp, DictItemResp, DictItemQuery, DictItemReq>, IService<DictItemDO>, CommonDictItemService {
/**
* 根据字典 ID 列表删除