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));
}
} }
/** /**
@ -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

@ -47,7 +47,9 @@ public class ProjectServiceImpl implements ProjectService {
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
@ -56,8 +58,9 @@ public class ProjectServiceImpl implements ProjectService {
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
@ -179,7 +182,7 @@ public class ProjectServiceImpl implements ProjectService {
@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