Переглянути джерело

Merge branch 'fu-dev' of uskycloud/usky-cloud into master

hanzhengyi 1 тиждень тому
батько
коміт
e3f88af378
12 змінених файлів з 167 додано та 99 видалено
  1. 28 18
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/MceReceiveController.java
  2. 2 1
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/SysUserController.java
  3. 2 1
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysRoleMapper.java
  4. 4 4
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysUserRoleMapper.java
  5. 1 1
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/ISysRoleService.java
  6. 2 0
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/MceReceiveService.java
  7. 33 6
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/MceReceiveServiceImpl.java
  8. 5 4
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysRoleServiceImpl.java
  9. 6 6
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserServiceImpl.java
  10. 25 11
      base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserTenantServiceImpl.java
  11. 7 7
      base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysRoleMapper.xml
  12. 52 40
      base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysUserRoleMapper.xml

+ 28 - 18
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/MceReceiveController.java

@@ -8,6 +8,7 @@ import com.usky.common.log.enums.BusinessType;
 import com.usky.system.domain.MceReceive;
 import com.usky.system.service.MceReceiveService;
 import io.swagger.models.auth.In;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -45,11 +46,10 @@ public class MceReceiveController {
                                                  @RequestParam(value = "infoType", required = false) String infoType,
                                                  @RequestParam(value = "startTime", required = false) String startTime,
                                                  @RequestParam(value = "endTime", required = false) String endTime,
-                                                 @RequestParam(value = "id",required = false) Integer id,
+                                                 @RequestParam(value = "id", required = false) Integer id,
                                                  @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
-                                                 @RequestParam(value = "size", required = false, defaultValue = "10") Integer size)
-    {
-        return ApiResult.success(mceReceiveService.mceList(infoTitle, infoType,startTime, endTime, id,current, size));
+                                                 @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
+        return ApiResult.success(mceReceiveService.mceList(infoTitle, infoType, startTime, endTime, id, current, size));
     }
 
     /**
@@ -68,9 +68,8 @@ public class MceReceiveController {
                                                        @RequestParam(value = "startTime", required = false) String startTime,
                                                        @RequestParam(value = "endTime", required = false) String endTime,
                                                        @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
-                                                       @RequestParam(value = "size", required = false, defaultValue = "10") Integer size)
-    {
-        return ApiResult.success(mceReceiveService.mceManageList(infoTitle, infoType,startTime, endTime, current, size));
+                                                       @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
+        return ApiResult.success(mceReceiveService.mceManageList(infoTitle, infoType, startTime, endTime, current, size));
     }
 
     /**
@@ -83,9 +82,8 @@ public class MceReceiveController {
     @GetMapping("/mceManageById")
     public ApiResult<CommonPage<MceReceive>> mceManageById(@RequestParam(value = "id") Integer id,
                                                            @RequestParam(value = "current", required = false, defaultValue = "1") Integer current,
-                                                           @RequestParam(value = "size", required = false, defaultValue = "10") Integer size)
-    {
-        return ApiResult.success(mceReceiveService.mceManageById(id,current,size));
+                                                           @RequestParam(value = "size", required = false, defaultValue = "10") Integer size) {
+        return ApiResult.success(mceReceiveService.mceManageById(id, current, size));
     }
 
     /**
@@ -93,8 +91,7 @@ public class MceReceiveController {
      * @return
      */
     @GetMapping("/mceReceiveStatic")
