| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.constant.UserConstants; |
| | | import org.dromara.common.core.domain.dto.UserDTO; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.service.UserService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.SpringUtils; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | ids.add(user.getDeptId()); |
| | | w.in("u.dept_id", ids); |
| | | }).orderByAsc("u.user_id"); |
| | | if (StringUtils.isNotBlank(user.getExcludeUserIds())) { |
| | | wrapper.notIn("u.user_id", StringUtils.splitList(user.getExcludeUserIds())); |
| | | } |
| | | return wrapper; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean registerUser(SysUserBo user, String tenantId) { |
| | | user.setCreateBy(user.getUserId()); |
| | | user.setUpdateBy(user.getUserId()); |
| | | user.setCreateBy(0L); |
| | | user.setUpdateBy(0L); |
| | | SysUser sysUser = MapstructUtils.convert(user, SysUser.class); |
| | | sysUser.setTenantId(tenantId); |
| | | return baseMapper.insert(sysUser) > 0; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过用户ID查询用户账户 |
| | | * |
| | | * @param userIds 用户ID 多个用逗号隔开 |
| | | * @return 用户账户 |
| | | */ |
| | | @Override |
| | | public String selectNicknameByIds(String userIds) { |
| | | List<String> list = new ArrayList<>(); |
| | | for (Long id : StringUtils.splitTo(userIds, Convert::toLong)) { |
| | | String nickname = SpringUtils.getAopProxy(this).selectNicknameById(id); |
| | | if (StringUtils.isNotBlank(nickname)) { |
| | | list.add(nickname); |
| | | } |
| | | } |
| | | return String.join(StringUtils.SEPARATOR, list); |
| | | } |
| | | |
| | | /** |
| | | * 通过用户ID查询用户手机号 |
| | | * |
| | | * @param userId 用户id |
| | |
| | | return ObjectUtil.isNull(sysUser) ? null : sysUser.getEmail(); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserDTO> selectListByIds(List<Long> userIds) { |
| | | if (CollUtil.isEmpty(userIds)) { |
| | | return List.of(); |
| | | } |
| | | List<SysUserVo> list = this.selectUserByIds(userIds, null); |
| | | return BeanUtil.copyToList(list, UserDTO.class); |
| | | } |
| | | |
| | | @Override |
| | | public List<Long> selectUserIdsByRoleIds(List<Long> roleIds) { |
| | | List<SysUserRole> userRoles = userRoleMapper.selectList( |
| | | new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getRoleId, roleIds)); |
| | | return StreamUtils.toList(userRoles, SysUserRole::getUserId); |
| | | } |
| | | |
| | | } |