package com.zhiqiyun.open.core.models.place;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
@TableName(value = "place_base_info", autoResultMap = true)
public class PlaceBaseInfo {
    @TableId(type = IdType.INPUT)
    private Long id;
    private String name;
    private Long categoryId;
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<String> litpics;
    private String brief;
    private String address;
    private String contacts;
    private String contactNumber;
    private BigDecimal lng;
    private BigDecimal lat;

    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Date createdTime;
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Long createdBy;

    private Date updatedTime;
    private Long updatedBy;

    @TableField(exist = false)
    private PlaceCategory category;

    @TableField(exist = false)
    private String litpic;

    public String getLitpic() {
        if (StringUtils.isBlank(this.litpic) && this.litpics != null && this.litpics.size() > 0) {
            this.litpic = this.litpics.get(0);
        }
        return this.litpic;
    }
}
