| | |
| | | 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.ResetClientPasswordPrarm; |
| | | import com.sandu.ximon.admin.param.UpdateClientPrarm; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | |
| | | import com.sandu.ximon.dao.domain.Role; |
| | | import com.sandu.ximon.dao.mapper.ClientMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | if (addClientPrarm.getClientSuperior() != null && !"".equals(addClientPrarm.getClientSuperior())) { |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, addClientPrarm.getClientSuperior())); |
| | | if (one != null) { |
| | | if(one.getSuperiorId() == null){ |
| | | if (one.getSuperiorId() == null) { |
| | | client.setSuperiorId(one.getId()); |
| | | }else{ |
| | | } else { |
| | | throw new BusinessException("ä¸çº§å®¢æ·ä¸è½ä¸ºäºçº§ç¨æ·"); |
| | | } |
| | | } else { |
| | |
| | | return updateById(client); |
| | | } |
| | | |
| | | public boolean resetPassword(ResetClientPasswordPrarm resetClientPasswordPrarm) { |
| | | Client client = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, resetClientPasswordPrarm.getId())); |
| | | |
| | | if (client == null) { |
| | | throw new BusinessException("è¯¥ç¨æ·ä¸åå¨ï¼"); |
| | | } |
| | | |
| | | PasswordEncoder pw = new BCryptPasswordEncoder(); |
| | | //夿æ§å¯ç 䏿°æ®åºæ¯å¦ä¸è´ |
| | | if (pw.matches(resetClientPasswordPrarm.getOldPassword(), client.getPassword())) { |
| | | //å 坿°å¯ç |
| | | String encode = pw.encode(resetClientPasswordPrarm.getNewPassword()); |
| | | client.setPassword(encode); |
| | | return updateById(client); |
| | | } else { |
| | | throw new BusinessException("æ§å¯ç 䏿£ç¡®ï¼è¯·éæ°ç¡®è®¤å¯ç ï¼"); |
| | | } |
| | | } |
| | | |
| | | public boolean deleteClient(Long id) { |
| | | //夿å é¤ç¨æ·æ¯å¦åå¨ |
| | | Client one = getById(id); |