提交代码实现v1.0
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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}")
|
||||
public Result<SysConfigResponse> update(@PathVariable Long id, @Valid @RequestBody SaveSysConfigRequest request) {
|
||||
return Result.success(sysConfigService.toResponse(sysConfigService.updateConfig(UserContext.requireUser(), id, request)));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询系统配置")
|
||||
@GetMapping
|
||||
public Result<PageResult<SysConfigResponse>> page(SysConfigPageQuery query) {
|
||||
return Result.success(sysConfigService.pageConfigs(UserContext.requireUser(), query));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询系统配置详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<SysConfigResponse> detail(@PathVariable Long id) {
|
||||
return Result.success(sysConfigService.getConfig(UserContext.requireUser(), id));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user