From 866f686c3c4ae1bd47affe146a26db5dd1ceb032 Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期三, 18 十二月 2024 14:57:44 +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 2fe6613..3f9f7e9 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
@@ -1,26 +1,29 @@
package com.ruoyi.system.service.impl;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import com.ruoyi.system.domain.vo.TreeSelect;
-import com.ruoyi.system.mapper.SysDeptMapper;
-import com.ruoyi.system.mapper.SysRoleMapper;
-import com.ruoyi.system.service.ISysDeptService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.text.Convert;
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;
import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.domain.vo.TreeSelect;
+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;
+import java.util.stream.Collectors;
/**
* 部门管理 服务实现
@@ -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);
}
@@ -214,11 +230,17 @@
{
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
+ 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());
+ }
return deptMapper.insertDept(dept);
}
@@ -233,12 +255,17 @@
{
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
- if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
- {
+ 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