site.sorghum.anno.anno.controller.BaseDictController Maven / Gradle / Ivy
The newest version!
package site.sorghum.anno.anno.controller;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import jakarta.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import site.sorghum.anno._common.AnnoBeanUtils;
import site.sorghum.anno._common.response.AnnoResult;
import site.sorghum.anno._metadata.AnEntity;
import site.sorghum.anno._metadata.MetadataManager;
import site.sorghum.anno.anno.annotation.field.type.AnnoOptionTypeImpl;
import site.sorghum.anno.anno.annotation.field.type.AnnoTreeTypeImpl;
import site.sorghum.anno.anno.entity.common.AnnoTreeDTO;
import site.sorghum.anno.anno.option.OptionDataSupplier;
import site.sorghum.anno.anno.proxy.AnnoBaseService;
import site.sorghum.anno.anno.proxy.PermissionProxy;
import site.sorghum.anno.anno.tree.TreeDataSupplier;
import site.sorghum.anno.anno.util.AnnoFieldCache;
import site.sorghum.anno.anno.util.AnnoUtil;
import site.sorghum.anno.anno.util.QuerySqlCache;
import site.sorghum.anno.anno.util.Utils;
import site.sorghum.anno.db.DbCriteria;
import site.sorghum.anno.db.QueryType;
import site.sorghum.anno.trans.OnlineDictCache;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 基本dict控制器
*
* @author Sorghum
* @since 2024/01/11
*/
@Slf4j
public class BaseDictController {
@Inject
AnnoBaseService baseService;
@Inject
MetadataManager metadataManager;
@Inject
PermissionProxy permissionProxy;
@Inject
OnlineDictCache onlineDictCache;
public AnnoResult>> loadDict(
String sqlKey,
String annoClazz,
String idKey,
String labelKey,
String onlineDictKey,
String optionAnnoClazz,
String treeAnnoClazz,
Map _extra
) {
if (StrUtil.isNotBlank(onlineDictKey)){
List onlineDictList = onlineDictCache.getForLoadDict(onlineDictKey);
List> trees = AnnoUtil.buildAnnoTree(
onlineDictList, "name", "value", "parentValue"
);
return AnnoResult.succeed(trees);
}
if (StrUtil.isNotBlank(sqlKey)) {
String actualSql = QuerySqlCache.get(sqlKey);
if (StrUtil.isEmpty(actualSql)) {
return AnnoResult.failure("sql 不存在,请检查相关配置项");
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy