| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.ClientPrarm; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import com.sandu.ximon.dao.mapper.ClientMapper; |
| | | import lombok.AllArgsConstructor; |
| | |
| | | public boolean addClient(ClientPrarm clientPrarm) { |
| | | Client client = new Client(); |
| | | if (clientPrarm.getClientSuperior() != null) { |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientSuperior, clientPrarm.getClientSuperior())); |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, clientPrarm.getClientSuperior())); |
| | | if (one != null) { |
| | | client.setSuperiorId(one.getId()); |
| | | } else { |
| | |
| | | |
| | | |
| | | public boolean updateClient(Long id, ClientPrarm clientPrarm) { |
| | | //Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, id)); |
| | | Client one = getById(id); |
| | | if (one == null) { |
| | | throw new BusinessException("该客户不存在"); |
| | | } |
| | | Client client = new Client(); |
| | | if (clientPrarm.getClientSuperior() != null) { |
| | | Client superior = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, clientPrarm.getClientSuperior())); |
| | | if (one != null) { |
| | | client.setSuperiorId(superior.getId()); |
| | | } else { |
| | | throw new BusinessException("上级客户不存在"); |
| | | } |
| | | } |
| | | client.setId(id); |
| | | client.setClientName(clientPrarm.getClientName()); |
| | | client.setLinkMan(clientPrarm.getLinkMan()); |
| | |
| | | public Client findByPhone(String phone) { |
| | | return getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getMobile, phone).last("limit 1")); |
| | | } |
| | | |
| | | /**\ |
| | | * 其他类用来查找客户id使用 如果没有上级客户 这返回用户ID |
| | | * @param |
| | | * @return |
| | | */ |
| | | public Long getClientId(){ |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Client one = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getId, userId)); |
| | | if(one!=null&&one.getSuperiorId()!=null){ |
| | | return one.getSuperiorId(); |
| | | }else { |
| | | return userId; |
| | | } |
| | | |
| | | } |
| | | } |