From 5ca038d888922e93bf45c7bd37f3c6dce849dcff Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 24 十二月 2021 11:36:02 +0800
Subject: [PATCH] update 调整监控依赖 从 common 迁移到 framework

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
index 6e0ed78..514afb1 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
@@ -1,14 +1,14 @@
 package com.ruoyi.system.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.ruoyi.common.annotation.DataScope;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.core.domain.PageQuery;
 import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.spring.SpringUtils;
@@ -44,9 +44,9 @@
     private SysRoleDeptMapper roleDeptMapper;
 
     @Override
-    @DataScope(deptAlias = "d")
-    public TableDataInfo<SysRole> selectPageRoleList(SysRole role) {
-        return PageUtils.buildDataInfo(baseMapper.selectPageRoleList(PageUtils.buildPage(), role));
+    public TableDataInfo<SysRole> selectPageRoleList(SysRole role, PageQuery pageQuery) {
+        Page<SysRole> page = baseMapper.selectPageRoleList(pageQuery.build(), role);
+        return TableDataInfo.build(page);
     }
 
     /**
@@ -56,7 +56,6 @@
      * @return 瑙掕壊鏁版嵁闆嗗悎淇℃伅
      */
     @Override
-    @DataScope(deptAlias = "d")
     public List<SysRole> selectRoleList(SysRole role) {
         return baseMapper.selectRoleList(role);
     }
@@ -117,7 +116,7 @@
      * @return 閫変腑瑙掕壊ID鍒楄〃
      */
     @Override
-    public List<Integer> selectRoleListByUserId(Long userId) {
+    public List<Long> selectRoleListByUserId(Long userId) {
         return baseMapper.selectRoleListByUserId(userId);
     }
 
@@ -141,9 +140,10 @@
     @Override
     public String checkRoleNameUnique(SysRole role) {
         Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
-        SysRole info = getOne(new LambdaQueryWrapper<SysRole>()
-                .eq(SysRole::getRoleName, role.getRoleName()).last("limit 1"));
-        if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
+        long count = count(new LambdaQueryWrapper<SysRole>()
+                .eq(SysRole::getRoleName, role.getRoleName())
+                .ne(SysRole::getRoleId, roleId));
+        if (count > 0) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -158,9 +158,10 @@
     @Override
     public String checkRoleKeyUnique(SysRole role) {
         Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
-        SysRole info = getOne(new LambdaQueryWrapper<SysRole>()
-                .eq(SysRole::getRoleKey, role.getRoleKey()).last("limit 1"));
-        if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
+        long count = count(new LambdaQueryWrapper<SysRole>()
+                .eq(SysRole::getRoleKey, role.getRoleKey())
+                .ne(SysRole::getRoleId, roleId));
+        if (count > 0) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -213,7 +214,7 @@
      * @return 缁撴灉
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public int insertRole(SysRole role) {
         // 鏂板瑙掕壊淇℃伅
         baseMapper.insert(role);
@@ -227,7 +228,7 @@
      * @return 缁撴灉
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public int updateRole(SysRole role) {
         // 淇敼瑙掕壊淇℃伅
         baseMapper.updateById(role);
@@ -254,7 +255,7 @@
      * @return 缁撴灉
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public int authDataScope(SysRole role) {
         // 淇敼瑙掕壊淇℃伅
         baseMapper.updateById(role);
@@ -313,7 +314,7 @@
      * @return 缁撴灉
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public int deleteRoleById(Long roleId) {
         // 鍒犻櫎瑙掕壊涓庤彍鍗曞叧鑱�
         roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
@@ -329,7 +330,7 @@
      * @return 缁撴灉
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public int deleteRoleByIds(Long[] roleIds) {
         for (Long roleId : roleIds) {
             checkRoleAllowed(new SysRole(roleId));

--
Gitblit v1.9.3