package com.hr.externelSystem;

import com.alibaba.fastjson.JSONObject;
import com.hr.dto.ApiLogDto;
import com.hr.dto.EsignParmDto;
import com.hr.dto.EsignReturnDto;
import com.hr.repository.domain.IpInterfacePO;
import com.hr.repository.domain.IpOrderPO;
import com.hr.repository.service.EsignService;
import com.hr.vo.CallbackResponseVO;
import com.hr.vo.ServiceTypeVO;
import com.yy.basedevelop.common.data.BaseReturnDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yaoy
 * @createTime 2025/10/23 16:08
 **/
@Service
@Slf4j
public class HrGenPdfService implements BizHandler<EsignParmDto, EsignReturnDto>{

    @Autowired
    private EsignService esignService;

    @Override
    public ServiceTypeVO getType() {
        return new ServiceTypeVO("hrPdf","平台PDF");
    }

    @Override
    public EsignReturnDto handle(EsignParmDto esignParmDto, IpInterfacePO ipInterfacePO, ApiLogDto logDto) {

        BaseReturnDto<EsignReturnDto> rdto=esignService.hrSignByPdfStream(esignParmDto);
        logDto.setHttpStatus(String.valueOf(rdto.getCode()));
        logDto.setUrl("http://sdkapi.esign.cn");
        logDto.setResponseParam(JSONObject.toJSONString(rdto));
        if(rdto.getCode()!=200){
            logDto.setErrorMessage(rdto.getMsg());
        }
        logDto.setBusinessNo(esignParmDto.getOssFileName());
        return rdto.getData();
    }

    @Override
    public Class<EsignParmDto> getRequestClass() {
        return EsignParmDto.class;
    }

    @Override
    public CallbackResponseVO doCallBack(IpOrderPO ipOrderPO, JSONObject callbackParam) {
        return null;
    }
}


