package com.nokia.tsl_data.entity;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.time.Instant;

@Data
@Entity
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
@Table(name = "user_count", schema = "tsl_data", indexes = {
        @Index(name = "month_city_unique", columnList = "month_id, city_name", unique = true)
})
public class UserCount {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "month_id", columnDefinition = "varchar(6)", nullable = false)
    private String monthId;

    @Column(name = "city_name", columnDefinition = "varchar(10)", nullable = false)
    private String cityName;

    // 管理端用户数统计
    @Column
    private Double managementUserCount;

    // 客户端用户数统计
    @Column
    private Double customerUserCount;

    @CreatedDate
    private Instant createDate;

    @LastModifiedDate
    private Instant lastUpdateDate;
}
