fix: 内容补丁
This commit is contained in:
parent
1de2e0a49f
commit
3179d945b8
@ -44,12 +44,14 @@ public class UserController {
|
||||
* @return {@link BaseResponse}
|
||||
*/
|
||||
@PutMapping("/user/delete")
|
||||
public BaseResponse userDelete(HttpServletRequest request,@RequestParam Long id) {
|
||||
public BaseResponse userDelete(HttpServletRequest request, @RequestParam String id) {
|
||||
log.info("请求接口[PUT]: /user/delete");
|
||||
// 判断是否有参数错误
|
||||
if (id == null) {
|
||||
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}
|
||||
*/
|
||||
@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");
|
||||
// 判断是否有参数错误
|
||||
if (id == null) {
|
||||
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:
|
||||
**/
|
||||
@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");
|
||||
// 判断是否有参数错误
|
||||
if (bindingResult.hasErrors()) {
|
||||
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()) {
|
||||
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 {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import com.jsl.oa.model.doData.ProjectCuttingDO;
|
||||
import com.jsl.oa.model.doData.ProjectDO;
|
||||
import com.jsl.oa.model.doData.info.ProjectShowDO;
|
||||
import com.jsl.oa.model.voData.ProjectInfoVO;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
@ -101,7 +100,7 @@ public class ProjectDAO {
|
||||
return projectMapper.get();
|
||||
}
|
||||
|
||||
public BaseResponse getByName(String name) {
|
||||
public ProjectDO getByName(String name) {
|
||||
log.info("\t> 执行 DAO 层 ProjectDAO.getByName 方法");
|
||||
return projectMapper.getByName(name);
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class ProcessException {
|
||||
@ -37,9 +41,18 @@ public class ProcessException {
|
||||
@ExceptionHandler(value = MissingServletRequestParameterException.class)
|
||||
public ResponseEntity<BaseResponse> businessMissingServletRequestParameterException(MissingServletRequestParameterException 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
|
||||
.status(400)
|
||||
.body(ResultUtil.error(ErrorCode.PARAMETER_ERROR, e.getMessage()));
|
||||
.body(ResultUtil.error(ErrorCode.PARAMETER_ERROR, "缺少 " + e.getParameterName() + " 参数"));
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
|
@ -44,27 +44,30 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
public BaseResponse projectEdit(@NotNull ProjectInfoVO projectEdit) {
|
||||
log.info("\t> 执行 Service 层 ProjectService.projectEdit 方法");
|
||||
//判断项目是否存在
|
||||
if(projectDAO.isExistProject(projectEdit.getId())) {
|
||||
if (projectDAO.isExistProject(projectEdit.getId())) {
|
||||
projectDAO.projectEdit(projectEdit);
|
||||
return ResultUtil.success("修改成功");
|
||||
}else return ResultUtil.error(ErrorCode.PROJECT_NOT_EXIST);
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.PROJECT_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse projectGetUserInCutting(Long uid) {
|
||||
log.info("\t> 执行 Service 层 ProjectService.projectGetUserInCutting 方法");
|
||||
if(userDAO.isExistUser(uid)) {
|
||||
List<ProjectCuttingDO> projectCuttingDOList =projectDAO.projectGetUserInCutting(uid);
|
||||
if (userDAO.isExistUser(uid)) {
|
||||
List<ProjectCuttingDO> projectCuttingDOList = projectDAO.projectGetUserInCutting(uid);
|
||||
return ResultUtil.success(projectCuttingDOList);
|
||||
} else {
|
||||
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
}
|
||||
else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse projectAddUserForCutting(Long uid, Long pid) {
|
||||
log.info("\t> 执行 Service 层 ProjectService.projectAddUserForCutting 方法");
|
||||
if(userDAO.isExistUser(uid)){
|
||||
projectDAO.projectAddUserForCutting(uid,pid);
|
||||
if (userDAO.isExistUser(uid)) {
|
||||
projectDAO.projectAddUserForCutting(uid, pid);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
return null;
|
||||
@ -172,14 +175,14 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
@Override
|
||||
public BaseResponse get() {
|
||||
log.info("\t> 执行 Service 层 ProjectService.get 方法");
|
||||
List<ProjectDO> projectDOList =projectDAO.get();
|
||||
List<ProjectDO> projectDOList = projectDAO.get();
|
||||
return ResultUtil.success(projectDOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse getByName(String name) {
|
||||
log.info("\t> 执行 Service 层 ProjectService.getByName 方法");
|
||||
return projectDAO.getByName(name);
|
||||
return ResultUtil.success(projectDAO.getByName(name));
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ spring:
|
||||
port: 6379
|
||||
password: 123456
|
||||
profiles:
|
||||
active: dev
|
||||
active: test
|
||||
mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
Loading…
x
Reference in New Issue
Block a user