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


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

import java.util.List;


/**
 * https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740300649701#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E9%80%9A%E7%94%A8%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fsmart_struct&method=post
 * 智能结构化
 */
@NoArgsConstructor
@Data
public class ASmartStructResp extends BBaseResp {


    @JsonProperty("words_result")
    private WordsResultDTO wordsResult;
    @JsonProperty("object_id_num")
    private Integer objectIdNum;
    @JsonProperty("log_id")
    private String logId;

    @NoArgsConstructor
    @Data
    public static class WordsResultDTO {
        @JsonProperty("struct_info")
        private StructInfoDTO structInfo;
        @JsonProperty("relations")
        private RelationsDTO relations;
        @JsonProperty("line_info")
        private List<LineInfoDTO> lineInfo;

        @NoArgsConstructor
        @Data
        public static class StructInfoDTO {
            @JsonProperty("group")
            private List<GroupDTO> group;

            @NoArgsConstructor
            @Data
            public static class GroupDTO {
                @JsonProperty("key")
                private List<KeyDTO> key;
                @JsonProperty("value")
                private List<ValueDTO> value;

                @NoArgsConstructor
                @Data
                public static class KeyDTO {
                    @JsonProperty("word")
                    private String word;
                }

                @NoArgsConstructor
                @Data
                public static class ValueDTO {
                    @JsonProperty("word")
                    private String word;
                }
            }
        }

        @NoArgsConstructor
        @Data
        public static class RelationsDTO {
            @JsonProperty("kv_relations")
            private List<KvRelationsDTO> kvRelations;
            @JsonProperty("table_relations")
            private TableRelationsDTO tableRelations;

            @NoArgsConstructor
            @Data
            public static class TableRelationsDTO {
                @JsonProperty("kk_relations")
                private List<KkRelationsDTO> kkRelations;
                @JsonProperty("kv_relations")
                private List<?> kvRelations;
                @JsonProperty("vv_relations")
                private List<?> vvRelations;

                @NoArgsConstructor
                @Data
                public static class KkRelationsDTO {
                    @JsonProperty("root_node")
                    private Integer rootNode;
                    @JsonProperty("leaf_nodes")
                    private List<Integer> leafNodes;
                }
            }

            @NoArgsConstructor
            @Data
            public static class KvRelationsDTO {
                @JsonProperty("root_node")
                private Integer rootNode;
                @JsonProperty("leaf_nodes")
                private List<Integer> leafNodes;
            }
        }

        @NoArgsConstructor
        @Data
        public static class LineInfoDTO {
            @JsonProperty("object_id")
            private Integer objectId;
            @JsonProperty("block_id")
            private Integer blockId;
            @JsonProperty("word")
            private String word;
            @JsonProperty("line_class")
            private String lineClass;
            @JsonProperty("line_class_probability")
            private String lineClassProbability;
            @JsonProperty("line__probability")
            private Double lineProbability;
            @JsonProperty("line_location")
            private LineLocationDTO lineLocation;
            @JsonProperty("width")
            private Double width;
            @JsonProperty("height")
            private Double height;
            @JsonProperty("top")
            private Double top;
            @JsonProperty("left")
            private Double left;

            @NoArgsConstructor
            @Data
            public static class LineLocationDTO {
            }
        }
    }
}
