【7.6.0】【sys】整理,迁移所有userRole关联查询的api

pull/57/head
fengshuonan 2023-06-18 23:24:09 +08:00
parent 6c0202ec1f
commit ca6c06d4a8
6 changed files with 45 additions and 31 deletions

View File

@ -0,0 +1,21 @@
package cn.stylefeng.roses.kernel.sys.api;
import java.util.List;
/**
* Api
*
* @author fengshuonan
* @since 2023/6/18 23:21
*/
public interface SysUserRoleServiceApi {
/**
* id
*
* @author fengshuonan
* @since 2023/6/12 11:29
*/
List<Long> getUserRoleIdList(Long userId);
}

View File

@ -45,14 +45,6 @@ public interface SysUserServiceApi {
*/
SimpleUserDTO getUserInfoByUserId(Long userId);
/**
* id
*
* @author fengshuonan
* @since 2023/6/12 11:29
*/
List<Long> getUserRoleIdList(Long userId);
/**
*
*

View File

@ -9,7 +9,6 @@ import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
import cn.stylefeng.roses.kernel.sys.api.pojo.user.SimpleUserDTO;
import cn.stylefeng.roses.kernel.sys.api.pojo.user.UserValidateDTO;
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser;
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserRole;
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserOrgService;
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserRoleService;
@ -19,7 +18,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@ -80,20 +78,6 @@ public class UserIntegrationService implements SysUserServiceApi {
return simpleUserDTO;
}
@Override
public List<Long> getUserRoleIdList(Long userId) {
if (userId == null) {
return new ArrayList<>();
}
LambdaQueryWrapper<SysUserRole> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysUserRole::getUserId, userId);
wrapper.select(SysUserRole::getRoleId);
List<SysUserRole> sysUserRoleList = this.sysUserRoleService.list(wrapper);
return sysUserRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
}
@Override
public String getUserRealName(Long userId) {
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();

View File

@ -1,6 +1,7 @@
package cn.stylefeng.roses.kernel.sys.modular.user.service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.sys.api.SysUserRoleServiceApi;
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserRole;
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRoleRequest;
import com.baomidou.mybatisplus.extension.service.IService;
@ -13,7 +14,7 @@ import java.util.List;
* @author fengshuonan
* @date 2023/06/10 21:26
*/
public interface SysUserRoleService extends IService<SysUserRole> {
public interface SysUserRoleService extends IService<SysUserRole>, SysUserRoleServiceApi {
/**
*

View File

@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
*
@ -30,7 +31,8 @@ import java.util.Set;
* @date 2023/06/10 21:26
*/
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService, RemoveUserCallbackApi, RemoveRoleCallbackApi {
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService,
RemoveUserCallbackApi, RemoveRoleCallbackApi {
@Override
public void add(SysUserRoleRequest sysUserRoleRequest) {
@ -114,6 +116,20 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
this.remove(wrapper);
}
@Override
public List<Long> getUserRoleIdList(Long userId) {
if (userId == null) {
return new ArrayList<>();
}
LambdaQueryWrapper<SysUserRole> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysUserRole::getUserId, userId);
wrapper.select(SysUserRole::getRoleId);
List<SysUserRole> sysUserRoleList = this.list(wrapper);
return sysUserRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
}
/**
*
*

View File

@ -12,7 +12,6 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.file.api.constants.FileConstants;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
import cn.stylefeng.roses.kernel.sys.api.SysUserServiceApi;
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveUserCallbackApi;
import cn.stylefeng.roses.kernel.sys.api.enums.user.UserStatusEnum;
import cn.stylefeng.roses.kernel.sys.api.expander.SysConfigExpander;
@ -22,6 +21,7 @@ import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserExceptionEnum;
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserMapper;
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest;
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserOrgService;
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserRoleService;
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -44,15 +44,15 @@ import java.util.Set;
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
@Resource
private SysUserServiceApi sysUserServiceApi;
@Resource
private PasswordStoredEncryptApi passwordStoredEncryptApi;
@Resource
private SysUserOrgService sysUserOrgService;
@Resource
private SysUserRoleService sysUserRoleService;
@Override
@Transactional(rollbackFor = Exception.class)
public void add(SysUserRequest sysUserRequest) {
@ -130,7 +130,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
sysUser.setUserOrgDTOList(userOrgList);
// 获取用户的角色信息
List<Long> userRoleIdList = sysUserServiceApi.getUserRoleIdList(sysUser.getUserId());
List<Long> userRoleIdList = sysUserRoleService.getUserRoleIdList(sysUser.getUserId());
sysUser.setRoleIdList(userRoleIdList);
// 屏蔽不需要的字段