package com.mosty.hczx.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyYszxFeignService;
import com.mosty.base.model.dto.yszx.TbYsRyDto;
import com.mosty.base.model.entity.yszx.TbYsRy;
import com.mosty.base.model.vo.yszx.*;
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;

@Slf4j
@Service
@AllArgsConstructor
public class TbYszxAdapRemoteService {

    private final MostyYszxFeignService mostyYszxFeignService;

    // 查询人员要素
    public TbYsRyVo getRyInfo(String sfzh) {
        ResponseResult<TbYsRyVo> responseResult = this.mostyYszxFeignService.getRyInfo(sfzh);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询人员要素异常 Result = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询人员要素异常");
        }
        return responseResult.getData();
    }

    // 添加人员要素
    public void addRyYs(TbYsRyDto dto) {
        ResponseResult<Void> responseResult = this.mostyYszxFeignService.addRyYs(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加人员要素异常 Result = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加人员要素异常");
        }
    }

    // 修改人员要素
    public void updateRyYs(TbYsRyDto dto) {
        ResponseResult<Void> responseResult = this.mostyYszxFeignService.updateRyYs(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("修改人员要素异常 Result = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("修改人员要素异常");
        }
    }

    // 修改人员标签要素
    public void updateRyBqYs(TbYsRyBqUpdateDto dto) {
        ResponseResult<Void> responseResult = this.mostyYszxFeignService.updateRyBqYs(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("修改人员标签要素异常 Result = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("修改人员标签要素异常");
        }
    }

    // 修改人员电话要素
    public void updateRyDhys(TbYsRyDhUpdateDto dto) {
        ResponseResult<Void> responseResult = this.mostyYszxFeignService.updateRyDhys(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("修改人员电话要素异常 Result = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("修改人员电话要素异常");
        }
    }
}
