mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-08 16:57:09 +08:00
refactor(extension/crud): 优化树型结构字典配置相关命名及注释 DICT_TREE -> TREE_DICT
This commit is contained in:
@@ -16,11 +16,17 @@
|
||||
|
||||
package top.continew.starter.extension.crud.annotation;
|
||||
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 字典结构映射
|
||||
*
|
||||
* <p>用于查询字典列表 API(下拉选项等场景)</p>
|
||||
*
|
||||
* @see top.continew.starter.extension.crud.controller.AbstractCrudController#dict(Object, SortQuery)
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
@@ -16,19 +16,16 @@
|
||||
|
||||
package top.continew.starter.extension.crud.annotation;
|
||||
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeProperties;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 树结构字段
|
||||
* 树结构字段映射
|
||||
*
|
||||
* <p>
|
||||
* 用于复杂树场景,例如:表格
|
||||
* 用于复杂树场景,例如:表格列表
|
||||
* </p>
|
||||
*
|
||||
* @see cn.hutool.core.lang.tree.TreeNodeConfig
|
||||
* @see CrudTreeProperties
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
|
@@ -19,6 +19,7 @@ package top.continew.starter.extension.crud.autoconfigure;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
|
||||
/**
|
||||
* CRUD 配置属性
|
||||
@@ -30,17 +31,19 @@ import top.continew.starter.core.constant.PropertiesConstants;
|
||||
public class CrudProperties {
|
||||
|
||||
/**
|
||||
* 树配置
|
||||
* <p>用于简单树场景,例如:树选择(下拉)</p>
|
||||
* 树型字典结构映射配置
|
||||
*
|
||||
* @see top.continew.starter.extension.crud.controller.AbstractCrudController#dictTree(Object, SortQuery)
|
||||
* @see top.continew.starter.extension.crud.service.CrudService#tree(Object, SortQuery, boolean)
|
||||
*/
|
||||
@NestedConfigurationProperty
|
||||
private CrudTreeProperties tree = new CrudTreeProperties();
|
||||
private CrudTreeDictModelProperties treeDictModel = new CrudTreeDictModelProperties();
|
||||
|
||||
public CrudTreeProperties getTree() {
|
||||
return tree;
|
||||
public CrudTreeDictModelProperties getTreeDictModel() {
|
||||
return treeDictModel;
|
||||
}
|
||||
|
||||
public void setTree(CrudTreeProperties tree) {
|
||||
this.tree = tree;
|
||||
public void setTreeDictModel(CrudTreeDictModelProperties treeDictModel) {
|
||||
this.treeDictModel = treeDictModel;
|
||||
}
|
||||
}
|
||||
|
@@ -19,20 +19,21 @@ package top.continew.starter.extension.crud.autoconfigure;
|
||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
|
||||
/**
|
||||
* CRUD 树列表配置属性
|
||||
* 树型字典结构映射配置属性
|
||||
*
|
||||
* <p>
|
||||
* 用于简单树场景,例如:树选择(下拉)
|
||||
* 用于查询树型结构字典列表 API(树型结构下拉选项等场景)
|
||||
* </p>
|
||||
*
|
||||
* @see TreeField
|
||||
* @see top.continew.starter.extension.crud.controller.AbstractCrudController#dictTree(Object, SortQuery)
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2.7.2
|
||||
*/
|
||||
public class CrudTreeProperties {
|
||||
public class CrudTreeDictModelProperties {
|
||||
|
||||
/**
|
||||
* ID 字段名
|
@@ -204,16 +204,16 @@ public abstract class AbstractCrudController<S extends CrudService<L, D, Q, C>,
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典树列表
|
||||
* 查询树型字典列表
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @param sortQuery 排序查询条件
|
||||
* @return 字典树列表信息
|
||||
* @return 树型字典列表信息
|
||||
*/
|
||||
@CrudApi(Api.DICT_TREE)
|
||||
@Operation(summary = "查询字典树列表", description = "查询树型结构字典列表(树型结构下拉选项等场景)")
|
||||
@CrudApi(Api.TREE_DICT)
|
||||
@Operation(summary = "查询树型字典列表", description = "查询树型结构字典列表(树型结构下拉选项等场景)")
|
||||
@GetMapping("/dict/tree")
|
||||
public List<Tree<Long>> dictTree(@Valid Q query, @Valid SortQuery sortQuery) {
|
||||
public List<Tree<Long>> treeDict(@Valid Q query, @Valid SortQuery sortQuery) {
|
||||
return baseService.tree(query, sortQuery, true);
|
||||
}
|
||||
}
|
||||
|
@@ -75,7 +75,7 @@ public enum Api {
|
||||
DICT,
|
||||
|
||||
/**
|
||||
* 字典树列表(树型结构下拉选项等场景)
|
||||
* 树型字典列表(树型结构下拉选项等场景)
|
||||
*/
|
||||
DICT_TREE
|
||||
TREE_DICT
|
||||
}
|
@@ -65,9 +65,11 @@ public interface CrudService<L, D, Q, C> {
|
||||
*
|
||||
* @param query 查询条件
|
||||
* @param sortQuery 排序查询条件
|
||||
* @param isSimple 是否为简单树结构(不包含基本树结构之外的扩展字段,简单树(下拉列表)使用全局配置结构,复杂树(表格)使用 @TreeField 局部配置)
|
||||
* @param isSimple 是否为简单树结构(不包含基本树结构之外的扩展字段,简单树(例如:下拉列表)使用 CrudTreeDictModelProperties
|
||||
* 全局树型字典映射配置,复杂树(例如:表格)使用 @TreeField 局部结构配置)
|
||||
* @return 树列表信息
|
||||
* @see TreeField
|
||||
* @see top.continew.starter.extension.crud.autoconfigure.CrudTreeDictModelProperties
|
||||
*/
|
||||
List<Tree<Long>> tree(@Valid Q query, @Valid SortQuery sortQuery, boolean isSimple);
|
||||
|
||||
@@ -82,6 +84,7 @@ public interface CrudService<L, D, Q, C> {
|
||||
* @author lishuyan
|
||||
* @since 2.13.3
|
||||
* @see TreeField
|
||||
* @see top.continew.starter.extension.crud.autoconfigure.CrudTreeDictModelProperties
|
||||
*/
|
||||
List<Tree<Long>> tree(@Valid Q query, @Valid SortQuery sortQuery, boolean isSimple, boolean isSingleRoot);
|
||||
|
||||
|
@@ -44,7 +44,7 @@ import top.continew.starter.excel.util.ExcelUtils;
|
||||
import top.continew.starter.extension.crud.annotation.DictModel;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudProperties;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeProperties;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeDictModelProperties;
|
||||
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
@@ -103,16 +103,16 @@ public class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D,
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
CrudProperties crudProperties = SpringUtil.getBean(CrudProperties.class);
|
||||
CrudTreeProperties treeProperties = crudProperties.getTree();
|
||||
CrudTreeDictModelProperties treeDictModel = crudProperties.getTreeDictModel();
|
||||
TreeField treeField = listClass.getDeclaredAnnotation(TreeField.class);
|
||||
TreeNodeConfig treeNodeConfig;
|
||||
Long rootId;
|
||||
// 简单树(下拉列表)使用全局配置结构,复杂树(表格)使用局部配置
|
||||
// 简单树(例如:下拉列表)使用 CrudTreeDictModelProperties 全局树型字典映射配置,复杂树(例如:表格)使用 @TreeField 局部结构配置
|
||||
if (isSimple) {
|
||||
treeNodeConfig = treeProperties.genTreeNodeConfig();
|
||||
rootId = treeProperties.getRootId();
|
||||
treeNodeConfig = treeDictModel.genTreeNodeConfig();
|
||||
rootId = treeDictModel.getRootId();
|
||||
} else {
|
||||
treeNodeConfig = treeProperties.genTreeNodeConfig(treeField);
|
||||
treeNodeConfig = treeDictModel.genTreeNodeConfig(treeField);
|
||||
rootId = treeField.rootId();
|
||||
}
|
||||
if (isSingleRoot) {
|
||||
|
@@ -46,7 +46,7 @@ import top.continew.starter.excel.util.ExcelUtils;
|
||||
import top.continew.starter.extension.crud.annotation.DictModel;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudProperties;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeProperties;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeDictModelProperties;
|
||||
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
@@ -105,16 +105,16 @@ public class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D,
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
CrudProperties crudProperties = SpringUtil.getBean(CrudProperties.class);
|
||||
CrudTreeProperties treeProperties = crudProperties.getTree();
|
||||
CrudTreeDictModelProperties treeDictModel = crudProperties.getTreeDictModel();
|
||||
TreeField treeField = listClass.getDeclaredAnnotation(TreeField.class);
|
||||
TreeNodeConfig treeNodeConfig;
|
||||
Long rootId;
|
||||
// 简单树(下拉列表)使用全局配置结构,复杂树(表格)使用局部配置
|
||||
// 简单树(例如:下拉列表)使用 CrudTreeDictModelProperties 全局树型字典映射配置,复杂树(例如:表格)使用 @TreeField 局部结构配置
|
||||
if (isSimple) {
|
||||
treeNodeConfig = treeProperties.genTreeNodeConfig();
|
||||
rootId = treeProperties.getRootId();
|
||||
treeNodeConfig = treeDictModel.genTreeNodeConfig();
|
||||
rootId = treeDictModel.getRootId();
|
||||
} else {
|
||||
treeNodeConfig = treeProperties.genTreeNodeConfig(treeField);
|
||||
treeNodeConfig = treeDictModel.genTreeNodeConfig(treeField);
|
||||
rootId = treeField.rootId();
|
||||
}
|
||||
if (isSingleRoot) {
|
||||
|
Reference in New Issue
Block a user