| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.*; |
| | | import com.sandu.ximon.admin.param.AddClientPrarm; |
| | | import com.sandu.ximon.admin.param.PwdParam; |
| | | import com.sandu.ximon.admin.param.UpdateClientPrarm; |
| | | import com.sandu.ximon.admin.param.UserPwsParm; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.Admin; |
| | | import com.sandu.ximon.dao.domain.Client; |
| | | import com.sandu.ximon.dao.domain.ClientRoleRelation; |
| | | 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; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | if (getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, addClientPrarm.getClientName().trim())) != null) { |
| | | throw new BusinessException("该用户名已存在!"); |
| | | } |
| | | // Long userId = SecurityUtils.getUserId(); |
| | | boolean clientId = findClientId(); |
| | | //判断是否为二级客户 如果是二级客户则不能继续添加 |
| | | if (SecurityUtils.getClientId() != null && !clientId) { |
| | | throw new BusinessException("权限不足,二级客户不能新增用户!"); |
| | | } |
| | | |
| | | |
| | | Client client = new Client(); |
| | | if (addClientPrarm.getClientSuperior() != null && !"".equals(addClientPrarm.getClientSuperior())) { |
| | | |
| | | if (SecurityUtils.getClientId() != null && clientId) { |
| | | //一级客户新增用户时 默认为自己名下的二级客户 |
| | | client.setSuperiorId(SecurityUtils.getUserId()); |
| | | client.setClientSuperior(addClientPrarm.getClientSuperior()); |
| | | } else 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) { |
| | | client.setSuperiorId(one.getId()); |
| | | client.setClientSuperior(addClientPrarm.getClientSuperior()); |
| | | } else { |
| | | throw new BusinessException("上级客户不能为二级用户"); |
| | | } |
| | |
| | | |
| | | client.setClientName(addClientPrarm.getClientName()); |
| | | client.setLinkMan(addClientPrarm.getLinkMan()); |
| | | // client.setClientSuperior(addClientPrarm.getClientSuperior()); |
| | | client.setMobile(addClientPrarm.getMobile()); |
| | | client.setClientSuperior(addClientPrarm.getClientSuperior()); |
| | | if (SecurityUtils.getClientId() != null && clientId) { |
| | | client.setClientSuperior(SecurityUtils.getUsername()); |
| | | } |
| | | client.setPassword(passwordEncoder.encode(addClientPrarm.getPassword())); |
| | | boolean flag = save(client); |
| | | |
| | |
| | | throw new BusinessException("该用户名已存在!"); |
| | | } |
| | | //判断上级用户是否存在 |
| | | boolean clientId = findClientId(); |
| | | |
| | | //判断更改的用户是否是属于自己名下的二级客户 |
| | | if(SecurityUtils.getClientId() != null && clientId){ |
| | | if(!Objects.equals(one.getSuperiorId(), SecurityUtils.getUserId())){ |
| | | throw new BusinessException("权限不足,不能更改其他客户的所属客户信息!"); |
| | | } |
| | | } |
| | | |
| | | Client client = new Client(); |
| | | if (updateClientPrarm.getClientSuperior() != null && updateClientPrarm.getClientSuperior().trim().length() != 0) { |
| | | if (SecurityUtils.getClientId() != null && clientId) { |
| | | //一级客户新增用户时 默认为自己名下的二级客户 |
| | | client.setSuperiorId(SecurityUtils.getUserId()); |
| | | client.setClientSuperior(updateClientPrarm.getClientSuperior()); |
| | | } else if (updateClientPrarm.getClientSuperior() != null && updateClientPrarm.getClientSuperior().trim().length() != 0) { |
| | | //超管 |
| | | Client superior = getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, updateClientPrarm.getClientSuperior())); |
| | | if (superior != null) { |
| | | if (superior.getId().equals(one.getId())) { |
| | |
| | | } |
| | | } |
| | | client.setId(id); |
| | | client.setClientName(updateClientPrarm.getClientName()); |
| | | // client.setClientName(updateClientPrarm.getClientName()); |
| | | client.setLinkMan(updateClientPrarm.getLinkMan()); |
| | | client.setMobile(updateClientPrarm.getMobile()); |
| | | |