更改了ProjectGroup相关的东西,适配了新的数据库结构变动

master
ArgonarioD 2022-07-05 20:47:17 +08:00
parent 16f55b05bd
commit 83d95b1227
3 changed files with 18 additions and 18 deletions

View File

@ -14,4 +14,5 @@ public class ProjectGroup {
Integer staffId;
Integer projectId;
String projectStaffPosition;
Integer projectAccessLevel;
}

View File

@ -9,5 +9,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IProjectGroupService extends IService<ProjectGroup> {
Boolean addCreator(Integer projectId, Integer staffId);
/**
* @return 0AccessLevel
*/
Integer getUserLevelInGroup(String token, Integer projectId);
}

View File

@ -1,7 +1,6 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
@ -9,8 +8,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.io.Serializable;
/**
* @author
* created at 2022/6/30 21:38
@ -24,25 +21,23 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
ProjectGroup projectGroup = new ProjectGroup();
projectGroup.setProjectId(projectId);
projectGroup.setStaffId(staffId);
projectGroup.setProjectStaffPosition("负责人");
projectGroup.setProjectStaffPosition("项目经理");
projectGroup.setProjectAccessLevel(1);
return baseMapper.insert(projectGroup) == 1;
}
//TODO:
@Override
public Integer getUserLevelInGroup(String token, Integer projectId) {
try {
Integer staffId = TokenUtils.getStaffId(token);
ProjectGroup projectGroup=baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery().eq(ProjectGroup::getStaffId, staffId).eq(ProjectGroup::getProjectId, projectId));
ProjectGroup projectGroup = baseMapper.selectOne(Wrappers.<ProjectGroup>lambdaQuery()
.eq(ProjectGroup::getStaffId, staffId)
.eq(ProjectGroup::getProjectId, projectId)
);
if (projectGroup == null)
return 0;
else if(projectGroup.getProjectStaffPosition().equals("负责人"))
return 3;
else if(projectGroup.getProjectStaffPosition().length()>0)
return 1;
else
return 0;
}catch(Exception e){//需要调整
return projectGroup.getProjectAccessLevel();
} catch (Exception e) {
return 0;
}
}