package com.casic.PgInterface.patroler.domain;

import com.casic.PgInterface.devTable.domain.PgAlarm;

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

/**
 * Created by yxw on 2017/10/31.
 */
@Entity
@Table(name = "PG_USER")
@SequenceGenerator(name = "SEQ_PG_USER_ID", sequenceName = "SEQ_PG_USER_ID",allocationSize=1,initialValue=1)
public class PgUser implements Serializable {

    private static final long serialVersionUID = 1L;
    private long id;
    private String userName;//用户名
    private String password;//密码
    private String department;//部门
    private String post;//职务
    private String phoneNumber;//电话
    private int active;//状态位
//    private PgRole pgRoleId;//权限
    private List<PgAlarm> pgAlarms;
    private List<PgLog> pgLogs;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_USER_ID")
    public long getId() {
        return id;
    }

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

    @Column(name = "USERNAME")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "PASSWORD")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "DEPARTMENT")
    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    @Column(name = "POST")
    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    @Column(name = "PHONENUMBER")
    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    @Column(name = "ACTIVE")
    public int getActive() {
        return active;
    }

    public void setActive(int active) {
        this.active = active;
    }

//    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
//    @NotFound(action = NotFoundAction.IGNORE)
//    @JoinColumn(name = "ROLEID")
//    public PgRole getPgRoleId() {
//        return pgRoleId;
//    }
//
//    public void setPgRoleId(PgRole pgRoleId) {
//        this.pgRoleId = pgRoleId;
//    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "userId")
    public List<PgAlarm> getPgAlarms() {
        return pgAlarms;
    }

    public void setPgAlarms(List<PgAlarm> pgAlarms) {
        this.pgAlarms = pgAlarms;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "userId")
    public List<PgLog> getPgLogs() {
        return pgLogs;
    }

    public void setPgLogs(List<PgLog> pgLogs) {
        this.pgLogs = pgLogs;
    }
}