应用使用模板时,模板使用量增加
This commit is contained in:
parent
d43c483cbd
commit
f326c5e676
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -48,10 +48,6 @@ public class PromptTemplatesRespVO {
|
||||
@Schema(description = "应用名称列表", example = "[1, 2, 3]")
|
||||
private List<String> 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;
|
||||
|
||||
}
|
||||
|
@ -47,4 +47,7 @@ public class PromptTemplatesSaveReqVO {
|
||||
|
||||
@Schema(description = "备份表id")
|
||||
private Long backupId;
|
||||
|
||||
@Schema(description = "使用量")
|
||||
private Integer useCount;
|
||||
}
|
||||
|
@ -92,4 +92,6 @@ public class ApplicationDO extends BaseDO {
|
||||
*/
|
||||
private Integer appModelType;
|
||||
|
||||
private Long promptId;
|
||||
|
||||
}
|
||||
|
@ -57,4 +57,6 @@ public class PromptTemplatesDO extends BaseDO {
|
||||
*/
|
||||
private Long backupId;
|
||||
|
||||
private Integer useCount;
|
||||
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -245,8 +245,6 @@ public class PromptTemplatesServiceImpl implements PromptTemplatesService {
|
||||
}
|
||||
|
||||
for(PromptTemplatesRespVO respVO : templatesRespList) {
|
||||
// TODO 使用量查询暂时设置为0
|
||||
respVO.setUsedCount(0);
|
||||
try {
|
||||
List<PromptTemplatesTagsDO> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user