Compare commits
No commits in common. "f0ca1ce6d9fa4511e6d68e41a34c48bc19a9f98f" and "e714f2e3d41ae67a868be875028f62ac57811ede" have entirely different histories.
f0ca1ce6d9
...
e714f2e3d4
10
pom.xml
10
pom.xml
|
@ -15,8 +15,6 @@
|
||||||
<description>ProjectManagementBackend</description>
|
<description>ProjectManagementBackend</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -156,14 +154,6 @@
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>15</source>
|
|
||||||
<target>15</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.UnauthorizedException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -21,8 +27,28 @@ public class ProjectGroupController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseList<Integer> getGroupNumber(@PathVariable Integer projectId, @RequestHeader("Token") String token) {
|
public ResponseList<Integer> getGroupNumber(@PathVariable Integer projectId) {
|
||||||
List<Integer> res = projectGroupService.findAllProjectNumber(token, projectId);
|
List<Integer> res = projectGroupService.findAllProjectNumber(projectId);
|
||||||
return ResponseList.ofSuccess("查询成功", res);
|
return ResponseList.ofSuccess("查询成功", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@GetMapping("/{staffId}")
|
||||||
|
public ResponseMap getStaffPostion(
|
||||||
|
@RequestHeader("Token") String token,
|
||||||
|
@PathVariable Integer staffId,
|
||||||
|
@PathVariable Integer projectId
|
||||||
|
) {
|
||||||
|
if (TokenUtils.getStaffId(token) != staffId) {
|
||||||
|
throw new BadRequestException("用户访问错误");
|
||||||
|
}
|
||||||
|
if (projectGroupService.getUserLevelInGroup(token, projectId) == 0) {
|
||||||
|
throw new UnauthorizedException("无该项目访问权限");
|
||||||
|
}
|
||||||
|
return ResponseMap.ofSuccess("查询成功", projectGroupService.getOne(
|
||||||
|
Wrappers.<ProjectGroup>lambdaQuery()
|
||||||
|
.eq(ProjectGroup::getStaffId, staffId)
|
||||||
|
.eq(ProjectGroup::getProjectId, projectId)
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.apache.ibatis.annotations.Select;
|
||||||
public interface ProjectMapper extends BaseMapper<Project> {
|
public interface ProjectMapper extends BaseMapper<Project> {
|
||||||
|
|
||||||
@Select("""
|
@Select("""
|
||||||
SELECT COUNT(*) FROM project WHERE project_id IN
|
SELECT COUNT(*) FROM project WHERE project_id IN
|
||||||
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})
|
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})
|
||||||
""")
|
""")
|
||||||
Long findProjectCount(@Param("id") Integer staffId);
|
Long findProjectCount(@Param("id") Integer staffId);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,5 +18,5 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
|
||||||
*/
|
*/
|
||||||
Integer getUserLevelInGroup(String token, Integer projectId);
|
Integer getUserLevelInGroup(String token, Integer projectId);
|
||||||
|
|
||||||
List<Integer> findAllProjectNumber(String token, Integer projectId) throws TokenException, BadRequestException;
|
List<Integer> findAllProjectNumber(Integer projectId) throws BadRequestException;
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
|
@ -49,19 +48,14 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> findAllProjectNumber(String token, Integer projectId) throws TokenException, BadRequestException {
|
public List<Integer> findAllProjectNumber(Integer projectId) throws BadRequestException {
|
||||||
List<Integer> res = new ArrayList<>();
|
List<Integer> res = new ArrayList<>();
|
||||||
Integer staffId = TokenUtils.getStaffId(token);
|
|
||||||
List<ProjectGroup> targetProject = baseMapper.selectList(Wrappers.<ProjectGroup>lambdaQuery().eq(ProjectGroup::getProjectId, projectId));
|
List<ProjectGroup> targetProject = baseMapper.selectList(Wrappers.<ProjectGroup>lambdaQuery().eq(ProjectGroup::getProjectId, projectId));
|
||||||
|
|
||||||
|
|
||||||
if (targetProject.size() == 0)
|
if (targetProject.size() == 0)
|
||||||
throw new BadRequestException("项目不存在");
|
throw new BadRequestException("项目不存在");
|
||||||
for (ProjectGroup projectGroup : targetProject) {
|
for (int i = 0; i < targetProject.size(); i++) {
|
||||||
res.add(projectGroup.getStaffId());
|
res.add(targetProject.get(i).getStaffId());
|
||||||
}
|
}
|
||||||
if(!res.contains(staffId))
|
|
||||||
throw new BadRequestException("用户请求非法");
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue