package com.ff.weijinxiao.domain;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ff.weijinxiao.util.jsonfilter.DateSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * 微信用户
 */
@Data
@Entity
@Table(name = "tb_cuser")
public class CUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "tid")
    private Integer id;

    @Column(name = "openid", columnDefinition = "varchar(200) COMMENT 'openId'")
    @ApiModelProperty(value = "openId")
    private String openId;

    @Column(name = "avatar_url", columnDefinition = "text COMMENT '微信头像'")
    @ApiModelProperty(value = "微信头像")
    private String avatarUrl;

    @Column(name = "nick_name", columnDefinition = "varchar(50) COMMENT '微信昵称'")
    @ApiModelProperty(value = "微信昵称")
    private String nickName;

    @Column(name = "city", columnDefinition = "varchar(30) COMMENT '城市'")
    @ApiModelProperty(value = "城市")
    private String city;

    @Column(name = "province", columnDefinition = "varchar(30) COMMENT '省'")
    @ApiModelProperty(value = "省")
    private String province;

    @Column(name = "gender", columnDefinition = "varchar(10) COMMENT '性别'")
    @ApiModelProperty(value = "性别")
    private String gender;

    //电话
    @Column(name = "phone", columnDefinition = "varchar(30) COMMENT '电话号码'")
    @ApiModelProperty(value = "电话号码")
    private String phone;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date createTime;

    @Column(name = "modify_time")
    @ApiModelProperty(value = "更新时间")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//json序列化实体类处理
    private Date modifyTime;

    @OneToOne
    @JoinColumn(name = "uid",referencedColumnName="uid",foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private UserInfo userInfo;

}
