| | |
| | | package com.mes.userinfo.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.mes.common.config.Const; |
| | | import com.mes.common.utils.JwtUtil; |
| | | import com.mes.common.utils.RedisUtil; |
| | | import com.mes.common.utils.UserInfoUtils; |
| | | import com.mes.entity.request.GeneralRequest; |
| | | import com.mes.menu.mapper.SysMenuMapper; |
| | |
| | | import com.mes.userinfo.entity.SysUserRole; |
| | | import com.mes.userinfo.entity.vo.SysUserVO; |
| | | import com.mes.userinfo.mapper.SysUserMapper; |
| | | import com.mes.userinfo.mapper.SysUserRoleMapper; |
| | | import com.mes.userinfo.service.SysUserRoleService; |
| | | import com.mes.userinfo.service.SysUserService; |
| | | import com.mes.utils.RedisUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.core.Authentication; |
| | |
| | | |
| | | @Resource |
| | | BCryptPasswordEncoder passwordEncoder; |
| | | @Resource |
| | | private SysUserRoleMapper sysUserRoleMapper; |
| | | |
| | | @Override |
| | | public Map<String, String> login(SysUser user) { |
| | |
| | | public String saveUser(SysUserVO user) { |
| | | log.info("保存用户信息"); |
| | | // 默认密码 |
| | | String password = passwordEncoder.encode(Const.DEFULT_PASSWORD); |
| | | String password = passwordEncoder.encode(user.getPassword()); |
| | | user.setPassword(password); |
| | | SysUser sysUser = new SysUser(); |
| | | BeanUtils.copyProperties(user, sysUser); |
| | |
| | | this.updateById(sysUser); |
| | | log.info("删除用户角色信息"); |
| | | List<Long> roleIds = user.getRoleList().stream().map(SysRole::getId).collect(Collectors.toList()); |
| | | sysUserRoleService.remove(new LambdaQueryWrapper<SysUserRole>() |
| | | .eq(SysUserRole::getUserId, sysUser.getId()).in(CollectionUtil.isNotEmpty(roleIds), SysUserRole::getRoleId, roleIds)); |
| | | log.info("保存用户角色信息"); |
| | | saveUserRole(user.getRoleList(), sysUser.getId()); |
| | | // sysUserRoleService.remove(new LambdaQueryWrapper<SysUserRole>() |
| | | // .eq(SysUserRole::getUserId, sysUser.getId()).in(CollectionUtil.isNotEmpty(roleIds), SysUserRole::getRoleId, roleIds)); |
| | | SysUserRole sysUserRole = new SysUserRole(sysUser.getId(),roleIds.get(0)); |
| | | sysUserRoleMapper.updateById(sysUserRole); |
| | | // log.info("保存用户角色信息"); |
| | | // saveUserRole(user.getRoleList(), sysUser.getId()); |
| | | return user; |
| | | } |
| | | |