package com.mosty.websocket.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyBaseFeignService;
import com.mosty.base.model.dto.base.SysDeptDTO;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 调用部门信息远程适配层
 *
 * @author kevin
 * @date 2022/7/6 10:37 上午
 * @since 1.0.0
 */
@Slf4j
@Service
@AllArgsConstructor
public class TbBaseAdaptRemoteService {

    private final MostyBaseFeignService mostyBaseFeignService;

    // 查询用户是否有该部门的数据权限
    public boolean getDataPermission(String sfz, String deptId) {
        ResponseResult<Boolean> responseResult = mostyBaseFeignService.getDataPermission(sfz, deptId);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询用户是否有该部门的数据权限异常 responseResult = {},{},{}", JSON.toJSONString(responseResult),sfz,deptId);
            throw new BusinessException("查询用户是否有该部门的数据权限");
        }
        return responseResult.getData();
    }
}
