项目列表操作

增加获得所有类,个人参与项目总数
master
yang.yongquan 2022-06-30 17:59:32 +08:00
parent 5fcfe0a5bd
commit afe0bc3c2e
5 changed files with 34 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.impl.ProjectServiceImpl;
@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@ -28,14 +30,22 @@ public class ProjectController {
@SneakyThrows
@GetMapping
public ResponseMap getProjectListOfStaff(
public ResponseList<ResultProject> getProjectListOfStaff(
@RequestHeader("Token") String token,
@RequestParam("pageCurrent") Integer pageCurrent,
@RequestParam("pageSize") Integer pageSize,
Map<String, Object> paramMap
) {
Page<ResultProject> page = projectServiceImpl.getOnePageProject(token, pageCurrent, pageSize, paramMap);
return ResponseMap.ofSuccess("返回列表", page);
return ResponseList.ofSuccess("成功返回列表", page);
}
@SneakyThrows
@GetMapping("/total")
public ResponseMap getProjectNumOfStaff(@RequestHeader("Token") String token) {
Map<String, Long> res = new HashMap<>();
res.put("totalNum", projectServiceImpl.getAllProjectOfStaff(token));
return ResponseMap.ofSuccess("获得参与项目总数", res);
}
}

View File

@ -25,5 +25,7 @@ public class ResultProject {
Boolean IsDeleted;
Boolean IsCompleted;
LocalDate projectCloseTime;
Integer CompleteNum;
Integer TotalNum;
// 带加的进度 Double projectProcess;
}

View File

@ -18,6 +18,12 @@ import java.util.List;
*/
public interface ProjectMapper extends BaseMapper<Project> {
@Select("""
SELECT COUNT(*) FROM project WHERE project_id IN
(SELECT DISTINCT project_id FROM project_group WHERE staff_id = #{id})
""")
Long findProjectCount(@Param("id") Integer staffId);
@Select("""
SELECT * FROM
(SELECT project_id,

View File

@ -14,6 +14,9 @@ import java.util.Map;
* @since 2022/6/29 17:08
*/
public interface IProjectService extends IService<Project> {
Long getAllProjectOfStaff(String token) throws TokenException;
Page<ResultProject> getOnePageProject(String token, Integer pageCurrent, Integer pageSize, Map<String,Object> params) throws TokenException;
Boolean setProjectCompleted(String token, Project project) throws TokenException;

View File

@ -11,7 +11,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import java.util.Map;
@ -22,6 +24,12 @@ import java.util.Map;
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
@Override
public Long getAllProjectOfStaff(String token) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token);
return baseMapper.findProjectCount(staffId);
}
@Override
public Page<ResultProject> getOnePageProject(
String token,
@ -29,10 +37,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
Integer pageSize,
Map<String, Object> params
) throws TokenException {
Integer staffId = 2;
Integer staffId = TokenUtils.getStaffId(token);
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
return (Page<ResultProject>) page;
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
return (Page<ResultProject>) userPage;
}
@Override