实现了新建项目和相关的数据库类
parent
0677f9a81d
commit
fa5ddab6b4
|
@ -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("操作成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import org.apache.poi.hpsf.Decimal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
|
@ -36,8 +36,8 @@ public class Project {
|
|||
private String projectCompany;
|
||||
private String projectDescription;
|
||||
private Boolean IsCompleted;
|
||||
private BigDecimal projectManMonth;
|
||||
@TableLogic
|
||||
private Boolean isDeleted;
|
||||
private Integer projectCreator;
|
||||
private Decimal projectManMonth;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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> {
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue