去除多余文件,优化接口权限,优化 model 实体类主键生成策略

This commit is contained in:
pengzhisheng
2025-03-24 20:08:33 +08:00
parent f3562e091f
commit 8f1fbbdeef
2 changed files with 0 additions and 152 deletions
@@ -1,106 +0,0 @@
package xiaozhi.modules.model.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import xiaozhi.common.page.PageData;
import xiaozhi.common.utils.Result;
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
import xiaozhi.modules.model.dto.ModelConfigDTO;
import xiaozhi.modules.model.dto.ModelProviderDTO;
import xiaozhi.modules.model.service.ModelConfigService;
import xiaozhi.modules.model.service.ModelProviderService;
import java.util.List;
@AllArgsConstructor
@RestController
@RequestMapping("/models")
@Tag(name = "模型配置")
public class ModelController {
private final ModelProviderService modelProviderService;
private final ModelConfigService modelConfigService;
@GetMapping("/models/names")
@Operation(summary = "获取所有模型名称")
public Result<List<String>> getModelNames(@RequestParam String modelType,
@RequestParam(required = false) String modelName) {
List<String> modelNameList = modelConfigService.getModelCodeList(modelType, modelName);
return new Result<List<String>>().ok(modelNameList);
}
@GetMapping("/{modelType}/provideTypes")
@Operation(summary = "获取模型供应器列表")
public Result<List<ModelProviderDTO>> getModelProviderList(@PathVariable String modelType) {
List<ModelProviderDTO> modelProviderDTOS = modelProviderService.getListByModelType(modelType);
return new Result<List<ModelProviderDTO>>().ok(modelProviderDTOS);
}
@GetMapping("/{modelType}/{provideCode}/fields")
@Operation(summary = "获取模型供应器字段")
public Result<List<String>> getModelProviderFields(@PathVariable String modelType, @PathVariable String provideCode) {
List<String> fieldList = modelProviderService.getFieldList(modelType, provideCode);
return new Result<List<String>>().ok(fieldList);
}
/**
* get model config list, by modelType and modelName with page, limit
*/
@GetMapping("/models/list")
@Operation(summary = "获取模型配置列表")
public Result<PageData<ModelConfigDTO>> getModelConfigList(@RequestParam String modelType,
@RequestParam(required = false) String modelName,
@RequestParam(required = false, defaultValue = "0") Integer page,
@RequestParam(required = false,defaultValue = "10") Integer limit) {
PageData<ModelConfigDTO> pageList = modelConfigService.getPageList(modelType, modelName, page, limit);
return new Result<PageData<ModelConfigDTO>>().ok(pageList);
}
/**
* post model config, path params is modelType and provideCode, the body is ModelConfigDTO, but exclude modelType and provideCode
*/
@PostMapping("/models/{modelType}/{provideCode}")
@Operation(summary = "新增模型配置")
public Result<ModelConfigDTO> addModelConfig(@PathVariable String modelType,
@PathVariable String provideCode,
@RequestBody ModelConfigBodyDTO modelConfigBodyDTO) {
ModelConfigDTO modelConfigDTO = modelConfigService.add(modelType, provideCode, modelConfigBodyDTO);
return new Result<ModelConfigDTO>().ok(modelConfigDTO);
}
/**
* put to edit model config, path params is modelType, provideCode and id, the body is ModelConfigDTO, but exclude modelType, provideCode and id
*/
@PutMapping("/models/{modelType}/{provideCode}/{id}")
@Operation(summary = "编辑模型配置")
public Result<ModelConfigDTO> editModelConfig(@PathVariable String modelType,
@PathVariable String provideCode,
@PathVariable String id,
@RequestBody ModelConfigBodyDTO modelConfigBodyDTO) {
ModelConfigDTO modelConfigDTO = modelConfigService.edit(modelType, provideCode, id, modelConfigBodyDTO);
return new Result<ModelConfigDTO>().ok(modelConfigDTO);
}
/**
* delete model config, path params is modelType, provideCode and id
*/
@DeleteMapping("/models/{modelType}/{provideCode}/{id}")
@Operation(summary = "删除模型配置")
public Result<Void> deleteModelConfig(@PathVariable String modelType, @PathVariable String provideCode, @PathVariable String id) {
modelConfigService.delete(modelType, provideCode, id);
return new Result<>();
}
@GetMapping("/models/{modelName}/voices")
@Operation(summary = "获取模型音色")
public Result<List<String>> getVoiceList(@PathVariable String modelName,
@RequestParam(required = false) String voiceName) {
List<String> voiceList = modelConfigService.getVoiceList(modelName, voiceName);
return new Result<List<String>>().ok(voiceList);
}
}
@@ -1,46 +0,0 @@
package xiaozhi.modules.model.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Date;
@Data
@TableName("ai_model_provider")
@Schema(description = "模型供应器表")
public class ModelProviderEntity {
@Schema(description = "主键")
private Long id;
@Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)")
private String modelType;
@Schema(description = "供应器类型")
private String providerCode;
@Schema(description = "供应器名称")
private String name;
@Schema(description = "供应器字段列表(JSON格式)")
@TableField(typeHandler = JacksonTypeHandler.class)
private String fields;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "创建者")
private Long creator;
@Schema(description = "创建时间")
private Date createDate;
@Schema(description = "更新者")
private Long updater;
@Schema(description = "更新时间")
private Date updateDate;
}