维护养护计划-逻辑修改

master
yangzhe123 2025-08-29 15:29:22 +08:00
parent 190b2faeef
commit 67f5573d16
2 changed files with 29 additions and 3 deletions

View File

@ -62,7 +62,15 @@ public class MentencePlanController extends AbstractCommonFileController {
@Operation(summary = "修改")
@PostMapping("/update")
public R<MentencePlan> update(@Validated(Update.class) @RequestBody MentencePlan dto) {
public R<MentencePlan> update(@Validated(Update.class) @RequestBody MentencePlan dto,HttpServletRequest request) {
SessionUser sessionUser = checkLogin(request);
if(sessionUser == null){
throw new IllegalArgumentException("未登录");
}
Long userId = sessionUser.getUserId();
if(!userId.equals(dto.getCreateId())){
throw new IllegalArgumentException("对不起,您没有编辑的权限");
}
boolean flag = mentencePlanService.update(dto);
if (flag) {
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
@ -72,13 +80,22 @@ public class MentencePlanController extends AbstractCommonFileController {
@Operation(summary = "删除")
@GetMapping("/del/{id}")
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id,HttpServletRequest request) {
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(MentencePlan::getId, id);
MentencePlan one = mentencePlanService.getOne(queryWrapper);
if(Objects.isNull(one)){
throw new RuntimeException("该计划不存在");
}
SessionUser sessionUser = checkLogin(request);
if(sessionUser == null){
throw new IllegalArgumentException("未登录");
}
Long userId = sessionUser.getUserId();
if(!userId.equals(one.getCreateId())){
throw new IllegalArgumentException("对不起,您没有编辑的权限");
}
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
queryWrapperDetail.eq(MentencePlanDetail::getMentencePlanId, id);
//先删细节
@ -92,7 +109,15 @@ public class MentencePlanController extends AbstractCommonFileController {
@Operation(summary = "审批")
@PostMapping("/approving")
public R<Boolean> approve(@Validated @RequestBody MentencePlan dto){
public R<Boolean> approve(@Validated @RequestBody MentencePlan dto,HttpServletRequest request){
SessionUser sessionUser = checkLogin(request);
if(sessionUser == null){
throw new IllegalArgumentException("未登录");
}
Long userId = sessionUser.getUserId();
if(!userId.toString().equals(dto.getApprovePersonId())){
throw new IllegalArgumentException("对不起,您没有审批的权限");
}
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(MentencePlan::getId, dto.getId());
MentencePlan one = mentencePlanService.getOne(queryWrapper);

View File

@ -97,6 +97,7 @@ public class MentencePlanService extends ServiceImpl<MentencePlanMapper, Menten
if(Objects.nonNull(pageSo.getStatus())){
queryWrapper.eq(MentencePlan::getPlanStatus,pageSo.getStatus());
}
queryWrapper.orderByAsc(MentencePlan::getCreateDate);
Page<MentencePlan> mentencePlanPage = baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
List<MentencePlan> records = mentencePlanPage.getRecords();
for (MentencePlan record : records) {