Merge remote-tracking branch 'origin/master'
commit
f8f36678f0
|
@ -1,6 +1,7 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
|
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.entity.ResultProject;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.impl.ProjectServiceImpl;
|
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -28,14 +30,29 @@ public class ProjectController {
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseMap getProjectListOfStaff(
|
public ResponseList<ResultProject> getProjectListOfStaff(
|
||||||
@RequestHeader("Token") String token,
|
@RequestHeader("Token") String token,
|
||||||
@RequestParam("pageCurrent") Integer pageCurrent,
|
@RequestParam("pageCurrent") Integer pageCurrent,
|
||||||
@RequestParam("pageSize") Integer pageSize,
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
Map<String, Object> paramMap
|
Map<String, Object> paramMap
|
||||||
) {
|
) {
|
||||||
Page<ResultProject> page = projectServiceImpl.getOnePageProject(token, pageCurrent, pageSize, 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("操作成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ public class Project {
|
||||||
private LocalDate projectFirstTestTime;
|
private LocalDate projectFirstTestTime;
|
||||||
private LocalDate projectFinalTestTime;
|
private LocalDate projectFinalTestTime;
|
||||||
private LocalDate projectEndTime;
|
private LocalDate projectEndTime;
|
||||||
|
private LocalDate projectCloseTime;
|
||||||
private String projectAbbreviation;
|
private String projectAbbreviation;
|
||||||
private Integer projectClassId;
|
private Integer projectClassId;
|
||||||
private Integer projectSubclassId;
|
private Integer projectSubclassId;
|
||||||
|
@ -37,6 +38,6 @@ public class Project {
|
||||||
private Boolean completed;
|
private Boolean completed;
|
||||||
@TableField("is_deleted")
|
@TableField("is_deleted")
|
||||||
@TableLogic
|
@TableLogic
|
||||||
private Boolean deleted;
|
private Boolean isDeleted;
|
||||||
private Integer projectCreator;
|
private Integer projectCreator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.time.LocalDate;
|
||||||
* @since 2022/6/29 20:45
|
* @since 2022/6/29 20:45
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ResultProject {
|
public class ResultProject {
|
||||||
Integer projectId;
|
Integer projectId;
|
||||||
|
@ -25,5 +24,11 @@ public class ResultProject {
|
||||||
Boolean IsDeleted;
|
Boolean IsDeleted;
|
||||||
Boolean IsCompleted;
|
Boolean IsCompleted;
|
||||||
LocalDate projectCloseTime;
|
LocalDate projectCloseTime;
|
||||||
|
Integer CompleteNum;
|
||||||
|
Integer TotalNum;
|
||||||
|
ResultProject() {
|
||||||
|
CompleteNum = 50;
|
||||||
|
TotalNum = 100;
|
||||||
|
}
|
||||||
// 带加的进度 Double projectProcess;
|
// 带加的进度 Double projectProcess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,12 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface ProjectMapper extends BaseMapper<Project> {
|
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("""
|
||||||
SELECT * FROM
|
SELECT * FROM
|
||||||
(SELECT project_id,
|
(SELECT project_id,
|
||||||
|
|
|
@ -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.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
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.exception.TokenException;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -14,9 +15,12 @@ import java.util.Map;
|
||||||
* @since 2022/6/29 17:08
|
* @since 2022/6/29 17:08
|
||||||
*/
|
*/
|
||||||
public interface IProjectService extends IService<Project> {
|
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;
|
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;
|
Boolean makeANewProject(Project project) throws TokenException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
|
@ -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.Project;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
|
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.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectMapper;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
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.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 阳勇权
|
* @author 阳勇权
|
||||||
|
@ -22,6 +27,12 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
|
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
|
@Override
|
||||||
public Page<ResultProject> getOnePageProject(
|
public Page<ResultProject> getOnePageProject(
|
||||||
String token,
|
String token,
|
||||||
|
@ -31,16 +42,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||||
) throws TokenException {
|
) throws TokenException {
|
||||||
Integer staffId = 2;
|
Integer staffId = 2;
|
||||||
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
|
IPage<ResultProject> page = new Page<>(pageCurrent, pageSize);
|
||||||
baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
|
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
|
||||||
return (Page<ResultProject>) page;
|
return (Page<ResultProject>) userPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Integer staffId = TokenUtils.getStaffId(token);
|
||||||
|
Project project=new Project();
|
||||||
|
project.setProjectId(projectId);
|
||||||
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
Project targetProject = baseMapper.selectOne(Wrappers.<Project>lambdaQuery().eq(Project::getProjectId, project.getProjectId()));
|
||||||
|
if(targetProject==null)
|
||||||
return 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
|
@Override
|
||||||
|
|
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue