|
|
@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
@ -37,8 +38,13 @@ public class JwtUtils { |
|
|
|
* 生成jwt token |
|
|
|
*/ |
|
|
|
public String generateToken(Long userId) { |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
map.put("userId",userId.toString()); |
|
|
|
map.put("app","gov"); |
|
|
|
map.put("client","web"); |
|
|
|
return Jwts.builder() |
|
|
|
.setHeaderParam("typ", "JWT") |
|
|
|
.setClaims(map) |
|
|
|
.setSubject(userId+"") |
|
|
|
.setIssuedAt(new Date()) |
|
|
|
.setExpiration(DateTime.now().plusSeconds(jwtProperties.getExpire()).toDate()) |
|
|
|