bug:子模块子系统查询,添加bug修复 #30

Merged
XiaoLFeng merged 5 commits from feature-jie into develop 2024-04-19 19:15:35 +08:00
11 changed files with 41 additions and 23 deletions

View File

@ -44,7 +44,7 @@ public class ModuleController {
* @return 子模块列表
*/
@GetMapping("/module/get/min")
public BaseResponse moduleGetBySysId(@RequestParam Integer sysId, HttpServletRequest request) {
public BaseResponse moduleGetBySysId(@RequestParam Long sysId, HttpServletRequest request) {
return moduleService.getBySysId(sysId, request);
}

View File

@ -15,7 +15,7 @@ public interface ModuleMapper {
List<ProjectChildDO> getByProjectId(Integer projectId, Long userId, int is);
List<ProjectModuleDO> getBySysId(Integer sysId, Long userId, int is);
List<ProjectModuleDO> getBySysId(Long sysId, Long userId, int is);
@Select("select principal_id from organize_oa.oa_project where id=#{projectId}")
Long getPidByProjectid(Integer projectId);

View File

@ -31,9 +31,9 @@ public interface ProjectMapper {
void projectWorkAdd(ProjectChildAddVO projectChildAddVO);
@Insert("insert into organize_oa.oa_project_modules (project_child_id, name, principal_id,"
+ " work_load, description, status, dead_line) "
+ " work_load, description, status, dead_line,cycle) "
+ "value (#{projectChildId},#{name},#{principalId},#{workLoad},"
+ "#{description},#{status},#{deadLine})")
+ "#{description},#{status},#{deadLine},#{cycle})")
void projectModuleAdd(ProjectModuleAddVO projectModuleAddVO);
void projectEdit(ProjectDO projectEdit);

View File

@ -13,6 +13,7 @@ public class ProjectModuleDO {
private Long id;
private Long projectChildId;
private Long principalId;
private Integer cycle;
private Integer workLoad;
private String description;
private String name;

View File

@ -16,6 +16,8 @@ public class ProjectModuleAddVO {
private Long principalId;
@NotNull(message = "工作量不能为空")
private Integer workLoad;
@NotNull(message = "周期不能为空")
private Integer cycle;
@NotNull(message = "名字不能为空")
private String name;
private String description;

View File

@ -15,7 +15,6 @@ import java.sql.Timestamp;
public class ProjectWorkAndNameVO {
private Long id;
private String childSystemName;
private Long projectChildId;
private Long principalId;
private String principalUser;
@ -23,11 +22,8 @@ public class ProjectWorkAndNameVO {
private Integer workLoad;
private String name;
private String description;
private Integer isDelete;
private String status;
private Timestamp deadLine;
private Timestamp beginTime;
private Timestamp completeTime;
}

View File

@ -8,7 +8,7 @@ import javax.servlet.http.HttpServletRequest;
public interface ModuleService {
BaseResponse getByProjectId(Integer projectId, HttpServletRequest request);
BaseResponse getBySysId(Integer sysId, HttpServletRequest request);
BaseResponse getBySysId(Long sysId, HttpServletRequest request);
BaseResponse deleteById(HttpServletRequest request, Long id);
}

View File

@ -1,5 +1,7 @@
package com.jsl.oa.services.impl;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.jsl.oa.dao.ProjectDAO;
import com.jsl.oa.dao.RoleDAO;
import com.jsl.oa.dao.UserDAO;
@ -21,6 +23,8 @@ import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import static java.lang.System.*;
@Slf4j
@Service
@RequiredArgsConstructor
@ -29,6 +33,7 @@ public class ModuleServiceImpl implements ModuleService {
private final ModuleMapper moduleMapper;
private final UserDAO userDAO;
private final RoleDAO roleDAO;
private final Gson gson;
@Override
public BaseResponse getByProjectId(Integer projectId, HttpServletRequest request) {
@ -48,21 +53,28 @@ public class ModuleServiceImpl implements ModuleService {
for (ProjectChildDO projectWorkDO : projectWorkDOList) {
ProjectChildGetVO projectWorkAndNameVO = new ProjectChildGetVO();
Processing.copyProperties(projectWorkDO, projectWorkAndNameVO);
projectWorkAndNameVO.setPrincipalName(userDAO.getUserById(projectWorkDO.getPrincipalId()).getUsername());
//描述转换,负责人名字转换
JsonObject jsonObject = gson.fromJson(projectWorkDO.getDescription(), JsonObject.class);
projectWorkAndNameVO.setDescription(jsonObject.get("description").getAsString());
if (projectWorkDO.getPrincipalId() != null) {
projectWorkAndNameVO
.setPrincipalName(userDAO.getUserById(projectWorkDO.getPrincipalId()).getUsername());
}
projectWorkAndNameVOS.add(projectWorkAndNameVO);
}
return ResultUtil.success(projectWorkAndNameVOS);
}
@SuppressWarnings("checkstyle:Regexp")
@Override
public BaseResponse getBySysId(Integer sysId, HttpServletRequest request) {
public BaseResponse getBySysId(Long sysId, HttpServletRequest request) {
log.info("SysService");
//获取用户id
Long userId = Processing.getAuthHeaderToUserId(request);
//获取子系统负责人id
Long pid = moduleMapper.getPidBySysid(sysId);
Long pid = moduleMapper.getPidBySysid(sysId.intValue());
//获取项目负责人id
Long prid = moduleMapper.getPridBySysyid(sysId);
Long prid = moduleMapper.getPridBySysyid(sysId.intValue());
//判断是否是子系统/项目负责人
int is = 1;
if (!pid.equals(userId) && !prid.equals(userId)) {
@ -70,18 +82,20 @@ public class ModuleServiceImpl implements ModuleService {
}
List<ProjectModuleDO> projectWorkDOList = moduleMapper.getBySysId(sysId, userId, is);
out.println(projectWorkDOList.size());
// 封装VO类
List<ProjectWorkAndNameVO> projectWorkAndNameVOS = new ArrayList<>();
for (ProjectModuleDO projectWorkDO : projectWorkDOList) {
ProjectWorkAndNameVO projectWorkAndNameVO = new ProjectWorkAndNameVO();
Processing.copyProperties(projectWorkDO, projectWorkAndNameVO);
// 添加负责人和子系统名称
projectWorkAndNameVO.
setChildSystemName(projectDAO.getProjectWorkerById(projectWorkDO.getProjectChildId()).getName())
.setPrincipalUser(userDAO.getUserById(projectWorkDO.getPrincipalId()).getUsername());
//描述转换负责人名字转换
JsonObject jsonObject = gson.fromJson(projectWorkDO.getDescription(), JsonObject.class);
projectWorkAndNameVO.setDescription(jsonObject.get("description").getAsString());
if (projectWorkDO.getPrincipalId() != null) {
projectWorkAndNameVO
.setPrincipalUser(userDAO.getUserById(projectWorkDO.getPrincipalId()).getUsername());
}
projectWorkAndNameVOS.add(projectWorkAndNameVO);
}
return ResultUtil.success(projectWorkAndNameVOS);
}

View File

@ -2,7 +2,7 @@ create table oa_project
(
id bigint unsigned auto_increment comment '项目id'
primary key,
name varchar(255) not null comment '项目名称',
name varchar(255) not null unique comment '项目名称',
principal_id bigint unsigned not null comment '项目负责人',
description json null comment '项目描述(技术选择,描述)',
tags json null comment '项目标签项目类型web大数据等',

View File

@ -6,13 +6,15 @@ create table oa_project_child
name varchar(100) not null comment '项目名称',
principal_id bigint unsigned not null comment '项目负责人',
description json null comment '项目描述(技术选择,描述)',
cycle int unsigned not null comment '项目周期',
cycle int unsigned not null comment '系统周期',
work_load int unsigned default '1' not null comment '工作量(人天)',
files json null comment '子项目文件',
complete_time date null comment '完成时间',
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
updated_at timestamp null comment '更新时间',
is_delete tinyint(1) default 0 not null comment '项目是否删除',
dead_line timestamp not null comment '子系统的截止时间',
status varchar(8) default 'progress' not null comment '系统状态draft: 草稿progress: 进行pause: 暂停abnormal: 异常complete: 完成)',
constraint oa_project_child_oa_user_id_fk
foreign key (principal_id) references oa_user (id)
on update cascade

View File

@ -6,14 +6,17 @@ create table oa_project_modules
name varchar(100) not null comment '模块名称',
principal_id bigint unsigned not null comment '模块负责人',
description json null comment '项目描述(技术选择,描述)',
cycle int unsigned null comment '模块周期',
cycle int unsigned not null comment '模块周期',
362612387 marked this conversation as resolved Outdated

项目还是模块?

项目还是模块?
work_load int unsigned default '1' not null comment '工作量(人天)',
complete_time datetime null comment '完成时间',
created_at timestamp default CURRENT_TIMESTAMP not null comment '创建时间',
updated_at timestamp null comment '更新时间',
is_delete tinyint(1) default 0 not null comment '项目是否删除',
dead_line timestamp not null comment '子模块的截止时间',
status varchar(8) default 'progress' not null comment '模块状态draft: 草稿progress: 进行pause: 暂停abnormal: 异常complete: 完成)',
constraint oa_project_modules_oa_user_id_fk
foreign key (principal_id) references oa_user (id)
on update cascade
)
comment '模块表';
comment '模块表';