优化:优化后端 CRUD 公共组件(移除 BaseService 中无用的默认实现,抽取 BaseRequest 基类来方便使用分组校验),并同步调整部门管理 API

This commit is contained in:
2023-01-30 22:35:17 +08:00
parent 2c6bef91e8
commit 83b01c2e4f
18 changed files with 144 additions and 111 deletions

View File

@@ -23,7 +23,6 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -53,7 +52,7 @@ import top.charles7c.cnadmin.common.util.validate.ValidationUtils;
@Tag(name = "登录 API")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/auth", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping("/auth")
public class LoginController {
private final LoginService loginService;

View File

@@ -27,7 +27,6 @@ import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -60,7 +59,7 @@ import top.charles7c.cnadmin.common.util.validate.CheckUtils;
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/common/captcha", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping("/common/captcha")
public class CaptchaController {
private final CaptchaProperties captchaProperties;

View File

@@ -23,7 +23,6 @@ import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,7 +44,7 @@ import top.charles7c.cnadmin.system.service.DeptService;
@Tag(name = "公共 API")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/common", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping("/common")
public class CommonController {
private final DeptService deptService;

View File

@@ -21,7 +21,6 @@ import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -49,7 +48,7 @@ import top.charles7c.cnadmin.monitor.service.LogService;
@Tag(name = "日志管理 API")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/monitor/log", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping("/monitor/log")
public class LogController {
private final LogService logService;

View File

@@ -26,7 +26,6 @@ import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -56,7 +55,7 @@ import top.charles7c.cnadmin.monitor.model.vo.*;
@Tag(name = "在线用户 API")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/monitor/online/user", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping("/monitor/online/user")
public class OnlineUserController {
@Operation(summary = "分页查询在线用户列表")

View File

@@ -21,8 +21,6 @@ import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api;
import java.util.List;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
@@ -30,7 +28,6 @@ import org.springframework.web.bind.annotation.*;
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
import top.charles7c.cnadmin.common.base.BaseController;
import top.charles7c.cnadmin.common.model.request.UpdateStatusRequest;
import top.charles7c.cnadmin.common.model.vo.R;
import top.charles7c.cnadmin.system.model.query.DeptQuery;
import top.charles7c.cnadmin.system.model.request.DeptRequest;
@@ -45,8 +42,8 @@ import top.charles7c.cnadmin.system.service.DeptService;
*/
@Tag(name = "部门管理 API")
@RestController
@CrudRequestMapping(value = "/system/dept", api = {Api.ALL})
public class DeptController extends BaseController<DeptService, DeptVO, DeptVO, DeptQuery, DeptRequest, DeptRequest> {
@CrudRequestMapping(value = "/system/dept", api = {Api.LIST, Api.DETAIL, Api.CREATE, Api.UPDATE, Api.DELETE})
public class DeptController extends BaseController<DeptService, DeptVO, DeptVO, DeptQuery, DeptRequest> {
@Override
@Operation(summary = "查询部门列表树")
@@ -54,12 +51,4 @@ public class DeptController extends BaseController<DeptService, DeptVO, DeptVO,
List<DeptVO> list = baseService.list(query);
return R.ok(baseService.buildListTree(list));
}
@Operation(summary = "修改部门状态")
@Parameter(name = "ids", description = "ID 列表", in = ParameterIn.PATH)
@PatchMapping("/{ids}")
public R updateStatus(@PathVariable List<Long> ids, @Validated @RequestBody UpdateStatusRequest request) {
baseService.updateStatus(ids, request.getStatus());
return R.ok(String.format("%s成功", request.getStatus().getDescription()));
}
}

View File

@@ -23,7 +23,6 @@ import lombok.RequiredArgsConstructor;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -56,7 +55,7 @@ import top.charles7c.cnadmin.system.service.UserService;
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/system/user/center", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping("/system/user/center")
public class UserCenterController {
private final UserService userService;