From 0bc3e6364efb4f6e16585c93afb84a6b1830feb5 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 21 七月 2025 14:41:07 +0800 Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 766820b..ed37278 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -1,9 +1,6 @@ package com.ruoyi.system.service.impl; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import javax.annotation.Resource; import javax.validation.Validator; @@ -13,6 +10,7 @@ import com.ruoyi.chargingPile.api.feignClient.SiteClient; import com.ruoyi.chargingPile.api.model.Site; import com.ruoyi.common.core.web.page.PageInfo; +import com.ruoyi.common.security.service.TokenService; import com.ruoyi.other.api.feignClient.RoleSiteClient; import com.ruoyi.other.api.feignClient.UserSiteClient; import com.ruoyi.system.api.query.ChangeUserQuery; @@ -89,6 +87,9 @@ @Resource private ISysRoleService sysRoleService; + + @Resource + private TokenService tokenService; /** @@ -235,7 +236,8 @@ */ @Override public void checkUserAllowed(SysUser user) { - if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { + Long userid = tokenService.getLoginUser().getUserid(); + if (StringUtils.isNotNull(user.getUserId()) && !userid.equals(user.getUserId()) && user.isAdmin()) { throw new ServiceException("不允许操作超级管理员用户"); } } @@ -247,7 +249,7 @@ */ @Override public void checkUserDataScope(Long userId) { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) { + if (!SysUser.isAdmin(tokenService.getLoginUser().getUserid())) { SysUser user = new SysUser(); user.setUserId(userId); List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user); @@ -267,12 +269,16 @@ @Transactional(rollbackFor = Exception.class) public int insertUser(SysUser user) { // 新增用户信息 - int rows = userMapper.insertUser(user); +// int rows = userMapper.insertUser(user); // // 新增用户岗位关联 // insertUserPost(user); // // 新增用户与角色管理 // insertUserRole(user); - return rows; + user.setCreateTime(new Date()); + user.setCreateBy(tokenService.getLoginUser().getUsername()); + user.setUpdateTime(new Date()); + user.setUpdateBy(tokenService.getLoginUser().getUsername()); + return userMapper.insert(user); } /** @@ -537,11 +543,11 @@ data1.addAll(data); } Set<Integer> siteIds = new HashSet<>(data1); - sysUser.setSiteIds(siteIds.stream().collect(Collectors.toList())); List<Site> data = siteClient.getSiteByIds(siteIds.stream().collect(Collectors.toList())).getData(); if (null != data) { List<String> siteNames = data.stream().map(Site::getName).collect(Collectors.toList()); sysUser.setSiteNames(siteNames); + sysUser.setSiteIds(data.stream().map(Site::getId).collect(Collectors.toList())); } List<String> roleNames = new ArrayList<>(); for (SysUserRole sysUserRole : list1) { -- Gitblit v1.7.1