2021与蓝度共同重构项目,服务端
liuhaonan
2022-05-11 f45610bb9bfd6c0ee95959e0849aa7830ddfc5f3
ximon-admin/src/main/java/com/sandu/ximon/admin/service/ClientService.java
@@ -20,7 +20,6 @@
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@Service
@AllArgsConstructor
@@ -37,17 +36,17 @@
        if (getOne(Wrappers.lambdaQuery(Client.class).eq(Client::getClientName, addClientPrarm.getClientName().trim())) != null) {
            throw new BusinessException("该用户名已存在!");
        }
//        Long userId = SecurityUtils.getUserId();
        Long userId = SecurityUtils.getUserId();
        boolean clientId = findClientId();
        //判断是否为二级客户  如果是二级客户则不能继续添加
        if (SecurityUtils.getClientId() != null && !clientId) {
        //判断是否为二级客户  如果是二级客户则不能继续添加   一级客户为FALSE
        if (SecurityUtils.getClientId() != null && clientId) {
            throw new BusinessException("权限不足,二级客户不能新增用户!");
        }
        Client client = new Client();
        if (SecurityUtils.getClientId() != null && clientId) {
        if (SecurityUtils.getClientId() != null && !clientId) {
            //一级客户新增用户时 默认为自己名下的二级客户
            client.setSuperiorId(SecurityUtils.getUserId());
            client.setClientSuperior(addClientPrarm.getClientSuperior());
@@ -108,17 +107,19 @@
        if (client1 != null && !client1.getId().equals(one.getId())) {
            throw new BusinessException("该用户名已存在!");
        }
        //判断上级用户是否存在
        boolean clientId = findClientId();
        Long userId = SecurityUtils.getUserId();
        //判断更改的用户是否是属于自己名下的二级客户
        if(SecurityUtils.getClientId() != null && clientId){
            if(!Objects.equals(one.getSuperiorId(), SecurityUtils.getUserId())){
        if (SecurityUtils.getClientId() != null && !clientId) {
            if (SecurityUtils.getUserId() != one.getSuperiorId()) {
                throw new BusinessException("权限不足,不能更改其他客户的所属客户信息!");
            }
        }
        Client client = new Client();
        client.setClientName(updateClientPrarm.getClientName());
        if (SecurityUtils.getClientId() != null && clientId) {
            //一级客户新增用户时 默认为自己名下的二级客户
            client.setSuperiorId(SecurityUtils.getUserId());
@@ -142,7 +143,6 @@
        client.setLinkMan(updateClientPrarm.getLinkMan());
        client.setMobile(updateClientPrarm.getMobile());
        // update(client);
        return updateById(client);
    }