Merge remote-tracking branch 'origin/master'

master
ArgonarioD 2022-06-30 21:23:20 +08:00
commit f8f36678f0
9 changed files with 135 additions and 10 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,29 @@ 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);
}
@SneakyThrows
@PostMapping("/complete")
public ResponseMap completeProject(@RequestHeader("Token") String token,@RequestBody Map<String,Object> map){
Integer targetProjectId=(Integer)map.get("projectId");
projectServiceImpl.setProjectCompleted(token, targetProjectId);
return ResponseMap.ofSuccess("操作成功");
}
}

View File

@ -0,0 +1,29 @@
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectTypeService;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseList;
import cn.edu.hfut.rmdjzz.projectmanagement.utils.response.ResponseMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author
* @since 2022/6/30 16:36
*/
@RestController
@RequestMapping("/projectType")
public class ProjectTypeController {
@Autowired
private IProjectTypeService projectTypeServiceImpl;
@GetMapping
public ResponseList<ProjectType> getAllProjectType() {
List<ProjectType> res = projectTypeServiceImpl.findAllProjectType();
return ResponseList.ofSuccess("获得所有类成功", res);
}
}

View File

@ -22,6 +22,7 @@ public class Project {
private LocalDate projectFirstTestTime;
private LocalDate projectFinalTestTime;
private LocalDate projectEndTime;
private LocalDate projectCloseTime;
private String projectAbbreviation;
private Integer projectClassId;
private Integer projectSubclassId;
@ -37,6 +38,6 @@ public class Project {
private Boolean completed;
@TableField("is_deleted")
@TableLogic
private Boolean deleted;
private Boolean isDeleted;
private Integer projectCreator;
}

View File

@ -13,7 +13,6 @@ import java.time.LocalDate;
* @since 2022/6/29 20:45
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultProject {
Integer projectId;
@ -25,5 +24,11 @@ public class ResultProject {
Boolean IsDeleted;
Boolean IsCompleted;
LocalDate projectCloseTime;
Integer CompleteNum;
Integer TotalNum;
ResultProject() {
CompleteNum = 50;
TotalNum = 100;
}
// 带加的进度 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

@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -14,9 +15,12 @@ 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;
Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException;
Boolean makeANewProject(Project project) throws TokenException;
}

View File

@ -0,0 +1,15 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @author
* @since 2022/6/30 16:27
*/
public interface IProjectTypeService extends IService<ProjectType> {
List<ProjectType> findAllProjectType();
}

View File

@ -2,6 +2,7 @@ package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
@ -11,9 +12,13 @@ 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.time.LocalDate;
import java.util.Map;
import java.util.Objects;
/**
* @author
@ -22,6 +27,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,
@ -31,16 +42,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
) throws TokenException {
Integer staffId = 2;
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
public Boolean setProjectCompleted(String token, Project project) throws TokenException {
public Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException {
Integer staffId = TokenUtils.getStaffId(token);
Project project=new Project();
project.setProjectId(projectId);
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
return null;
if(targetProject==null)
throw new BadRequestException("项目不存在");
if(!Objects.equals(staffId, targetProject.getProjectCreator()))
throw new BadRequestException("用户请求非法");
if(targetProject.getIsCompleted())
throw new BadRequestException("该项目已结项");
targetProject.setIsCompleted(true);
targetProject.setProjectCloseTime(LocalDate.now());
if(baseMapper.updateById(targetProject)==1)
return true;
throw new BadRequestException("操作失败");
}
@Override

View File

@ -0,0 +1,26 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectType;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectTypeMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectTypeService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author
* @since 2022/6/30 16:28
*/
@Service
public class ProjectTypeServiceImpl extends ServiceImpl<ProjectTypeMapper, ProjectType> implements IProjectTypeService {
@Override
public List<ProjectType> findAllProjectType() {
return baseMapper.selectList(Wrappers.<ProjectType>lambdaQuery().ne(ProjectType::getProjectClassId, 0));
}
}