diff --git a/yudao-module-llm/yudao-module-llm-api/src/main/java/cn/iocoder/yudao/module/llm/enums/ErrorCodeConstants.java b/yudao-module-llm/yudao-module-llm-api/src/main/java/cn/iocoder/yudao/module/llm/enums/ErrorCodeConstants.java index 320f073d0..9436e8c69 100644 --- a/yudao-module-llm/yudao-module-llm-api/src/main/java/cn/iocoder/yudao/module/llm/enums/ErrorCodeConstants.java +++ b/yudao-module-llm/yudao-module-llm-api/src/main/java/cn/iocoder/yudao/module/llm/enums/ErrorCodeConstants.java @@ -13,6 +13,10 @@ public interface ErrorCodeConstants { ErrorCode FINE_TUNING_TASK_NOT_EXISTS = new ErrorCode(10005, "微调任务不存在"); - ErrorCode APPLICATION_NOT_EXISTS = new ErrorCode(10005, "应用名称服务不存在"); + ErrorCode APPLICATION_NOT_EXISTS = new ErrorCode(10006, "应用名称服务不存在"); + + ErrorCode DATA_REFLUX_DATA_NOT_EXISTS = new ErrorCode(10007, "数据回流 —— 数据不存在"); + + ErrorCode DATA_REFLUX_CONFIG_NOT_EXISTS = new ErrorCode(10008, "数据回流不存在"); } diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/DataRefluxConfigController.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/DataRefluxConfigController.java new file mode 100644 index 000000000..91fc353cf --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/DataRefluxConfigController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig; + +import org.springframework.web.bind.annotation.*; +import javax.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 javax.validation.constraints.*; +import javax.validation.*; +import javax.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.*; + +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.vo.*; +import cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxconfig.DataRefluxConfigDO; +import cn.iocoder.yudao.module.llm.service.datarefluxconfig.DataRefluxConfigService; + +@Tag(name = "管理后台 - 数据回流配置") +@RestController +@RequestMapping("/llm/data-reflux-config") +@Validated +public class DataRefluxConfigController { + + @Resource + private DataRefluxConfigService dataRefluxConfigService; + + @PostMapping("/create") + @Operation(summary = "创建数据回流配置") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-config:create')") + public CommonResult createDataRefluxConfig(@Valid @RequestBody DataRefluxConfigSaveReqVO createReqVO) { + return success(dataRefluxConfigService.createDataRefluxConfig(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新数据回流配置") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-config:update')") + public CommonResult updateDataRefluxConfig(@Valid @RequestBody DataRefluxConfigSaveReqVO updateReqVO) { + dataRefluxConfigService.updateDataRefluxConfig(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除数据回流配置") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('llm:data-reflux-config:delete')") + public CommonResult deleteDataRefluxConfig(@RequestParam("id") Long id) { + dataRefluxConfigService.deleteDataRefluxConfig(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得数据回流配置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-config:query')") + public CommonResult getDataRefluxConfig(@RequestParam("id") Long id) { + DataRefluxConfigDO dataRefluxConfig = dataRefluxConfigService.getDataRefluxConfig(id); + return success(BeanUtils.toBean(dataRefluxConfig, DataRefluxConfigRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得数据回流配置分页") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-config:query')") + public CommonResult> getDataRefluxConfigPage(@Valid DataRefluxConfigPageReqVO pageReqVO) { + PageResult pageResult = dataRefluxConfigService.getDataRefluxConfigPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, DataRefluxConfigRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出数据回流配置 Excel") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-config:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDataRefluxConfigExcel(@Valid DataRefluxConfigPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = dataRefluxConfigService.getDataRefluxConfigPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "数据回流配置.xls", "数据", DataRefluxConfigRespVO.class, + BeanUtils.toBean(list, DataRefluxConfigRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigPageReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigPageReqVO.java new file mode 100644 index 000000000..617a1462a --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigPageReqVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.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 = "管理后台 - 数据回流配置分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DataRefluxConfigPageReqVO extends PageParam { + + @Schema(description = "模型服务ID", example = "2475") + private Long modelServiceId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigRespVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigRespVO.java new file mode 100644 index 000000000..f08891ddd --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigRespVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.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 com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 数据回流配置 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DataRefluxConfigRespVO { + + @Schema(description = "配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31011") + @ExcelProperty("配置ID") + private Long id; + + @Schema(description = "模型服务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2475") + @ExcelProperty("模型服务ID") + private Long modelServiceId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigSaveReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigSaveReqVO.java new file mode 100644 index 000000000..875e07013 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxconfig/vo/DataRefluxConfigSaveReqVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 数据回流配置新增/修改 Request VO") +@Data +public class DataRefluxConfigSaveReqVO { + + @Schema(description = "配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "31011") + private Long id; + + @Schema(description = "模型服务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2475") + @NotNull(message = "模型服务ID不能为空") + private Long modelServiceId; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/DataRefluxDataController.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/DataRefluxDataController.java new file mode 100644 index 000000000..6ca925490 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/DataRefluxDataController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata; + +import org.springframework.web.bind.annotation.*; +import javax.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 javax.validation.constraints.*; +import javax.validation.*; +import javax.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.*; + +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.vo.*; +import cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxdata.DataRefluxDataDO; +import cn.iocoder.yudao.module.llm.service.datarefluxdata.DataRefluxDataService; + +@Tag(name = "管理后台 - 数据回流 —— 数据") +@RestController +@RequestMapping("/llm/data-reflux-data") +@Validated +public class DataRefluxDataController { + + @Resource + private DataRefluxDataService dataRefluxDataService; + + @PostMapping("/create") + @Operation(summary = "创建数据回流 —— 数据") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-data:create')") + public CommonResult createDataRefluxData(@Valid @RequestBody DataRefluxDataSaveReqVO createReqVO) { + return success(dataRefluxDataService.createDataRefluxData(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新数据回流 —— 数据") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-data:update')") + public CommonResult updateDataRefluxData(@Valid @RequestBody DataRefluxDataSaveReqVO updateReqVO) { + dataRefluxDataService.updateDataRefluxData(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除数据回流 —— 数据") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('llm:data-reflux-data:delete')") + public CommonResult deleteDataRefluxData(@RequestParam("id") Long id) { + dataRefluxDataService.deleteDataRefluxData(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得数据回流 —— 数据") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-data:query')") + public CommonResult getDataRefluxData(@RequestParam("id") Long id) { + DataRefluxDataDO dataRefluxData = dataRefluxDataService.getDataRefluxData(id); + return success(BeanUtils.toBean(dataRefluxData, DataRefluxDataRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得数据回流 —— 数据分页") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-data:query')") + public CommonResult> getDataRefluxDataPage(@Valid DataRefluxDataPageReqVO pageReqVO) { + PageResult pageResult = dataRefluxDataService.getDataRefluxDataPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, DataRefluxDataRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出数据回流 —— 数据 Excel") + @PreAuthorize("@ss.hasPermission('llm:data-reflux-data:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDataRefluxDataExcel(@Valid DataRefluxDataPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = dataRefluxDataService.getDataRefluxDataPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "数据回流 —— 数据.xls", "数据", DataRefluxDataRespVO.class, + BeanUtils.toBean(list, DataRefluxDataRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataPageReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataPageReqVO.java new file mode 100644 index 000000000..9f15eed92 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataPageReqVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.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 = "管理后台 - 数据回流 —— 数据分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class DataRefluxDataPageReqVO extends PageParam { + + @Schema(description = "模型服务ID", example = "16823") + private Long modelServiceId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "system") + private String system; + + @Schema(description = "Prompt") + private String prompt; + + @Schema(description = "Response") + private String response; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataRespVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataRespVO.java new file mode 100644 index 000000000..9556c06f0 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataRespVO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.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 com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 数据回流 —— 数据 Response VO") +@Data +@ExcelIgnoreUnannotated +public class DataRefluxDataRespVO { + + @Schema(description = "配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11768") + @ExcelProperty("配置ID") + private Long id; + + @Schema(description = "模型服务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16823") + @ExcelProperty("模型服务ID") + private Long modelServiceId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "system") + @ExcelProperty("system") + private String system; + + @Schema(description = "Prompt") + @ExcelProperty("Prompt") + private String prompt; + + @Schema(description = "Response") + @ExcelProperty("Response") + private String response; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataSaveReqVO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataSaveReqVO.java new file mode 100644 index 000000000..20ad5ac6d --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/controller/admin/datarefluxdata/vo/DataRefluxDataSaveReqVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 数据回流 —— 数据新增/修改 Request VO") +@Data +public class DataRefluxDataSaveReqVO { + + @Schema(description = "配置ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11768") + private Long id; + + @Schema(description = "模型服务ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16823") + @NotNull(message = "模型服务ID不能为空") + private Long modelServiceId; + + @Schema(description = "system") + private String system; + + @Schema(description = "Prompt") + private String prompt; + + @Schema(description = "Response") + private String response; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/datarefluxconfig/DataRefluxConfigDO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/datarefluxconfig/DataRefluxConfigDO.java new file mode 100644 index 000000000..19afb8860 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/datarefluxconfig/DataRefluxConfigDO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxconfig; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 数据回流配置 DO + * + * @author 华大大模型 + */ +@TableName("llm_data_reflux_config") +@KeySequence("llm_data_reflux_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DataRefluxConfigDO extends BaseDO { + + /** + * 配置ID + */ + @TableId + private Long id; + /** + * 模型服务ID + */ + private Long modelServiceId; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/datarefluxdata/DataRefluxDataDO.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/datarefluxdata/DataRefluxDataDO.java new file mode 100644 index 000000000..caf4a36bb --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/dataobject/datarefluxdata/DataRefluxDataDO.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxdata; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 数据回流 —— 数据 DO + * + * @author 华大大模型 + */ +@TableName("llm_data_reflux_data") +@KeySequence("llm_data_reflux_data_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DataRefluxDataDO extends BaseDO { + + /** + * 配置ID + */ + @TableId + private Long id; + /** + * 模型服务ID + */ + private Long modelServiceId; + /** + * system + */ + private String system; + /** + * Prompt + */ + private String prompt; + /** + * Response + */ + private String response; + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/mysql/datarefluxconfig/DataRefluxConfigMapper.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/mysql/datarefluxconfig/DataRefluxConfigMapper.java new file mode 100644 index 000000000..da2584a83 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/mysql/datarefluxconfig/DataRefluxConfigMapper.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.llm.dal.mysql.datarefluxconfig; + +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.llm.dal.dataobject.datarefluxconfig.DataRefluxConfigDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.vo.*; + +/** + * 数据回流配置 Mapper + * + * @author 华大大模型 + */ +@Mapper +public interface DataRefluxConfigMapper extends BaseMapperX { + + default PageResult selectPage(DataRefluxConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DataRefluxConfigDO::getModelServiceId, reqVO.getModelServiceId()) + .betweenIfPresent(DataRefluxConfigDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DataRefluxConfigDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/mysql/datarefluxdata/DataRefluxDataMapper.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/mysql/datarefluxdata/DataRefluxDataMapper.java new file mode 100644 index 000000000..df0e77283 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/dal/mysql/datarefluxdata/DataRefluxDataMapper.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.llm.dal.mysql.datarefluxdata; + +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.llm.dal.dataobject.datarefluxdata.DataRefluxDataDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.vo.*; + +/** + * 数据回流 —— 数据 Mapper + * + * @author 华大大模型 + */ +@Mapper +public interface DataRefluxDataMapper extends BaseMapperX { + + default PageResult selectPage(DataRefluxDataPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DataRefluxDataDO::getModelServiceId, reqVO.getModelServiceId()) + .betweenIfPresent(DataRefluxDataDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(DataRefluxDataDO::getSystem, reqVO.getSystem()) + .eqIfPresent(DataRefluxDataDO::getPrompt, reqVO.getPrompt()) + .eqIfPresent(DataRefluxDataDO::getResponse, reqVO.getResponse()) + .orderByDesc(DataRefluxDataDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxconfig/DataRefluxConfigService.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxconfig/DataRefluxConfigService.java new file mode 100644 index 000000000..7f0275cc6 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxconfig/DataRefluxConfigService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.llm.service.datarefluxconfig; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.vo.*; +import cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxconfig.DataRefluxConfigDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 数据回流配置 Service 接口 + * + * @author 华大大模型 + */ +public interface DataRefluxConfigService { + + /** + * 创建数据回流配置 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDataRefluxConfig(@Valid DataRefluxConfigSaveReqVO createReqVO); + + /** + * 更新数据回流配置 + * + * @param updateReqVO 更新信息 + */ + void updateDataRefluxConfig(@Valid DataRefluxConfigSaveReqVO updateReqVO); + + /** + * 删除数据回流配置 + * + * @param id 编号 + */ + void deleteDataRefluxConfig(Long id); + + /** + * 获得数据回流配置 + * + * @param id 编号 + * @return 数据回流配置 + */ + DataRefluxConfigDO getDataRefluxConfig(Long id); + + /** + * 获得数据回流配置分页 + * + * @param pageReqVO 分页查询 + * @return 数据回流配置分页 + */ + PageResult getDataRefluxConfigPage(DataRefluxConfigPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxconfig/DataRefluxConfigServiceImpl.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxconfig/DataRefluxConfigServiceImpl.java new file mode 100644 index 000000000..783f4e52e --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxconfig/DataRefluxConfigServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.llm.service.datarefluxconfig; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxconfig.vo.*; +import cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxconfig.DataRefluxConfigDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.llm.dal.mysql.datarefluxconfig.DataRefluxConfigMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*; + +/** + * 数据回流配置 Service 实现类 + * + * @author 华大大模型 + */ +@Service +@Validated +public class DataRefluxConfigServiceImpl implements DataRefluxConfigService { + + @Resource + private DataRefluxConfigMapper dataRefluxConfigMapper; + + @Override + public Long createDataRefluxConfig(DataRefluxConfigSaveReqVO createReqVO) { + // 插入 + DataRefluxConfigDO dataRefluxConfig = BeanUtils.toBean(createReqVO, DataRefluxConfigDO.class); + dataRefluxConfigMapper.insert(dataRefluxConfig); + // 返回 + return dataRefluxConfig.getId(); + } + + @Override + public void updateDataRefluxConfig(DataRefluxConfigSaveReqVO updateReqVO) { + // 校验存在 + validateDataRefluxConfigExists(updateReqVO.getId()); + // 更新 + DataRefluxConfigDO updateObj = BeanUtils.toBean(updateReqVO, DataRefluxConfigDO.class); + dataRefluxConfigMapper.updateById(updateObj); + } + + @Override + public void deleteDataRefluxConfig(Long id) { + // 校验存在 + validateDataRefluxConfigExists(id); + // 删除 + dataRefluxConfigMapper.deleteById(id); + } + + private void validateDataRefluxConfigExists(Long id) { + if (dataRefluxConfigMapper.selectById(id) == null) { + throw exception(DATA_REFLUX_CONFIG_NOT_EXISTS); + } + } + + @Override + public DataRefluxConfigDO getDataRefluxConfig(Long id) { + return dataRefluxConfigMapper.selectById(id); + } + + @Override + public PageResult getDataRefluxConfigPage(DataRefluxConfigPageReqVO pageReqVO) { + return dataRefluxConfigMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxdata/DataRefluxDataService.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxdata/DataRefluxDataService.java new file mode 100644 index 000000000..5128c5abe --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxdata/DataRefluxDataService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.llm.service.datarefluxdata; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.vo.*; +import cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxdata.DataRefluxDataDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 数据回流 —— 数据 Service 接口 + * + * @author 华大大模型 + */ +public interface DataRefluxDataService { + + /** + * 创建数据回流 —— 数据 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDataRefluxData(@Valid DataRefluxDataSaveReqVO createReqVO); + + /** + * 更新数据回流 —— 数据 + * + * @param updateReqVO 更新信息 + */ + void updateDataRefluxData(@Valid DataRefluxDataSaveReqVO updateReqVO); + + /** + * 删除数据回流 —— 数据 + * + * @param id 编号 + */ + void deleteDataRefluxData(Long id); + + /** + * 获得数据回流 —— 数据 + * + * @param id 编号 + * @return 数据回流 —— 数据 + */ + DataRefluxDataDO getDataRefluxData(Long id); + + /** + * 获得数据回流 —— 数据分页 + * + * @param pageReqVO 分页查询 + * @return 数据回流 —— 数据分页 + */ + PageResult getDataRefluxDataPage(DataRefluxDataPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxdata/DataRefluxDataServiceImpl.java b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxdata/DataRefluxDataServiceImpl.java new file mode 100644 index 000000000..ffdd1aa4f --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/java/cn/iocoder/yudao/module/llm/service/datarefluxdata/DataRefluxDataServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.llm.service.datarefluxdata; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.llm.controller.admin.datarefluxdata.vo.*; +import cn.iocoder.yudao.module.llm.dal.dataobject.datarefluxdata.DataRefluxDataDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.llm.dal.mysql.datarefluxdata.DataRefluxDataMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*; + +/** + * 数据回流 —— 数据 Service 实现类 + * + * @author 华大大模型 + */ +@Service +@Validated +public class DataRefluxDataServiceImpl implements DataRefluxDataService { + + @Resource + private DataRefluxDataMapper dataRefluxDataMapper; + + @Override + public Long createDataRefluxData(DataRefluxDataSaveReqVO createReqVO) { + // 插入 + DataRefluxDataDO dataRefluxData = BeanUtils.toBean(createReqVO, DataRefluxDataDO.class); + dataRefluxDataMapper.insert(dataRefluxData); + // 返回 + return dataRefluxData.getId(); + } + + @Override + public void updateDataRefluxData(DataRefluxDataSaveReqVO updateReqVO) { + // 校验存在 + validateDataRefluxDataExists(updateReqVO.getId()); + // 更新 + DataRefluxDataDO updateObj = BeanUtils.toBean(updateReqVO, DataRefluxDataDO.class); + dataRefluxDataMapper.updateById(updateObj); + } + + @Override + public void deleteDataRefluxData(Long id) { + // 校验存在 + validateDataRefluxDataExists(id); + // 删除 + dataRefluxDataMapper.deleteById(id); + } + + private void validateDataRefluxDataExists(Long id) { + if (dataRefluxDataMapper.selectById(id) == null) { + throw exception(DATA_REFLUX_DATA_NOT_EXISTS); + } + } + + @Override + public DataRefluxDataDO getDataRefluxData(Long id) { + return dataRefluxDataMapper.selectById(id); + } + + @Override + public PageResult getDataRefluxDataPage(DataRefluxDataPageReqVO pageReqVO) { + return dataRefluxDataMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/resources/mapper/datarefluxconfig/DataRefluxConfigMapper.xml b/yudao-module-llm/yudao-module-llm-biz/src/main/resources/mapper/datarefluxconfig/DataRefluxConfigMapper.xml new file mode 100644 index 000000000..4f08ac827 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/resources/mapper/datarefluxconfig/DataRefluxConfigMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/yudao-module-llm/yudao-module-llm-biz/src/main/resources/mapper/datarefluxdata/DataRefluxDataMapper.xml b/yudao-module-llm/yudao-module-llm-biz/src/main/resources/mapper/datarefluxdata/DataRefluxDataMapper.xml new file mode 100644 index 000000000..98b57f3b7 --- /dev/null +++ b/yudao-module-llm/yudao-module-llm-biz/src/main/resources/mapper/datarefluxdata/DataRefluxDataMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file