package cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.response.SID5SelectBillInfo;

import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.response._SzhtxxPaperInvoiceBaseResponse;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;

import java.io.UnsupportedEncodingException;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/7/15 11:02 上午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/7/15 11:02 上午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@JsonIgnoreProperties(ignoreUnknown = true)
@SuperBuilder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SID5SelectBillInfoResponseBody extends _SzhtxxPaperInvoiceBaseResponse {

    @ApiModelProperty("密文-解密-反序列化")
    private SID5SelectBillInfoResponseBodyEncmsgVo encmsgVo;

    public SID5SelectBillInfoResponseBody unPacking() {

        try {
            String jsonStr = this.base64ReplaceAndDecode(this.ENCMSG);
            log.info("\nunPacking\n{}\n{}", this.ENCMSG, jsonStr);
            encmsgVo = AnJsonUtils.toObject(jsonStr, SID5SelectBillInfoResponseBodyEncmsgVo.class);
        } catch (UnsupportedEncodingException unsupportedEncodingException) {
            unsupportedEncodingException.printStackTrace();
        }

        return this;
    }

//    public static void main(String[] args) {
//
//        String encMsg = "ew0KICAieHNkaCI6ICIiLA0KICAiZ2ZtYyI6ICIiLA0KICAiZ2ZzaCI6ICIiLA0KICAieGZtYyI6ICIiLA0KICAiZnBkbSI6ICIiLA0KICAia3BqaCI6ICIiLA0KICAiZnBobSI6ICIiLA0KICAiemZieiI6ICIiLA0KICAicWRieiI6ICIiLA0KICAiZHlieiI6ICIiLA0KICAiYnNieiI6ICIiLA0KICAieGZzaCI6ICIiLA0KICAiQmVnaW5EYXRlIjogIjIwMTktMDItMjYiLA0KICAiRW5kRGF0ZSI6ICIyMDE5LTAyLTI2IiwNCiAgImZwemwiOiAwDQp9";
//
//        SID5ResponseBody responseBody = SID5ResponseBody
//                .builder()
//                .ENCMSG(encMsg)
//                .build();
//        try {
//            String jsonStr = responseBody.base64ReplaceAndDecode(encMsg);
//
//            log.info("\nunPacking\n{}\n{}", encMsg, jsonStr);
//        } catch (UnsupportedEncodingException unsupportedEncodingException) {
//            unsupportedEncodingException.printStackTrace();
//        }
//
//
//    }


}
