2026-04-27 10:27:57 +08:00
|
|
|
package com.labelsys.backend.controller;
|
|
|
|
|
|
|
|
|
|
import com.labelsys.backend.annotation.RequirePosition;
|
|
|
|
|
import com.labelsys.backend.common.Result;
|
|
|
|
|
import com.labelsys.backend.context.UserContext;
|
|
|
|
|
import com.labelsys.backend.dto.common.PageResult;
|
|
|
|
|
import com.labelsys.backend.dto.request.SaveSysConfigRequest;
|
|
|
|
|
import com.labelsys.backend.dto.request.SysConfigPageQuery;
|
|
|
|
|
import com.labelsys.backend.dto.response.SysConfigResponse;
|
|
|
|
|
import com.labelsys.backend.enums.UserPosition;
|
|
|
|
|
import com.labelsys.backend.service.SysConfigService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2026-04-27 16:25:39 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
2026-04-27 10:27:57 +08:00
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
2026-04-27 16:25:39 +08:00
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
2026-04-27 10:27:57 +08:00
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
@Tag(name = "系统配置管理")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/sys-configs")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class SysConfigController {
|
|
|
|
|
|
|
|
|
|
private final SysConfigService sysConfigService;
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "创建系统配置")
|
|
|
|
|
@RequirePosition(UserPosition.ADMIN)
|
|
|
|
|
@PostMapping
|
|
|
|
|
public Result<SysConfigResponse> create(@Valid @RequestBody SaveSysConfigRequest request) {
|
|
|
|
|
return Result.success(sysConfigService.toResponse(sysConfigService.saveConfig(UserContext.requireUser(), request)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "更新系统配置")
|
|
|
|
|
@RequirePosition(UserPosition.ADMIN)
|
|
|
|
|
@PutMapping("/{id}")
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<SysConfigResponse> update(
|
|
|
|
|
@Parameter(description = "配置ID", example = "191000000000000501")
|
|
|
|
|
@PathVariable Long id,
|
|
|
|
|
@Valid @RequestBody SaveSysConfigRequest request
|
|
|
|
|
) {
|
2026-04-27 10:27:57 +08:00
|
|
|
return Result.success(sysConfigService.toResponse(sysConfigService.updateConfig(UserContext.requireUser(), id, request)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "分页查询系统配置")
|
|
|
|
|
@GetMapping
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<PageResult<SysConfigResponse>> page(@ParameterObject SysConfigPageQuery query) {
|
2026-04-27 10:27:57 +08:00
|
|
|
return Result.success(sysConfigService.pageConfigs(UserContext.requireUser(), query));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "查询系统配置详情")
|
|
|
|
|
@GetMapping("/{id}")
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<SysConfigResponse> detail(
|
|
|
|
|
@Parameter(description = "配置ID", example = "191000000000000501")
|
|
|
|
|
@PathVariable Long id
|
|
|
|
|
) {
|
2026-04-27 10:27:57 +08:00
|
|
|
return Result.success(sysConfigService.getConfig(UserContext.requireUser(), id));
|
|
|
|
|
}
|
|
|
|
|
}
|