package easydo.technology.core;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

import lombok.Getter;
import lombok.Setter;
import zmo.technology.lite.core.ZeroCoreStructs;

@Setter
@Getter
public class SysUser extends ZeroCoreStructs {

    private Long userID;
    private Long deptID;
    private String username;
    private String nickName;
    private String gender;
    private String phone;
    private String email;
    private String avatarName;
    private String avatarPath;
    private Long enabled;
    private String createBy;
    private String updateBy;
    private Date pwdResetTime;
    private Date createTime;
    private Date updateTime;
    private Integer projectFpiID;
    private String projectUserType;

    public SysUser() {
        super();
    }

    public SysUser(ResultSet set) throws SQLException {
        super(set);

        if (inResultSet(set, "USER_ID") && set.getObject("USER_ID") != null)
            userID = set.getLong("USER_ID");

        if (inResultSet(set, "DEPT_ID") && set.getObject("DEPT_ID") != null)
            deptID = set.getLong("DEPT_ID");

        if (inResultSet(set, "USERNAME"))
            username = set.getString("USERNAME");

        if (inResultSet(set, "NICK_NAME"))
            nickName = set.getString("NICK_NAME");

        if (inResultSet(set, "GENDER"))
            gender = set.getString("GENDER");

        if (inResultSet(set, "PHONE"))
            phone = set.getString("PHONE");

        if (inResultSet(set, "EMAIL"))
            email = set.getString("EMAIL");

        if (inResultSet(set, "AVATAR_NAME"))
            avatarName = set.getString("AVATAR_NAME");

        if (inResultSet(set, "AVATAR_PATH"))
            avatarPath = set.getString("AVATAR_PATH");

        if (inResultSet(set, "ENABLED") && set.getObject("ENABLED") != null)
            enabled = set.getLong("ENABLED");

        if (inResultSet(set, "CREATE_BY"))
            createBy = set.getString("CREATE_BY");

        if (inResultSet(set, "UPDATE_BY"))
            updateBy = set.getString("UPDATE_BY");

        if (inResultSet(set, "PWD_RESET_TIME") && set.getObject("PWD_RESET_TIME") != null)
            pwdResetTime = new Date(set.getTimestamp("PWD_RESET_TIME").getTime());

        if (inResultSet(set, "CREATE_TIME") && set.getObject("CREATE_TIME") != null)
            createTime = new Date(set.getTimestamp("CREATE_TIME").getTime());

        if (inResultSet(set, "UPDATE_TIME") && set.getObject("UPDATE_TIME") != null)
            updateTime = new Date(set.getTimestamp("UPDATE_TIME").getTime());

        if (inResultSet(set, "PROJECT_FPI_ID") && set.getObject("PROJECT_FPI_ID") != null)
            projectFpiID = set.getInt("PROJECT_FPI_ID");

        if (inResultSet(set, "PROJECT_USER_TYPE"))
            projectUserType = set.getString("PROJECT_USER_TYPE");
    }
}
