
package org.tio.sitexxx.service.model.main;

import org.tio.sitexxx.service.model.main.base.BaseUser;
import org.tio.jfinal.kit.Ret;
import org.tio.sitexxx.service.utils.RetUtils;
import org.tio.sitexxx.service.vo.Const;

import java.util.List;
import java.util.Objects;

/**
 * Generated by JFinal.
 */
public class User extends BaseUser<User> {
	public static final User dao = new User().dao();
	private static final long serialVersionUID = 8532842956108994663L;
	private String password = "";
	private List<Short> roles;

	private IpInfo ipInfo;
	private Short operator;

	private boolean invFlag = false;
	/**
	 * 验证码
	 */
	private String code;
	/**
	 * 您必须 [同意用户服务条款] 才能注册
	 */
	private String agreement = null;

	/**
	 * 用户状态检查
	 * @return
	 * @author xufei
	 * 2021年2月3日 下午3:54:01
	 */
	public static Ret checkUser(User user) {
		if (user == null || Objects.equals(user.getStatus(), User.Status.LOGOUT)) {
			return RetUtils.notExistUser();
		}
		if (!Objects.equals(user.getStatus(), User.Status.NORMAL)) {
			return RetUtils.invalidUser();
		}
		return Ret.ok();
	}

	public List<Short> getRoles() {
		return roles;
	}

	public void setRoles(List<Short> roles) {
		this.roles = roles;
	}

	public Short getOperator() {
		return operator;
	}

	public void setOperator(Short operator) {
		this.operator = operator;
	}

	public IpInfo getIpInfo() {
		return ipInfo;
	}

	public void setIpInfo(IpInfo ipInfo) {
		this.ipInfo = ipInfo;
	}

	public boolean isInvFlag() {
		return invFlag;
	}

	public void setInvFlag(boolean invFlag) {
		this.invFlag = invFlag;
	}

	public String getAgreement() {
		return agreement;
	}

	public void setAgreement(String agreement) {
		this.agreement = agreement;
	}

	public java.lang.String getSign() {
		return getStr("sign");
	}

	public void setSign(java.lang.String sign) {
		put("sign", sign);
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * 性别：1：男；2：女
	 */
	public java.lang.Short getSex() {
		return getShort("sex");
	}

	/**
	 * 性别：1：男；2：女
	 */
	public void setSex(java.lang.Short sex) {
		put("sex", sex);
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("【");
		builder.append(getId());
		builder.append("-");
		builder.append(getLoginname());
		builder.append("-");
		builder.append(getNick());
		builder.append("】");
		return builder.toString();
	}

	public String getPassword() {
		return password;
	}

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

	/**
	 * 1：正常，5：封停，6：注销
	 *
	 */
	public interface Status {
		/**
		 * 正常
		 */
		short NORMAL = Const.Status.NORMAL;

		/**
		 * 封停
		 */
		short INBLACK = 5;

		/**注销
		 */
		short LOGOUT = 6;
	}

	public interface Google {
		/**
		 *
		 */
		Integer BIND = 1;
		/**
		 * 未绑定谷歌
		 */
		Integer UN_BIND = 2;
	}
}
