| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.linghu.utils.OpenCryptUtil; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | String decrypt = openCryptUtil.decrypt(token); |
| | | System.out.println(decrypt); |
| | | System.out.println("----------------"); |
| | | JSONObject jsonObject = JSONObject.parseObject(decrypt); |
| | | |
| | | |
| | | // 返回用户信息 |
| | | return ResponseEntity.ok(decrypt); |
| | | return ResponseEntity.ok(jsonObject.get("name")); |
| | | } |
| | | |
| | | // @GetMapping("/getToken") |
| | | // @ApiOperation(value = "获取token") |
| | | // public ResponseEntity<?> getToken(@RequestBody User user) { |
| | | // // 创建用户对 |
| | | // |
| | | // // 创建JwtUtils对象,并生成JWT令牌 |
| | | // OpenCryptUtil openCryptUtil = new OpenCryptUtil(); |
| | | // String decrypt = openCryptUtil.encrypt(user); |
| | | // // 返回JWT令牌 |
| | | // return ResponseEntity.ok(decrypt); |
| | | // } |
| | | @GetMapping("/getToken") |
| | | @ApiOperation(value = "获取token") |
| | | public ResponseEntity<?> getToken( String user) { |
| | | // 创建用户对 |
| | | |
| | | // 创建JwtUtils对象,并生成JWT令牌 |
| | | OpenCryptUtil openCryptUtil = new OpenCryptUtil(); |
| | | String decrypt = openCryptUtil.encrypt(user); |
| | | // 返回JWT令牌 |
| | | return ResponseEntity.ok(decrypt); |
| | | } |
| | | } |