修复了update时如果完全没有改动会报错的问题

master
ArgonarioD 2022-07-14 09:21:34 +08:00
parent c160793d93
commit 70ecdff768
2 changed files with 15 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author
@ -99,16 +100,24 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
@Override
public Boolean updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException, BadRequestException {
int accessLevel = getProjectAccessLevel(token, projectId);
int originTargetLevel = getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId);
if (originTargetLevel == 0) {
//int originTargetLevel = getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId);
ProjectGroup originProjectGroup = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery()
.select(ProjectGroup::getProjectStaffPosition, ProjectGroup::getProjectAccessLevel)
.eq(ProjectGroup::getStaffId, targetId)
.eq(ProjectGroup::getProjectId, projectId)
);
if (originProjectGroup == null || originProjectGroup.getProjectAccessLevel() == 0) {
throw new BadRequestException("该项目中不存在该成员");
}
if (Objects.equals(positions, originProjectGroup.getProjectStaffPosition())) {
return true;
}
int targetLevel = 3;
if (accessLevel == 0) {
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
}
if (accessLevel > 2 || accessLevel >= originTargetLevel) {
if (accessLevel > 2 || accessLevel >= originProjectGroup.getProjectAccessLevel()) {
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
String[] positionArray = positions.split(",");

View File

@ -123,6 +123,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
}
Project rawProject = baseMapper.selectById(project.getProjectId());
if (Objects.equals(project, rawProject)) {
return true;
}
if (!project.checkModification(rawProject)) {
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
}