### 1. 启用 `@GoEnableToken` ### 2. 配置yml文件 ``` fastboot: token: header: token include-paths: - /api/** - /xxx/** exclude-paths: - /static/** - /xxx/** ``` header :请求header中key值,默认token include-paths: 处理请求 exclude-paths: 排除请求 ### 3.生成令牌 ``` // 获取token Map<String, Object> claims = Maps.newHashMap(); claims.put(TokenCfg.USERID, member.getId()); claims.put(TokenCfg.USERNAME, member.getMobile()); String token = JwtHelper.create("fastboot", "api", claims, JwtHelper.JWT_EXPIRE_D_7); ``` ### 4. 如何使用 方法参数中加入@GoToken注解 ``` @RequestMapping("/member") public BaseResult member(@GoToken CurrentToken currentToken) { // 获取信息 Member member = mMemberRepository.findOne(currentToken.getUserId()); return xxx; } ``` ### 5.验证结果 不传返回: ``` { "code": 5000, "msg": "凭据错误:未登录", "success": false } ``` 传错返回: ``` { "code": 5000, "msg": "凭据错误", "success": false } ``` 过期返回: ``` { "code": 5000, "msg": "凭据过期", "success": false } ```