From 2c99eb1b27b9fbad752aaeab8783399af32514e6 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 15 一月 2025 21:00:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | 63 ++++++++++++++++++++++---------
1 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
index f484336..2b26388 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -6,6 +6,7 @@
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
+import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysRole;
@@ -14,9 +15,11 @@
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.service.ISysDeptService;
+import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -35,6 +38,15 @@
@Autowired
private SysRoleMapper roleMapper;
+
+ @Resource
+ private TokenService tokenService;
+
+ @Resource
+ private ISysUserService sysUserService;
+
+
+
/**
* 查询部门管理数据
@@ -44,8 +56,12 @@
*/
@Override
@DataScope(deptAlias = "d")
- public List<SysDept> selectDeptList(SysDept dept)
- {
+ public List<SysDept> selectDeptList(SysDept dept) {
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserService.getById(userid);
+ if(sysUser.getRoleType() == 2){
+ dept.setShopId(sysUser.getObjectId());
+ }
return deptMapper.selectDeptList(dept);
}
@@ -212,13 +228,19 @@
@Override
public int insertDept(SysDept dept)
{
- SysDept info = deptMapper.selectDeptById(dept.getParentId());
- // 如果父节点不为正常状态,则不允许新增子节点
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
- {
- throw new ServiceException("部门停用,不允许新增");
+// SysDept info = deptMapper.selectDeptById(dept.getParentId());
+// // 如果父节点不为正常状态,则不允许新增子节点
+// if (null != info && !UserConstants.DEPT_NORMAL.equals(info.getStatus()))
+// {
+// throw new ServiceException("部门停用,不允许新增");
+// }
+// dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+ //判断店铺数据
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserService.getById(userid);
+ if(sysUser.getRoleType() == 2){
+ dept.setShopId(sysUser.getObjectId());
}
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
@@ -231,14 +253,19 @@
@Override
public int updateDept(SysDept dept)
{
- SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
- SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
- if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
- {
- String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
- String oldAncestors = oldDept.getAncestors();
- dept.setAncestors(newAncestors);
- updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+// SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
+// SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
+// if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
+// String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
+// String oldAncestors = oldDept.getAncestors();
+// dept.setAncestors(newAncestors);
+// updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+// }
+ //判断店铺数据
+ Long userid = tokenService.getLoginUser().getUserid();
+ SysUser sysUser = sysUserService.getById(userid);
+ if(sysUser.getRoleType() == 2){
+ dept.setShopId(sysUser.getObjectId());
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
@@ -320,7 +347,7 @@
Iterator<SysDept> it = list.iterator();
while (it.hasNext())
{
- SysDept n = (SysDept) it.next();
+ SysDept n = it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
tlist.add(n);
@@ -334,6 +361,6 @@
*/
private boolean hasChild(List<SysDept> list, SysDept t)
{
- return getChildList(list, t).size() > 0 ? true : false;
+ return getChildList(list, t).size() > 0;
}
}
--
Gitblit v1.7.1