From f326c5e676a16e6ea51435472b22f091b51db71a Mon Sep 17 00:00:00 2001 From: ire <931903008@qq.com> Date: Tue, 7 Jan 2025 17:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=BD=BF=E7=94=A8=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=97=B6=EF=BC=8C=E6=A8=A1=E6=9D=BF=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=87=8F=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/application/vo/ApplicationRespVO.java | 3 +++ .../admin/application/vo/ApplicationSaveReqVO.java | 3 +++ .../vo/PromptTemplatesPageReqVO.java | 4 ++++ .../prompttemplates/vo/PromptTemplatesRespVO.java | 7 +++---- .../vo/PromptTemplatesSaveReqVO.java | 3 +++ .../dal/dataobject/application/ApplicationDO.java | 2 ++ .../prompttemplates/PromptTemplatesDO.java | 2 ++ .../application/ApplicationServiceImpl.java | 14 ++++++++++++++ .../prompttemplates/PromptTemplatesService.java | 4 ++++ .../PromptTemplatesServiceImpl.java | 7 +++++-- 10 files changed, 43 insertions(+), 6 deletions(-) diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationRespVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationRespVO.java index 78ab429f0..78fb16439 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationRespVO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationRespVO.java @@ -82,6 +82,9 @@ public class ApplicationRespVO { @ExcelProperty("系统Prompt") private String prompt; + @Schema(description = "prompt模板id") + private Long promptId; + @Schema(description = "创建人id") private String creator; diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationSaveReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationSaveReqVO.java index 37c93d2d6..3263a17df 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationSaveReqVO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/application/vo/ApplicationSaveReqVO.java @@ -57,6 +57,9 @@ public class ApplicationSaveReqVO { @Schema(description = "系统Prompt") private String prompt; + @Schema(description = "prompt模板id") + private Long promptId; + @Schema(description = "创建人id") private String creator; diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesPageReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesPageReqVO.java index 2b1455f93..b9098455a 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesPageReqVO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesPageReqVO.java @@ -37,4 +37,8 @@ public class PromptTemplatesPageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; + @Schema(description = "使用量") + private Integer useCount; + + } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesRespVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesRespVO.java index e68072f91..0f40c7b44 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesRespVO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesRespVO.java @@ -48,10 +48,6 @@ public class PromptTemplatesRespVO { @Schema(description = "应用名称列表", example = "[1, 2, 3]") private List applicationNames; - @Schema(description = "使用量") - @ExcelProperty("使用量") - private int usedCount; - @Schema(description = "关联应用") @ExcelProperty("关联应用") private int applicationCount; @@ -75,4 +71,7 @@ public class PromptTemplatesRespVO { @Schema(description = "备份模板Id") private Long backupId; + @Schema(description = "使用量") + private Integer useCount; + } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesSaveReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesSaveReqVO.java index 5ddc6d5f5..e8a47c027 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesSaveReqVO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/prompttemplates/vo/PromptTemplatesSaveReqVO.java @@ -47,4 +47,7 @@ public class PromptTemplatesSaveReqVO { @Schema(description = "备份表id") private Long backupId; + + @Schema(description = "使用量") + private Integer useCount; } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/application/ApplicationDO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/application/ApplicationDO.java index 4771b9689..1854718e3 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/application/ApplicationDO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/application/ApplicationDO.java @@ -92,4 +92,6 @@ public class ApplicationDO extends BaseDO { */ private Integer appModelType; + private Long promptId; + } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/prompttemplates/PromptTemplatesDO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/prompttemplates/PromptTemplatesDO.java index 1ca2b641e..3d47c6996 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/prompttemplates/PromptTemplatesDO.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/prompttemplates/PromptTemplatesDO.java @@ -57,4 +57,6 @@ public class PromptTemplatesDO extends BaseDO { */ private Long backupId; + private Integer useCount; + } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/application/ApplicationServiceImpl.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/application/ApplicationServiceImpl.java index e2539f3d4..d9b6fac2a 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/application/ApplicationServiceImpl.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/application/ApplicationServiceImpl.java @@ -5,11 +5,14 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.llm.controller.admin.application.vo.ApplicationPageReqVO; import cn.iocoder.yudao.module.llm.controller.admin.application.vo.ApplicationRespVO; import cn.iocoder.yudao.module.llm.controller.admin.application.vo.ApplicationSaveReqVO; +import cn.iocoder.yudao.module.llm.controller.admin.prompttemplates.vo.PromptTemplatesRespVO; 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.prompttemplates.PromptTemplatesDO; import cn.iocoder.yudao.module.llm.dal.mysql.application.ApplicationMapper; import cn.iocoder.yudao.module.llm.dal.mysql.label.LabelMapper; import cn.iocoder.yudao.module.llm.service.label.LabelService; +import cn.iocoder.yudao.module.llm.service.prompttemplates.PromptTemplatesService; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -42,12 +45,23 @@ public class ApplicationServiceImpl implements ApplicationService { @Resource private LabelMapper labelMapper; + @Resource + private PromptTemplatesService promptTemplatesService; + @Override public Long createApplication(ApplicationSaveReqVO createReqVO) { // 插入 ApplicationDO application = BeanUtils.toBean(createReqVO, ApplicationDO.class); applicationMapper.insert(application); + + //prompt使用量+1 + Long promptId = application.getPromptId(); + PromptTemplatesRespVO promptTemplates = promptTemplatesService.getPromptTemplates(promptId); + PromptTemplatesDO promptTemplatesDO = new PromptTemplatesDO(); + promptTemplatesDO.setUseCount(promptTemplates.getUseCount() == null?1:promptTemplates.getUseCount() + 1); + promptTemplatesDO.setId(promptTemplates.getId()); + promptTemplatesService.updatePromptTemplatesById(promptTemplatesDO); // 返回 return application.getId(); } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesService.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesService.java index 426025bad..08ddb6c42 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesService.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesService.java @@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.*; import cn.iocoder.yudao.module.llm.controller.admin.prompttemplates.vo.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.llm.dal.dataobject.prompttemplates.PromptTemplatesDO; public interface PromptTemplatesService { Long createPromptTemplates(@Valid PromptTemplatesSaveReqVO createReqVO); @@ -22,4 +23,7 @@ public interface PromptTemplatesService { void backupPromptTemplates(@Valid PromptTemplatesSaveReqVO updateReqVO); void unbackupPromptTemplates(PromptTemplatesSaveReqVO updateReqVO); + + void updatePromptTemplatesById(@Valid PromptTemplatesDO promptTemplatesDO); + } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesServiceImpl.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesServiceImpl.java index 4985dc4d4..b27c901cf 100644 --- a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesServiceImpl.java +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/prompttemplates/PromptTemplatesServiceImpl.java @@ -245,8 +245,6 @@ public class PromptTemplatesServiceImpl implements PromptTemplatesService { } for(PromptTemplatesRespVO respVO : templatesRespList) { - // TODO 使用量查询暂时设置为0 - respVO.setUsedCount(0); try { List tagDOList = this.promptTemplatesTagsMapper .selectList("prompt_template_id", respVO.getId()); @@ -355,4 +353,9 @@ public class PromptTemplatesServiceImpl implements PromptTemplatesService { promptTemplatesDO.setId(updateReqVO.getId()); promptTemplatesMapper.updateById(promptTemplatesDO); } + + @Override + public void updatePromptTemplatesById(PromptTemplatesDO promptTemplatesDO) { + promptTemplatesMapper.updateById(promptTemplatesDO); + } }