package com.hwrj.cloud.portal.domain;

import com.hwrj.cloud.portal.model.UmsMemberPlatform;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Arrays;
import java.util.Collection;

public class UmsMemberPlaformDo implements UserDetails {
    private UmsMemberPlatform umsMemberPlatform;

    public UmsMemberPlaformDo(UmsMemberPlatform umsMemberPlatform){
        this.umsMemberPlatform=umsMemberPlatform;

    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        //返回当前用户的权限
        return Arrays.asList(new SimpleGrantedAuthority("TEST"));
    }

    @Override
    public String getPassword() {
        return umsMemberPlatform.getOpenid();
    }

    @Override
    public String getUsername() {
        return umsMemberPlatform.getNickname();
    }

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

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

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

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

    public UmsMemberPlatform getUmsMemberPlatform(){
        return umsMemberPlatform;
    }
}
