| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.bo.AdminUserDetails; |
| | | import com.ycl.dto.UmsAdminParam; |
| | | import com.ycl.dto.UpdateAdminPasswordParam; |
| | | import com.ycl.entity.depart.UmsDepart; |
| | | import com.ycl.entity.user.*; |
| | | import com.ycl.exception.ApiException; |
| | | import com.ycl.exception.Asserts; |
| | |
| | | import com.ycl.utils.SpringUtil; |
| | | import com.ycl.utils.common.LiveTimeMillisecond; |
| | | import com.ycl.utils.common.MacUtils; |
| | | import com.ycl.utils.common.PojoUtils; |
| | | import com.ycl.utils.redis.RedisKey; |
| | | import com.ycl.vo.user.UserVO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | } |
| | | //对用户名系统默认添加 |
| | | //umsAdmin.setNickName(RandomUtils.getUserId(umsAdmin.getId())); |
| | | baseMapper.updateById(umsAdmin); |
| | | //添加部门 |
| | | UmsDepartManage departManage = new UmsDepartManage(); |
| | | departManage.setUserId(umsAdmin.getId()); |
| | | departManage.setDepartId(umsAdminParam.getDepartmentId()); |
| | | departManage.setCreateTime(new Date()); |
| | | departManage.setUpdateTime(new Date()); |
| | | umsDepartManageMapper.insert(departManage); |
| | | |
| | | baseMapper.updateById(umsAdmin); |
| | | return umsAdmin; |
| | | } |
| | | |
| | |
| | | token = jwtTokenUtil.generateToken(userDetails.getUserId(), userDetails.getUsername()); |
| | | redisService.set(RedisKey.PLATFORM_TOKEN_KEY.concat(username), token, LiveTimeMillisecond.s7200.time); |
| | | // updateLoginTimeByUsername(username); |
| | | insertLoginLog(username); |
| | | //insertLoginLog(username); |
| | | } catch (AuthenticationException e) { |
| | | LOGGER.warn("登录异常:{}", e.getMessage()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<UmsResource> getResourceList(Long adminId) { |
| | | List<UmsResource> resourceList = getCacheService().getResourceList(adminId); |
| | | if (CollUtil.isNotEmpty(resourceList)) { |
| | | return resourceList; |
| | | public List<UmsMenu> getResourceList(Long adminId) { |
| | | List<UmsMenu> umsMenuList = getCacheService().getResourceList(adminId); |
| | | if (CollUtil.isNotEmpty(umsMenuList)) { |
| | | return umsMenuList; |
| | | } |
| | | resourceList = umsResourceMapper.getResourceList(adminId); |
| | | if (CollUtil.isNotEmpty(resourceList)) { |
| | | getCacheService().setResourceList(adminId, resourceList); |
| | | } |
| | | return resourceList; |
| | | umsMenuList = umsMenuMapper.getMenuList(adminId); |
| | | getCacheService().setResourceList(adminId, umsMenuList); |
| | | return umsMenuList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | //获取用户信息 |
| | | UmsAdmin admin = getAdminByUsername(username); |
| | | if (admin != null) { |
| | | List<UmsResource> resourceList = getResourceList(admin.getId()); |
| | | List<UmsMenu> resourceList = getResourceList(admin.getId()); |
| | | return new AdminUserDetails(admin, resourceList); |
| | | } |
| | | throw new UsernameNotFoundException("用户名或密码错误"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IPage<UmsAdmin> pageUser(UserVO.PageUserVO pageUserVO) { |
| | | public Page<UmsAdmin> pageUser(UserVO.PageUserVO pageUserVO) { |
| | | int pageSize = pageUserVO.getPageSize(); |
| | | int current = pageUserVO.getCurrent(); |
| | | Page<UmsAdmin> page = new Page<>(current, pageSize); |
| | | LambdaQueryWrapper<UmsAdmin> queryWrapper = new LambdaQueryWrapper<>(); |
| | | /* LambdaQueryWrapper<UmsAdmin> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | if (StringUtils.isNotBlank(pageUserVO.getKeyword())) { |
| | | queryWrapper.like(UmsAdmin::getUsername, pageUserVO.getKeyword()) |
| | |
| | | } |
| | | if (PojoUtils.Vo.isUsefulSearchParam(pageUserVO.getUserType())) { |
| | | queryWrapper.eq(UmsAdmin::getUserType, pageUserVO.getUserType()); |
| | | }*/ |
| | | UmsAdmin umsAdmin = new UmsAdmin(); |
| | | if (pageUserVO.getUserType()!=null) { |
| | | umsAdmin.setUserType(pageUserVO.getUserType()); |
| | | } |
| | | if (PojoUtils.Vo.isUsefulSearchParam(pageUserVO.getDepartmentId())) { |
| | | queryWrapper.eq(UmsAdmin::getDepartmentId, pageUserVO.getDepartmentId()); |
| | | if (pageUserVO.getKeyword()!=null&&!("".equals(pageUserVO.getKeyword()))) { |
| | | umsAdmin.setKeyword(pageUserVO.getKeyword()); |
| | | } |
| | | Page<UmsAdmin> page1 = baseMapper.selectPage(page, queryWrapper); |
| | | List<UmsAdmin> records = page1.getRecords(); |
| | | if (CollUtil.isNotEmpty(records)) { |
| | | records.forEach(e -> { |
| | | UmsDepart umsDepart = departService.getById(e.getDepartmentId()); |
| | | if (null != umsDepart) { |
| | | e.setDepartName(umsDepart.getDepartName()); |
| | | } |
| | | //获取角色列表 |
| | | List<UmsRole> roles = umsRoleMapper.getRoleList(e.getId()); |
| | | e.setRoles(roles); |
| | | }); |
| | | if (pageUserVO.getJobTitle()!=null&&!("".equals(pageUserVO.getJobTitle()))) { |
| | | umsAdmin.setJobTitle(pageUserVO.getJobTitle()); |
| | | } |
| | | Page<UmsAdmin> page1 = baseMapper.selectCondPage(page,umsAdmin); |
| | | |
| | | return page1; |
| | | } |
| | | |