mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	refactor: 优化字典管理相关 API
1.合并 DictResp 及 DictDetailResp 2.合并 DictItemResp 及 DictItemDetailResp 3.字典项增加状态 status 字段
This commit is contained in:
		| @@ -56,11 +56,6 @@ public class CacheConstants { | ||||
|      */ | ||||
|     public static final String MENU_KEY_PREFIX = "MENU" + DELIMITER; | ||||
|  | ||||
|     /** | ||||
|      * 字典缓存键前缀 | ||||
|      */ | ||||
|     public static final String DICT_KEY_PREFIX = "DICT" + DELIMITER; | ||||
|  | ||||
|     /** | ||||
|      * 参数缓存键前缀 | ||||
|      */ | ||||
|   | ||||
| @@ -16,14 +16,13 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.entity; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
|  | ||||
| import lombok.Data; | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.starter.extension.crud.model.entity.BaseDO; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 字典项实体 | ||||
|  * | ||||
| @@ -62,6 +61,11 @@ public class DictItemDO extends BaseDO { | ||||
|      */ | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 字典ID | ||||
|      */ | ||||
|   | ||||
| @@ -18,6 +18,8 @@ package top.charles7c.continew.admin.system.model.query; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import top.charles7c.continew.starter.data.core.annotation.Query; | ||||
| import top.charles7c.continew.starter.data.core.enums.QueryType; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
| @@ -35,6 +37,19 @@ public class DictItemQuery implements Serializable { | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 关键词 | ||||
|      */ | ||||
|     @Schema(description = "关键词") | ||||
|     @Query(columns = {"label", "description"}, type = QueryType.LIKE) | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", example = "1") | ||||
|     private Integer status; | ||||
|  | ||||
|     /** | ||||
|      * 字典 ID | ||||
|      */ | ||||
|   | ||||
| @@ -38,10 +38,9 @@ public class DictQuery implements Serializable { | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 名称 | ||||
|      * 关键词 | ||||
|      */ | ||||
|     @Schema(description = "名称") | ||||
|     @Schema(description = "关键词") | ||||
|     @Query(columns = {"name", "code", "description"}, type = QueryType.LIKE) | ||||
|     private String name; | ||||
|  | ||||
|     private String description; | ||||
| } | ||||
| @@ -16,18 +16,17 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.req; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import jakarta.validation.constraints.*; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import jakarta.validation.constraints.Min; | ||||
| import jakarta.validation.constraints.NotBlank; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import lombok.Data; | ||||
| import org.hibernate.validator.constraints.Length; | ||||
|  | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.starter.extension.crud.model.req.BaseReq; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 创建或修改字典项信息 | ||||
|  * | ||||
| @@ -78,6 +77,12 @@ public class DictItemReq extends BaseReq { | ||||
|     @Length(max = 200, message = "描述长度不能超过 {max} 个字符") | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 所属字典 | ||||
|      */ | ||||
|   | ||||
| @@ -1,63 +0,0 @@ | ||||
| /* | ||||
|  * 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.continew.admin.system.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp; | ||||
|  | ||||
| /** | ||||
|  * 字典详情信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/11 21:29 | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "字典详情信息") | ||||
| public class DictDetailResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 名称 | ||||
|      */ | ||||
|     @Schema(description = "名称", example = "公告类型") | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * 编码 | ||||
|      */ | ||||
|     @Schema(description = "编码", example = "announcement_type") | ||||
|     private String code; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述", example = "公告类型描述信息") | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 是否为系统内置数据 | ||||
|      */ | ||||
|     @Schema(description = "是否为系统内置数据", example = "true") | ||||
|     private Boolean isSystem; | ||||
| } | ||||
| @@ -1,98 +0,0 @@ | ||||
| /* | ||||
|  * 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.continew.admin.system.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| 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.continew.starter.extension.crud.model.resp.BaseDetailResp; | ||||
|  | ||||
| /** | ||||
|  * 字典项详情信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/11 21:29 | ||||
|  */ | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| @Schema(description = "字典项详情信息") | ||||
| public class DictItemDetailResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 标签 | ||||
|      */ | ||||
|     @Schema(description = "标签", example = "通知") | ||||
|     @ExcelProperty(value = "标签", order = 2) | ||||
|     private String label; | ||||
|  | ||||
|     /** | ||||
|      * 值 | ||||
|      */ | ||||
|     @Schema(description = "值", example = "1") | ||||
|     @ExcelProperty(value = "值", order = 3) | ||||
|     private String value; | ||||
|  | ||||
|     /** | ||||
|      * 标签颜色 | ||||
|      */ | ||||
|     @Schema(description = "标签颜色", example = "blue") | ||||
|     @ExcelProperty(value = "标签颜色", order = 4) | ||||
|     private String color; | ||||
|  | ||||
|     /** | ||||
|      * 排序 | ||||
|      */ | ||||
|     @Schema(description = "排序", example = "1") | ||||
|     @ExcelProperty(value = "排序", order = 5) | ||||
|     private Integer sort; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述", example = "通知描述信息") | ||||
|     @ExcelProperty(value = "描述", order = 6) | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 字典 ID | ||||
|      */ | ||||
|     @Schema(description = "字典 ID", example = "1") | ||||
|     private Long dictId; | ||||
|  | ||||
|     /** | ||||
|      * 字典名称 | ||||
|      */ | ||||
|     @Schema(hidden = true) | ||||
|     @ExcelProperty(value = "字典名称", order = 7) | ||||
|     private String dictName; | ||||
|  | ||||
|     /** | ||||
|      * 字典编码 | ||||
|      */ | ||||
|     @Schema(hidden = true) | ||||
|     @ExcelProperty(value = "字典编码", order = 8) | ||||
|     private String dictCode; | ||||
| } | ||||
| @@ -16,13 +16,14 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter; | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp; | ||||
|  | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp; | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 字典项信息 | ||||
| @@ -32,7 +33,7 @@ import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp; | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "字典项信息") | ||||
| public class DictItemResp extends BaseResp { | ||||
| public class DictItemResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
| @@ -56,14 +57,27 @@ public class DictItemResp extends BaseResp { | ||||
|     private String color; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "描述", example = "通知描述信息") | ||||
|     private String description; | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") | ||||
|     @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class) | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 排序 | ||||
|      */ | ||||
|     @Schema(description = "排序", example = "1") | ||||
|     private Integer sort; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述", example = "通知描述信息") | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 字典 ID | ||||
|      */ | ||||
|     @Schema(description = "字典 ID", example = "1") | ||||
|     private Long dictId; | ||||
| } | ||||
| @@ -16,13 +16,11 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp; | ||||
|  | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp; | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 字典信息 | ||||
| @@ -32,7 +30,7 @@ import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp; | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "字典信息") | ||||
| public class DictResp extends BaseResp { | ||||
| public class DictResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|   | ||||
| @@ -20,10 +20,9 @@ import top.charles7c.continew.admin.common.model.resp.LabelValueResp; | ||||
| import top.charles7c.continew.admin.system.model.entity.DictItemDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DictItemQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictItemReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemResp; | ||||
| import top.charles7c.continew.starter.extension.crud.service.BaseService; | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.service.IService; | ||||
| import top.charles7c.continew.starter.extension.crud.service.BaseService; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.List; | ||||
| @@ -34,15 +33,7 @@ import java.util.List; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/11 21:29 | ||||
|  */ | ||||
| public interface DictItemService extends BaseService<DictItemResp, DictItemDetailResp, DictItemQuery, DictItemReq>, IService<DictItemDO> { | ||||
|  | ||||
|     /** | ||||
|      * 根据字典 ID 查询 | ||||
|      * | ||||
|      * @param dictId 字典 ID | ||||
|      * @return 字典项列表 | ||||
|      */ | ||||
|     List<DictItemDetailResp> listByDictId(Long dictId); | ||||
| public interface DictItemService extends BaseService<DictItemResp, DictItemResp, DictItemQuery, DictItemReq>, IService<DictItemDO> { | ||||
|  | ||||
|     /** | ||||
|      * 根据字典编码查询 | ||||
|   | ||||
| @@ -19,10 +19,9 @@ package top.charles7c.continew.admin.system.service; | ||||
| import top.charles7c.continew.admin.system.model.entity.DictDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DictQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictResp; | ||||
| import top.charles7c.continew.starter.extension.crud.service.BaseService; | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.service.IService; | ||||
| import top.charles7c.continew.starter.extension.crud.service.BaseService; | ||||
|  | ||||
| /** | ||||
|  * 字典业务接口 | ||||
| @@ -30,4 +29,4 @@ import top.charles7c.continew.starter.data.mybatis.plus.service.IService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/11 21:29 | ||||
|  */ | ||||
| public interface DictService extends BaseService<DictResp, DictDetailResp, DictQuery, DictReq>, IService<DictDO> {} | ||||
| public interface DictService extends BaseService<DictResp, DictResp, DictQuery, DictReq>, IService<DictDO> {} | ||||
| @@ -23,12 +23,10 @@ import top.charles7c.continew.admin.system.mapper.DictItemMapper; | ||||
| import top.charles7c.continew.admin.system.model.entity.DictItemDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DictItemQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictItemReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemResp; | ||||
| import top.charles7c.continew.admin.system.service.DictItemService; | ||||
| import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.service.impl.BaseServiceImpl; | ||||
| import top.charles7c.continew.starter.extension.crud.model.query.SortQuery; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.List; | ||||
| @@ -41,7 +39,7 @@ import java.util.List; | ||||
|  */ | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| public class DictItemServiceImpl extends BaseServiceImpl<DictItemMapper, DictItemDO, DictItemResp, DictItemDetailResp, DictItemQuery, DictItemReq> implements DictItemService { | ||||
| public class DictItemServiceImpl extends BaseServiceImpl<DictItemMapper, DictItemDO, DictItemResp, DictItemResp, DictItemQuery, DictItemReq> implements DictItemService { | ||||
|  | ||||
|     @Override | ||||
|     protected void beforeAdd(DictItemReq req) { | ||||
| @@ -55,17 +53,6 @@ public class DictItemServiceImpl extends BaseServiceImpl<DictItemMapper, DictIte | ||||
|         CheckUtils.throwIf(this.isValueExists(value, id, req.getDictId()), "修改失败,字典值 [{}] 已存在", value); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<DictItemDetailResp> listByDictId(Long dictId) { | ||||
|         DictItemQuery dictItemQuery = new DictItemQuery(); | ||||
|         dictItemQuery.setDictId(dictId); | ||||
|         SortQuery sortQuery = new SortQuery(); | ||||
|         sortQuery.setSort(new String[] {"sort,asc"}); | ||||
|         List<DictItemDetailResp> detailList = super.list(dictItemQuery, sortQuery, DictItemDetailResp.class); | ||||
|         detailList.forEach(super::fill); | ||||
|         return detailList; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<LabelValueResp<Serializable>> listByDictCode(String dictCode) { | ||||
|         return baseMapper.listByDictCode(dictCode); | ||||
|   | ||||
| @@ -16,24 +16,18 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.service.impl; | ||||
|  | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.springframework.stereotype.Service; | ||||
| import top.charles7c.continew.admin.system.mapper.DictMapper; | ||||
| import top.charles7c.continew.admin.system.model.entity.DictDO; | ||||
| import top.charles7c.continew.admin.system.model.query.DictQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictResp; | ||||
| import top.charles7c.continew.admin.system.service.DictItemService; | ||||
| import top.charles7c.continew.admin.system.service.DictService; | ||||
| import top.charles7c.continew.starter.core.util.validate.CheckUtils; | ||||
| import top.charles7c.continew.starter.extension.crud.service.impl.BaseServiceImpl; | ||||
| import top.charles7c.continew.starter.extension.crud.model.query.SortQuery; | ||||
| import top.charles7c.continew.starter.file.excel.util.ExcelUtils; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
|  | ||||
| @@ -45,7 +39,7 @@ import java.util.Optional; | ||||
|  */ | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictResp, DictDetailResp, DictQuery, DictReq> implements DictService { | ||||
| public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictResp, DictResp, DictQuery, DictReq> implements DictService { | ||||
|  | ||||
|     private final DictItemService dictItemService; | ||||
|  | ||||
| @@ -64,7 +58,7 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes | ||||
|         String code = req.getCode(); | ||||
|         CheckUtils.throwIf(this.isCodeExists(code, id), "修改失败,[{}] 已存在", code); | ||||
|         DictDO oldDict = super.getById(id); | ||||
|         if (oldDict.getIsSystem()) { | ||||
|         if (Boolean.TRUE.equals(oldDict.getIsSystem())) { | ||||
|             CheckUtils.throwIfNotEqual(req.getCode(), oldDict.getCode(), "[{}] 是系统内置字典,不允许修改字典编码", oldDict.getName()); | ||||
|         } | ||||
|     } | ||||
| @@ -81,21 +75,6 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes | ||||
|         dictItemService.deleteByDictIds(ids); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void export(DictQuery query, SortQuery sortQuery, HttpServletResponse response) { | ||||
|         List<DictResp> dictList = this.list(query, sortQuery); | ||||
|         List<DictItemDetailResp> dictItemList = new ArrayList<>(); | ||||
|         for (DictResp dict : dictList) { | ||||
|             List<DictItemDetailResp> tempDictItemList = dictItemService.listByDictId(dict.getId()); | ||||
|             for (DictItemDetailResp dictItem : tempDictItemList) { | ||||
|                 dictItem.setDictName(dict.getName()); | ||||
|                 dictItem.setDictCode(dict.getCode()); | ||||
|                 dictItemList.add(dictItem); | ||||
|             } | ||||
|         } | ||||
|         ExcelUtils.export(dictItemList, "导出数据", DictItemDetailResp.class, response); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 名称是否存在 | ||||
|      * | ||||
|   | ||||
| @@ -20,8 +20,6 @@ import cn.dev33.satoken.annotation.SaIgnore; | ||||
| import cn.hutool.core.lang.tree.Tree; | ||||
| import cn.hutool.core.util.ClassUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import com.alicp.jetcache.anno.CachePenetrationProtect; | ||||
| import com.alicp.jetcache.anno.CacheRefresh; | ||||
| import com.alicp.jetcache.anno.Cached; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| @@ -106,9 +104,6 @@ public class CommonController { | ||||
|     @Operation(summary = "查询字典", description = "查询字典列表") | ||||
|     @Parameter(name = "code", description = "字典编码", example = "announcement_type", in = ParameterIn.PATH) | ||||
|     @GetMapping("/dict/{code}") | ||||
|     @CachePenetrationProtect | ||||
|     @CacheRefresh(refresh = 3600, stopRefreshAfterLastAccess = 7200) | ||||
|     @Cached(key = "#code", name = CacheConstants.DICT_KEY_PREFIX) | ||||
|     public R<List<LabelValueResp<Serializable>>> listDict(@PathVariable String code) { | ||||
|         Optional<Class<?>> enumClassOptional = this.getEnumClassByName(code); | ||||
|         return R.ok(enumClassOptional.map(this::listEnumDict).orElseGet(() -> dictItemService.listByDictCode(code))); | ||||
|   | ||||
| @@ -17,16 +17,14 @@ | ||||
| package top.charles7c.continew.admin.webapi.system; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import top.charles7c.continew.admin.system.model.query.DictQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictResp; | ||||
| import top.charles7c.continew.admin.system.service.DictService; | ||||
| import top.charles7c.continew.starter.extension.crud.annotation.CrudRequestMapping; | ||||
| import top.charles7c.continew.starter.extension.crud.controller.BaseController; | ||||
| import top.charles7c.continew.starter.extension.crud.enums.Api; | ||||
|  | ||||
| /** | ||||
|  * 字典管理 API | ||||
| @@ -36,5 +34,5 @@ import top.charles7c.continew.starter.extension.crud.controller.BaseController; | ||||
|  */ | ||||
| @Tag(name = "字典管理 API") | ||||
| @RestController | ||||
| @CrudRequestMapping("/system/dict") | ||||
| public class DictController extends BaseController<DictService, DictResp, DictDetailResp, DictQuery, DictReq> {} | ||||
| @CrudRequestMapping(value = "/system/dict", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE}) | ||||
| public class DictController extends BaseController<DictService, DictResp, DictResp, DictQuery, DictReq> {} | ||||
| @@ -17,12 +17,9 @@ | ||||
| package top.charles7c.continew.admin.webapi.system; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import top.charles7c.continew.admin.system.model.query.DictItemQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.DictItemReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.DictItemResp; | ||||
| import top.charles7c.continew.admin.system.service.DictItemService; | ||||
| import top.charles7c.continew.starter.extension.crud.annotation.CrudRequestMapping; | ||||
| @@ -38,4 +35,4 @@ import top.charles7c.continew.starter.extension.crud.enums.Api; | ||||
| @Tag(name = "字典项管理 API") | ||||
| @RestController | ||||
| @CrudRequestMapping(value = "/system/dict/item", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE}) | ||||
| public class DictItemController extends BaseController<DictItemService, DictItemResp, DictItemDetailResp, DictItemQuery, DictItemReq> {} | ||||
| public class DictItemController extends BaseController<DictItemService, DictItemResp, DictItemResp, DictItemQuery, DictItemReq> {} | ||||
| @@ -124,10 +124,10 @@ VALUES | ||||
| (547889614262632491, '公告类型', 'announcement_type', NULL, b'1', 1, NOW(), NULL, NULL); | ||||
|  | ||||
| INSERT INTO `sys_dict_item` | ||||
| (`id`, `label`, `value`, `color`, `sort`, `description`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`) | ||||
| (`id`, `label`, `value`, `color`, `sort`, `description`, `status`, `dict_id`, `create_user`, `create_time`, `update_user`, `update_time`) | ||||
| VALUES | ||||
| (547889649658363951, '通知', '1', 'blue', 1, NULL, 547889614262632491, 1, NOW(), NULL, NULL), | ||||
| (547890124537462835, '活动', '2', 'orangered', 2, NULL, 547889614262632491, 1, NOW(), NULL, NULL); | ||||
| (547889649658363951, '通知', '1', 'blue', 1, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL), | ||||
| (547890124537462835, '活动', '2', 'orangered', 2, NULL, 1, 547889614262632491, 1, NOW(), NULL, NULL); | ||||
|  | ||||
| -- 初始化默认用户和角色关联数据 | ||||
| INSERT INTO `sys_user_role` | ||||
|   | ||||
| @@ -157,6 +157,7 @@ CREATE TABLE IF NOT EXISTS `sys_dict_item` ( | ||||
|     `color`       varchar(30)  DEFAULT NULL                COMMENT '标签颜色', | ||||
|     `sort`        int          NOT NULL DEFAULT 999        COMMENT '排序', | ||||
|     `description` varchar(200) DEFAULT NULL                COMMENT '描述', | ||||
|     `status`      tinyint(1)   UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态(1:启用;2:禁用)', | ||||
|     `dict_id`     bigint(20)   NOT NULL                    COMMENT '字典ID', | ||||
|     `create_user` bigint(20)   NOT NULL                    COMMENT '创建人', | ||||
|     `create_time` datetime     NOT NULL                    COMMENT '创建时间', | ||||
|   | ||||
| @@ -124,10 +124,10 @@ VALUES | ||||
| (547889614262632491, '公告类型', 'announcement_type', NULL, true, 1, NOW(), NULL, NULL); | ||||
|  | ||||
| INSERT INTO "sys_dict_item" | ||||
| ("id", "label", "value", "color", "sort", "description", "dict_id", "create_user", "create_time", "update_user", "update_time") | ||||
| ("id", "label", "value", "color", "sort", "description", "status", "dict_id", "create_user", "create_time", "update_user", "update_time") | ||||
| VALUES | ||||
| (547889649658363951, '通知', '1', 'blue', 1, NULL, 547889614262632491, 1, NOW(), NULL, NULL), | ||||
| (547890124537462835, '活动', '2', 'orangered', 2, NULL, 547889614262632491, 1, NOW(), NULL, NULL); | ||||
| (547889649658363951, '通知', '1', 'blue', 1, NULL, 547889614262632491, 1, 1, NOW(), NULL, NULL), | ||||
| (547890124537462835, '活动', '2', 'orangered', 2, NULL, 547889614262632491, 1, 1, NOW(), NULL, NULL); | ||||
|  | ||||
| -- 初始化默认用户和角色关联数据 | ||||
| INSERT INTO "sys_user_role" | ||||
|   | ||||
| @@ -256,6 +256,7 @@ CREATE TABLE IF NOT EXISTS "sys_dict_item" ( | ||||
|     "color"       varchar(30)  DEFAULT NULL, | ||||
|     "sort"        int4         NOT NULL DEFAULT 999, | ||||
|     "description" varchar(200) DEFAULT NULL, | ||||
|     "status"      int2         NOT NULL DEFAULT 1, | ||||
|     "dict_id"     int8         NOT NULL, | ||||
|     "create_user" int8         NOT NULL, | ||||
|     "create_time" timestamp    NOT NULL, | ||||
| @@ -273,6 +274,7 @@ COMMENT ON COLUMN "sys_dict_item"."value"       IS '值'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."color"       IS '标签颜色'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."sort"        IS '排序'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."description" IS '描述'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."status"      IS '状态(1:启用;2:禁用)'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."dict_id"     IS '字典ID'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."create_user" IS '创建人'; | ||||
| COMMENT ON COLUMN "sys_dict_item"."create_time" IS '创建时间'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user