| | |
| | | private AiModelService modelService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建模型") |
| | | @Operation(summary = "创建 AI 模型") |
| | | @PreAuthorize("@ss.hasPermission('ai:model:create')") |
| | | public CommonResult<Long> createModel(@Valid @RequestBody AiModelSaveReqVO createReqVO) { |
| | | return success(modelService.createModel(createReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "更新模型") |
| | | @Operation(summary = "更新 AI 模型") |
| | | @PreAuthorize("@ss.hasPermission('ai:model:update')") |
| | | public CommonResult<Boolean> updateModel(@Valid @RequestBody AiModelSaveReqVO updateReqVO) { |
| | | modelService.updateModel(updateReqVO); |
| | |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除模型") |
| | | @Operation(summary = "删除 AI 模型") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('ai:model:delete')") |
| | | public CommonResult<Boolean> deleteModel(@RequestParam("id") Long id) { |
| | |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得模型") |
| | | @Operation(summary = "获取 AI 模型") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('ai:model:query')") |
| | | public CommonResult<AiModelRespVO> getModel(@RequestParam("id") Long id) { |
| | | AiModelDO model = modelService.getModel(id); |
| | | return success(BeanUtils.toBean(model, AiModelRespVO.class)); |
| | | return success(BeanUtils.toBean(modelService.getModel(id), AiModelRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得模型分页") |
| | | @Operation(summary = "获取 AI 模型分页") |
| | | @PreAuthorize("@ss.hasPermission('ai:model:query')") |
| | | public CommonResult<PageResult<AiModelRespVO>> getModelPage(@Valid AiModelPageReqVO pageReqVO) { |
| | | PageResult<AiModelDO> pageResult = modelService.getModelPage(pageReqVO); |
| | |
| | | } |
| | | |
| | | @GetMapping("/simple-list") |
| | | @Operation(summary = "获得模型列表") |
| | | @Parameter(name = "type", description = "类型", required = true, example = "1") |
| | | @Parameter(name = "platform", description = "平台", example = "midjourney") |
| | | @Operation(summary = "获得模型简单列表", description = "用于下拉选择器等场景") |
| | | @Parameter(name = "type", description = "模型类型", required = true, example = "1") |
| | | @Parameter(name = "platform", description = "模型平台", example = "TongYi") |
| | | public CommonResult<List<AiModelRespVO>> getModelSimpleList( |
| | | @RequestParam("type") Integer type, |
| | | @RequestParam(value = "platform", required = false) String platform) { |
| | | List<AiModelDO> list = modelService.getModelListByStatusAndType( |
| | | CommonStatusEnum.ENABLE.getStatus(), type, platform); |
| | | return success(convertList(list, model -> new AiModelRespVO().setId(model.getId()) |
| | | .setName(model.getName()).setModel(model.getModel()).setPlatform(model.getPlatform()))); |
| | | return success(convertList(list, model -> new AiModelRespVO() |
| | | .setId(model.getId()) |
| | | .setName(model.getName()) |
| | | .setModel(model.getModel()) |
| | | .setPlatform(model.getPlatform()))); |
| | | } |
| | | |
| | | } |