Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/cn/edu/hfut/rmdjzz/projectmanagement/entity/Project.java
master
ArgonarioD 2022-06-30 22:02:52 +08:00
commit f9804ef791
9 changed files with 108 additions and 7 deletions

View File

@ -55,4 +55,11 @@ public class ProjectController {
projectServiceImpl.setProjectCompleted(token, targetProjectId);
return ResponseMap.ofSuccess("操作成功");
}
@SneakyThrows
@PostMapping("/create")
public ResponseMap createProject(@RequestHeader("Token") String token,@RequestBody Project project){
projectServiceImpl.createProject(token, project);
return ResponseMap.ofSuccess("操作成功");
}
}

View File

@ -0,0 +1,17 @@
package cn.edu.hfut.rmdjzz.projectmanagement.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
* @author
* created at 2022/6/30 21:31
*/
@Data
public class ProjectGroup {
@TableId(type = IdType.AUTO)
Integer staffId;
Integer projectId;
String projectStaffPosition;
}

View File

@ -17,6 +17,7 @@ import java.time.LocalDate;
public class ResultProject {
Integer projectId;
String projectName;
Integer projectCreator;
Long contractAmount;
String projectImportance;
String projectClassName;

View File

@ -0,0 +1,13 @@
package cn.edu.hfut.rmdjzz.projectmanagement.mapper;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author
* created at 2022/6/30 21:34
*/
public interface ProjectGroupMapper extends BaseMapper<ProjectGroup> {
}

View File

@ -30,6 +30,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
project_name,
contract_amount,
project_importance,
project_creator,
pt1.project_class_name as project_class_name,
pt2.project_class_name as project_subclass_name,
is_completed,
@ -50,7 +51,8 @@ public interface ProjectMapper extends BaseMapper<Project> {
@Result(column = "project_class_name", property = "projectClassName"),
@Result(column = "is_completed", property = "IsCompleted"),
@Result(column = "is_deleted", property = "IsDeleted"),
@Result(column = "project_close_time", property = "projectCloseTime")
@Result(column = "project_close_time", property = "projectCloseTime"),
@Result(column = "project_creator", property = "projectCreator")
})
IPage<ResultProject> findMyProject(IPage<ResultProject> pg, @Param("id") Integer staff_id, @Param(Constants.WRAPPER) Wrapper<Project> wrapper);
}

View File

@ -0,0 +1,14 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author
* created at 2022/6/30 21:36
*/
public interface IProjectGroupService extends IService<ProjectGroup>{
public Boolean addCreator(Integer projectId,Integer staffId);
}

View File

@ -22,5 +22,5 @@ public interface IProjectService extends IService<Project> {
Boolean setProjectCompleted(String token, Integer projectId) throws TokenException, BadRequestException;
Boolean makeANewProject(Project project) throws TokenException;
Boolean createProject(String token,Project project) throws TokenException, BadRequestException;
}

View File

@ -0,0 +1,24 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.mapper.ProjectGroupMapper;
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author
* created at 2022/6/30 21:38
*/
@Service
public class ProjectGroupServiceImpl extends ServiceImpl<ProjectGroupMapper, ProjectGroup> implements IProjectGroupService {
public Boolean addCreator(Integer projectId,Integer staffId){
if(projectId==null||staffId==null)
return false;
ProjectGroup projectGroup=new ProjectGroup();
projectGroup.setProjectId(projectId);
projectGroup.setStaffId(staffId);
projectGroup.setProjectStaffPosition("负责人");
return baseMapper.insert(projectGroup) == 1;
}
}

View File

@ -1,6 +1,7 @@
package cn.edu.hfut.rmdjzz.projectmanagement.service.impl;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Project;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ProjectGroup;
import cn.edu.hfut.rmdjzz.projectmanagement.entity.ResultProject;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
@ -13,6 +14,7 @@ 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@ -26,7 +28,8 @@ import java.util.Objects;
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements IProjectService {
@Autowired
private ProjectGroupServiceImpl projectGroupServiceImpl;
@Override
public Long getAllProjectOfStaff(String token) throws TokenException {
Integer staffId = TokenUtils.getStaffId(token);
@ -40,7 +43,7 @@ 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);
IPage<ResultProject> userPage = baseMapper.findMyProject(page, staffId, WrapperUtils.allEqAndTimeIntervalQueryWrapper(params, false));
return (Page<ResultProject>) userPage;
@ -66,8 +69,28 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
}
@Override
public Boolean makeANewProject(Project project) throws TokenException {
return null;
public Boolean createProject(String token,Project project) throws TokenException, BadRequestException {
project.setProjectId(null);
project.setIsCompleted(false);
project.setProjectCreator(TokenUtils.getStaffId(token));
project.setProjectCloseTime(null);
if(project.getExpectedCompletion()==null){
project.setExpectedCompletion((short) 100);
}
else if(project.getExpectedCompletion()<0||project.getExpectedCompletion()>100||
project.getProjectStartTime()==null||project.getProjectEndTime()==null||
project.getProjectStartTime().isAfter(project.getProjectEndTime())
){
throw new BadRequestException("参数错误");
}
try{
if(baseMapper.insert(project)==1){
return projectGroupServiceImpl.addCreator(project.getProjectId(),TokenUtils.getStaffId(token));
}
}catch(Exception e){
System.out.println(e);
throw new BadRequestException("新建失败");
}
return false;
}
}