package com.doumee.config.Jwt;
|
|
import io.swagger.models.auth.In;
|
import lombok.Data;
|
|
import java.util.HashMap;
|
import java.util.Map;
|
|
/**
|
* jwt的第二部分
|
*
|
* @author fengshuonan
|
* @Date 2019/7/20 20:45
|
*/
|
@Data
|
public class JwtPayLoad {
|
|
/**
|
* 用户id
|
*/
|
private long userId;
|
private Integer userType;
|
private long expire;
|
|
|
public JwtPayLoad() {
|
}
|
|
/**
|
* @param userId
|
* @param userType 0=消费者 Member 1=内部员工
|
*/
|
public JwtPayLoad(long userId,Integer userType) {
|
this.userId = userId;
|
this.userType = userType;
|
}
|
|
/**
|
* payload转化为map形式
|
*
|
* @author fengshuonan
|
* @Date 2019/7/20 20:50
|
*/
|
public Map<String, Object> toMap() {
|
HashMap<String, Object> map = new HashMap<>();
|
map.put("userId", this.userId);
|
map.put("userType", this.userType);
|
return map;
|
}
|
|
/**
|
* payload转化为map形式
|
*
|
* @author fengshuonan
|
* @Date 2019/7/20 20:50
|
*/
|
public static JwtPayLoad toBean(Map<String, Object> map) {
|
if (map == null || map.size() == 0) {
|
return new JwtPayLoad();
|
} else {
|
JwtPayLoad jwtPayLoad = new JwtPayLoad();
|
jwtPayLoad.setUserId(Long.valueOf(map.get("userId").toString()) );
|
jwtPayLoad.setUserType((Integer) map.get("userType"));
|
return jwtPayLoad;
|
}
|
}
|
|
|
|
}
|