/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.security.api.model;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Collections;

/**
 * 用户详细信息
 * @author LGH
 */
@Data
public class YamiUser implements UserDetails {

	/**
	 * 用户ID
	 */
	private String userId;

	private String bizUserId;

	private String pic;

	private String name;

	private Integer appType;

	private boolean enabled;

	private String password;

	/**
	 * 小程序session_key
	 */
	private String sessionKey;

	public YamiUser (){

	}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return Collections.emptyList();
	}

	@Override
	public String getPassword() {
		return this.password;
	}

	@Override
	public String getUsername() {
		return StrUtil.isBlank(userId)? bizUserId: userId;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return this.enabled;
	}
}
