feat(admin): implement category management functionality
- Added AddCategoryReqVO for category creation with validation - Created AdminCategoryController with endpoints for add, list, delete and select operations - Implemented AdminCategoryService interface and its methods - Added Category entity with JPA annotations and logical delete support - Created CategoryRepository extending JpaRepository with custom query methods - Added SQL table creation script for t_category with indexes and constraints - Implemented PageResponse utility for handling paginated results - Added FindCategoryPageListReqVO and FindCategoryPageListRspVO for pagination - Included DeleteCategoryReqVO for category deletion requests - Updated Jackson configuration to ignore unknown properties - Added base page query model and user info response VO - Fixed typo in response code enum for user not exist error
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
package com.hanserwei.web.controller;
|
||||
|
||||
import com.hanserwei.common.aspect.ApiOperationLog;
|
||||
import com.hanserwei.common.utils.Response;
|
||||
import com.hanserwei.web.model.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class TestController {
|
||||
|
||||
@PostMapping("/admin/test")
|
||||
@ApiOperationLog(description = "测试接口")
|
||||
public ResponseEntity<String>test(@RequestBody @Validated User user, BindingResult bindingResult) {
|
||||
// 是否存在校验错误
|
||||
if (bindingResult.hasErrors()) {
|
||||
// 获取校验不通过字段的提示信息
|
||||
String errorMsg = bindingResult.getFieldErrors()
|
||||
.stream()
|
||||
.map(FieldError::getDefaultMessage)
|
||||
.collect(Collectors.joining(", "));
|
||||
|
||||
return ResponseEntity.badRequest().body(errorMsg);
|
||||
}
|
||||
|
||||
// 返参
|
||||
return ResponseEntity.ok("参数没有任何问题");
|
||||
}
|
||||
|
||||
@PostMapping("/admin/update")
|
||||
@ApiOperationLog(description = "测试更新接口")
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
public Response<?> testUpdate() {
|
||||
log.info("更新成功...");
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user