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;

/**
 * {
 * "binary": "UEsDBBQACAg..."
 * "suffix": "xlsx",
 * "name": "rest-2.0-ocr-v1-table",
 * "tips": "下载Excel"
 * }
 */
@NoArgsConstructor
@Data
public class ATableResp extends BBaseResp {

    /**
     * excel
     */
    @JsonProperty("binary")
    private String binary;
    @JsonProperty("suffix")
    private String suffix;
    @JsonProperty("name")
    private String name;
    @JsonProperty("tips")
    private String tips;

    /**
     * 非excel
     */

    @JsonProperty("tables_result")
    private List<TablesResultDTO> tablesResult;
    @JsonProperty("table_num")
    private Integer tableNum;
    @JsonProperty("log_id")
    private String logId;

    @NoArgsConstructor
    @Data
    public static class TablesResultDTO {
        @JsonProperty("header")
        private List<?> header;
        @JsonProperty("body")
        private List<BodyDTO> body;
        @JsonProperty("table_location")
        private List<TableLocationDTO> tableLocation;
        @JsonProperty("footer")
        private List<?> footer;

        @NoArgsConstructor
        @Data
        public static class BodyDTO {
            @JsonProperty("col_end")
            private Integer colEnd;
            @JsonProperty("row_end")
            private Integer rowEnd;
            @JsonProperty("cell_location")
            private List<CellLocationDTO> cellLocation;
            @JsonProperty("row_start")
            private Integer rowStart;
            @JsonProperty("col_start")
            private Integer colStart;
            @JsonProperty("words")
            private String words;
            @JsonProperty("contents")
            private List<ContentsDTO> contents;

            @NoArgsConstructor
            @Data
            public static class CellLocationDTO {
                @JsonProperty("x")
                private Integer x;
                @JsonProperty("y")
                private Integer y;
            }

            @NoArgsConstructor
            @Data
            public static class ContentsDTO {
                @JsonProperty("poly_location")
                private List<PolyLocationDTO> polyLocation;
                @JsonProperty("word")
                private String word;

                @NoArgsConstructor
                @Data
                public static class PolyLocationDTO {
                    @JsonProperty("x")
                    private Integer x;
                    @JsonProperty("y")
                    private Integer y;
                }
            }
        }

        @NoArgsConstructor
        @Data
        public static class TableLocationDTO {
            @JsonProperty("x")
            private Integer x;
            @JsonProperty("y")
            private Integer y;
        }
    }
}
