package com.uas.platform.b2b.manage.model;

import com.uas.platform.b2b.manage.core.support.SystemSession;
import org.hibernate.validator.constraints.Length;

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

/**
 * 使用日志
 *
 * @author hejq
 * @date 2018-04-26
 */
@Table(name = "log$manage")
@Entity
public class UseLog implements Serializable {

    /**
     * 序列
     */
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Id
    @Column(name = "log_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

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

    /**
     * 手机
     */
    @Column(name = "log_tel")
    private String tel = "";

    /**
     * 时间
     */
    @Column(name = "log_time")
    private Date time = new Date(System.currentTimeMillis());

    /**
     * 标题
     */
    @Column(name = "log_title")
    private String title = "";

    /**
     * 详情
     */
    @Column(name = "log_message")
    @Length(max = 1000)
    private String message = "";

    /**
     * ip
     */
    @Column(name = "log_ip")
    private String ip = "";

    /**
     * 含参定义日志
     *
     * @param title 标题
     * @param message 详情
     * @param ip ip
     */
    public UseLog(String title, String message, String ip) {
        this.title = title;
        this.ip = ip;
        this.message = message;
        User user =SystemSession.getUser();
        if (null != user) {
            this.name = SystemSession.getUser().getName();
            this.tel = SystemSession.getUser().getTel();
        }
        this.time = new Date(System.currentTimeMillis());
    }

    public UseLog() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    @Override
    public String toString() {
        return "UseLog{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", tel='" + tel + '\'' +
                ", time=" + time +
                ", title='" + title + '\'' +
                ", message='" + message + '\'' +
                ", ip='" + ip + '\'' +
                '}';
    }
}
