feat(generator): 代码生成字段配置支持选择关联字典

暂时仅支持前端部分生成

Closes #I9SWQB
Closes #55
This commit is contained in:
2024-08-27 00:01:57 +08:00
parent e17d5db0fb
commit fdd21a01c1
17 changed files with 143 additions and 93 deletions

View File

@@ -18,6 +18,7 @@ package top.continew.admin.system.model.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import top.continew.starter.extension.crud.annotation.DictField;
import top.continew.starter.extension.crud.model.entity.BaseDO;
import java.io.Serial;
@@ -29,6 +30,7 @@ import java.io.Serial;
* @since 2023/9/11 21:29
*/
@Data
@DictField(valueKey = "code")
@TableName("sys_dict")
public class DictDO extends BaseDO {

View File

@@ -48,4 +48,11 @@ public interface DictItemService extends BaseService<DictItemResp, DictItemResp,
* @param dictIds 字典 ID 列表
*/
void deleteByDictIds(List<Long> dictIds);
/**
* 查询枚举字典名称列表
*
* @return 枚举字典名称列表
*/
List<String> listEnumDictNames();
}

View File

@@ -21,8 +21,11 @@ import top.continew.admin.system.model.query.DictQuery;
import top.continew.admin.system.model.req.DictReq;
import top.continew.admin.system.model.resp.DictResp;
import top.continew.starter.data.mybatis.plus.service.IService;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.service.BaseService;
import java.util.List;
/**
* 字典业务接口
*
@@ -30,4 +33,11 @@ import top.continew.starter.extension.crud.service.BaseService;
* @since 2023/9/11 21:29
*/
public interface DictService extends BaseService<DictResp, DictResp, DictQuery, DictReq>, IService<DictDO> {
/**
* 查询枚举字典
*
* @return 枚举字典列表
*/
List<LabelValueResp> listEnumDict();
}

View File

@@ -32,8 +32,8 @@ import top.continew.admin.system.service.DictItemService;
import top.continew.starter.cache.redisson.util.RedisUtils;
import top.continew.starter.core.autoconfigure.project.ProjectProperties;
import top.continew.starter.core.constant.StringConstants;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.core.enums.BaseEnum;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
@@ -81,6 +81,11 @@ public class DictItemServiceImpl extends BaseServiceImpl<DictItemMapper, DictIte
RedisUtils.deleteByPattern(CacheConstants.DICT_KEY_PREFIX + StringConstants.ASTERISK);
}
@Override
public List<String> listEnumDictNames() {
return ENUM_DICT_CACHE.keySet().stream().toList();
}
/**
* 字典值是否存在
*

View File

@@ -26,6 +26,7 @@ import top.continew.admin.system.model.resp.DictResp;
import top.continew.admin.system.service.DictItemService;
import top.continew.admin.system.service.DictService;
import top.continew.starter.core.util.validate.CheckUtils;
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
import java.util.List;
@@ -71,6 +72,12 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes
dictItemService.deleteByDictIds(ids);
}
@Override
public List<LabelValueResp> listEnumDict() {
List<String> enumDictNameList = dictItemService.listEnumDictNames();
return enumDictNameList.stream().map(name -> new LabelValueResp(name, name)).toList();
}
/**
* 名称是否存在
*