根据项目id查找项目成员id,无查询权限检测

master
ShiPengHui 2022-07-05 22:03:45 +08:00
parent 83d95b1227
commit 4e4bd33e1c
4 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,35 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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;
/**
* @author
* @since 2022/7/5 9:32
*/
@RestController
@RequestMapping("/project/{projectId}/group")
public class ProjectGroupController {
@Autowired
private IProjectGroupService projectGroupService;
@GetMapping
public ResponseList<Integer> getGroupNumber(@PathVariable Integer projectId) {
List<Integer> res = null;
try {
res = projectGroupService.findAllProjectNumber(projectId);
} catch (BadRequestException e) {
throw new RuntimeException(e);
}
return ResponseList.ofSuccess("查询成功", res);
}
}

View File

@ -1,12 +1,15 @@
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* @author
* created at 2022/6/30 21:34
*/
public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
}

View File

@ -1,8 +1,11 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author
* created at 2022/6/30 21:36
@ -14,4 +17,6 @@ public interface IProjectGroupService extends IService<ProjectGroup> {
* @return 0AccessLevel
*/
Integer getUserLevelInGroup(String token, Integer projectId);
List<Integer> findAllProjectNumber(Integer projectId) throws BadRequestException;
}

View File

@ -1,6 +1,8 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
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.service.IProjectGroupService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
@ -8,6 +10,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author
* created at 2022/6/30 21:38
@ -41,4 +46,16 @@ public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, Pro
return 0;
}
}
@Override
public List<Integer> findAllProjectNumber(Integer projectId) throws BadRequestException {
List<Integer> res= new ArrayList<>();
List<ProjectGroup> targetProject = baseMapper.selectList(Wrappers.<ProjectGroup>lambdaQuery().eq(ProjectGroup::getProjectId, projectId));
if(targetProject.size() == 0)
throw new BadRequestException("项目不存在");
for (int i = 0; i < targetProject.size(); i++) {
res.add(targetProject.get(i).getStaffId());
}
return res;
}
}