增加查询项目职位的功能

master
yang.yongquan 2022-07-06 16:45:32 +08:00
parent 1eb05a9c8a
commit e714f2e3d4
1 changed files with 26 additions and 4 deletions

View File

@ -1,14 +1,16 @@
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.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.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -29,4 +31,24 @@ public class ProjectGroupController {
List<Integer> res = projectGroupService.findAllProjectNumber(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)
));
}
} }