package org.jeecg.modules.system.app.dto;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sun.istack.NotNull;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author DM
 * @date 2025/7/7 17:39
 * @description
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
@Schema(description="商户补充信息入参自定义DTO")
public class AppSiteDTO {
    @Schema(description = "id")
    private String id;
    /**部门编码*/
    @Excel(name = "部门编码", width = 15)
    @Schema(description = "部门编码")
    private String orgCode;
    /**关联部门id*/
    @Excel(name = "关联部门id", width = 15)
    @Schema(description = "关联部门id")
    private String tenantId;
    /**名称*/
    @Excel(name = "名称", width = 15)
    @Schema(description = "名称")
    private String name;
    /**省*/
    @Excel(name = "省", width = 15)
    @Schema(description = "省")
    private String province;
    /**市*/
    @Excel(name = "市", width = 15)
    @Schema(description = "市")
    private String city;
    /**区县*/
    @Excel(name = "区县", width = 15)
    @Schema(description = "区县")
    private String area;
    /**地址*/
    @Excel(name = "地址", width = 15)
    @Schema(description = "地址")
    private String address;
    /**0学校 1体育馆*/
    @Excel(name = "0学校 1体育馆", width = 15)
    @Schema(description = "0学校 1体育馆")
    private Integer type;
    /**经营状态0营业 1休息*/
    @Excel(name = "经营状态0营业 1休息", width = 15)
    @Schema(description = "经营状态0营业 1休息")
    private Integer runStatus;
    /**经营类型0全天 1自定义*/
    @Excel(name = "经营类型0全天 1自定义", width = 15)
    @Schema(description = "经营类型0全天 1自定义")
    private Integer runType;
    /**开始营业时间 */
    @Excel(name = "开始营业时间", width = 20, format = "HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
    @DateTimeFormat(pattern="HH:mm:ss")
    @Schema(description = "开始营业时间")
    private Date startTime;
    /**结束营业时间*/
    @Excel(name = "结束营业时间", width = 20, format = "HH:mm:ss")
    @JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
    @DateTimeFormat(pattern="HH:mm:ss")
    @Schema(description = "结束营业时间")
    private Date endTime;    /**客服电话*/
    @Excel(name = "客服电话", width = 15)
    @Schema(description = "客服电话")
    private String phone;
    /**运动类目id;多个用逗号分割*/
    @Excel(name = "运动类目id;多个用逗号分割", width = 15)
    @Schema(description = "运动类目id;多个用逗号分割")
    @NotBlank(message = "运动类目不能为空")
    private String categoryId;
    /**信息/设施*/
    @Excel(name = "信息/设施", width = 15)
    @Schema(description = "信息/设施")
    private String facility;
    /**图片*/
    @Excel(name = "图片", width = 15)
    @Schema(description = "图片")
    private String cover;
    /**视频*/
    @Excel(name = "视频", width = 15)
    @Schema(description = "视频")
    private String video;
    /**好评率*/
    @Excel(name = "好评率", width = 15)
    @Schema(description = "好评率")
    private BigDecimal goodRate;
    /**纬度*/
    @Excel(name = "纬度", width = 15)
    @Schema(description = "纬度")
    private BigDecimal latitude;
    /**经度*/
    @Excel(name = "经度", width = 15)
    @Schema(description = "经度")
    private BigDecimal longitude;
    /**排序*/
    @Excel(name = "排序", width = 15)
    @Schema(description = "排序")
    private Integer sort;
    /**vr图JSON数据*/
    @Excel(name = "vr图JSON数据", width = 15)
    @Schema(description = "vr图JSON数据")
    private String vr;


    @JsonCreator
    public AppSiteDTO(@JsonProperty("latitude") String latitude,@JsonProperty("longitude") String longitude) {
        if(!latitude.isEmpty() && !longitude.isEmpty()){
            this.latitude = new BigDecimal(latitude); // 显式转换
            this.longitude = new BigDecimal(longitude); // 显式转换
        }else {
            this.latitude = new BigDecimal(0); // 显式转换
            this.longitude = new BigDecimal(0); // 显式转换
        }
    }

}