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