From 363f7d1a2f793f4c72f8123d32f3d4d10c9551bf Mon Sep 17 00:00:00 2001 From: Quella <2892744389@qq.com> Date: Mon, 8 Sep 2025 17:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=90=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BizSubModuleController.java | 199 +++++++++++ .../com/ruoyi/models/domain/BizSubModule.java | 115 +++++++ .../models/mapper/BizSubModuleMapper.java | 26 ++ .../models/service/IBizSubModuleService.java | 36 ++ .../service/impl/BizSubModuleServiceImpl.java | 122 +++++++ .../mapper/models/BizSubModuleMapper.xml | 99 ++++++ ruoyi-ui/src/api/project/submodule.js | 79 +++++ ruoyi-ui/src/views/models/models/index.vue | 316 ------------------ ruoyi-ui/src/views/project/module/index.vue | 73 ++-- .../src/views/project/module/myModules.vue | 161 ++++++++- 10 files changed, 859 insertions(+), 367 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/models/controller/BizSubModuleController.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/models/domain/BizSubModule.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/models/mapper/BizSubModuleMapper.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/models/service/IBizSubModuleService.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/models/service/impl/BizSubModuleServiceImpl.java create mode 100644 ruoyi-admin/src/main/resources/mapper/models/BizSubModuleMapper.xml create mode 100644 ruoyi-ui/src/api/project/submodule.js delete mode 100644 ruoyi-ui/src/views/models/models/index.vue diff --git a/ruoyi-admin/src/main/java/com/ruoyi/models/controller/BizSubModuleController.java b/ruoyi-admin/src/main/java/com/ruoyi/models/controller/BizSubModuleController.java new file mode 100644 index 0000000..6c8357a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/models/controller/BizSubModuleController.java @@ -0,0 +1,199 @@ +package com.ruoyi.models.controller; + +import java.util.List; +import java.util.Map; +import java.util.HashMap; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.models.domain.BizSubModule; +import com.ruoyi.models.domain.BizModule; +import com.ruoyi.models.service.IBizSubModuleService; +import com.ruoyi.models.service.IBizModuleService; +import com.ruoyi.project.service.IBizProjectService; + +/** + * 子模块Controller + */ +@RestController +@RequestMapping("/project/submodule") +public class BizSubModuleController extends BaseController +{ + @Autowired + private IBizSubModuleService subService; + + @Autowired + private IBizModuleService moduleService; + + @Autowired + private IBizProjectService projectService; + + /** + * 查询子模块列表(按条件) + */ + @PreAuthorize("@ss.hasPermi('project:module:list')") + @GetMapping("/list") + public TableDataInfo list(BizSubModule subModule) + { + startPage(); + List list = subService.selectBizSubModuleList(subModule); + return getDataTable(list); + } + + /** + * 按模块ID查询子模块 + */ + @PreAuthorize("@ss.hasPermi('project:module:list')") + @GetMapping("/byModule/{moduleId}") + public TableDataInfo listByModule(@PathVariable Long moduleId) + { + startPage(); + List list = subService.selectByModuleId(moduleId); + return getDataTable(list); + } + + /** 获取详情 */ + @PreAuthorize("@ss.hasPermi('project:module:query')") + @GetMapping(value = "/{subId}") + public AjaxResult getInfo(@PathVariable("subId") Long subId) + { + return success(subService.selectBizSubModuleBySubId(subId)); + } + + /** 新增子模块(仅父模块接取人,且父模块需处于进行中)*/ + @PreAuthorize("@ss.hasPermi('project:module:add')") + @Log(title = "子模块", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BizSubModule subModule) + { + if (subModule.getModuleId() == null) + { + return AjaxResult.error("缺少所属模块"); + } + BizModule module = moduleService.selectBizModuleByModuleId(subModule.getModuleId()); + if (module == null) + { + return AjaxResult.error("父模块不存在"); + } + // 仅模块接取人可新增子模块 + if (!String.valueOf(getUserId()).equals(module.getAssignee())) + { + return AjaxResult.error("仅接取人可在该模块下新增子模块"); + } + // 父模块需处于进行中 + if (!"1".equals(module.getStatus())) + { + return AjaxResult.error("父模块未处于进行中,无法新增子模块"); + } + subModule.setStatus("0"); + return toAjax(subService.insertBizSubModule(subModule)); + } + + /** 修改子模块(仅模块接取人) */ + @PreAuthorize("@ss.hasPermi('project:module:edit')") + @Log(title = "子模块", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BizSubModule subModule) + { + BizSubModule current = subService.selectBizSubModuleBySubId(subModule.getSubId()); + if (current == null) + { + return AjaxResult.error("子模块不存在"); + } + BizModule module = moduleService.selectBizModuleByModuleId(current.getModuleId()); + if (!String.valueOf(getUserId()).equals(module.getAssignee())) + { + return AjaxResult.error("仅接取人可修改子模块"); + } + return toAjax(subService.updateBizSubModule(subModule)); + } + + /** 删除子模块(软删除,且仅模块接取人,有状态限制:非进行中/已完成可删或随需) */ + @PreAuthorize("@ss.hasPermi('project:module:remove')") + @Log(title = "子模块", businessType = BusinessType.DELETE) + @DeleteMapping("/{subIds}") + public AjaxResult remove(@PathVariable Long[] subIds) + { + for (Long subId : subIds) + { + BizSubModule sub = subService.selectBizSubModuleBySubId(subId); + if (sub == null) + { + return AjaxResult.error("子模块不存在"); + } + BizModule module = moduleService.selectBizModuleByModuleId(sub.getModuleId()); + if (!String.valueOf(getUserId()).equals(module.getAssignee())) + { + return AjaxResult.error("仅接取人可删除子模块"); + } + } + return toAjax(subService.deleteBizSubModuleBySubIds(subIds)); + } + + /** 接取子模块(仅模块接取人) */ + @PreAuthorize("@ss.hasPermi('project:module:claim')") + @Log(title = "子模块接取", businessType = BusinessType.UPDATE) + @PostMapping("/receive/{subId}") + public AjaxResult receive(@PathVariable Long subId) + { + return toAjax(subService.receiveSubModule(subId, getUserId())); + } + + /** 完成子模块(仅模块接取人) */ + @PreAuthorize("@ss.hasPermi('project:module:complete')") + @Log(title = "子模块完成", businessType = BusinessType.UPDATE) + @PostMapping("/complete/{subId}") + public AjaxResult complete(@PathVariable Long subId) + { + return toAjax(subService.completeSubModule(subId, getUserId())); + } + + /** + * 管理员或项目管理员:查看项目下模块及其子模块 + */ + @PreAuthorize("@ss.hasPermi('project:module:list')") + @GetMapping("/treeByProject/{projectId}") + public AjaxResult treeByProject(@PathVariable Long projectId) + { + com.ruoyi.project.domain.BizProject project = projectService.selectBizProjectByProjectId(projectId); + if (project == null) + { + return AjaxResult.error("项目不存在"); + } + Long currentUserId = getUserId(); + boolean isOwner = project.getOwnerId() != null && project.getOwnerId().equals(currentUserId); + boolean isAdmin = com.ruoyi.common.utils.SecurityUtils.isAdmin(currentUserId); + if (!isOwner && !isAdmin) + { + return AjaxResult.error("无权查看该项目结构"); + } + + com.ruoyi.models.domain.BizModule query = new com.ruoyi.models.domain.BizModule(); + query.setProjectId(projectId); + List modules = moduleService.selectBizModuleList(query); + java.util.List> result = new java.util.ArrayList<>(); + for (com.ruoyi.models.domain.BizModule m : modules) + { + Map item = new HashMap<>(); + item.put("module", m); + item.put("subModules", subService.selectByModuleId(m.getModuleId())); + result.add(item); + } + return AjaxResult.success(result); + } +} + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/models/domain/BizSubModule.java b/ruoyi-admin/src/main/java/com/ruoyi/models/domain/BizSubModule.java new file mode 100644 index 0000000..1742fc9 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/models/domain/BizSubModule.java @@ -0,0 +1,115 @@ +package com.ruoyi.models.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 子模块对象 biz_sub_module + */ +public class BizSubModule extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 子模块ID */ + private Long subId; + + /** 所属模块ID */ + @Excel(name = "所属模块ID") + private Long moduleId; + + /** 子模块名称 */ + @Excel(name = "子模块名称") + private String subName; + + /** 状态(0待处理 1进行中 2已完成) */ + @Excel(name = "状态(0待处理 1进行中 2已完成)") + private String status; + + /** 描述 */ + @Excel(name = "描述") + private String description; + + /** 删除标志0=正常,2=软删除 */ + private String delFlag; + + public Long getSubId() + { + return subId; + } + + public void setSubId(Long subId) + { + this.subId = subId; + } + + public Long getModuleId() + { + return moduleId; + } + + public void setModuleId(Long moduleId) + { + this.moduleId = moduleId; + } + + public String getSubName() + { + return subName; + } + + public void setSubName(String subName) + { + this.subName = subName; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + @Override + public String toString() + { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("subId", getSubId()) + .append("moduleId", getModuleId()) + .append("subName", getSubName()) + .append("status", getStatus()) + .append("description", getDescription()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/models/mapper/BizSubModuleMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/models/mapper/BizSubModuleMapper.java new file mode 100644 index 0000000..61278a7 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/models/mapper/BizSubModuleMapper.java @@ -0,0 +1,26 @@ +package com.ruoyi.models.mapper; + +import java.util.List; +import com.ruoyi.models.domain.BizSubModule; + +/** + * 子模块Mapper接口 + */ +public interface BizSubModuleMapper +{ + public BizSubModule selectBizSubModuleBySubId(Long subId); + + public List selectBizSubModuleList(BizSubModule subModule); + + public int insertBizSubModule(BizSubModule subModule); + + public int updateBizSubModule(BizSubModule subModule); + + public int deleteBizSubModuleBySubId(Long subId); + + public int deleteBizSubModuleBySubIds(Long[] subIds); + + public List selectByModuleId(Long moduleId); +} + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/models/service/IBizSubModuleService.java b/ruoyi-admin/src/main/java/com/ruoyi/models/service/IBizSubModuleService.java new file mode 100644 index 0000000..4b67ee5 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/models/service/IBizSubModuleService.java @@ -0,0 +1,36 @@ +package com.ruoyi.models.service; + +import java.util.List; +import com.ruoyi.models.domain.BizSubModule; + +/** + * 子模块Service接口 + */ +public interface IBizSubModuleService +{ + public BizSubModule selectBizSubModuleBySubId(Long subId); + + public List selectBizSubModuleList(BizSubModule subModule); + + public int insertBizSubModule(BizSubModule subModule); + + public int updateBizSubModule(BizSubModule subModule); + + public int deleteBizSubModuleBySubIds(Long[] subIds); + + public int deleteBizSubModuleBySubId(Long subId); + + public List selectByModuleId(Long moduleId); + + /** + * 用户接取子模块(仅父模块接取人有权) + */ + public int receiveSubModule(Long subId, Long userId); + + /** + * 用户完成子模块(仅接取人有权) + */ + public int completeSubModule(Long subId, Long userId); +} + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/models/service/impl/BizSubModuleServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/models/service/impl/BizSubModuleServiceImpl.java new file mode 100644 index 0000000..0cc7b33 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/models/service/impl/BizSubModuleServiceImpl.java @@ -0,0 +1,122 @@ +package com.ruoyi.models.service.impl; + +import java.util.List; + +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.models.mapper.BizSubModuleMapper; +import com.ruoyi.models.mapper.BizModuleMapper; +import com.ruoyi.models.domain.BizSubModule; +import com.ruoyi.models.domain.BizModule; +import com.ruoyi.models.service.IBizSubModuleService; + +/** + * 子模块Service业务层处理 + */ +@Service +public class BizSubModuleServiceImpl implements IBizSubModuleService +{ + @Autowired + private BizSubModuleMapper subMapper; + + @Autowired + private BizModuleMapper moduleMapper; + + @Override + public BizSubModule selectBizSubModuleBySubId(Long subId) + { + return subMapper.selectBizSubModuleBySubId(subId); + } + + @Override + public List selectBizSubModuleList(BizSubModule subModule) + { + return subMapper.selectBizSubModuleList(subModule); + } + + @Override + public int insertBizSubModule(BizSubModule subModule) + { + subModule.setCreateTime(DateUtils.getNowDate()); + subModule.setStatus(subModule.getStatus() == null ? "0" : subModule.getStatus()); + return subMapper.insertBizSubModule(subModule); + } + + @Override + public int updateBizSubModule(BizSubModule subModule) + { + subModule.setUpdateTime(DateUtils.getNowDate()); + return subMapper.updateBizSubModule(subModule); + } + + @Override + public int deleteBizSubModuleBySubIds(Long[] subIds) + { + return subMapper.deleteBizSubModuleBySubIds(subIds); + } + + @Override + public int deleteBizSubModuleBySubId(Long subId) + { + return subMapper.deleteBizSubModuleBySubId(subId); + } + + @Override + public List selectByModuleId(Long moduleId) + { + return subMapper.selectByModuleId(moduleId); + } + + @Override + public int receiveSubModule(Long subId, Long userId) + { + BizSubModule sub = selectBizSubModuleBySubId(subId); + if (sub == null || !"0".equals(sub.getStatus())) + { + throw new RuntimeException("子模块不存在或状态异常"); + } + + BizModule module = moduleMapper.selectBizModuleByModuleId(sub.getModuleId()); + if (module == null) + { + throw new RuntimeException("父模块不存在"); + } + if (!String.valueOf(userId).equals(module.getAssignee())) + { + throw new RuntimeException("仅父模块接取人可接取子模块"); + } + + sub.setStatus("1"); + sub.setUpdateBy(String.valueOf(userId)); + sub.setUpdateTime(DateUtils.getNowDate()); + return updateBizSubModule(sub); + } + + @Override + public int completeSubModule(Long subId, Long userId) + { + BizSubModule sub = selectBizSubModuleBySubId(subId); + if (sub == null || !"1".equals(sub.getStatus())) + { + throw new RuntimeException("子模块不存在或状态异常"); + } + + BizModule module = moduleMapper.selectBizModuleByModuleId(sub.getModuleId()); + if (module == null) + { + throw new RuntimeException("父模块不存在"); + } + if (!String.valueOf(userId).equals(module.getAssignee())) + { + throw new RuntimeException("仅父模块接取人可完成子模块"); + } + + sub.setStatus("2"); + sub.setUpdateBy(String.valueOf(userId)); + sub.setUpdateTime(DateUtils.getNowDate()); + return updateBizSubModule(sub); + } +} + + diff --git a/ruoyi-admin/src/main/resources/mapper/models/BizSubModuleMapper.xml b/ruoyi-admin/src/main/resources/mapper/models/BizSubModuleMapper.xml new file mode 100644 index 0000000..54fb9e5 --- /dev/null +++ b/ruoyi-admin/src/main/resources/mapper/models/BizSubModuleMapper.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + select sub_id, module_id, sub_name, status, description, del_flag, create_by, create_time, update_by, update_time + from biz_sub_module + + + + + + + + + + insert into biz_sub_module + + module_id, + sub_name, + status, + description, + del_flag, + create_by, + create_time, + + + #{moduleId}, + #{subName}, + #{status}, + #{description}, + #{delFlag}, + #{createBy}, + #{createTime}, + + + + + update biz_sub_module + + module_id = #{moduleId}, + sub_name = #{subName}, + status = #{status}, + description = #{description}, + del_flag = #{delFlag}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where sub_id = #{subId} + + + + update biz_sub_module set del_flag = '2' where sub_id = #{subId} + + + + update biz_sub_module set del_flag = '2' where sub_id in + + #{id} + + + + + + diff --git a/ruoyi-ui/src/api/project/submodule.js b/ruoyi-ui/src/api/project/submodule.js new file mode 100644 index 0000000..f140d60 --- /dev/null +++ b/ruoyi-ui/src/api/project/submodule.js @@ -0,0 +1,79 @@ +import request from '@/utils/request' + +// 查询子模块列表 +export function listSubmodule(query) { + return request({ + url: '/project/submodule/list', + method: 'get', + params: query + }) +} + +// 按模块查询子模块 +export function listSubmoduleByModule(moduleId, query) { + return request({ + url: '/project/submodule/byModule/' + moduleId, + method: 'get', + params: query + }) +} + +// 获取子模块详情 +export function getSubmodule(subId) { + return request({ + url: '/project/submodule/' + subId, + method: 'get' + }) +} + +// 新增子模块 +export function addSubmodule(data) { + return request({ + url: '/project/submodule', + method: 'post', + data: data + }) +} + +// 修改子模块 +export function updateSubmodule(data) { + return request({ + url: '/project/submodule', + method: 'put', + data: data + }) +} + +// 删除子模块(软删) +export function delSubmodule(subIds) { + return request({ + url: '/project/submodule/' + subIds, + method: 'delete' + }) +} + +// 接取子模块 +export function receiveSubmodule(subId) { + return request({ + url: '/project/submodule/receive/' + subId, + method: 'post' + }) +} + +// 完成子模块 +export function completeSubmodule(subId) { + return request({ + url: '/project/submodule/complete/' + subId, + method: 'post' + }) +} + +// 管理员查看项目下模块及子模块树 +export function treeByProject(projectId) { + return request({ + url: '/project/submodule/treeByProject/' + projectId, + method: 'get' + }) +} + + diff --git a/ruoyi-ui/src/views/models/models/index.vue b/ruoyi-ui/src/views/models/models/index.vue deleted file mode 100644 index a775f01..0000000 --- a/ruoyi-ui/src/views/models/models/index.vue +++ /dev/null @@ -1,316 +0,0 @@ - - - diff --git a/ruoyi-ui/src/views/project/module/index.vue b/ruoyi-ui/src/views/project/module/index.vue index 05e1b22..010c322 100644 --- a/ruoyi-ui/src/views/project/module/index.vue +++ b/ruoyi-ui/src/views/project/module/index.vue @@ -40,55 +40,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + +