Java Code Examples for org.jeecg.common.constant.CacheConstant#SYS_USERS_CACHE
The following examples show how to use
org.jeecg.common.constant.CacheConstant#SYS_USERS_CACHE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysUserServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
@Override @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) public Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword) { SysUser user = userMapper.getUserByName(username); String passwordEncode = PasswordUtil.encrypt(username, oldpassword, user.getSalt()); if (!user.getPassword().equals(passwordEncode)) { return Result.error("旧密码输入错误!"); } if (oConvertUtils.isEmpty(newpassword)) { return Result.error("新密码不允许为空!"); } if (!newpassword.equals(confirmpassword)) { return Result.error("两次输入密码不一致!"); } String password = PasswordUtil.encrypt(username, newpassword, user.getSalt()); this.userMapper.update(new SysUser().setPassword(password), new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, user.getId())); return Result.ok("密码重置成功!"); }
Example 2
Source File: SysUserServiceImpl.java From teaching with Apache License 2.0 | 6 votes |
@Override @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) public Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword) { SysUser user = userMapper.getUserByName(username); String passwordEncode = PasswordUtil.encrypt(username, oldpassword, user.getSalt()); if (!user.getPassword().equals(passwordEncode)) { return Result.error("旧密码输入错误!"); } if (oConvertUtils.isEmpty(newpassword)) { return Result.error("新密码不允许为空!"); } if (!newpassword.equals(confirmpassword)) { return Result.error("两次输入密码不一致!"); } String password = PasswordUtil.encrypt(username, newpassword, user.getSalt()); this.userMapper.update(new SysUser().setPassword(password), new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, user.getId())); return Result.ok("密码重置成功!"); }
Example 3
Source File: SysUserServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteBatchUsers(String userIds) { //1.删除用户 this.removeByIds(Arrays.asList(userIds.split(","))); //2.删除用户部门关系 LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>(); for(String id : userIds.split(",")) { query.eq(SysUserDepart::getUserId, id); this.sysUserDepartMapper.delete(query); } //3.删除用户角色关系 //TODO return false; }
Example 4
Source File: SysUserServiceImpl.java From teaching with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteBatchUsers(String userIds) { //1.删除用户 this.removeByIds(Arrays.asList(userIds.split(","))); return false; }
Example 5
Source File: SysBaseApiImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username") public LoginUser getUserByName(String username) { if(oConvertUtils.isEmpty(username)) { return null; } LoginUser loginUser = new LoginUser(); SysUser sysUser = userMapper.getUserByName(username); if(sysUser==null) { return null; } BeanUtils.copyProperties(sysUser, loginUser); return loginUser; }
Example 6
Source File: SysUserServiceImpl.java From teaching with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) public Result<?> changePassword(SysUser sysUser) { String salt = oConvertUtils.randomGen(8); sysUser.setSalt(salt); String password = sysUser.getPassword(); String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt); sysUser.setPassword(passwordEncode); this.userMapper.updateById(sysUser); return Result.ok("密码修改成功!"); }
Example 7
Source File: SysBaseApiImpl.java From jeecg-boot-with-activiti with MIT License | 5 votes |
@Override @Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username") public LoginUser getUserByName(String username) { if(oConvertUtils.isEmpty(username)) { return null; } LoginUser loginUser = new LoginUser(); SysUser sysUser = userMapper.getUserByName(username); if(sysUser==null) { return null; } BeanUtils.copyProperties(sysUser, loginUser); return loginUser; }
Example 8
Source File: SysUserServiceImpl.java From jeecg-boot-with-activiti with MIT License | 5 votes |
@Override @Transactional @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) public void editUserWithDepart(SysUser user, String departs) { this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次 //先删后加 sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); if(oConvertUtils.isNotEmpty(departs)) { String[] arr = departs.split(","); for (String departId : arr) { SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); sysUserDepartMapper.insert(userDepart); } } }
Example 9
Source File: SysUserServiceImpl.java From jeecg-boot-with-activiti with MIT License | 5 votes |
@Override @CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional public void editUserWithRole(SysUser user, String roles) { this.updateById(user); //先删后加 sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); if(oConvertUtils.isNotEmpty(roles)) { String[] arr = roles.split(","); for (String roleId : arr) { SysUserRole userRole = new SysUserRole(user.getId(), roleId); sysUserRoleMapper.insert(userRole); } } }
Example 10
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional public void editUserWithRole(SysUser user, String roles) { this.updateById(user); //先删后加 sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId())); if(oConvertUtils.isNotEmpty(roles)) { String[] arr = roles.split(","); for (String roleId : arr) { SysUserRole userRole = new SysUserRole(user.getId(), roleId); sysUserRoleMapper.insert(userRole); } } }
Example 11
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @Transactional(rollbackFor = Exception.class) @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) public void editUserWithDepart(SysUser user, String departs) { this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次 String[] arr = {}; if(oConvertUtils.isNotEmpty(departs)){ arr = departs.split(","); } //查询已关联部门 List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); if(userDepartList != null && userDepartList.size()>0){ for(SysUserDepart depart : userDepartList ){ //修改已关联部门删除部门用户角色关系 if(!Arrays.asList(arr).contains(depart.getDepId())){ List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList( new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId,depart.getDepId())); List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList()); if(roleIds != null && roleIds.size()>0){ departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()) .in(SysDepartRoleUser::getDroleId,roleIds)); } } } } //先删后加 sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); if(oConvertUtils.isNotEmpty(departs)) { for (String departId : arr) { SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); sysUserDepartMapper.insert(userDepart); } } }
Example 12
Source File: SysUserServiceImpl.java From teaching with Apache License 2.0 | 5 votes |
@Override @Transactional @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) public void editUserWithDepart(SysUser user, String departs) { this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次 //先删后加 sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); if(oConvertUtils.isNotEmpty(departs)) { String[] arr = departs.split(","); for (String departId : arr) { SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); sysUserDepartMapper.insert(userDepart); } } }
Example 13
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) public Result<?> changePassword(SysUser sysUser) { String salt = oConvertUtils.randomGen(8); sysUser.setSalt(salt); String password = sysUser.getPassword(); String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt); sysUser.setPassword(passwordEncode); this.userMapper.updateById(sysUser); return Result.ok("密码修改成功!"); }
Example 14
Source File: SysUserServiceImpl.java From jeecg-cloud with Apache License 2.0 | 5 votes |
@Override @Transactional(rollbackFor = Exception.class) @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) public void editUserWithDepart(SysUser user, String departs) { this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次 String[] arr = {}; if(oConvertUtils.isNotEmpty(departs)){ arr = departs.split(","); } //查询已关联部门 List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); if(userDepartList != null && userDepartList.size()>0){ for(SysUserDepart depart : userDepartList ){ //修改已关联部门删除部门用户角色关系 if(!Arrays.asList(arr).contains(depart.getDepId())){ List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList( new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId,depart.getDepId())); List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList()); if(roleIds != null && roleIds.size()>0){ departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId()) .in(SysDepartRoleUser::getDroleId,roleIds)); } } } } //先删后加 sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId())); if(oConvertUtils.isNotEmpty(departs)) { for (String departId : arr) { SysUserDepart userDepart = new SysUserDepart(user.getId(), departId); sysUserDepartMapper.insert(userDepart); } } }
Example 15
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteUser(String userId) { //1.删除用户 this.removeById(userId); return false; }
Example 16
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteBatchUsers(String userIds) { //1.删除用户 this.removeByIds(Arrays.asList(userIds.split(","))); return false; }
Example 17
Source File: SysUserServiceImpl.java From jeecg-cloud with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteBatchUsers(String userIds) { //1.删除用户 this.removeByIds(Arrays.asList(userIds.split(","))); return false; }
Example 18
Source File: SysUserServiceImpl.java From jeecg-cloud with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteUser(String userId) { //1.删除用户 this.removeById(userId); return false; }
Example 19
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 4 votes |
@Override @CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, key="#username") public void updateUserDepart(String username,String orgCode) { baseMapper.updateUserDepart(username, orgCode); }
Example 20
Source File: SysUserServiceImpl.java From teaching with Apache License 2.0 | 4 votes |
@Override @CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, key="#username") public void updateUserDepart(String username,String orgCode) { baseMapper.updateUserDepart(username, orgCode); }