package com.izouma.dingdong.domain;

import com.izouma.dingdong.enums.FinancialType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Where(clause = "enabled = 1")
@ApiModel(value = "余额记录", description = "余额记录")
public class MoneyRecord extends BaseEntity {
    @ApiModelProperty(value = "显示头像")
    private String avatar;

    private Long fromUserId;

    @ApiModelProperty(value = "用户ID", name = "userId")
    private Long userId;

    @ApiModelProperty(value = "消费名称", name = "name")
    private String name;

    @ApiModelProperty(value = "流水号", name = "num")
    private String num;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "类型", name = "type")
    private FinancialType type;

    @ApiModelProperty(value = "时间", name = "time")
    private LocalDateTime time;

    @Column(precision = 10, scale = 2)
    @ApiModelProperty(value = "金额", name = "amount")
    private BigDecimal amount;

    @ApiModelProperty(value = "备注", name = "remark")
    private String remark;

    @Column(nullable = false)
    private Boolean enabled = true;
}
