修复了update时如果完全没有改动会报错的问题
parent
c160793d93
commit
70ecdff768
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 张韬
|
* @author 张韬
|
||||||
|
@ -99,16 +100,24 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException, BadRequestException {
|
public Boolean updateStaffPositions(String token, Integer projectId, Integer targetId, String positions) throws ForbiddenException, BadRequestException {
|
||||||
int accessLevel = getProjectAccessLevel(token, projectId);
|
int accessLevel = getProjectAccessLevel(token, projectId);
|
||||||
int originTargetLevel = getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId);
|
//int originTargetLevel = getProjectAccessLevelIgnoreGlobalLevel(targetId, projectId);
|
||||||
if (originTargetLevel == 0) {
|
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("该项目中不存在该成员");
|
throw new BadRequestException("该项目中不存在该成员");
|
||||||
}
|
}
|
||||||
|
if (Objects.equals(positions, originProjectGroup.getProjectStaffPosition())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
int targetLevel = 3;
|
int targetLevel = 3;
|
||||||
|
|
||||||
if (accessLevel == 0) {
|
if (accessLevel == 0) {
|
||||||
throw new ForbiddenException(IProjectGroupService.UNABLE_TO_ACCESS_PROJECT);
|
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);
|
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||||
}
|
}
|
||||||
String[] positionArray = positions.split(",");
|
String[] positionArray = positions.split(",");
|
||||||
|
|
|
@ -123,6 +123,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
throw new ForbiddenException(ForbiddenException.UNABLE_TO_OPERATE);
|
||||||
}
|
}
|
||||||
Project rawProject = baseMapper.selectById(project.getProjectId());
|
Project rawProject = baseMapper.selectById(project.getProjectId());
|
||||||
|
if (Objects.equals(project, rawProject)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!project.checkModification(rawProject)) {
|
if (!project.checkModification(rawProject)) {
|
||||||
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
throw new BadRequestException(BadRequestException.WRONG_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue