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

import cn.reghao.jutil.jdk.converter.DateTimeConverter;
import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.common.auth.UserContext;
import cn.reghao.tnb.content.app.geo.model.vo.MapPoint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

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

/**
 * @author reghao
 * @date 2024-09-10 17:37:07
 */
@NoArgsConstructor
@Setter
@Getter
public class GeoPoint extends BaseObject<Integer> {
    // 经度
    private BigDecimal longitude;
    // 纬度
    private BigDecimal latitude;
    private Integer pointType;
    private String deviceId;
    private Long createBy;
    private LocalDateTime createAt;

    public GeoPoint(MapPoint mapPoint) {
        this.pointType = 2;
        this.longitude = BigDecimal.valueOf(mapPoint.getLng());
        this.latitude = BigDecimal.valueOf(mapPoint.getLat());
        this.deviceId = "xxx";
        this.createBy = UserContext.getUserId();
        this.createAt = DateTimeConverter.localDateTime(System.currentTimeMillis());
    }

    public GeoPoint(MapPoint mapPoint, int pointType) {
        this.pointType = pointType;
        this.longitude = BigDecimal.valueOf(mapPoint.getLng());
        this.latitude = BigDecimal.valueOf(mapPoint.getLat());
        this.deviceId = "xxx";
        this.createBy = UserContext.getUserId();
        this.createAt = DateTimeConverter.localDateTime(System.currentTimeMillis());
    }
}
