fix: 内容补丁

This commit is contained in:
筱锋xiao_lfeng 2024-01-20 21:25:19 +08:00
parent 1de2e0a49f
commit 3179d945b8
No known key found for this signature in database
GPG Key ID: F693AA12AABBFA87
5 changed files with 37 additions and 21 deletions

View File

@ -44,12 +44,14 @@ public class UserController {
* @return {@link BaseResponse} * @return {@link BaseResponse}
*/ */
@PutMapping("/user/delete") @PutMapping("/user/delete")
public BaseResponse userDelete(HttpServletRequest request,@RequestParam Long id) { public BaseResponse userDelete(HttpServletRequest request, @RequestParam String id) {
log.info("请求接口[PUT]: /user/delete"); log.info("请求接口[PUT]: /user/delete");
// 判断是否有参数错误 // 判断是否有参数错误
if (id == null) { if (id == null) {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR); return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
} else return userService.userDelete(request,id); } else {
return userService.userDelete(request, Long.valueOf(id));
}
} }
/** /**
@ -59,13 +61,13 @@ public class UserController {
* @return {@link BaseResponse} * @return {@link BaseResponse}
*/ */
@PutMapping("/user/lock") @PutMapping("/user/lock")
public BaseResponse userLock(HttpServletRequest request,@RequestParam Long id,@RequestParam Long isLock) { public BaseResponse userLock(HttpServletRequest request, @RequestParam Long id, @RequestParam Long isLock) {
log.info("请求接口[PUT]: /user/lock"); log.info("请求接口[PUT]: /user/lock");
// 判断是否有参数错误 // 判断是否有参数错误
if (id == null) { if (id == null) {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR); return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
} }
return userService.userLock(request,id,isLock); return userService.userLock(request, id, isLock);
} }
/** /**
@ -158,13 +160,13 @@ public class UserController {
* @Param bindingResult: * @Param bindingResult:
**/ **/
@PostMapping("/user/add") @PostMapping("/user/add")
public BaseResponse userAdd(@RequestBody @Validated UserAddVo userAddVo, BindingResult bindingResult, HttpServletRequest request){ public BaseResponse userAdd(@RequestBody @Validated UserAddVo userAddVo, BindingResult bindingResult, HttpServletRequest request) {
log.info("请求接口[POST]: /user/add"); log.info("请求接口[POST]: /user/add");
// 判断是否有参数错误 // 判断是否有参数错误
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult)); return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
} }
return userService.userAdd(userAddVo,request); return userService.userAdd(userAddVo, request);
} }
@ -175,7 +177,7 @@ public class UserController {
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult)); return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
} }
return userService.userEdit(userEditVO,request); return userService.userEdit(userEditVO, request);
} }
@ -186,5 +188,4 @@ public class UserController {
} }
} }

View File

@ -6,7 +6,6 @@ import com.jsl.oa.model.doData.ProjectCuttingDO;
import com.jsl.oa.model.doData.ProjectDO; import com.jsl.oa.model.doData.ProjectDO;
import com.jsl.oa.model.doData.info.ProjectShowDO; import com.jsl.oa.model.doData.info.ProjectShowDO;
import com.jsl.oa.model.voData.ProjectInfoVO; import com.jsl.oa.model.voData.ProjectInfoVO;
import com.jsl.oa.utils.BaseResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
@ -101,7 +100,7 @@ public class ProjectDAO {
return projectMapper.get(); return projectMapper.get();
} }
public BaseResponse getByName(String name) { public ProjectDO getByName(String name) {
log.info("\t> 执行 DAO 层 ProjectDAO.getByName 方法"); log.info("\t> 执行 DAO 层 ProjectDAO.getByName 方法");
return projectMapper.getByName(name); return projectMapper.getByName(name);
} }

View File

