package com.mosty.qwzx.remote;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.feign.service.MostyYszxFeignService;
import com.mosty.base.model.dto.yszx.TbYsGajgGlbmDto;
import com.mosty.base.model.vo.yszx.TbYsGajgGlbmVo;
import com.mosty.base.model.vo.yszx.TbYsGajgQuery;
import com.mosty.base.model.vo.yszx.TbYsGajgVo;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dw
 * @since 2022/8/29
 * 外部调用要素中心接口
 **/
@Service
@Slf4j
public class TbYszxAdaptRemoteService {

    @Resource
    private MostyYszxFeignService mostyYszxFeignService;

    // 查询公安机关要素详情
    public TbYsGajgVo getInfo(String id) {
        ResponseResult<TbYsGajgVo> responseResult = mostyYszxFeignService.getInfo(id);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询公安机关要素详情失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询公安机关要素详情失败");
        }
        return responseResult.getData();
    }

    // 查询公安机关要素列表
    public List<TbYsGajgGlbmVo> getGajgList(TbYsGajgQuery dto) {
        ResponseResult<List<TbYsGajgGlbmVo>> responseResult = mostyYszxFeignService.getGajgList(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询公安机关要素列表失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询公安机关要素列表失败");
        }
        return responseResult.getData();
    }
}
