package com.mosty.hczx.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyJcglFeignService;
import com.mosty.base.model.dto.jcgl.TbJcglXfllVo;
import com.mosty.base.model.entity.jcgl.TbSbGzjr;
import com.mosty.base.model.query.jcgl.TbJcglXfllQueryAllDto;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 基础管理远程调用
 */
@Slf4j
@Service
@AllArgsConstructor
public class TbJcglAdaptRemoteService {

    private final MostyJcglFeignService mostyJcglFeignService;

    // 获取部门下的巡防力量信息
    public List<TbJcglXfllVo> getXfll(TbJcglXfllQueryAllDto dto) {
        ResponseResult<List<TbJcglXfllVo>> responseResult = mostyJcglFeignService.getXfll(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("获取部门下的巡防力量信息失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("获取部门下的巡防力量信息失败");
        }
        return responseResult.getData();
    }


    // 查询感知接入列表
    public List<TbSbGzjr> getGzjrList(TbSbGzjr dto) {
        ResponseResult<List<TbSbGzjr>> responseResult = mostyJcglFeignService.getGzjrList(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("获取部门下的巡防力量信息失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("获取部门下的巡防力量信息失败");
        }
        return responseResult.getData();
    }
}
