package com.bizzan.bitrade.entity;

import java.math.BigDecimal;
import java.util.Map;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Where;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Entity
@Data
public class UserPurse implements IWallet {
    @Id
    private Long id;
	
    @ApiModelProperty("账户余额")
	@Column(columnDefinition = "decimal(18,8) comment '可用余额'")
    private BigDecimal balance;
    @ApiModelProperty("已用保证金")
    @Column(columnDefinition = "decimal(18,8) comment '冻结余额'")
    private BigDecimal frozenBalance;
    
    @ApiModelProperty("冻结保证金")
    private BigDecimal frozenMargin;
    
    private String eUsdtAddress;
    private String tUsdtAddress;

    @ApiModelProperty("杠杆")
    private BigDecimal leverage;
    private BigDecimal buyLeverage;
    private BigDecimal sellLeverage;
    
    @ApiModelProperty("仓位类型：0合仓，1分仓")
    @Enumerated(EnumType.ORDINAL)
    private ContractPositionType positionType;

    @ApiModelProperty("资金类型：0U本位，1币本位")
    @Enumerated(EnumType.ORDINAL)
    private ContractMoneyType moneyType;
    
    @ApiModelProperty("账户是否被监控")
    private Integer isSupervised;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "memberId", fetch = FetchType.EAGER)
    @Where(clause="status<>2 and follow_position_id is null")
    @OrderBy(clause = "createTime desc")
    private Set<MemberContractPosition> currentPositionList;
    
}
