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

import cn.hutool.json.JSONUtil;
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/4/25 7:10 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/4/25 7:10 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@JsonIgnoreProperties(ignoreUnknown = true)
@SuperBuilder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SID1SingleBillingResponseBody extends _SzhtxxPaperInvoiceBaseResponse {

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

    public SID1SingleBillingResponseBody unPacking() {

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

        return this;
    }

    public static void main(String[] args) {

//        String encMsg = "eyJTSUQiOiIxIiwiaGlzSW5mb0tpbmQiOiItMSIsIkNpcGhlciI6IiIsIkluZm9BbW91bnQiOjAsInJldGNvZGUiOiI0MDEyIiwicmV0bXNnIjoiWzIyMjAzNV212jM10NCjrFvJzMa3w/uzxl2zpLbIsrvV/ci3o6y/yb3TytzWtVvSwcD7vfC15LS/xaPEzDE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ponseBody
                .builder()
                .ENCMSG(encMsg)
                .build();

        responseBody.unPacking();

        log.info("{}", JSONUtil.toJsonStr(responseBody.getEncmsgVo()));



    }
}
