diff --git a/vetti-admin/src/main/java/com/vetti/web/controller/system/SysDictDataController.java b/vetti-admin/src/main/java/com/vetti/web/controller/system/SysDictDataController.java index ca50337..a1ca66a 100644 --- a/vetti-admin/src/main/java/com/vetti/web/controller/system/SysDictDataController.java +++ b/vetti-admin/src/main/java/com/vetti/web/controller/system/SysDictDataController.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.vetti.common.core.domain.R; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -67,11 +68,10 @@ public class SysDictDataController extends BaseController * 查询字典数据详细 */ @ApiOperation("查询字典数据详细") - @PreAuthorize("@ss.hasPermi('system:dict:query')") @GetMapping(value = "/{dictCode}") - public AjaxResult getInfo(@PathVariable Long dictCode) + public R getInfo(@PathVariable Long dictCode) { - return success(dictDataService.selectDictDataById(dictCode)); + return R.ok(dictDataService.selectDictDataById(dictCode)); } /** @@ -79,14 +79,14 @@ public class SysDictDataController extends BaseController */ @ApiOperation("根据字典类型查询字典数据信息") @GetMapping(value = "/type/{dictType}") - public AjaxResult> dictType(@PathVariable String dictType) + public R> dictType(@PathVariable String dictType) { List data = dictTypeService.selectDictDataByType(dictType); if (StringUtils.isNull(data)) { data = new ArrayList(); } - return success(data); + return R.ok(data); } /** diff --git a/vetti-admin/src/main/resources/application-druid.yml b/vetti-admin/src/main/resources/application-druid.yml index c85208c..ef91b57 100644 --- a/vetti-admin/src/main/resources/application-druid.yml +++ b/vetti-admin/src/main/resources/application-druid.yml @@ -170,7 +170,7 @@ chatGpt: apiKey: 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 apiUrl: https://api.openai.com/v1/chat/completions model: ft:gpt-3.5-turbo-0125:vetti:interview-unified:CaGyCXOr - modelQuestion: gpt-4o-mini + modelQuestion: ft:gpt-4o-mini-2024-07-18:vetti:interview-corpus:ChvLmzLu modelCV: ft:gpt-3.5-turbo-0125:vetti:vetti-resume-full:CYT0C8JG modelJxCv: gpt-4o-mini role: system diff --git a/vetti-admin/target/classes/application-druid.yml b/vetti-admin/target/classes/application-druid.yml index c85208c..ef91b57 100644 --- a/vetti-admin/target/classes/application-druid.yml +++ b/vetti-admin/target/classes/application-druid.yml @@ -170,7 +170,7 @@ chatGpt: apiKey: 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 apiUrl: https://api.openai.com/v1/chat/completions model: ft:gpt-3.5-turbo-0125:vetti:interview-unified:CaGyCXOr - modelQuestion: gpt-4o-mini + modelQuestion: ft:gpt-4o-mini-2024-07-18:vetti:interview-corpus:ChvLmzLu modelCV: ft:gpt-3.5-turbo-0125:vetti:vetti-resume-full:CYT0C8JG modelJxCv: gpt-4o-mini role: system diff --git a/vetti-common/src/main/java/com/vetti/common/core/domain/entity/SysDictData.java b/vetti-common/src/main/java/com/vetti/common/core/domain/entity/SysDictData.java index 114bc19..2437d7e 100644 --- a/vetti-common/src/main/java/com/vetti/common/core/domain/entity/SysDictData.java +++ b/vetti-common/src/main/java/com/vetti/common/core/domain/entity/SysDictData.java @@ -4,6 +4,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import com.vetti.common.international.International; +import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.vetti.common.annotation.Excel; @@ -11,6 +12,8 @@ import com.vetti.common.annotation.Excel.ColumnType; import com.vetti.common.constant.UserConstants; import com.vetti.common.core.domain.BaseEntity; +import java.util.List; + /** * 字典数据表 sys_dict_data * @@ -21,40 +24,52 @@ public class SysDictData extends BaseEntity private static final long serialVersionUID = 1L; /** 字典编码 */ + @ApiModelProperty("字典编码") @Excel(name = "字典编码", cellType = ColumnType.NUMERIC) private Long dictCode; + /** 字典编码 */ + @ApiModelProperty("字典父编码") + @Excel(name = "字典父编码", cellType = ColumnType.NUMERIC) + private Long dictParentCode; + /** 字典排序 */ + @ApiModelProperty("字典排序") @Excel(name = "字典排序", cellType = ColumnType.NUMERIC) private Long dictSort; /** 字典标签 */ + @ApiModelProperty("字典标签") @Excel(name = "字典标签") - @International(type = "sys_dict_label") private String dictLabel; /** 字典键值 */ + @ApiModelProperty("字典键值") @Excel(name = "字典键值") private String dictValue; /** 字典类型 */ + @ApiModelProperty("字典类型") @Excel(name = "字典类型") private String dictType; - /** 样式属性(其他样式扩展) */ + @ApiModelProperty("样式属性(其他样式扩展)") private String cssClass; - /** 表格字典样式 */ + @ApiModelProperty("表格字典样式") private String listClass; - /** 是否默认(Y是 N否) */ + @ApiModelProperty("是否默认(Y是 N否)") @Excel(name = "是否默认", readConverterExp = "Y=是,N=否") private String isDefault; - /** 状态(0正常 1停用) */ + @ApiModelProperty("状态(0正常 1停用)") @Excel(name = "状态", readConverterExp = "0=正常,1=停用") private String status; + @ApiModelProperty("字典子类集合") + private List childrenDictData; + public Long getDictCode() { return dictCode; @@ -65,6 +80,14 @@ public class SysDictData extends BaseEntity this.dictCode = dictCode; } + public Long getDictParentCode() { + return dictParentCode; + } + + public void setDictParentCode(Long dictParentCode) { + this.dictParentCode = dictParentCode; + } + public Long getDictSort() { return dictSort; @@ -156,7 +179,16 @@ public class SysDictData extends BaseEntity { this.status = status; } - + + + public List getChildrenDictData() { + return childrenDictData; + } + + public void setChildrenDictData(List childrenDictData) { + this.childrenDictData = childrenDictData; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/HotakeCvInfoDto.java b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/HotakeCvInfoDto.java index 177781a..c6000be 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/HotakeCvInfoDto.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/HotakeCvInfoDto.java @@ -28,17 +28,17 @@ public class HotakeCvInfoDto { @ApiModelProperty("地点") private String location; @ApiModelProperty("链接对象集合") - private List linksList; + private List links; @ApiModelProperty("自我介绍") private String about; @ApiModelProperty("技能工具-许可证、注册/会员资格、认证") - private List skillsToolsList; + private List skillsTools; @ApiModelProperty("语言") - private List languagesList; + private List languages; @ApiModelProperty("工作经验集合") - private List experienceList; + private List experience; @ApiModelProperty("教育经历") - private List educationList; + private List education; } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcCertificateDto.java b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcCertificateDto.java new file mode 100644 index 0000000..5aecbde --- /dev/null +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcCertificateDto.java @@ -0,0 +1,29 @@ +package com.vetti.hotake.domain.dto.VcDto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 简历-教育经历-证书-信息对象 + * + * @author wangxiangshun + * @date 2025-11-30 + */ +@Data +@Accessors(chain = true) +public class VcCertificateDto { + + @ApiModelProperty("文件名称") + private String fileName; + + @ApiModelProperty("文件后缀(doc/pdf)") + private String fileSuffix; + + @ApiModelProperty("文件地址") + private String fileUrl; + + @ApiModelProperty("文件大小") + private String fileSizeShow; + +} diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcEducationDto.java b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcEducationDto.java index 1ba2cce..cf010eb 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcEducationDto.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcEducationDto.java @@ -22,4 +22,8 @@ public class VcEducationDto { @ApiModelProperty("时间") private String date; + + @ApiModelProperty("证书附件") + private VcCertificateDto certificate; + } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcExperienceDto.java b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcExperienceDto.java index 13e207d..8ca9e2c 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcExperienceDto.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcExperienceDto.java @@ -29,6 +29,6 @@ public class VcExperienceDto { private String duration; @ApiModelProperty("描述集合") - private List descriptionList; + private List description; } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcSkillsToolsDto.java b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcSkillsToolsDto.java index 2933e8b..94ddf18 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcSkillsToolsDto.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/domain/dto/VcDto/VcSkillsToolsDto.java @@ -16,7 +16,4 @@ public class VcSkillsToolsDto { @ApiModelProperty("内容") private String content; - - @ApiModelProperty("证书附件URL") - private String fileUrl; } diff --git a/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java b/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java index f655604..ff445fb 100644 --- a/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java +++ b/vetti-hotakes/src/main/java/com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.java @@ -13,6 +13,7 @@ import com.vetti.common.utils.readFile.FileContentUtil; import com.vetti.hotake.domain.HotakeCvInfo; import com.vetti.hotake.domain.HotakeProblemBaseInfo; import com.vetti.hotake.domain.dto.HotakeCvInfoDto; +import com.vetti.hotake.domain.dto.VcDto.*; import com.vetti.hotake.mapper.HotakeCvInfoMapper; import com.vetti.hotake.service.IHotakeCvInfoService; import com.vetti.hotake.service.IHotakeProblemBaseInfoService; @@ -67,8 +68,11 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC @Override public HotakeCvInfo selectHotakeCvInfoById(Long id) { HotakeCvInfo cvInfo = hotakeCvInfoMapper.selectHotakeCvInfoById(id); - HotakeCvInfoDto cvInfoDto = JSONUtil.toBean(cvInfo.getCvTemplateJson(),HotakeCvInfoDto.class); - cvInfo.setCvInfoDto(cvInfoDto); + if(StrUtil.isNotEmpty(cvInfo.getCvTemplateJson())){ + HotakeCvInfoDto cvInfoDto = JSONUtil.toBean(cvInfo.getCvTemplateJson(),HotakeCvInfoDto.class); + cvInfo.setCvInfoDto(cvInfoDto); + } + HotakeProblemBaseInfo query = new HotakeProblemBaseInfo(); query.setCvId(id); List problemBaseInfoList = hotakeProblemBaseInfoService.selectHotakeProblemBaseInfoList(query); @@ -138,8 +142,8 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC mapEntityOne.put("role", "user"); mapEntityOne.put("content", "Position: Construction Labourer" + "\\nCandidate: " + cvInfoDto.getName() + - "\\nKey Skills: " + JSONUtil.toJsonStr(cvInfoDto.getSkillsToolsList()) + - "\\nExperience: " + JSONUtil.toJsonStr(cvInfoDto.getExperienceList()) + + "\\nKey Skills: " + JSONUtil.toJsonStr(cvInfoDto.getSkillsTools()) + + "\\nExperience: " + JSONUtil.toJsonStr(cvInfoDto.getExperience()) + "\\nStrengths: Professional certifications, Relevant experience" + "\\nConcerns: " + JSONUtil.toJsonStr(cvInfoDto.getAbout())); list.add(mapEntityOne); @@ -180,7 +184,12 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC fill(FillTypeEnum.UPDATE.getCode(), hotakeCvInfo); hotakeCvInfo.setCvTemplateJson(JSONUtil.toJsonStr(hotakeCvInfo.getCvInfoDto())); + //修改的时候重新生成问题和评分 + + + hotakeCvInfoMapper.updateHotakeCvInfo(hotakeCvInfo); + return hotakeCvInfo; } @@ -269,12 +278,109 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC List> list = new LinkedList(); Map entity = new HashMap<>(); entity.put("role","user"); - entity.put("content","从下面提供的文本中提取所有能识别到的简历信息,只提取原文中存在的内容,不要补充、不推测、不总结。需要提取的字段包括:name(姓名)、phone(电话号码)、email(电子邮件地址)、position(岗位)、location(地点)、links(所有链接地址)、about(关于我/自我介绍)、skills_tools(关键资格(许可证、注册/会员资格、认证))、languages(语言能力)、experience(工作经历(除了title、company、location、duration其他的都放到描述里面))、education(教育经历)。请将提取结果以结构化 JSON 格式返回,格式如下:{ \\\"name\\\": \\\"\\\", \\\"phone\\\": \\\"\\\", \\\"email\\\": \\\"\\\", \\\"links\\\": [{\\\"content\\\":\\\"\\\"}], \\\"about\\\": \\\"\\\", \\\"skillsTools\\\": [{\\\"content\\\":\\\"\\\"}], \\\"languages\\\": [{\\\"content\\\":\\\"\\\"}], \\\"experience\\\": [{\\\"title\\\": \\\"\\\", \\\"company\\\": \\\"\\\",\\\"location\\\": \\\"\\\",\\\"duration\\\": \\\"\\\",\\\"description\\\": [{\\\"content\\\":\\\"\\\"}]}], \\\"education\\\": [{\\\"degree\\\": \\\"\\\",\\\"institution\\\": \\\"\\\",\\\"date\\\": \\\"\\\"}] }。字段不存在则返回 null 或空数组。只返回标准可解析的 JSON结构 ,不要多余的```json等信息,不要解释说明,不要改写内容。以下为待处理文本:"+contents); + entity.put("content","从下面提供的文本中提取所有能识别到的简历信息,只提取原文中存在的内容,不要补充、不推测、不总结。需要提取的字段包括:name(姓名)、phone(电话号码)、email(电子邮件地址)、position(岗位)、location(地点)、links(所有链接地址)、about(关于我/自我介绍)、skills_tools(关键资格(许可证、注册/会员资格、认证))、languages(语言能力)、experience(工作经历(除了title、company、location、duration,其他的都放到description里面,并且description里面要根据换行符分成不同的content))、education(教育经历)。请将提取结果以结构化 JSON 格式返回,格式如下:{ \\\"name\\\": \\\"\\\", \\\"phone\\\": \\\"\\\", \\\"email\\\": \\\"\\\", \\\"links\\\": [{\\\"content\\\":\\\"\\\"}], \\\"about\\\": \\\"\\\", \\\"skillsTools\\\": [{\\\"content\\\":\\\"\\\"}], \\\"languages\\\": [{\\\"content\\\":\\\"\\\"}], \\\"experience\\\": [{\\\"title\\\": \\\"\\\", \\\"company\\\": \\\"\\\",\\\"location\\\": \\\"\\\",\\\"duration\\\": \\\"\\\",\\\"description\\\": [{\\\"content\\\":\\\"\\\"}]}], \\\"education\\\": [{\\\"degree\\\": \\\"\\\",\\\"institution\\\": \\\"\\\",\\\"date\\\": \\\"\\\"}] }。字段不存在则返回 null 或空数组。只返回标准可解析的 JSON结构 ,不要多余的```json等信息,不要解释说明,不要改写内容。以下为待处理文本:"+contents); //根据AI做 list.add(entity); String resultCv = chatGPTClient.handleAiChat(JSONUtil.toJsonStr(list), "JX"); log.info("开始返回简历解析结果:{}", resultCv); HotakeCvInfoDto cvInfoDto = JSONUtil.toBean(resultCv, HotakeCvInfoDto.class); + //数据添加默认值 + if(cvInfoDto != null){ + if(StrUtil.isEmpty(cvInfoDto.getName())){ + cvInfoDto.setName("-"); + } + if(StrUtil.isEmpty(cvInfoDto.getPhone())){ + cvInfoDto.setPhone("-"); + } + if(StrUtil.isEmpty(cvInfoDto.getEmail())){ + cvInfoDto.setEmail("-"); + } + if(StrUtil.isEmpty(cvInfoDto.getPosition())){ + cvInfoDto.setPosition("-"); + } + if(StrUtil.isEmpty(cvInfoDto.getLocation())){ + cvInfoDto.setLocation("-"); + } + if(StrUtil.isEmpty(cvInfoDto.getAbout())){ + cvInfoDto.setAbout("-"); + } + if(CollectionUtil.isNotEmpty(cvInfoDto.getSkillsTools())){ + for (VcSkillsToolsDto toolsDto :cvInfoDto.getSkillsTools()) { + if(StrUtil.isEmpty(toolsDto.getContent())){ + toolsDto.setContent("-"); + } + } + } + if(CollectionUtil.isNotEmpty(cvInfoDto.getLinks())){ + for (VcLinksDto linksDto :cvInfoDto.getLinks()) { + if(StrUtil.isEmpty(linksDto.getContent())){ + linksDto.setContent("-"); + } + } + } + + if(CollectionUtil.isNotEmpty(cvInfoDto.getLanguages())){ + for (VcLanguagesDto languagesDto :cvInfoDto.getLanguages()) { + if(StrUtil.isEmpty(languagesDto.getContent())){ + languagesDto.setContent("-"); + } + } + } + + if(CollectionUtil.isNotEmpty(cvInfoDto.getExperience())){ + for (VcExperienceDto experienceDto :cvInfoDto.getExperience()) { + if (StrUtil.isEmpty(experienceDto.getTitle())){ + experienceDto.setTitle("-"); + } + if(StrUtil.isEmpty(experienceDto.getCompany())){ + experienceDto.setCompany("-"); + } + if(StrUtil.isEmpty(experienceDto.getLocation())){ + experienceDto.setLocation("-"); + } + if(StrUtil.isEmpty(experienceDto.getDuration())){ + experienceDto.setDuration("-"); + } + if (CollectionUtil.isNotEmpty(experienceDto.getDescription())){ + for(VcExperienceDescriptionDto descriptionDto :experienceDto.getDescription()){ + if(StrUtil.isEmpty(descriptionDto.getContent())){ + descriptionDto.setContent("-"); + } + + } + } + } + } + + if(CollectionUtil.isNotEmpty(cvInfoDto.getEducation())){ + for (VcEducationDto educationDto :cvInfoDto.getEducation()) { + if (StrUtil.isEmpty(educationDto.getDegree())){ + educationDto.setDegree("-"); + } + if(StrUtil.isEmpty(educationDto.getInstitution())){ + educationDto.setInstitution("-"); + } + if(StrUtil.isEmpty(educationDto.getDate())){ + educationDto.setDate("-"); + } + if(educationDto.getCertificate() != null){ + if(StrUtil.isEmpty(educationDto.getCertificate().getFileName())){ + educationDto.getCertificate().setFileName("-"); + } + if (StrUtil.isEmpty(educationDto.getCertificate().getFileSuffix())){ + educationDto.getCertificate().setFileSuffix("-"); + } + if (StrUtil.isEmpty(educationDto.getCertificate().getFileUrl())){ + educationDto.getCertificate().setFileUrl("-"); + } + if (StrUtil.isEmpty(educationDto.getCertificate().getFileSizeShow())){ + educationDto.getCertificate().setFileSizeShow("-"); + } + } + } + } + } + return cvInfoDto; } catch (Exception e) { e.printStackTrace(); @@ -303,10 +409,10 @@ public class HotakeCvInfoServiceImpl extends BaseServiceImpl implements IHotakeC mapEntityOne.put("content", "Position: Construction Labourer" + "\\nCandidate: " + cvInfoDto.getName() + "\\nResume Summary: " + JSONUtil.toJsonStr(cvInfoDto.getAbout()) + - "\\nSkills: " + JSONUtil.toJsonStr(cvInfoDto.getSkillsToolsList()) + - "\\nExperience: " + JSONUtil.toJsonStr(cvInfoDto.getExperienceList()) + - "\\nEducation: " + JSONUtil.toJsonStr(cvInfoDto.getEducationList()) + - "\\nCertifications: " + JSONUtil.toJsonStr(cvInfoDto.getSkillsToolsList())); + "\\nSkills: " + JSONUtil.toJsonStr(cvInfoDto.getSkillsTools()) + + "\\nExperience: " + JSONUtil.toJsonStr(cvInfoDto.getExperience()) + + "\\nEducation: " + JSONUtil.toJsonStr(cvInfoDto.getEducation()) + + "\\nCertifications: " + JSONUtil.toJsonStr(cvInfoDto.getSkillsTools())); list.add(mapEntityOne); String promptText = JSONUtil.toJsonStr(list); resultMsg = chatGPTClient.handleAiChat(promptText, "CV"); diff --git a/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index c416d29..922fdc2 100644 --- a/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/vetti-hotakes/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -4,3 +4,4 @@ com/vetti/hotake/domain/dto/VcDto/VcEducationDto.class com/vetti/hotake/domain/dto/VcDto/VcLinksDto.class com/vetti/hotake/domain/dto/VcDto/VcExperienceDescriptionDto.class com/vetti/hotake/domain/dto/VcDto/VcLanguagesDto.class +com/vetti/hotake/service/impl/HotakeCvInfoServiceImpl.class diff --git a/vetti-system/src/main/java/com/vetti/system/service/impl/SysDictTypeServiceImpl.java b/vetti-system/src/main/java/com/vetti/system/service/impl/SysDictTypeServiceImpl.java index 6e5fa8e..d32d133 100644 --- a/vetti-system/src/main/java/com/vetti/system/service/impl/SysDictTypeServiceImpl.java +++ b/vetti-system/src/main/java/com/vetti/system/service/impl/SysDictTypeServiceImpl.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.annotation.PostConstruct; + +import cn.hutool.core.collection.CollectionUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -73,20 +75,46 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService @Override public List selectDictDataByType(String dictType) { - List dictDatas = DictUtils.getDictCache(dictType); +// List dictDataTops = DictUtils.getDictCache(dictType); +// if (StringUtils.isNotEmpty(dictDataTops)) +// { +// return dictDataTops; +// } + List dictDatas = dictDataMapper.selectDictDataByType(dictType); if (StringUtils.isNotEmpty(dictDatas)) { - return dictDatas; - } - dictDatas = dictDataMapper.selectDictDataByType(dictType); - if (StringUtils.isNotEmpty(dictDatas)) - { - DictUtils.setDictCache(dictType, dictDatas); - return dictDatas; + //先查询父类字典数据 + List dictParentDatas = dictDatas.stream().filter(e->e.getDictParentCode().longValue() == -1L).toList(); + if(CollectionUtil.isNotEmpty(dictParentDatas)){ + //递归查询子集 + for(SysDictData dictData : dictParentDatas){ + //查询对应的子级数据 + getChildrenDictData(dictDatas,dictData); + } + } +// DictUtils.setDictCache(dictType, dictParentDatas); + return dictParentDatas; } return null; } + /** + * 查询子级字典数据 + * @param dictDatas + * @param dictParentData + */ + private void getChildrenDictData(List dictDatas,SysDictData dictParentData){ + List dictChildrenDatas = dictDatas.stream(). + filter(e->e.getDictParentCode().longValue() == dictParentData.getDictCode().longValue()).toList(); + if(CollectionUtil.isNotEmpty(dictChildrenDatas)){ + for(SysDictData dictChildData : dictChildrenDatas){ + getChildrenDictData(dictDatas,dictChildData); + } + dictParentData.setChildrenDictData(dictChildrenDatas); + } + } + + /** * 根据字典类型ID查询信息 * diff --git a/vetti-system/src/main/resources/mapper/system/SysDictDataMapper.xml b/vetti-system/src/main/resources/mapper/system/SysDictDataMapper.xml index 6ab9190..37dde18 100644 --- a/vetti-system/src/main/resources/mapper/system/SysDictDataMapper.xml +++ b/vetti-system/src/main/resources/mapper/system/SysDictDataMapper.xml @@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -21,13 +22,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark + select dict_code, dict_parent_code,dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark from sys_dict_data + + AND dict_parent_code = #{dictParentCode} + AND dict_type = #{dictType}