返回信息调整
Some checks failed
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head There was a failure building this commit

This commit is contained in:
176yunxuan 2024-03-16 10:19:56 +08:00
parent ea457a6604
commit 61a4e2e592
6 changed files with 145 additions and 18 deletions

View File

@ -15,9 +15,9 @@ public interface ProjectMapper {
@Insert("insert into organize_oa.oa_project " +
"(name, description, principal_id, cycle,file,complete_time," +
"deadline,status,is_finish,tags) " +
"deadline,status,is_finish,tags,work_Load) " +
"value (#{name},#{description},#{principalId},#{cycle},#{file}" +
",#{completeTime},#{deadline},#{status},#{isFinish},#{tags})")
",#{completeTime},#{deadline},#{status},#{isFinish},#{tags},#{workLoad})")
void projectAdd(ProjectInfoVO projectAdd);
@Insert("insert into organize_oa.oa_project_work (project_id, pid, name, principal_id," +

View File

@ -29,6 +29,7 @@ public class ProjectDO {
private String description;
private Integer isDelete;
private Integer isFinish;
private Long workLoad;
private boolean status;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
private Timestamp beginTime;

View File

@ -1,5 +1,6 @@
package com.jsl.oa.model.voData;
import lombok.Builder;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@ -17,6 +18,8 @@ public class ProjectInfoVO {
private String description;
@NotNull(message = "周期不能为空")
private Long cycle;
@NotNull(message = "工作量不能为空")
private Long workLoad;
private String tags;
private String file;
private Timestamp completeTime;

View File

@ -0,0 +1,19 @@
package com.jsl.oa.model.voData;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProjectSimpleVO {
private String name;
private String principalUser;
private Integer isFinish;
private String description;
private Long cycle;
private Long workLoad;
private Long id;
private String tags;
}

View File

@ -1,6 +1,7 @@
package com.jsl.oa.services.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jsl.oa.annotations.CheckUserHasPermission;
import com.jsl.oa.dao.ProjectDAO;
@ -48,10 +49,14 @@ public class ProjectServiceImpl implements ProjectService {
private final RoleMapper roleMapper;
private final ProjectDAO projectDAO;
private final UserDAO userDAO;
private final ObjectMapper objectMapper;
@Override
public BaseResponse projectAdd(HttpServletRequest request, ProjectInfoVO projectAdd) {
log.info("\t> 执行 Service 层 ProjectService.projectAdd 方法");
if(projectAdd.getDescription().isEmpty()){
projectAdd.setDescription("{}");
}
projectDAO.projectAdd(projectAdd);
return ResultUtil.success("添加成功");
}
@ -69,23 +74,45 @@ public class ProjectServiceImpl implements ProjectService {
//根据id查询
if (id != null){
ProjectDO projectDO = projectMapper.tgetProjectById(id);
return ResultUtil.success(projectDO);
ProjectSimpleVO projectSimpleVO = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO,projectDO,userDAO,objectMapper);
return ResultUtil.success(projectSimpleVO);
}
//根据标签查询
if (tags != null && !tags.isEmpty()) {
List<ProjectDO> projectDOList = projectDAO.tget(id,isFinish,tags);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
//根据状态查询
if (isFinish != null && !isFinish.isEmpty()) {
List<ProjectDO> projectDOList = projectDAO.tget(id,isFinish,tags);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
List<ProjectDO> projectDOList = projectDAO.tget(id,isFinish,tags);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
@Override
@ -269,24 +296,49 @@ public class ProjectServiceImpl implements ProjectService {
//根据标签查询
if (tags != null && !tags.isEmpty()) {
List<ProjectDO> projectDOList = projectDAO.get(userId, listAll, tags, isFinish);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
//根据状态查询
if (isFinish != null && !isFinish.isEmpty()) {
List<ProjectDO> projectDOList = projectDAO.get(userId, listAll, tags, isFinish);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
//判断是否是老师(项目负责人)
if (listAll != null && Processing.checkUserIsTeacher(request, roleMapper)) {
List<ProjectDO> projectDOList = projectDAO.get(userId, listAll, tags, isFinish);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
} else {
listAll = 0;
List<ProjectDO> projectDOList = projectDAO.get(userId, listAll, tags, isFinish);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
}
@ -301,24 +353,48 @@ public class ProjectServiceImpl implements ProjectService {
//根据标签查询
if (tags != null && !tags.isEmpty()) {
List<ProjectDO> projectDOList = projectDAO.workget(userId, listAll, tags, isFinish,is);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
//根据状态查询
if (isFinish != null && !isFinish.isEmpty()) {
List<ProjectDO> projectDOList = projectDAO.workget(userId, listAll, tags, isFinish,is);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
//判断是否是老师(项目负责人)
if (listAll != null && Processing.checkUserIsTeacher(request, roleMapper)) {
List<ProjectDO> projectDOList = projectDAO.workget(userId, listAll, tags, isFinish,is);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
} else {
listAll = 0;
List<ProjectDO> projectDOList = projectDAO.workget(userId, listAll, tags, isFinish,is);
return ResultUtil.success(projectDOList);
List<ProjectSimpleVO> projectSimpleVOList = new ArrayList<>();
for (ProjectDO projectDO:projectDOList){
ProjectSimpleVO projectSimpleVO1 = new ProjectSimpleVO();
Processing.projectTosimply(projectSimpleVO1,projectDO,userDAO,objectMapper);
projectSimpleVOList.add(projectSimpleVO1);
}
return ResultUtil.success(projectSimpleVOList);
}
}

View File

@ -1,14 +1,16 @@
package com.jsl.oa.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jsl.oa.dao.PermissionDAO;
import com.jsl.oa.dao.RoleDAO;
import com.jsl.oa.dao.UserDAO;
import com.jsl.oa.exception.ClassCopyException;
import com.jsl.oa.mapper.RoleMapper;
import com.jsl.oa.model.doData.PermissionDO;
import com.jsl.oa.model.doData.RoleDO;
import com.jsl.oa.model.doData.RoleUserDO;
import com.jsl.oa.model.doData.UserDO;
import com.jsl.oa.model.doData.*;
import com.jsl.oa.model.voData.PermissionContentVo;
import com.jsl.oa.model.voData.ProjectSimpleVO;
import com.jsl.oa.model.voData.UserCurrentBackVO;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
@ -346,7 +348,33 @@ public class Processing {
return userDOS;
}
public static void projectTosimply(ProjectSimpleVO projectSimpleVO, ProjectDO projectDO,
UserDAO userDAO,ObjectMapper objectMapper) {
projectSimpleVO.setId(projectDO.getId());
projectSimpleVO.setName(projectDO.getName());
projectSimpleVO.setTags(projectDO.getTags());
projectSimpleVO.setCycle(projectDO.getCycle());
projectSimpleVO.setIsFinish(projectDO.getIsFinish());
projectSimpleVO.setWorkLoad(projectDO.getWorkLoad());
projectSimpleVO.setPrincipalUser(userDAO.getUserById(projectDO.getPrincipalId()).getUsername());
// 解析JSON字符串
JsonNode rootNode = null;
try {
rootNode = objectMapper.readTree(projectDO.getDescription());
// 访问特定的key
JsonNode targetNode = rootNode.get("description");
if(targetNode != null && !rootNode.isNull()){
projectSimpleVO.setDescription(targetNode.asText());
}else{
projectSimpleVO.setDescription("null");
}
} catch (JsonProcessingException ignored) {
}
//return ProjectSimpleVO;
}
/**
* @Description: 将Permission归纳为父子关系的json形式