优化
This commit is contained in:
@@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.tik.enums.AiModelTypeEnum;
|
||||
import cn.iocoder.yudao.module.tik.enums.AiPlatformEnum;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiagent.dal.AiAgentDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiagent.service.AiAgentService;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.points.service.PointsService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -63,7 +63,7 @@ public class DifyServiceImpl implements DifyService {
|
||||
AiModelTypeEnum modelTypeEnum = "standard".equals(reqVO.getModelMode())
|
||||
? AiModelTypeEnum.DIFY_WRITING_STANDARD
|
||||
: AiModelTypeEnum.DIFY_WRITING_PRO;
|
||||
AiModelConfigDO config = pointsService.getConfig(
|
||||
AiServiceConfigDO config = pointsService.getConfig(
|
||||
AiPlatformEnum.DIFY.getPlatform(),
|
||||
modelTypeEnum.getModelCode());
|
||||
|
||||
@@ -161,7 +161,7 @@ public class DifyServiceImpl implements DifyService {
|
||||
AiModelTypeEnum modelTypeEnum = "forecast_pro".equals(reqVO.getModelType())
|
||||
? AiModelTypeEnum.FORECAST_PRO
|
||||
: AiModelTypeEnum.FORECAST_STANDARD;
|
||||
AiModelConfigDO config = pointsService.getConfig(
|
||||
AiServiceConfigDO config = pointsService.getConfig(
|
||||
AiPlatformEnum.DIFY.getPlatform(),
|
||||
modelTypeEnum.getModelCode());
|
||||
|
||||
@@ -277,7 +277,7 @@ public class DifyServiceImpl implements DifyService {
|
||||
}
|
||||
|
||||
// 获取积分配置(使用标准模式的 API Key)
|
||||
AiModelConfigDO config = pointsService.getConfig(
|
||||
AiServiceConfigDO config = pointsService.getConfig(
|
||||
AiPlatformEnum.DIFY.getPlatform(),
|
||||
AiModelTypeEnum.DIFY_WRITING_STANDARD.getModelCode());
|
||||
|
||||
@@ -296,7 +296,7 @@ public class DifyServiceImpl implements DifyService {
|
||||
}
|
||||
|
||||
// 获取积分配置(使用标准模式的 API Key)
|
||||
AiModelConfigDO config = pointsService.getConfig(
|
||||
AiServiceConfigDO config = pointsService.getConfig(
|
||||
AiPlatformEnum.DIFY.getPlatform(),
|
||||
AiModelTypeEnum.DIFY_WRITING_STANDARD.getModelCode());
|
||||
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.service.AiApplicationService;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationRespVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationSaveReqVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - AI应用功能")
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/muye/ai-application")
|
||||
@Validated
|
||||
public class AiApplicationController {
|
||||
|
||||
@Resource
|
||||
private AiApplicationService aiApplicationService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建AI应用功能")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:create')")
|
||||
public CommonResult<Long> createAiApplication(@Valid @RequestBody AiApplicationSaveReqVO createReqVO) {
|
||||
return success(aiApplicationService.createAiApplication(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新AI应用功能")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:update')")
|
||||
public CommonResult<Boolean> updateAiApplication(@Valid @RequestBody AiApplicationSaveReqVO updateReqVO) {
|
||||
aiApplicationService.updateAiApplication(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除AI应用功能")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:delete')")
|
||||
public CommonResult<Boolean> deleteAiApplication(@RequestParam("id") Long id) {
|
||||
aiApplicationService.deleteAiApplication(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除AI应用功能")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:delete')")
|
||||
public CommonResult<Boolean> deleteAiApplicationList(@RequestParam("ids") List<Long> ids) {
|
||||
aiApplicationService.deleteAiApplicationListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得AI应用功能")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:query')")
|
||||
public CommonResult<AiApplicationRespVO> getAiApplication(@RequestParam("id") Long id) {
|
||||
AiApplicationDO aiApplication = aiApplicationService.getAiApplication(id);
|
||||
return success(BeanUtils.toBean(aiApplication, AiApplicationRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得AI应用功能分页")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:query')")
|
||||
public CommonResult<PageResult<AiApplicationRespVO>> getAiApplicationPage(@Valid AiApplicationPageReqVO pageReqVO) {
|
||||
PageResult<AiApplicationDO> pageResult = aiApplicationService.getAiApplicationPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, AiApplicationRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出AI应用功能 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-application:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportAiApplicationExcel(@Valid AiApplicationPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<AiApplicationDO> list = aiApplicationService.getAiApplicationPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "AI应用功能.xls", "数据", AiApplicationRespVO.class,
|
||||
BeanUtils.toBean(list, AiApplicationRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.dal;
|
||||
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* AI应用功能 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("muye_ai_application")
|
||||
@KeySequence("muye_ai_application_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AiApplicationDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 应用名称
|
||||
*/
|
||||
private String appName;
|
||||
/**
|
||||
* 第三方API秘钥
|
||||
*/
|
||||
private String apiKey;
|
||||
/**
|
||||
* 单位消耗积分
|
||||
*/
|
||||
private Integer consumePoints;
|
||||
/**
|
||||
* 消耗单位(time-时长 count-次数)
|
||||
*/
|
||||
private String unitType;
|
||||
/**
|
||||
* 单位值(如:1min、20次)
|
||||
*/
|
||||
private String unitValue;
|
||||
/**
|
||||
* 状态(0-禁用 1-启用)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.mapper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* AI应用功能 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AiApplicationMapper extends BaseMapperX<AiApplicationDO> {
|
||||
|
||||
default PageResult<AiApplicationDO> selectPage(AiApplicationPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AiApplicationDO>()
|
||||
.eqIfPresent(AiApplicationDO::getAppId, reqVO.getAppId())
|
||||
.likeIfPresent(AiApplicationDO::getAppName, reqVO.getAppName())
|
||||
.eqIfPresent(AiApplicationDO::getApiKey, reqVO.getApiKey())
|
||||
.eqIfPresent(AiApplicationDO::getConsumePoints, reqVO.getConsumePoints())
|
||||
.eqIfPresent(AiApplicationDO::getUnitType, reqVO.getUnitType())
|
||||
.eqIfPresent(AiApplicationDO::getUnitValue, reqVO.getUnitValue())
|
||||
.eqIfPresent(AiApplicationDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(AiApplicationDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(AiApplicationDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(AiApplicationDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* AI应用功能 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface AiApplicationService {
|
||||
|
||||
/**
|
||||
* 创建AI应用功能
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createAiApplication(@Valid AiApplicationSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新AI应用功能
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateAiApplication(@Valid AiApplicationSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除AI应用功能
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteAiApplication(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除AI应用功能
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteAiApplicationListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得AI应用功能
|
||||
*
|
||||
* @param id 编号
|
||||
* @return AI应用功能
|
||||
*/
|
||||
AiApplicationDO getAiApplication(Long id);
|
||||
|
||||
/**
|
||||
* 获得AI应用功能分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return AI应用功能分页
|
||||
*/
|
||||
PageResult<AiApplicationDO> getAiApplicationPage(AiApplicationPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.dal.AiApplicationDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.mapper.AiApplicationMapper;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiapplication.vo.AiApplicationSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* AI应用功能 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AiApplicationServiceImpl implements AiApplicationService {
|
||||
|
||||
@Resource
|
||||
private AiApplicationMapper aiApplicationMapper;
|
||||
|
||||
@Override
|
||||
public Long createAiApplication(AiApplicationSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
AiApplicationDO aiApplication = BeanUtils.toBean(createReqVO, AiApplicationDO.class);
|
||||
aiApplicationMapper.insert(aiApplication);
|
||||
|
||||
// 返回
|
||||
return aiApplication.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAiApplication(AiApplicationSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateAiApplicationExists(updateReqVO.getId());
|
||||
// 更新
|
||||
AiApplicationDO updateObj = BeanUtils.toBean(updateReqVO, AiApplicationDO.class);
|
||||
aiApplicationMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAiApplication(Long id) {
|
||||
// 校验存在
|
||||
validateAiApplicationExists(id);
|
||||
// 删除
|
||||
aiApplicationMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAiApplicationListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
aiApplicationMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateAiApplicationExists(Long id) {
|
||||
if (aiApplicationMapper.selectById(id) == null) {
|
||||
throw exception(new ErrorCode(1004, "AI应用功能不存在"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiApplicationDO getAiApplication(Long id) {
|
||||
return aiApplicationMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AiApplicationDO> getAiApplicationPage(AiApplicationPageReqVO pageReqVO) {
|
||||
return aiApplicationMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - AI应用功能分页 Request VO")
|
||||
@Data
|
||||
public class AiApplicationPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "应用ID", example = "6241")
|
||||
private String appId;
|
||||
|
||||
@Schema(description = "应用名称", example = "芋艿")
|
||||
private String appName;
|
||||
|
||||
@Schema(description = "第三方API秘钥")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "单位消耗积分")
|
||||
private Integer consumePoints;
|
||||
|
||||
@Schema(description = "消耗单位(time-时长 count-次数)", example = "1")
|
||||
private String unitType;
|
||||
|
||||
@Schema(description = "单位值(如:1min、20次)")
|
||||
private String unitValue;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.idev.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - AI应用功能 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class AiApplicationRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "5521")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "应用ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6241")
|
||||
@ExcelProperty("应用ID")
|
||||
private String appId;
|
||||
|
||||
@Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("应用名称")
|
||||
private String appName;
|
||||
|
||||
@Schema(description = "第三方API秘钥", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("第三方API秘钥")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "单位消耗积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("单位消耗积分")
|
||||
private Integer consumePoints;
|
||||
|
||||
@Schema(description = "消耗单位(time-时长 count-次数)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("消耗单位(time-时长 count-次数)")
|
||||
private String unitType;
|
||||
|
||||
@Schema(description = "单位值(如:1min、20次)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("单位值(如:1min、20次)")
|
||||
private String unitValue;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("状态(0-禁用 1-启用)")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiapplication.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - AI应用功能新增/修改 Request VO")
|
||||
@Data
|
||||
public class AiApplicationSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "5521")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "应用ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6241")
|
||||
@NotEmpty(message = "应用ID不能为空")
|
||||
private String appId;
|
||||
|
||||
@Schema(description = "应用名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "应用名称不能为空")
|
||||
private String appName;
|
||||
|
||||
@Schema(description = "第三方API秘钥", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "第三方API秘钥不能为空")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "单位消耗积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "单位消耗积分不能为空")
|
||||
private Integer consumePoints;
|
||||
|
||||
@Schema(description = "消耗单位(time-时长 count-次数)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "消耗单位(time-时长 count-次数)不能为空")
|
||||
private String unitType;
|
||||
|
||||
@Schema(description = "单位值(如:1min、20次)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "单位值(如:1min、20次)不能为空")
|
||||
private String unitValue;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态(0-禁用 1-启用)不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigRespVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigSaveReqVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.service.AiModelConfigService;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
@Tag(name = "管理后台 - AI模型配置")
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/muye/ai-model-config")
|
||||
@Validated
|
||||
public class AiModelConfigController {
|
||||
|
||||
@Resource
|
||||
private AiModelConfigService aiModelConfigService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建AI模型配置")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:create')")
|
||||
public CommonResult<Long> createAiModelConfig(@Valid @RequestBody AiModelConfigSaveReqVO createReqVO) {
|
||||
return success(aiModelConfigService.createAiModelConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新AI模型配置")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:update')")
|
||||
public CommonResult<Boolean> updateAiModelConfig(@Valid @RequestBody AiModelConfigSaveReqVO updateReqVO) {
|
||||
aiModelConfigService.updateAiModelConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除AI模型配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:delete')")
|
||||
public CommonResult<Boolean> deleteAiModelConfig(@RequestParam("id") Long id) {
|
||||
aiModelConfigService.deleteAiModelConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除AI模型配置")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:delete')")
|
||||
public CommonResult<Boolean> deleteAiModelConfigList(@RequestParam("ids") List<Long> ids) {
|
||||
aiModelConfigService.deleteAiModelConfigListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得AI模型配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:query')")
|
||||
public CommonResult<AiModelConfigRespVO> getAiModelConfig(@RequestParam("id") Long id) {
|
||||
AiModelConfigDO aiModelConfig = aiModelConfigService.getAiModelConfig(id);
|
||||
return success(BeanUtils.toBean(aiModelConfig, AiModelConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得AI模型配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:query')")
|
||||
public CommonResult<PageResult<AiModelConfigRespVO>> getAiModelConfigPage(@Valid AiModelConfigPageReqVO pageReqVO) {
|
||||
PageResult<AiModelConfigDO> pageResult = aiModelConfigService.getAiModelConfigPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, AiModelConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出AI模型配置 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportAiModelConfigExcel(@Valid AiModelConfigPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<AiModelConfigDO> list = aiModelConfigService.getAiModelConfigPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "AI模型配置.xls", "数据", AiModelConfigRespVO.class,
|
||||
BeanUtils.toBean(list, AiModelConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list-enabled")
|
||||
@Operation(summary = "获取所有启用的模型配置列表(前端积分显示用)")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-model-config:query')")
|
||||
public CommonResult<Map<String, List<AiModelConfigService.ModelConfigSimpleVO>>> getEnabledModelConfigList() {
|
||||
return success(aiModelConfigService.getEnabledModelConfigList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* AI模型配置 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AiModelConfigMapper extends BaseMapperX<AiModelConfigDO> {
|
||||
|
||||
default PageResult<AiModelConfigDO> selectPage(AiModelConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AiModelConfigDO>()
|
||||
.likeIfPresent(AiModelConfigDO::getModelName, reqVO.getModelName())
|
||||
.eqIfPresent(AiModelConfigDO::getModelCode, reqVO.getModelCode())
|
||||
.eqIfPresent(AiModelConfigDO::getPlatform, reqVO.getPlatform())
|
||||
.eqIfPresent(AiModelConfigDO::getApiKey, reqVO.getApiKey())
|
||||
.eqIfPresent(AiModelConfigDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(AiModelConfigDO::getModelType, reqVO.getModelType())
|
||||
.eqIfPresent(AiModelConfigDO::getConsumePoints, reqVO.getConsumePoints())
|
||||
.eqIfPresent(AiModelConfigDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(AiModelConfigDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(AiModelConfigDO::getId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据平台和模型标识查询配置
|
||||
*/
|
||||
default AiModelConfigDO selectByPlatformAndModelCode(String platform, String modelCode) {
|
||||
return selectOne(new LambdaQueryWrapperX<AiModelConfigDO>()
|
||||
.eq(AiModelConfigDO::getPlatform, platform)
|
||||
.eq(AiModelConfigDO::getModelCode, modelCode)
|
||||
.eq(AiModelConfigDO::getStatus, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有启用的模型配置
|
||||
*/
|
||||
default List<AiModelConfigDO> selectEnabledList() {
|
||||
return selectList(new LambdaQueryWrapperX<AiModelConfigDO>()
|
||||
.eq(AiModelConfigDO::getStatus, 1)
|
||||
.orderByAsc(AiModelConfigDO::getPlatform, AiModelConfigDO::getModelCode));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.service;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* AI模型配置 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface AiModelConfigService {
|
||||
|
||||
/**
|
||||
* 创建AI模型配置
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createAiModelConfig(@Valid AiModelConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新AI模型配置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateAiModelConfig(@Valid AiModelConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除AI模型配置
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteAiModelConfig(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除AI模型配置
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteAiModelConfigListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得AI模型配置
|
||||
*
|
||||
* @param id 编号
|
||||
* @return AI模型配置
|
||||
*/
|
||||
AiModelConfigDO getAiModelConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获得AI模型配置分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return AI模型配置分页
|
||||
*/
|
||||
PageResult<AiModelConfigDO> getAiModelConfigPage(AiModelConfigPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取所有启用的模型配置列表(前端积分显示用)
|
||||
*
|
||||
* @return 模型配置列表(按平台分组)
|
||||
*/
|
||||
Map<String, List<ModelConfigSimpleVO>> getEnabledModelConfigList();
|
||||
|
||||
/**
|
||||
* 启用的模型配置简单VO(用于前端显示)
|
||||
*/
|
||||
@Data
|
||||
class ModelConfigSimpleVO {
|
||||
private String modelCode;
|
||||
private String modelName;
|
||||
private Integer consumePoints;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper.AiModelConfigMapper;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo.AiModelConfigSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* AI模型配置 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AiModelConfigServiceImpl implements AiModelConfigService {
|
||||
|
||||
@Resource
|
||||
private AiModelConfigMapper aiModelConfigMapper;
|
||||
|
||||
@Override
|
||||
public Long createAiModelConfig(AiModelConfigSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
AiModelConfigDO aiModelConfig = BeanUtils.toBean(createReqVO, AiModelConfigDO.class);
|
||||
aiModelConfigMapper.insert(aiModelConfig);
|
||||
|
||||
// 返回
|
||||
return aiModelConfig.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAiModelConfig(AiModelConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateAiModelConfigExists(updateReqVO.getId());
|
||||
// 更新
|
||||
AiModelConfigDO updateObj = BeanUtils.toBean(updateReqVO, AiModelConfigDO.class);
|
||||
aiModelConfigMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAiModelConfig(Long id) {
|
||||
// 校验存在
|
||||
validateAiModelConfigExists(id);
|
||||
// 删除
|
||||
aiModelConfigMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAiModelConfigListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
aiModelConfigMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateAiModelConfigExists(Long id) {
|
||||
if (aiModelConfigMapper.selectById(id) == null) {
|
||||
throw exception(new ErrorCode(1004, "AI模型配置不存在"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiModelConfigDO getAiModelConfig(Long id) {
|
||||
return aiModelConfigMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AiModelConfigDO> getAiModelConfigPage(AiModelConfigPageReqVO pageReqVO) {
|
||||
return aiModelConfigMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<ModelConfigSimpleVO>> getEnabledModelConfigList() {
|
||||
List<AiModelConfigDO> configList = aiModelConfigMapper.selectEnabledList();
|
||||
Map<String, List<ModelConfigSimpleVO>> result = new HashMap<>();
|
||||
for (AiModelConfigDO config : configList) {
|
||||
ModelConfigSimpleVO simpleVO = new ModelConfigSimpleVO();
|
||||
simpleVO.setModelCode(config.getModelCode());
|
||||
simpleVO.setModelName(config.getModelName());
|
||||
simpleVO.setConsumePoints(config.getConsumePoints());
|
||||
result.computeIfAbsent(config.getPlatform(), k -> new ArrayList<>()).add(simpleVO);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigRespVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigSaveReqVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service.AiServiceConfigService;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
@Tag(name = "管理后台 - AI第三方服务配置")
|
||||
@RestController
|
||||
@RequestMapping("/admin-api/muye/ai-service-config")
|
||||
@Validated
|
||||
public class AiServiceConfigController {
|
||||
|
||||
@Resource
|
||||
private AiServiceConfigService aiServiceConfigService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建AI服务配置")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:create')")
|
||||
public CommonResult<Long> createAiServiceConfig(@Valid @RequestBody AiServiceConfigSaveReqVO createReqVO) {
|
||||
return success(aiServiceConfigService.createAiServiceConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新AI服务配置")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:update')")
|
||||
public CommonResult<Boolean> updateAiServiceConfig(@Valid @RequestBody AiServiceConfigSaveReqVO updateReqVO) {
|
||||
aiServiceConfigService.updateAiServiceConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除AI服务配置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:delete')")
|
||||
public CommonResult<Boolean> deleteAiServiceConfig(@RequestParam("id") Long id) {
|
||||
aiServiceConfigService.deleteAiServiceConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除AI服务配置")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:delete')")
|
||||
public CommonResult<Boolean> deleteAiServiceConfigList(@RequestParam("ids") List<Long> ids) {
|
||||
aiServiceConfigService.deleteAiServiceConfigListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得AI服务配置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:query')")
|
||||
public CommonResult<AiServiceConfigRespVO> getAiServiceConfig(@RequestParam("id") Long id) {
|
||||
AiServiceConfigDO aiServiceConfig = aiServiceConfigService.getAiServiceConfig(id);
|
||||
return success(BeanUtils.toBean(aiServiceConfig, AiServiceConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得AI服务配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:query')")
|
||||
public CommonResult<PageResult<AiServiceConfigRespVO>> getAiServiceConfigPage(@Valid AiServiceConfigPageReqVO pageReqVO) {
|
||||
PageResult<AiServiceConfigDO> pageResult = aiServiceConfigService.getAiServiceConfigPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, AiServiceConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出AI服务配置 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportAiServiceConfigExcel(@Valid AiServiceConfigPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<AiServiceConfigDO> list = aiServiceConfigService.getAiServiceConfigPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "AI服务配置.xls", "数据", AiServiceConfigRespVO.class,
|
||||
BeanUtils.toBean(list, AiServiceConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list-enabled")
|
||||
@Operation(summary = "获取所有启用的服务配置列表(前端积分显示用)")
|
||||
@PreAuthorize("@ss.hasPermission('muye:ai-service-config:query')")
|
||||
public CommonResult<Map<String, List<AiServiceConfigService.ServiceConfigSimpleVO>>> getEnabledServiceConfigList() {
|
||||
return success(aiServiceConfigService.getEnabledServiceConfigList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig;
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.service.AiModelConfigService;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service.AiServiceConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -16,21 +16,21 @@ import java.util.Map;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 用户 App - AI模型配置
|
||||
* 用户 App - AI第三方服务配置
|
||||
*/
|
||||
@Tag(name = "用户 App - AI模型配置")
|
||||
@Tag(name = "用户 App - AI第三方服务配置")
|
||||
@RestController
|
||||
@RequestMapping("/api/tik/ai-model-config")
|
||||
@RequestMapping("/api/tik/ai-service-config")
|
||||
@Validated
|
||||
public class AppAiModelConfigController {
|
||||
public class AppAiServiceConfigController {
|
||||
|
||||
@Resource
|
||||
private AiModelConfigService aiModelConfigService;
|
||||
private AiServiceConfigService aiServiceConfigService;
|
||||
|
||||
@GetMapping("/list-enabled")
|
||||
@Operation(summary = "获取所有启用的模型配置列表(前端积分显示用)")
|
||||
public CommonResult<Map<String, List<AiModelConfigService.ModelConfigSimpleVO>>> getEnabledModelConfigList() {
|
||||
return success(aiModelConfigService.getEnabledModelConfigList());
|
||||
@Operation(summary = "获取所有启用的服务配置列表(前端积分显示用)")
|
||||
public CommonResult<Map<String, List<AiServiceConfigService.ServiceConfigSimpleVO>>> getEnabledServiceConfigList() {
|
||||
return success(aiServiceConfigService.getEnabledServiceConfigList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal;
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal;
|
||||
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* AI模型配置 DO
|
||||
* AI第三方服务配置 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("muye_ai_model_config")
|
||||
@KeySequence("muye_ai_model_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@TableName("muye_ai_service_config")
|
||||
@KeySequence("muye_ai_service_config_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AiModelConfigDO extends BaseDO {
|
||||
public class AiServiceConfigDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
@@ -25,13 +25,13 @@ public class AiModelConfigDO extends BaseDO {
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 模型名称
|
||||
* 服务名称
|
||||
*/
|
||||
private String modelName;
|
||||
private String serviceName;
|
||||
/**
|
||||
* 模型标识/编码
|
||||
* 服务标识
|
||||
*/
|
||||
private String modelCode;
|
||||
private String serviceCode;
|
||||
/**
|
||||
* 所属平台
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ public class AiModelConfigDO extends BaseDO {
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 模型类型(image-图像 text-文本 video-视频 audio-音频)
|
||||
* 服务类型(image-图像 text-文本 video-视频 audio-音频)
|
||||
*/
|
||||
private String modelType;
|
||||
/**
|
||||
@@ -57,5 +57,4 @@ public class AiModelConfigDO extends BaseDO {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* AI第三方服务配置 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface AiServiceConfigMapper extends BaseMapperX<AiServiceConfigDO> {
|
||||
|
||||
default PageResult<AiServiceConfigDO> selectPage(AiServiceConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<AiServiceConfigDO>()
|
||||
.likeIfPresent(AiServiceConfigDO::getServiceName, reqVO.getServiceName())
|
||||
.eqIfPresent(AiServiceConfigDO::getServiceCode, reqVO.getServiceCode())
|
||||
.eqIfPresent(AiServiceConfigDO::getPlatform, reqVO.getPlatform())
|
||||
.eqIfPresent(AiServiceConfigDO::getApiKey, reqVO.getApiKey())
|
||||
.eqIfPresent(AiServiceConfigDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(AiServiceConfigDO::getModelType, reqVO.getModelType())
|
||||
.eqIfPresent(AiServiceConfigDO::getConsumePoints, reqVO.getConsumePoints())
|
||||
.eqIfPresent(AiServiceConfigDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(AiServiceConfigDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(AiServiceConfigDO::getId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据平台和服务标识查询配置
|
||||
*/
|
||||
default AiServiceConfigDO selectByPlatformAndServiceCode(String platform, String serviceCode) {
|
||||
return selectOne(new LambdaQueryWrapperX<AiServiceConfigDO>()
|
||||
.eq(AiServiceConfigDO::getPlatform, platform)
|
||||
.eq(AiServiceConfigDO::getServiceCode, serviceCode)
|
||||
.eq(AiServiceConfigDO::getStatus, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有启用的服务配置
|
||||
*/
|
||||
default List<AiServiceConfigDO> selectEnabledList() {
|
||||
return selectList(new LambdaQueryWrapperX<AiServiceConfigDO>()
|
||||
.eq(AiServiceConfigDO::getStatus, 1)
|
||||
.orderByAsc(AiServiceConfigDO::getPlatform, AiServiceConfigDO::getServiceCode));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.Data;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigSaveReqVO;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* AI第三方服务配置 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface AiServiceConfigService {
|
||||
|
||||
/**
|
||||
* 创建AI服务配置
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createAiServiceConfig(@Valid AiServiceConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新AI服务配置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateAiServiceConfig(@Valid AiServiceConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除AI服务配置
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteAiServiceConfig(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除AI服务配置
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteAiServiceConfigListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得AI服务配置
|
||||
*
|
||||
* @param id 编号
|
||||
* @return AI服务配置
|
||||
*/
|
||||
AiServiceConfigDO getAiServiceConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获得AI服务配置分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return AI服务配置分页
|
||||
*/
|
||||
PageResult<AiServiceConfigDO> getAiServiceConfigPage(AiServiceConfigPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获取所有启用的服务配置列表(前端积分显示用)
|
||||
*
|
||||
* @return 服务配置列表(按平台分组)
|
||||
*/
|
||||
Map<String, List<ServiceConfigSimpleVO>> getEnabledServiceConfigList();
|
||||
|
||||
/**
|
||||
* 启用的服务配置简单VO(用于前端显示)
|
||||
*/
|
||||
@Data
|
||||
class ServiceConfigSimpleVO {
|
||||
private String serviceCode;
|
||||
private String serviceName;
|
||||
private Integer consumePoints;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper.AiServiceConfigMapper;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo.AiServiceConfigSaveReqVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* AI第三方服务配置 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AiServiceConfigServiceImpl implements AiServiceConfigService {
|
||||
|
||||
@Resource
|
||||
private AiServiceConfigMapper aiServiceConfigMapper;
|
||||
|
||||
@Override
|
||||
public Long createAiServiceConfig(AiServiceConfigSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
AiServiceConfigDO aiServiceConfig = BeanUtils.toBean(createReqVO, AiServiceConfigDO.class);
|
||||
aiServiceConfigMapper.insert(aiServiceConfig);
|
||||
|
||||
// 返回
|
||||
return aiServiceConfig.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAiServiceConfig(AiServiceConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateAiServiceConfigExists(updateReqVO.getId());
|
||||
// 更新
|
||||
AiServiceConfigDO updateObj = BeanUtils.toBean(updateReqVO, AiServiceConfigDO.class);
|
||||
aiServiceConfigMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAiServiceConfig(Long id) {
|
||||
// 校验存在
|
||||
validateAiServiceConfigExists(id);
|
||||
// 删除
|
||||
aiServiceConfigMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAiServiceConfigListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
aiServiceConfigMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateAiServiceConfigExists(Long id) {
|
||||
if (aiServiceConfigMapper.selectById(id) == null) {
|
||||
throw exception(new ErrorCode(1004, "AI服务配置不存在"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiServiceConfigDO getAiServiceConfig(Long id) {
|
||||
return aiServiceConfigMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<AiServiceConfigDO> getAiServiceConfigPage(AiServiceConfigPageReqVO pageReqVO) {
|
||||
return aiServiceConfigMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<ServiceConfigSimpleVO>> getEnabledServiceConfigList() {
|
||||
List<AiServiceConfigDO> configList = aiServiceConfigMapper.selectEnabledList();
|
||||
Map<String, List<ServiceConfigSimpleVO>> result = new HashMap<>();
|
||||
for (AiServiceConfigDO config : configList) {
|
||||
ServiceConfigSimpleVO simpleVO = new ServiceConfigSimpleVO();
|
||||
simpleVO.setServiceCode(config.getServiceCode());
|
||||
simpleVO.setServiceName(config.getServiceName());
|
||||
simpleVO.setConsumePoints(config.getConsumePoints());
|
||||
result.computeIfAbsent(config.getPlatform(), k -> new ArrayList<>()).add(simpleVO);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo;
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -8,16 +8,16 @@ import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - AI模型配置分页 Request VO")
|
||||
@Schema(description = "管理后台 - AI第三方服务配置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AiModelConfigPageReqVO extends SortablePageParam {
|
||||
public class AiServiceConfigPageReqVO extends SortablePageParam {
|
||||
|
||||
@Schema(description = "模型名称", example = "李四")
|
||||
private String modelName;
|
||||
@Schema(description = "服务名称", example = "AI文案-Pro版")
|
||||
private String serviceName;
|
||||
|
||||
@Schema(description = "模型标识/编码")
|
||||
private String modelCode;
|
||||
@Schema(description = "服务标识")
|
||||
private String serviceCode;
|
||||
|
||||
@Schema(description = "所属平台")
|
||||
private String platform;
|
||||
@@ -25,20 +25,20 @@ public class AiModelConfigPageReqVO extends SortablePageParam {
|
||||
@Schema(description = "API秘钥")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", example = "2")
|
||||
@Schema(description = "状态(0-禁用 1-启用)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "模型类型(image-图像 text-文本 video-视频 audio-音频)", example = "2")
|
||||
@Schema(description = "服务类型(image-图像 text-文本 video-视频 audio-音频)", example = "text")
|
||||
private String modelType;
|
||||
|
||||
@Schema(description = "消耗积分")
|
||||
private Integer consumePoints;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@Schema(description = "备注", example = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo;
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.idev.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - AI模型配置 Response VO")
|
||||
@Schema(description = "管理后台 - AI第三方服务配置 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class AiModelConfigRespVO {
|
||||
public class AiServiceConfigRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29327")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("模型名称")
|
||||
private String modelName;
|
||||
@Schema(description = "服务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "AI文案-Pro版")
|
||||
@ExcelProperty("服务名称")
|
||||
private String serviceName;
|
||||
|
||||
@Schema(description = "模型标识/编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("模型标识/编码")
|
||||
private String modelCode;
|
||||
@Schema(description = "服务标识", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("服务标识")
|
||||
private String serviceCode;
|
||||
|
||||
@Schema(description = "所属平台", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("所属平台")
|
||||
@@ -30,19 +30,19 @@ public class AiModelConfigRespVO {
|
||||
@ExcelProperty("API秘钥")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("状态(0-禁用 1-启用)")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "模型类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("模型类型(image-图像 text-文本 video-视频 audio-音频)")
|
||||
@Schema(description = "服务类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "text")
|
||||
@ExcelProperty("服务类型")
|
||||
private String modelType;
|
||||
|
||||
@Schema(description = "消耗积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("消耗积分")
|
||||
private Integer consumePoints;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
|
||||
@Schema(description = "备注", example = "备注信息")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.aimodelconfig.vo;
|
||||
package cn.iocoder.yudao.module.tik.muye.aiserviceconfig.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - AI模型配置新增/修改 Request VO")
|
||||
@Schema(description = "管理后台 - AI第三方服务配置新增/修改 Request VO")
|
||||
@Data
|
||||
public class AiModelConfigSaveReqVO {
|
||||
public class AiServiceConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29327")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotEmpty(message = "模型名称不能为空")
|
||||
private String modelName;
|
||||
@Schema(description = "服务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "AI文案-Pro版")
|
||||
@NotEmpty(message = "服务名称不能为空")
|
||||
private String serviceName;
|
||||
|
||||
@Schema(description = "模型标识/编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "模型标识/编码不能为空")
|
||||
private String modelCode;
|
||||
@Schema(description = "服务标识", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "服务标识不能为空")
|
||||
private String serviceCode;
|
||||
|
||||
@Schema(description = "所属平台", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "所属平台不能为空")
|
||||
@@ -26,19 +26,19 @@ public class AiModelConfigSaveReqVO {
|
||||
@Schema(description = "API秘钥")
|
||||
private String apiKey;
|
||||
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@Schema(description = "状态(0-禁用 1-启用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "模型类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "模型类型不能为空")
|
||||
@Schema(description = "服务类型(image-图像 text-文本 video-视频 audio-音频)", requiredMode = Schema.RequiredMode.REQUIRED, example = "text")
|
||||
@NotEmpty(message = "服务类型不能为空")
|
||||
private String modelType;
|
||||
|
||||
@Schema(description = "消耗积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "消耗积分不能为空")
|
||||
private Integer consumePoints;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@Schema(description = "备注", example = "备注信息")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.tik.muye.points.service;
|
||||
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
|
||||
/**
|
||||
* 积分扣减公共服务
|
||||
@@ -12,11 +12,11 @@ public interface PointsService {
|
||||
/**
|
||||
* 获取积分配置
|
||||
*
|
||||
* @param platform 平台标识(dify/tikhub/voice/digital_human)
|
||||
* @param modelCode 模型标识
|
||||
* @param platform 平台标识(dify/tikhub/voice/digital_human)
|
||||
* @param serviceCode 服务标识
|
||||
* @return 积分配置
|
||||
*/
|
||||
AiModelConfigDO getConfig(String platform, String modelCode);
|
||||
AiServiceConfigDO getConfig(String platform, String serviceCode);
|
||||
|
||||
/**
|
||||
* 预检积分(余额不足抛异常)
|
||||
|
||||
@@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.tik.muye.points.service;
|
||||
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper.AiModelConfigMapper;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper.AiServiceConfigMapper;
|
||||
import cn.iocoder.yudao.module.tik.muye.memberuserprofile.dal.MemberUserProfileDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.memberuserprofile.mapper.MemberUserProfileMapper;
|
||||
import cn.iocoder.yudao.module.tik.muye.pointrecord.dal.PointRecordDO;
|
||||
@@ -37,7 +37,7 @@ public class PointsServiceImpl implements PointsService {
|
||||
private static final String STATUS_CANCELED = "canceled";
|
||||
|
||||
@Resource
|
||||
private AiModelConfigMapper aiModelConfigMapper;
|
||||
private AiServiceConfigMapper aiServiceConfigMapper;
|
||||
|
||||
@Resource
|
||||
private MemberUserProfileMapper memberUserProfileMapper;
|
||||
@@ -49,8 +49,8 @@ public class PointsServiceImpl implements PointsService {
|
||||
private MemberUserService memberUserService;
|
||||
|
||||
@Override
|
||||
public AiModelConfigDO getConfig(String platform, String modelCode) {
|
||||
AiModelConfigDO config = aiModelConfigMapper.selectByPlatformAndModelCode(platform, modelCode);
|
||||
public AiServiceConfigDO getConfig(String platform, String serviceCode) {
|
||||
AiServiceConfigDO config = aiServiceConfigMapper.selectByPlatformAndServiceCode(platform, serviceCode);
|
||||
if (config == null) {
|
||||
throw exception(POINTS_CONFIG_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.tik.tikhup.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.points.service.PointsService;
|
||||
import cn.iocoder.yudao.module.tik.tikhup.mapper.TikPromptMapper;
|
||||
import cn.iocoder.yudao.module.tik.tikhup.mapper.TikTokenMapper;
|
||||
@@ -94,7 +94,7 @@ public class TikHupServiceImpl implements TikHupService {
|
||||
// 2. 获取当前用户ID并预检积分
|
||||
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
||||
String userId = loginUserId != null ? loginUserId.toString() : "1";
|
||||
AiModelConfigDO config;
|
||||
AiServiceConfigDO config;
|
||||
try {
|
||||
config = pointsService.getConfig(PLATFORM_TIKHUB, MODEL_CODE_CRAWLER);
|
||||
pointsService.checkPoints(userId, config.getConsumePoints());
|
||||
|
||||
@@ -17,7 +17,7 @@ import cn.iocoder.yudao.module.tik.file.dal.dataobject.TikUserFileDO;
|
||||
import cn.iocoder.yudao.module.tik.file.dal.mysql.TikUserFileMapper;
|
||||
import cn.iocoder.yudao.module.tik.file.service.TikOssInitService;
|
||||
import cn.iocoder.yudao.module.tik.kling.dto.KlingLipSyncCreateResponse;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.points.service.PointsService;
|
||||
import cn.iocoder.yudao.module.tik.voice.dal.dataobject.TikDigitalHumanTaskDO;
|
||||
import cn.iocoder.yudao.module.tik.voice.dal.dataobject.TikUserVoiceDO;
|
||||
@@ -98,7 +98,7 @@ public class DigitalHumanTaskServiceImpl implements DigitalHumanTaskService {
|
||||
// 2. 积分预检和预扣
|
||||
String aiProvider = StrUtil.blankToDefault(reqVO.getAiProvider(), "302ai");
|
||||
String modelCode = "kling".equalsIgnoreCase(aiProvider) ? MODEL_CODE_KLING : MODEL_CODE_LATENTSYNC;
|
||||
AiModelConfigDO config = pointsService.getConfig(PLATFORM_DIGITAL_HUMAN, modelCode);
|
||||
AiServiceConfigDO config = pointsService.getConfig(PLATFORM_DIGITAL_HUMAN, modelCode);
|
||||
pointsService.checkPoints(userId.toString(), config.getConsumePoints());
|
||||
Long pendingRecordId = pointsService.createPendingDeduct(
|
||||
userId.toString(),
|
||||
|
||||
@@ -25,7 +25,7 @@ import cn.iocoder.yudao.module.tik.voice.client.VoiceCloneProvider;
|
||||
import cn.iocoder.yudao.module.tik.voice.client.VoiceCloneProviderFactory;
|
||||
import cn.iocoder.yudao.module.tik.voice.client.dto.VoiceTtsRequest;
|
||||
import cn.iocoder.yudao.module.tik.voice.client.dto.VoiceTtsResult;
|
||||
import cn.iocoder.yudao.module.tik.muye.aimodelconfig.dal.AiModelConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.aiserviceconfig.dal.AiServiceConfigDO;
|
||||
import cn.iocoder.yudao.module.tik.muye.points.service.PointsService;
|
||||
import cn.iocoder.yudao.module.tik.voice.dal.dataobject.TikUserVoiceDO;
|
||||
import cn.iocoder.yudao.module.tik.voice.dal.mysql.TikUserVoiceMapper;
|
||||
@@ -414,7 +414,7 @@ public class TikUserVoiceServiceImpl implements TikUserVoiceService {
|
||||
}
|
||||
|
||||
// 获取积分配置并预检(缓存未命中,需要实际调用 TTS)
|
||||
AiModelConfigDO ttsConfig = pointsService.getConfig(PLATFORM_VOICE, MODEL_CODE_TTS);
|
||||
AiServiceConfigDO ttsConfig = pointsService.getConfig(PLATFORM_VOICE, MODEL_CODE_TTS);
|
||||
pointsService.checkPoints(userId.toString(), ttsConfig.getConsumePoints());
|
||||
|
||||
// 使用 Provider 接口进行 TTS 合成(支持前端选择供应商,不传则使用默认)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.tik.muye.aimodelconfig.mapper.AiModelConfigMapper">
|
||||
<mapper namespace="cn.iocoder.yudao.module.tik.muye.aiserviceconfig.mapper.AiServiceConfigMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
Reference in New Issue
Block a user