prompt模板 标签,应用,回显

This commit is contained in:
ire 2025-01-03 19:29:13 +08:00
parent 89792d05fc
commit 7ba6ab3ed0
4 changed files with 45 additions and 3 deletions

View File

@ -39,9 +39,15 @@ public class PromptTemplatesRespVO {
@Schema(description = "标签Id列表", example = "[1, 2, 3]")
private List<String> tagIds;
@Schema(description = "标签名称列表", example = "[1, 2, 3]")
private List<String> tagNames;
@Schema(description = "应用Id列表", example = "[1, 2, 3]")
private List<String> applicationIds;
@Schema(description = "应用名称列表", example = "[1, 2, 3]")
private List<String> applicationNames;
@Schema(description = "使用量")
@ExcelProperty("使用量")
private int usedCount;

View File

@ -54,4 +54,6 @@ public interface ApplicationService {
List<ApplicationRespVO> getApplicationList(ApplicationPageReqVO pageReqVO);
List<ApplicationDO> getList();
}

View File

@ -143,4 +143,9 @@ public class ApplicationServiceImpl implements ApplicationService {
return result;
}
@Override
public List<ApplicationDO> getList() {
return applicationMapper.selectList();
}
}

View File

@ -2,12 +2,14 @@ package cn.iocoder.yudao.module.llm.service.prompttemplates;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.llm.controller.admin.prompttemplatesbackup.vo.PromptTemplatesBackupSaveReqVO;
import cn.iocoder.yudao.module.llm.dal.dataobject.application.ApplicationDO;
import cn.iocoder.yudao.module.llm.dal.dataobject.label.LabelDO;
import cn.iocoder.yudao.module.llm.dal.dataobject.prompttemplatesapplications.PromptTemplatesApplicationsDO;
import cn.iocoder.yudao.module.llm.dal.dataobject.prompttemplatesbackup.PromptTemplatesBackupDO;
import cn.iocoder.yudao.module.llm.dal.dataobject.prompttemplatestags.PromptTemplatesTagsDO;
import cn.iocoder.yudao.module.llm.dal.mysql.prompttemplatesapplications.PromptTemplatesApplicationsMapper;
import cn.iocoder.yudao.module.llm.dal.mysql.prompttemplatestags.PromptTemplatesTagsMapper;
import cn.iocoder.yudao.module.llm.service.application.ApplicationService;
import cn.iocoder.yudao.module.llm.service.label.LabelService;
import cn.iocoder.yudao.module.llm.service.prompttemplatesbackup.PromptTemplatesBackupService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
@ -48,6 +50,8 @@ public class PromptTemplatesServiceImpl implements PromptTemplatesService {
private LabelService labelService;
@Resource
private PromptTemplatesBackupService promptTemplatesBackupService;
@Resource
private ApplicationService applicationService;
@Override
public Long createPromptTemplates(PromptTemplatesSaveReqVO createReqVO) {
@ -226,6 +230,19 @@ public class PromptTemplatesServiceImpl implements PromptTemplatesService {
PageResult<PromptTemplatesDO> pageDoList = this.promptTemplatesMapper.selectPage(pageReqVO);
PageResult<PromptTemplatesRespVO> pageRespList = BeanUtils.toBean(pageDoList, PromptTemplatesRespVO.class);
List<PromptTemplatesRespVO> templatesRespList = pageRespList.getList();
List<LabelDO> labelList = labelService.getLabelList();
HashMap<Long,String> labelMap = new HashMap<>();
for (LabelDO labelDO : labelList) {
labelMap.put(labelDO.getId(),labelDO.getLabelName());
}
List<ApplicationDO> appList = applicationService.getList();
HashMap<Long,String> appMap = new HashMap<>();
for (ApplicationDO applicationDO : appList) {
appMap.put(applicationDO.getId(),applicationDO.getAppName());
}
for(PromptTemplatesRespVO respVO : templatesRespList) {
// TODO 使用量查询暂时设置为0
respVO.setUsedCount(0);
@ -236,16 +253,28 @@ public class PromptTemplatesServiceImpl implements PromptTemplatesService {
List<String> tagIds = tagDOList.stream()
.map(p->p.getTagId().toString())
.collect(Collectors.toList());
respVO.setTagIds(tagIds);
List<String> labelNameList = new ArrayList<>();
for (String tagId : tagIds) {
labelNameList.add(labelMap.get(Long.parseLong(tagId)));
}
// respVO.setTagIds(tagIds);
respVO.setTagNames(labelNameList);
}
} catch(Exception e) {
e.printStackTrace();
}
try {
Long applicationCount = this.promptTemplatesApplicationsMapper.selectCount(
List<PromptTemplatesApplicationsDO> applicationIds = this.promptTemplatesApplicationsMapper.selectList(
new QueryWrapper<PromptTemplatesApplicationsDO>()
.eq("prompt_template_id", respVO.getId()));
respVO.setApplicationCount(Integer.parseInt(applicationCount.toString()));
List<String> appNames = new ArrayList<>();
for (PromptTemplatesApplicationsDO applicationId : applicationIds) {
appNames.add(appMap.get(applicationId.getId()));
}
respVO.setApplicationCount(applicationIds.size());
respVO.setApplicationNames(appNames);
} catch(Exception e) {
e.printStackTrace();
}