package com.mosty.yjzl.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.model.dto.jcgl.TbJcglXfllVo;
import com.mosty.base.feign.service.MostyJcglFeignService;
import com.mosty.base.model.dto.jcgl.TbJcglXfqyDto;
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.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
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<TbJcglXfqyDto> getListXfqyAll() {
        ResponseResult<List<TbJcglXfqyDto>> responseResult = mostyJcglFeignService.getListXfqyAll();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询所有巡防区数据失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询所有巡防区数据失败");
        }
        return responseResult.getData();
    }
}