@ -13,6 +13,10 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j @Slf4j
@RestControllerAdvice @RestControllerAdvice
public class ProcessException { public class ProcessException {
@ -37,9 +41,18 @@ public class ProcessException {
@ExceptionHandler(value = MissingServletRequestParameterException.class) @ExceptionHandler(value = MissingServletRequestParameterException.class)
public ResponseEntity<BaseResponse> businessMissingServletRequestParameterException(MissingServletRequestParameterException e) { public ResponseEntity<BaseResponse> businessMissingServletRequestParameterException(MissingServletRequestParameterException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
// 使用正则表达式匹配并提取'id'部分
Pattern pattern = Pattern.compile("'.*?'");
Matcher matcher = pattern.matcher(Objects.requireNonNull(e.getMessage()));
// 查找匹配项
while (matcher.find()) {
String matchedGroup = matcher.group();
}
return ResponseEntity return ResponseEntity
.status(400) .status(400)
.body(ResultUtil.error(ErrorCode.PARAMETER_ERROR, e.getMessage())); .body(ResultUtil.error(ErrorCode.PARAMETER_ERROR, "缺少 " + e.getParameterName() + " 参数"));
} }
@ExceptionHandler(value = Exception.class) @ExceptionHandler(value = Exception.class)

View File

@ -44,27 +44,30 @@ public class ProjectServiceImpl implements ProjectService {
public BaseResponse projectEdit(@NotNull ProjectInfoVO projectEdit) { public BaseResponse projectEdit(@NotNull ProjectInfoVO projectEdit) {
log.info("\t> 执行 Service 层 ProjectService.projectEdit 方法"); log.info("\t> 执行 Service 层 ProjectService.projectEdit 方法");
//判断项目是否存在 //判断项目是否存在
if(projectDAO.isExistProject(projectEdit.getId())) { if (projectDAO.isExistProject(projectEdit.getId())) {
projectDAO.projectEdit(projectEdit); projectDAO.projectEdit(projectEdit);
return ResultUtil.success("修改成功"); return ResultUtil.success("修改成功");
}else return ResultUtil.error(ErrorCode.PROJECT_NOT_EXIST); } else {
return ResultUtil.error(ErrorCode.PROJECT_NOT_EXIST);
}
} }
@Override @Override
public BaseResponse projectGetUserInCutting(Long uid) { public BaseResponse projectGetUserInCutting(Long uid) {
log.info("\t> 执行 Service 层 ProjectService.projectGetUserInCutting 方法"); log.info("\t> 执行 Service 层 ProjectService.projectGetUserInCutting 方法");
if(userDAO.isExistUser(uid)) { if (userDAO.isExistUser(uid)) {
List<ProjectCuttingDO> projectCuttingDOList =projectDAO.projectGetUserInCutting(uid); List<ProjectCuttingDO> projectCuttingDOList = projectDAO.projectGetUserInCutting(uid);
return ResultUtil.success(projectCuttingDOList); return ResultUtil.success(projectCuttingDOList);
} else {
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
} }
else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
} }
@Override @Override
public BaseResponse projectAddUserForCutting(Long uid, Long pid) { public BaseResponse projectAddUserForCutting(Long uid, Long pid) {
log.info("\t> 执行 Service 层 ProjectService.projectAddUserForCutting 方法"); log.info("\t> 执行 Service 层 ProjectService.projectAddUserForCutting 方法");
if(userDAO.isExistUser(uid)){ if (userDAO.isExistUser(uid)) {
projectDAO.projectAddUserForCutting(uid,pid); projectDAO.projectAddUserForCutting(uid, pid);
return ResultUtil.success(); return ResultUtil.success();
} }
return null; return null;
@ -172,14 +175,14 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public BaseResponse get() { public BaseResponse get() {
log.info("\t> 执行 Service 层 ProjectService.get 方法"); log.info("\t> 执行 Service 层 ProjectService.get 方法");
List<ProjectDO> projectDOList =projectDAO.get(); List<ProjectDO> projectDOList = projectDAO.get();
return ResultUtil.success(projectDOList); return ResultUtil.success(projectDOList);
} }
@Override @Override
public BaseResponse getByName(String name) { public BaseResponse getByName(String name) {
log.info("\t> 执行 Service 层 ProjectService.getByName 方法"); log.info("\t> 执行 Service 层 ProjectService.getByName 方法");
return projectDAO.getByName(name); return ResultUtil.success(projectDAO.getByName(name));
} }

View File

@ -12,7 +12,7 @@ spring:
port: 6379 port: 6379
password: 123456 password: 123456
profiles: profiles:
active: dev active: test
mybatis: mybatis:
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true