| | |
| | | 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; |
| | |
| | | AdminMenuRelationMapper adminMenuRelationMapper; |
| | | @Resource |
| | | UmsMenuMapper umsMenuMapper; |
| | | @Resource |
| | | UmsAdminMapper umsAdminMapper; |
| | | |
| | | @Override |
| | | public UmsAdmin getAdminByUsername(String username) { |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UmsAdmin register(UmsAdminParam umsAdminParam) { |
| | | UmsAdmin umsAdmin = new UmsAdmin(); |
| | | //TODO mac,ip,职务,用户类型 |
| | | BeanUtils.copyProperties(umsAdminParam, umsAdmin); |
| | | umsAdmin.setCreateTime(new Date()); |
| | | umsAdmin.setStatus(1); |
| | |
| | | } |
| | | //将密码进行加密操作 |
| | | String encodePassword = passwordEncoder.encode(umsAdmin.getPassword()); |
| | | |
| | | if ( !umsAdmin.getPassword().matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$")) { |
| | | Asserts.fail("密码长度8到16位且密码中的字符必须包含字母(大写或者小写)和必须包含数字,不能包含空格"); |
| | | } |
| | | if(umsAdmin.getUsername().equals(umsAdmin.getPassword())){ |
| | | Asserts.fail("密码不能和登录名完全一致"); |
| | | } |
| | | umsAdmin.setPassword(encodePassword); |
| | | baseMapper.insert(umsAdmin); |
| | | |
| | |
| | | } |
| | | umsRoleMenuRelations |
| | | .stream() |
| | | .map(item->item.getMenuId()) |
| | | .map(item -> item.getMenuId()) |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .distinct() |
| | |
| | | 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()); |
| | | } |
| | |
| | | return umsMenuList; |
| | | } |
| | | umsMenuList = umsMenuMapper.getMenuList(adminId); |
| | | getCacheService().setResourceList(adminId, umsMenuList); |
| | | getCacheService().setResourceList(adminId, umsMenuList); |
| | | return umsMenuList; |
| | | } |
| | | |
| | | @Override |
| | | public int updatePassword(UpdateAdminPasswordParam param) { |
| | | if (StrUtil.isEmpty(param.getUsername()) |
| | | || StrUtil.isEmpty(param.getOldPassword()) |
| | | || StrUtil.isEmpty(param.getNewPassword())) { |
| | | if (StrUtil.isNotEmpty(param.getUsername()) |
| | | && StrUtil.isNotEmpty(param.getOldPassword()) |
| | | && StrUtil.isNotEmpty(param.getNewPassword()) |
| | | && !param.getNewPassword().matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$")) { |
| | | return -1; |
| | | } |
| | | if(param.getUsername().equals(param.getNewPassword())){ |
| | | return -4; |
| | | } |
| | | QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(UmsAdmin::getUsername, param.getUsername()); |
| | |
| | | int pageSize = pageUserVO.getPageSize(); |
| | | int current = pageUserVO.getCurrent(); |
| | | Page<UmsAdmin> page = new Page<>(current, pageSize); |
| | | return umsAdminMapper.selectPageByWordKey(page,pageUserVO.getKeyword()); |
| | | /* LambdaQueryWrapper<UmsAdmin> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | if (StringUtils.isNotBlank(pageUserVO.getKeyword())) { |
| | | queryWrapper.like(UmsAdmin::getUsername, pageUserVO.getKeyword()) |
| | | .or().like(UmsAdmin::getNickName, pageUserVO.getKeyword()) |
| | | .or().like(UmsAdmin::getMobile, pageUserVO.getKeyword()); |
| | | } |
| | | if (StringUtils.isNotBlank(pageUserVO.getJobTitle())) { |
| | | queryWrapper.eq(UmsAdmin::getJobTitle, pageUserVO.getJobTitle()); |
| | | } |
| | | 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 (pageUserVO.getKeyword() != null && !("".equals(pageUserVO.getKeyword()))) { |
| | | umsAdmin.setKeyword(pageUserVO.getKeyword()); |
| | | } |
| | | if (pageUserVO.getJobTitle() != null && !("".equals(pageUserVO.getJobTitle()))) { |
| | | umsAdmin.setJobTitle(pageUserVO.getJobTitle()); |
| | | } |
| | | Page<UmsAdmin> page1 = baseMapper.selectCondPage(page, umsAdmin); |
| | | |
| | | return page1; |
| | | } |
| | | |
| | | @Override |