package com.heyu.api.baidu.response.certificate;


import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.heyu.api.baidu.response.BBaseResp;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740301134480#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E5%8D%A1%E8%AF%81OCR&api=rest%2F2.0%2Focr%2Fv1%2Fidcard&method=post
 * <p>
 * 身份证识别
 * <p>
 * {
 * "words_result": {
 * "姓名": {
 * "words": "瞿贻晓",
 * "location": {
 * "top": 399,
 * "left": 695,
 * "width": 41,
 * "height": 121
 * }
 * },
 * "民族": {
 * "words": "苗",
 * "location": {
 * "top": 565,
 * "left": 630,
 * "width": 33,
 * "height": 40
 * }
 * },
 * "住址": {
 * "words": "湖南省城步苗族自治县丹口镇尖口村3组28号",
 * "location": {
 * "top": 363,
 * "left": 439,
 * "width": 89,
 * "height": 381
 * }
 * },
 * "公民身份号码": {
 * "words": "430529199209255030",
 * "location": {
 * "top": 497,
 * "left": 288,
 * "width": 52,
 * "height": 533
 * }
 * },
 * "出生": {
 * "words": "19920925",
 * "location": {
 * "top": 380,
 * "left": 563,
 * "width": 36,
 * "height": 299
 * }
 * },
 * "性别": {
 * "words": "男",
 * "location": {
 * "top": 385,
 * "left": 630,
 * "width": 34,
 * "height": 31
 * }
 * }
 * },
 * "words_result_num": 6,
 * "idcard_number_type": 1,
 * "image_status": "normal",
 * "log_id": "1898283374799704079"
 * }
 * <p>
 * <p>
 * <p>
 * <p>
 * //
 * {
 * "words_result": {},
 * "words_result_num": 0,
 * "idcard_number_type": -1,
 * "image_status": "other_type_card",
 * "log_id": "1898283609126207223"
 * }
 */
@NoArgsConstructor
@Data
public class BIdcardResp extends BBaseResp {


    @JsonProperty("words_result")
    private WordsResultDTO wordsResult;
    @JsonProperty("words_result_num")
    private Integer wordsResultNum;
    @JsonProperty("idcard_number_type")
    private Integer idcardNumberType;
    @JsonProperty("image_status")
    private String imageStatus;
    @JsonProperty("log_id")
    private String logId;

    @NoArgsConstructor
    @Data
    public static class WordsResultDTO {
        @JsonProperty("姓名")
        private 姓名DTO 姓名;
        @JsonProperty("民族")
        private 民族DTO 民族;
        @JsonProperty("住址")
        private 住址DTO 住址;
        @JsonProperty("公民身份号码")
        private 公民身份号码DTO 公民身份号码;
        @JsonProperty("出生")
        private 出生DTO 出生;
        @JsonProperty("性别")
        private 性别DTO 性别;

        @JsonProperty("失效日期")
        private 失效日期DTO 失效日期;
        @JsonProperty("签发机关")
        private 签发机关DTO 签发机关;
        @JsonProperty("签发日期")
        private 签发日期DTO 签发日期;

        @NoArgsConstructor
        @Data
        public static class 姓名DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 民族DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 住址DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 公民身份号码DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 出生DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 性别DTO {
            @JsonProperty("words")
            private String words;
        }

        @NoArgsConstructor
        @Data
        public static class 失效日期DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 签发机关DTO {
            @JsonProperty("words")
            private String words;

        }

        @NoArgsConstructor
        @Data
        public static class 签发日期DTO {
            @JsonProperty("words")
            private String words;


        }

    }


    public static void main(String[] args) {
        String a = "{\n" +
                "    \"words_result\": {\n" +
                "        \"姓名\": {\n" +
                "            \"words\": \"瞿贻晓\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 399,\n" +
                "                \"left\": 695,\n" +
                "                \"width\": 41,\n" +
                "                \"height\": 121\n" +
                "            }\n" +
                "        },\n" +
                "        \"民族\": {\n" +
                "            \"words\": \"苗\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 565,\n" +
                "                \"left\": 630,\n" +
                "                \"width\": 33,\n" +
                "                \"height\": 40\n" +
                "            }\n" +
                "        },\n" +
                "        \"住址\": {\n" +
                "            \"words\": \"湖南省城步苗族自治县丹口镇尖口村3组28号\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 363,\n" +
                "                \"left\": 439,\n" +
                "                \"width\": 89,\n" +
                "                \"height\": 381\n" +
                "            }\n" +
                "        },\n" +
                "        \"公民身份号码\": {\n" +
                "            \"words\": \"430529199209255030\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 497,\n" +
                "                \"left\": 288,\n" +
                "                \"width\": 52,\n" +
                "                \"height\": 533\n" +
                "            }\n" +
                "        },\n" +
                "        \"出生\": {\n" +
                "            \"words\": \"19920925\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 380,\n" +
                "                \"left\": 563,\n" +
                "                \"width\": 36,\n" +
                "                \"height\": 299\n" +
                "            }\n" +
                "        },\n" +
                "        \"性别\": {\n" +
                "            \"words\": \"男\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 385,\n" +
                "                \"left\": 630,\n" +
                "                \"width\": 34,\n" +
                "                \"height\": 31\n" +
                "            }\n" +
                "        }\n" +
                "    },\n" +
                "    \"words_result_num\": 6,\n" +
                "    \"idcard_number_type\": 1,\n" +
                "    \"image_status\": \"normal\",\n" +
                "    \"log_id\": \"1898283374799704079\"\n" +
                "}";


        String b = "{\n" +
                "    \"words_result\": {\n" +
                "        \"失效日期\": {\n" +
                "            \"words\": \"20391011\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 903,\n" +
                "                \"left\": 336,\n" +
                "                \"width\": 47,\n" +
                "                \"height\": 205\n" +
                "            }\n" +
                "        },\n" +
                "        \"签发机关\": {\n" +
                "            \"words\": \"城步苗族自治县公安局\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 671,\n" +
                "                \"left\": 419,\n" +
                "                \"width\": 49,\n" +
                "                \"height\": 392\n" +
                "            }\n" +
                "        },\n" +
                "        \"签发日期\": {\n" +
                "            \"words\": \"20191011\",\n" +
                "            \"location\": {\n" +
                "                \"top\": 667,\n" +
                "                \"left\": 336,\n" +
                "                \"width\": 49,\n" +
                "                \"height\": 207\n" +
                "            }\n" +
                "        }\n" +
                "    },\n" +
                "    \"words_result_num\": 3,\n" +
                "    \"image_status\": \"normal\",\n" +
                "    \"log_id\": \"1898298054314861401\"\n" +
                "}";
        BIdcardResp idcardResp = JSONObject.parseObject(b, BIdcardResp.class);
        System.out.println(idcardResp.getImageStatus());

        System.out.println(idcardResp.getWordsResult().get签发日期().getWords());
    }
}
