mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 15:13:55 +08:00
去除多余文件,优化接口权限,优化 model 实体类主键生成策略
This commit is contained in:
+9
-1
@@ -3,6 +3,7 @@ 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.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.utils.Result;
|
||||
@@ -24,9 +25,9 @@ public class ModelController {
|
||||
|
||||
private final ModelConfigService modelConfigService;
|
||||
|
||||
|
||||
@GetMapping("/models/names")
|
||||
@Operation(summary = "获取所有模型名称")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<List<String>> getModelNames(@RequestParam String modelType,
|
||||
@RequestParam(required = false) String modelName) {
|
||||
List<String> modelNameList = modelConfigService.getModelCodeList(modelType, modelName);
|
||||
@@ -35,6 +36,7 @@ public class ModelController {
|
||||
|
||||
@GetMapping("/{modelType}/provideTypes")
|
||||
@Operation(summary = "获取模型供应器列表")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<List<ModelProviderDTO>> getModelProviderList(@PathVariable String modelType) {
|
||||
List<ModelProviderDTO> modelProviderDTOS = modelProviderService.getListByModelType(modelType);
|
||||
return new Result<List<ModelProviderDTO>>().ok(modelProviderDTOS);
|
||||
@@ -42,6 +44,7 @@ public class ModelController {
|
||||
|
||||
@GetMapping("/{modelType}/{provideCode}/fields")
|
||||
@Operation(summary = "获取模型供应器字段")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
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);
|
||||
@@ -50,6 +53,7 @@ public class ModelController {
|
||||
|
||||
@GetMapping("/models/list")
|
||||
@Operation(summary = "获取模型配置列表")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<PageData<ModelConfigDTO>> getModelConfigList(@RequestParam String modelType,
|
||||
@RequestParam(required = false) String modelName,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer page,
|
||||
@@ -61,6 +65,7 @@ public class ModelController {
|
||||
|
||||
@PostMapping("/models/{modelType}/{provideCode}")
|
||||
@Operation(summary = "新增模型配置")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<ModelConfigDTO> addModelConfig(@PathVariable String modelType,
|
||||
@PathVariable String provideCode,
|
||||
@RequestBody ModelConfigBodyDTO modelConfigBodyDTO) {
|
||||
@@ -71,6 +76,7 @@ public class ModelController {
|
||||
|
||||
@PutMapping("/models/{modelType}/{provideCode}/{id}")
|
||||
@Operation(summary = "编辑模型配置")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<ModelConfigDTO> editModelConfig(@PathVariable String modelType,
|
||||
@PathVariable String provideCode,
|
||||
@PathVariable String id,
|
||||
@@ -82,6 +88,7 @@ public class ModelController {
|
||||
|
||||
@DeleteMapping("/models/{modelType}/{provideCode}/{id}")
|
||||
@Operation(summary = "删除模型配置")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> deleteModelConfig(@PathVariable String modelType, @PathVariable String provideCode, @PathVariable String id) {
|
||||
modelConfigService.delete(modelType, provideCode, id);
|
||||
return new Result<>();
|
||||
@@ -89,6 +96,7 @@ public class ModelController {
|
||||
|
||||
@GetMapping("/models/{modelName}/voices")
|
||||
@Operation(summary = "获取模型音色")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<List<String>> getVoiceList(@PathVariable String modelName,
|
||||
@RequestParam(required = false) String voiceName) {
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package xiaozhi.modules.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -14,8 +16,9 @@ import java.util.Date;
|
||||
@Schema(description = "模型配置表")
|
||||
public class ModelConfigEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
private String id;
|
||||
|
||||
@Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)")
|
||||
private String modelType;
|
||||
|
||||
+4
-1
@@ -1,6 +1,8 @@
|
||||
package xiaozhi.modules.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -13,8 +15,9 @@ import java.util.Date;
|
||||
@Schema(description = "模型供应器表")
|
||||
public class ModelProviderEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
private String id;
|
||||
|
||||
@Schema(description = "模型类型(Memory/ASR/VAD/LLM/TTS)")
|
||||
private String modelType;
|
||||
|
||||
@@ -11,11 +11,6 @@ jasypt:
|
||||
encryptor:
|
||||
password: P9Hx718z8L
|
||||
spring:
|
||||
sql:
|
||||
init:
|
||||
#初始化数据库默认数据,对应sql文件必须存在
|
||||
data-locations:
|
||||
- classpath:db/changelog/data.sql
|
||||
datasource:
|
||||
druid:
|
||||
#MySQL
|
||||
|
||||
@@ -39,13 +39,6 @@ spring:
|
||||
min-idle: 5 # 连接池中的最小空闲连接
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
sql:
|
||||
init:
|
||||
mode: always
|
||||
# 启动时自动执行创建表的sql,对应sql文件必须存在
|
||||
schema-locations:
|
||||
- classpath:db/changelog/202503141335.sql
|
||||
- classpath:db/changelog/202503141346.sql
|
||||
knife4j:
|
||||
enable: true
|
||||
basic:
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
-- password: Admin123456.
|
||||
INSERT INTO xiaozhi_esp32_server.sys_user (id, username, password, super_admin, status, create_date, updater, creator, update_date)
|
||||
VALUES (1903735517485289473, 'admin', '$2a$10$VY1sr9hJc9pMVNACVSvA9eadivi.WcWBRLsPzGdLduv3LqOkxz98u', 1, 1, '2025-03-23 17:08:12', null, null, '2025-03-23 17:08:12');
|
||||
Reference in New Issue
Block a user