package cn.reghao.tnb.content.app.geo.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.content.api.dto.CamPhoto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author reghao
 * @date 2024-09-07 12:01:03
 */
@NoArgsConstructor
@Setter
@Getter
public class CameraPhoto extends BaseObject<Integer> {
    private String albumType;
    private Long albumId;
    private String objectId;
    private Integer channelCode;
    private String photoUrl;
    private String manufacturer;
    private String model;
    private String software;
    private LocalDateTime shotAt;
    private BigDecimal longitude;
    private BigDecimal latitude;
    private Boolean geoValid;
    private Integer areaCode;

    public CameraPhoto(long replyId, CamPhoto camPhoto) {
        this.albumType = "MallReply";
        this.albumId = replyId;
        this.objectId = camPhoto.getObjectId();
        this.channelCode = camPhoto.getChannelCode();
        this.photoUrl = camPhoto.getPhotoUrl();
        this.manufacturer = camPhoto.getManufacturer();
        this.model = camPhoto.getModel();
        this.software = camPhoto.getSoftware();
        Double lng = camPhoto.getLongitude();
        if (lng != null && lng != 0.0) {
            this.longitude = BigDecimal.valueOf(camPhoto.getLongitude());
            this.geoValid = true;
        } else {
            this.geoValid = false;
        }

        Double lat = camPhoto.getLatitude();
        if (lat != null && lat != 0.0) {
            this.latitude = BigDecimal.valueOf(camPhoto.getLatitude());
            this.geoValid = true;
        } else {
            this.geoValid = false;
        }
        this.areaCode = 0;
    }
}
