package com.dtok.entity;

import javax.persistence.*;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @Description  
 * @Author  C.J
 * @Date 2024-03-08 
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table ( name ="acc_account" )
public class Account implements Serializable {

	private static final long serialVersionUID =  8809453470721335304L;

	public static final String FINAL_ROLE = "SuperAdmin";

	/**
	 * 用户ID自增
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id" )
	private Long id;

	/**
	 * 用户名
	 */
   	@Column(name = "username" )
	private String username;

	/**
	 * 密码
	 */
   	@Column(name = "password" )
	private String password;

	/**
	 * 加密盐
	 */
   	@Column(name = "salt" )
	private String salt;

	/**
	 * 最大设备数量
	 */
	@Column(name = "max_devices" )
	private Integer maxDevices;
	/**
	 * 手机号
	 */
   	@Column(name = "phone_number" )
	private Long phoneNumber;

	/**
	 * 名称
	 */
   	@Column(name = "name" )
	private String name;

	/**
	 * 1 正常 0 冻结

	 */
   	@Column(name = "status" )
	private Boolean status;

   	@Column(name = "is_super" )
	private Boolean isSuper;

   	@Column(name = "role_code" )
	private String roleCode;


	@OneToOne
	@JoinColumn(name = "role_code", referencedColumnName = "code", insertable = false, updatable = false)
	private AccountRole role;

	/**
	 * 最新更新时间
	 */
   	@Column(name = "last_modify_at" )
	private Date lastModifyAt;

	/**
	 * 过期时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@Column(name = "expire_at" )
	private Date expireAt;

	/**
	 * 创建时间
	 */
   	@Column(name = "created_at" )
	private Date createdAt;

}