-    public ApiResult<Map<String, Object>> mceReceiveStatic()
-    {
+    public ApiResult<Map<String, Object>> mceReceiveStatic() {
         return ApiResult.success(mceReceiveService.mceReceiveStatic());
     }
 
@@ -103,7 +100,7 @@ public class MceReceiveController {
      * @return
      */
     @PutMapping
-    ApiResult<Void> updateMceReceive(@RequestBody MceReceive mceReceive){
+    ApiResult<Void> updateMceReceive(@RequestBody MceReceive mceReceive) {
         mceReceiveService.updateMceReceive(mceReceive);
         return ApiResult.success();
     }
@@ -114,20 +111,33 @@ public class MceReceiveController {
      */
     @Log(title = "新增发布消息", businessType = BusinessType.INSERT)
     @PostMapping("/mceAdd")
-    ApiResult<Void> add(@RequestBody String mceReceive){
+    ApiResult<Void> add(@RequestBody String mceReceive) {
         mceReceiveService.add(mceReceive);
         return ApiResult.success();
     }
 
     /**
-     * 删除
+     * 删除消息及内容,并清空所有的消息接收表数据
      */
     @Log(title = "删除已发布消息", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{id}")
-    public ApiResult<Void> removeById(@PathVariable("id") Integer id)
-    {
+    @DeleteMapping("/remove/{contentId}")
+    public ApiResult<Void> removeById(@PathVariable("contentId") Integer id) {
         mceReceiveService.removeById(id);
         return ApiResult.success();
     }
+
+    /**
+     * 删除一条消息
+     **/
+    @Log(title = "删除消息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{id}")
+    public ApiResult<Void> deleteById(@PathVariable("id") Integer id) {
+        boolean f = mceReceiveService.deleteById(id);
+        if (f) {
+            return ApiResult.success();
+        } else {
+            return ApiResult.error("删除失败");
+        }
+    }
 }
 

+ 2 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/controller/web/SysUserController.java

@@ -118,6 +118,7 @@ public class SysUserController extends BaseController
     @GetMapping(value = { "/", "/{userId}" })
     public ApiResult<Map<String,Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId)
     {
+        Integer tenantId = SecurityUtils.getTenantId();
         Map<String,Object> ajax = new HashMap<>();
         List<SysRole> roles = roleService.selectRoleAll();
         ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
@@ -126,7 +127,7 @@ public class SysUserController extends BaseController
         {
             ajax.put("data", userService.selectUserById(userId));
             ajax.put("postIds", postService.selectPostListByUserId(userId));
-            ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
+            ajax.put("roleIds", roleService.selectRoleListByUserId(userId, tenantId));
         }
         return ApiResult.success(ajax);
     }

+ 2 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysRoleMapper.java

@@ -45,7 +45,8 @@ public interface SysRoleMapper extends CrudMapper<SysRole>
      * @param userId 用户ID
      * @return 选中角色ID列表
      */
-    public List<Integer> selectRoleListByUserId(@Param("userId") Long userId);
+    public List<Integer> selectRoleListByUserId(@Param("userId") Long userId,
+                                                @Param("tenantId") Integer tenantId);
 
     /**
      * 通过角色ID查询角色

+ 4 - 4
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/mapper/SysUserRoleMapper.java

@@ -22,7 +22,7 @@ public interface SysUserRoleMapper extends CrudMapper<SysUserRole>
      * @param userId 用户ID
      * @return 结果
      */
-    public int deleteUserRoleByUserId(@Param("userId") Long userId);
+    public int deleteUserRoleByUserId(@Param("userId") Long userId, @Param("tenantId") Integer tenantId);
 
     /**
      * 批量删除用户和角色关联
@@ -30,7 +30,7 @@ public interface SysUserRoleMapper extends CrudMapper<SysUserRole>
      * @param ids 需要删除的数据ID
      * @return 结果
      */
-    public int deleteUserRole(@Param("ids") Long[] ids);
+    public int deleteUserRole(@Param("ids") Long[] ids, @Param("tenantId") Integer tenantId);
 
     /**
      * 通过角色ID查询角色使用数量
@@ -38,7 +38,7 @@ public interface SysUserRoleMapper extends CrudMapper<SysUserRole>
      * @param roleId 角色ID
      * @return 结果
      */
-    public int countUserRoleByRoleId(@Param("roleId") Long roleId);
+    public int countUserRoleByRoleId(@Param("roleId") Long roleId, @Param("tenantId") Integer tenantId);
 
     /**
      * 批量新增用户角色信息
@@ -63,5 +63,5 @@ public interface SysUserRoleMapper extends CrudMapper<SysUserRole>
      * @param userIds 需要删除的用户数据ID
      * @return 结果
      */
-    public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
+    public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds, @Param("tenantId") Integer tenantId);
 }

+ 1 - 1
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/ISysRoleService.java

@@ -52,7 +52,7 @@ public interface ISysRoleService extends CrudService<SysRole>
      * @param userId 用户ID
      * @return 选中角色ID列表
      */
-    public List<Integer> selectRoleListByUserId(Long userId);
+    public List<Integer> selectRoleListByUserId(Long userId, Integer tenantId);
 
     /**
      * 通过角色ID查询角色

+ 2 - 0
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/MceReceiveService.java

@@ -33,4 +33,6 @@ public interface MceReceiveService extends CrudService<MceReceive> {
 
     boolean removeById(Integer id);
 
+    boolean deleteById(Integer id);
+
 }

+ 33 - 6
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/MceReceiveServiceImpl.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.usky.common.core.bean.CommonPage;
+import com.usky.common.core.exception.BusinessException;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.system.domain.*;
 import com.usky.system.mapper.MceReceiveMapper;
@@ -58,6 +59,9 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
     @Autowired
     private MceSettingMapper mceSettingMapper;
 
+    @Autowired
+    private MceReceiveMapper mceReceiveMapper;
+
     @Override
     public CommonPage<Object> mceList(String infoTitle, String infoType, String startTime, String endTime, Integer id, Integer current, Integer size) {
         List<Object> list = new ArrayList<>();
@@ -76,7 +80,7 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
             LambdaQueryWrapper<MceReceive> lambdaQuery = Wrappers.lambdaQuery();
             lambdaQuery.select(MceReceive::getId, MceReceive::getInfoType,
                             MceReceive::getContentId, MceReceive::getReadFlag, MceReceive::getCreateTime,
-                            MceReceive::getReceiverId, MceReceive::getModuleId)
+                            MceReceive::getReceiverId, MceReceive::getModuleId, MceReceive::getCreateBy)
                     .between(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime), MceReceive::getCreateTime,
                             startTime, endTime)
                     .eq(StringUtils.isNotBlank(infoType), MceReceive::getInfoType, infoType)
@@ -94,6 +98,7 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
                     map.put("readFlag", page.getRecords().get(i).getReadFlag());
                     map.put("moduleId", page.getRecords().get(i).getModuleId());
                     map.put("createTime", page.getRecords().get(i).getCreateTime());
+                    map.put("createBy", page.getRecords().get(i).getCreateBy());
                     if (CollectionUtils.isNotEmpty(list1)) {
                         for (int j = 0; j < list1.size(); j++) {
                             if (page.getRecords().get(i).getContentId().equals(list1.get(j).getId())) {
@@ -240,6 +245,7 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
     }
 
     @Async
+    @Override
     public void addMceReceive(MceRequestVO mceRequestVO) {
         // 如果 infoTypeName 为空,则从字典数据中获取
         if (mceRequestVO.getInfoTypeName() == null) {
@@ -247,8 +253,10 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
             mceRequestVO.setInfoTypeName(infoTypeName);
         }
 
+        Integer tenantId = userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, mceRequestVO.getUserName()).select(SysUser::getTenantId)).getTenantId();
+
         // 获取当前租户的所有用户
-        List<SysUser> userList = userMapper.tenantIdUserList(SecurityUtils.getTenantId());
+        List<SysUser> userList = userMapper.tenantIdUserList(tenantId);
         if (CollectionUtils.isEmpty(userList)) {
             return;
         }
@@ -299,12 +307,12 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
             for (SysUser user : userList) {
                 if (user.getUserId().equals(userId)) {
                     // 创建消息接收记录
-                    List<MceSetting> setting =  mceSettingService.list(Wrappers.lambdaQuery(MceSetting.class).eq(MceSetting::getCreateBy, user.getUserName()));
+                    List<MceSetting> setting = mceSettingService.list(Wrappers.lambdaQuery(MceSetting.class).eq(MceSetting::getCreateBy, user.getUserName()));
                     Integer receiveId = 0;
-                    if (CollectionUtils.isNotEmpty(setting)){
+                    if (CollectionUtils.isNotEmpty(setting)) {
                         MceReceive mceReceive = createMceReceive(user, generatedContentId, mceRequestVO, userNameNickNameMap);
                         this.save(mceReceive);
-                       receiveId =  mceReceive.getId();
+                        receiveId = mceReceive.getId();
                     }
 
                     if (mbUserOptional.isPresent()) {
@@ -482,7 +490,8 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
             mceReceiveVO.put("infoTypeName", infoTypeName);
         }
 
-        List<SysUser> list = userMapper.tenantIdUserList(SecurityUtils.getTenantId());
+        Integer tenantId = userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, mceReceiveVO.get("userName")).select(SysUser::getTenantId)).getTenantId();
+        List<SysUser> list = userMapper.tenantIdUserList(tenantId);
         // 获取用户昵称与真实姓名Map
         Map<String, String> userNameNickNameMap = list.stream().collect(Collectors.toMap(SysUser::getUserName, SysUser::getNickName));
         MceContent mceContent = new MceContent();
@@ -580,4 +589,22 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
         this.remove(lambdaQuery);
         return mceContentService.removeById(id);
     }
+
+    @Override
+    public boolean deleteById(Integer id) {
+        boolean f;
+        Integer userId = SecurityUtils.getUserId().intValue();
+        MceReceive mceReceive = mceReceiveMapper.selectOne(new LambdaQueryWrapper<MceReceive>().eq(MceReceive::getId, id));
+        if (mceReceive != null) {
+            if (userId.equals(mceReceive.getReceiverId())) {
+                mceReceiveMapper.deleteById(id);
+                f = true;
+            } else {
+                throw new BusinessException("您无权删除该条记录!");
+            }
+        } else {
+            throw new BusinessException("记录不存在,删除失败!");
+        }
+        return f;
+    }
 }

+ 5 - 4
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysRoleServiceImpl.java

@@ -125,9 +125,9 @@ public class SysRoleServiceImpl extends AbstractCrudService<SysRoleMapper, SysRo
      * @return 选中角色ID列表
      */
     @Override
-    public List<Integer> selectRoleListByUserId(Long userId)
+    public List<Integer> selectRoleListByUserId(Long userId, Integer tenantId)
     {
-        return roleMapper.selectRoleListByUserId(userId);
+        return roleMapper.selectRoleListByUserId(userId,tenantId);
     }
 
     /**
@@ -201,7 +201,7 @@ public class SysRoleServiceImpl extends AbstractCrudService<SysRoleMapper, SysRo
     @Override
     public int countUserRoleByRoleId(Long roleId)
     {
-        return userRoleMapper.countUserRoleByRoleId(roleId);
+        return userRoleMapper.countUserRoleByRoleId(roleId,SecurityUtils.getTenantId());
     }
 
     /**
@@ -395,7 +395,8 @@ public class SysRoleServiceImpl extends AbstractCrudService<SysRoleMapper, SysRo
     @Override
     public int deleteAuthUsers(Long roleId, Long[] userIds)
     {
-        return userRoleMapper.deleteUserRoleInfos(roleId, userIds);
+        Integer tenantId = SecurityUtils.getTenantId();
+        return userRoleMapper.deleteUserRoleInfos(roleId, userIds, tenantId);
     }
 
     /**

+ 6 - 6
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserServiceImpl.java

@@ -406,7 +406,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
     public int updateUser(SysUser user) {
         Long userId = user.getUserId();
         // 删除用户与角色关联
-        userRoleMapper.deleteUserRoleByUserId(userId);
+        userRoleMapper.deleteUserRoleByUserId(userId,SecurityUtils.getTenantId());
         // 新增用户与角色管理
         insertUserRole(user);
         // 删除用户与岗位关联
@@ -437,7 +437,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
     @Override
     @Transactional
     public void insertUserAuth(Long userId, Long[] roleIds) {
-        userRoleMapper.deleteUserRoleByUserId(userId);
+        userRoleMapper.deleteUserRoleByUserId(userId, SecurityUtils.getTenantId());
         insertUserRole(userId, roleIds);
     }
 
@@ -512,7 +512,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
                 SysUserRole ur = new SysUserRole();
                 ur.setUserId(user.getUserId());
                 ur.setRoleId(roleId);
-                ur.setTenantId(user.getTenantId());
+                ur.setTenantId(SecurityUtils.getTenantId());
                 list.add(ur);
             }
             if (list.size() > 0) {
@@ -577,7 +577,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
     @Transactional
     public int deleteUserById(Long userId) {
         // 删除用户与角色关联
-        userRoleMapper.deleteUserRoleByUserId(userId);
+        userRoleMapper.deleteUserRoleByUserId(userId, SecurityUtils.getTenantId());
         // 删除用户与岗位表
         userPostMapper.deleteUserPostByUserId(userId);
         return userMapper.deleteUserById(userId);
@@ -596,7 +596,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
             checkUserAllowed(new SysUser(userId));
         }
         // 删除用户与角色关联
-        userRoleMapper.deleteUserRole(userIds);
+        userRoleMapper.deleteUserRole(userIds, SecurityUtils.getTenantId());
         // 删除用户与岗位关联
         userPostMapper.deleteUserPost(userIds);
         return userMapper.deleteUserByIds(userIds);
@@ -609,7 +609,7 @@ public class SysUserServiceImpl extends AbstractCrudService<SysUserMapper, SysUs
         SysUser user = this.selectUserById(userId);
         if (user.getPassword().equals(password)) {
             // 删除用户与角色关联
-            userRoleMapper.deleteUserRoleByUserId(userId);
+            userRoleMapper.deleteUserRoleByUserId(userId, SecurityUtils.getTenantId());
             // 删除用户与岗位表
             userPostMapper.deleteUserPostByUserId(userId);
             return userMapper.deleteUserById(userId);

+ 25 - 11
base-modules/service-system/service-system-biz/src/main/java/com/usky/system/service/impl/SysUserTenantServiceImpl.java

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.usky.common.core.exception.BusinessException;
 import com.usky.system.RemoteDeptService;
 import com.usky.system.domain.SysTenant;
+import com.usky.system.domain.SysUserRole;
 import com.usky.system.domain.SysUserTenant;
+import com.usky.system.mapper.SysUserRoleMapper;
 import com.usky.system.mapper.SysUserTenantMapper;
 import com.usky.system.service.SysTenantService;
 import com.usky.system.service.SysUserTenantService;
@@ -33,6 +35,9 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
     @Autowired
     private SysTenantService sysTenantService;
 
+    @Autowired
+    private SysUserRoleMapper sysUserRoleMapper;
+
     /**
      * 企业邀请用户
      *
@@ -42,9 +47,16 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
     @Transactional
     public void insertInviteUser(SysUserTenant sysUserTenant) {
         int userCount = baseMapper.checkUserIdUnique(sysUserTenant.getTenantId(), sysUserTenant.getUserId());
-        if (userCount > 0){
+        if (userCount > 0) {
             throw new BusinessException("用户已绑定,无法重复绑定!");
-        }else {
+        } else {
+            // SysUserRole sysUserRole = sysUserRoleMapper.selectOne(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, sysUserTenant.getUserId()).eq(SysUserRole::getTenantId, sysUserTenant.getTenantId()));
+            // if (sysUserRole == null) {
+            //     SysUserRole sysUserRole1 = new SysUserRole();
+            //     sysUserRole1.setUserId(sysUserTenant.getUserId());
+            //     sysUserRole1.setTenantId(sysUserTenant.getTenantId());
+            //     sysUserRoleMapper.insert(sysUserRole1);
+            // }
             this.save(sysUserTenant);
         }
     }
@@ -57,8 +69,10 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
      */
     @Override
     @Transactional
-    public void deleteUserTenant(Integer tenantId,Long userId) {
+    public void deleteUserTenant(Integer tenantId, Long userId) {
         baseMapper.deleteUserTenant(tenantId, userId);
+        Long[] userIds = new Long[]{userId};
+        sysUserRoleMapper.deleteUserRole(userIds, tenantId);
     }
 
     /**
@@ -66,19 +80,19 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
      */
     @Override
     @Transactional
-    public List<SysTenant> getTenantByUser(Long userId){
+    public List<SysTenant> getTenantByUser(Long userId) {
         LambdaQueryWrapper<SysUserTenant> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(SysUserTenant::getUserId,userId);
+        queryWrapper.eq(SysUserTenant::getUserId, userId);
         List<SysUserTenant> userTenants = this.list(queryWrapper);
         List<Integer> tenantIdList = new ArrayList<>();
         List<SysTenant> tenantList = new ArrayList<>();
         LambdaQueryWrapper<SysTenant> queryWrapper1 = Wrappers.lambdaQuery();
-        if (CollectionUtils.isNotEmpty(userTenants)){
+        if (CollectionUtils.isNotEmpty(userTenants)) {
             for (int i = 0; i < userTenants.size(); i++) {
                 tenantIdList.add(userTenants.get(i).getTenantId());
             }
-            queryWrapper1.in(SysTenant::getId,tenantIdList)
-                    .eq(SysTenant::getStatus,0);
+            queryWrapper1.in(SysTenant::getId, tenantIdList)
+                    .eq(SysTenant::getStatus, 0);
             tenantList = sysTenantService.list(queryWrapper1);
         }
         return tenantList;
@@ -86,10 +100,10 @@ public class SysUserTenantServiceImpl extends AbstractCrudService<SysUserTenantM
 
     @Override
     @Transactional
-    public Boolean getIdByUser(Integer tenantId,Long userId){
+    public Boolean getIdByUser(Integer tenantId, Long userId) {
         LambdaQueryWrapper<SysUserTenant> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(SysUserTenant::getUserId,userId)
-                .eq(SysUserTenant::getTenantId,tenantId);
+        queryWrapper.eq(SysUserTenant::getUserId, userId)
+                .eq(SysUserTenant::getTenantId, tenantId);
         List<SysUserTenant> userTenants = this.list(queryWrapper);
         return userTenants.get(0).getIsDefault();
     }

+ 7 - 7
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -68,13 +68,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	<select id="selectRoleAll" resultMap="SysRoleResult">
 		<include refid="selectRoleVo"/>
 	</select>
-	
-	<select id="selectRoleListByUserId" parameterType="Long" resultType="Integer">
-		select r.role_id
-        from sys_role r
-	        left join sys_user_role ur on ur.role_id = r.role_id
-	        left join sys_user u on u.user_id = ur.user_id
-	    where u.user_id = #{userId}
+
+	<select id="selectRoleListByUserId" parameterType="map" resultType="Integer">
+		SELECT r.role_id
+		FROM sys_role r
+				 LEFT JOIN sys_user_role ur ON ur.role_id = r.role_id
+				 LEFT JOIN sys_user u ON u.user_id = ur.user_id
+		WHERE u.user_id = #{userId, jdbcType=BIGINT} AND r.tenant_id = #{tenantId, jdbcType=INTEGER}
 	</select>
 	
 	<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">

+ 52 - 40
base-modules/service-system/service-system-biz/src/main/resources/mapper/system/SysUserRoleMapper.xml

@@ -1,45 +1,57 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.usky.system.mapper.SysUserRoleMapper">
 
-	<resultMap type="com.usky.system.domain.SysUserRole" id="SysUserRoleResult">
-		<result property="userId"     column="user_id"      />
-		<result property="roleId"     column="role_id"      />
-		<result property="tenantId"   column="tenant_id"    />
-	</resultMap>
-
-	<delete id="deleteUserRoleByUserId" parameterType="Long">
-		delete from sys_user_role where user_id=#{userId}
-	</delete>
-	
-	<select id="countUserRoleByRoleId" resultType="Integer">
-	    select count(1) from sys_user_role where role_id=#{roleId}  
-	</select>
-	
-	<delete id="deleteUserRole" parameterType="Long">
- 		delete from sys_user_role where user_id in
- 		<foreach collection="ids" item="ids" open="(" separator="," close=")">
- 			#{ids}
-        </foreach> 
- 	</delete>
-	
-	<insert id="batchUserRole">
-		insert into sys_user_role(user_id, role_id, tenant_id) values
-		<foreach item="item" index="index" collection="list" separator=",">
-			(#{item.userId},#{item.roleId},#{item.tenantId})
-		</foreach>
-	</insert>
-	
-	<delete id="deleteUserRoleInfo" parameterType="com.usky.system.domain.SysUserRole">
-		delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}
-	</delete>
-	
-	<delete id="deleteUserRoleInfos">
-	    delete from sys_user_role where role_id=#{roleId} and user_id in
- 	    <foreach collection="userIds" item="userId" open="(" separator="," close=")">
- 	        #{userId}
-            </foreach> 
-	</delete>
+    <resultMap type="com.usky.system.domain.SysUserRole" id="SysUserRoleResult">
+        <result property="userId" column="user_id"/>
+        <result property="roleId" column="role_id"/>
+        <result property="tenantId" column="tenant_id"/>
+    </resultMap>
+
+    <delete id="deleteUserRoleByUserId" parameterType="map">
+        delete
+        from sys_user_role
+        where user_id = #{userId, jdbcType=BIGINT}
+          and tenant_id = #{tenantId, jdbcType=INTEGER}
+    </delete>
+
+    <select id="countUserRoleByRoleId" resultType="Integer">
+        select count(1)
+        from sys_user_role
+        where role_id = #{roleId, jdbcType=BIGINT}
+          and tenant_id = #{tenantId, jdbcType=INTEGER}
+    </select>
+
+    <delete id="deleteUserRole" parameterType="map">
+        delete from sys_user_role where user_id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id, jdbcType=BIGINT}
+        </foreach>
+        and tenant_id=#{tenantId, jdbcType=INTEGER}
+    </delete>
+
+    <insert id="batchUserRole">
+        insert into sys_user_role(user_id, role_id, tenant_id) values
+        <foreach item="item" index="index" collection="list" separator=",">
+            (#{item.userId, jdbcType=BIGINT}, #{item.roleId, jdbcType=INTEGER}, #{item.tenantId, jdbcType=INTEGER})
+        </foreach>
+    </insert>
+
+    <delete id="deleteUserRoleInfo" parameterType="map">
+        delete
+        from sys_user_role
+        where user_id = #{userId, jdbcType=BIGINT}
+          and role_id = #{roleId, jdbcType=INTEGER}
+    </delete>
+
+    <delete id="deleteUserRoleInfos" parameterType="map">
+        delete from sys_user_role where role_id=#{roleId, jdbcType=INTEGER} and user_id in
+        <foreach collection="userIds" item="userId" open="(" separator="," close=")">
+            #{userId, jdbcType=BIGINT}
+        </foreach>
+        and tenant_id=#{tenantId, jdbcType=INTEGER}
+    </delete>
+
 </mapper>