package com.zhgd.xmgl.security;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * @author peng
 * @date 扩展用户信息
 */
public class SecurityUser extends User {

	private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

	/**
	 * 用户ID
	 */
	@Getter
	@Setter
	private String userId;

	/**
	 * 真实姓名
	 */
	@Getter
	@Setter
	private String realName;

	/**
	 * 手机号
	 */
	@Getter
	@Setter
	private String userTel;

	/**
	 * 账号类型，1系统管理员，2.政务;3.企业;4.项目
	 */
	@Getter
	@Setter
	private Integer accountType;

	/**
	 *  政务、企业或项目sn
	 */
	@Getter
	@Setter
	private String sn;

	/**
	 *  是否为管理员账号
	 */
	@Getter
	@Setter
	private boolean isManager;

	/**
	 *  是否为工程账号
	 */
	@Getter
	@Setter
	private String engineeringSn;

	@JsonCreator
	public SecurityUser(@JsonProperty("userId") String userId, @JsonProperty("account") String account,
                        @JsonProperty("realName")String realName, @JsonProperty("userTel") String userTel,
						@JsonProperty("accountType") Integer accountType, @JsonProperty("sn") String sn,
						@JsonProperty("isManager") boolean isManager, @JsonProperty("engineeringSn") String engineeringSn,
						@JsonProperty("password") String password, @JsonProperty("enabled") boolean enabled,
                        @JsonProperty("accountNonExpired") boolean accountNonExpired,
                        @JsonProperty("credentialsNonExpired") boolean credentialsNonExpired,
                        @JsonProperty("accountNonLocked") boolean accountNonLocked,
                        @JsonProperty("authorities") Collection<? extends GrantedAuthority> authorities) {
		super(account, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
		this.userId = userId;
		this.realName = realName;
		this.userTel = userTel;
		this.accountType = accountType;
		this.sn = sn;
		this.isManager = isManager;
		this.engineeringSn = engineeringSn;
	}

}
