| | |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.AddClientPrarm; |
| | | import com.sandu.ximon.admin.param.PwdParam; |
| | | import com.sandu.ximon.admin.param.ResetClientPasswordPrarm; |
| | | import com.sandu.ximon.admin.param.UpdateClientPrarm; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | |
| | | return updateById(client); |
| | | } |
| | | |
| | | public boolean resetPassword(ResetClientPasswordPrarm resetClientPasswordPrarm) { |
| | | Client client = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, resetClientPasswordPrarm.getId())); |
| | | public boolean resetPassword(PwdParam param) { |
| | | |
| | | Client client = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, SecurityUtils.getUserDetails().getUserId())); |
| | | |
| | | if (client == null) { |
| | | throw new BusinessException("该用户不存在!"); |
| | | } |
| | | |
| | | PasswordEncoder pw = new BCryptPasswordEncoder(); |
| | | //判断旧密码与数据库是否一致 |
| | | if (pw.matches(resetClientPasswordPrarm.getOldPassword(), client.getPassword())) { |
| | | if (passwordEncoder.matches(param.getOldPass(), client.getPassword())) { |
| | | //加密新密码 |
| | | String encode = pw.encode(resetClientPasswordPrarm.getNewPassword()); |
| | | String encode = passwordEncoder.encode(param.getNewPass()); |
| | | client.setPassword(encode); |
| | | return updateById(client); |
| | | } else { |
| | |
| | | } |
| | | |
| | | /** |
| | | * \ |
| | | * 其他类用来查找客户id使用 如果没有上级客户 这返回用户ID |
| | | * |
| | | * @param |
| | | * @return |
| | | */ |
| | | public Long getClientId(Long userId) { |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, userId)); |
| | | if (one != null && one.getSuperiorId() != null) { |
| | | return one.getSuperiorId(); |
| | | } else { |
| | | return userId; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 一级客户返回false 二级客户返回true |
| | | * |
| | | * @return |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 一级客户返回false 二级客户返回true |
| | | * |
| | | * @return |
| | | */ |
| | | public boolean findClientId(Long userId) { |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, userId)); |
| | | if (one != null && one.getSuperiorId() != null) { |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改普通用户头像 |
| | | * |
| | | * @param userId |
| | | * @param IconUrl |
| | | * @return |
| | | */ |
| | | public boolean updateIcon(Long userId, String IconUrl) { |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, userId)); |
| | | if (one == null) { |
| | | throw new BusinessException("用户不存在"); |
| | | } |
| | | one.setIcon(IconUrl); |
| | | return updateById(one); |
| | | } |
| | | } |