| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.linghu.model.common.ResponseResult; |
| | | import com.linghu.model.dto.TokenRequest; |
| | | import com.linghu.utils.OpenCryptUtil; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | //open-crypt解析token |
| | | @PostMapping("/parseToken") |
| | | @ApiOperation(value = "解析token") |
| | | public ResponseEntity<?> parseToken(@RequestBody TokenRequest tokenRequest) { |
| | | public ResponseResult<?> parseToken(@RequestBody TokenRequest tokenRequest) { |
| | | String token = tokenRequest.getToken(); |
| | | if (token == null || token.isEmpty()) { |
| | | return ResponseEntity.ok("token为空"); |
| | | return ResponseResult.success("token为空"); |
| | | } |
| | | |
| | | // try { |
| | | // 解密token |
| | | OpenCryptUtil openCryptUtil = new OpenCryptUtil(); |
| | | String decrypt = openCryptUtil.decrypt(token); |
| | | //转换为对象 |
| | | try { |
| | | |
| | | return ResponseResult.success(decrypt); |
| | | } catch (Exception e) { |
| | | return ResponseResult.error(e.getMessage()); |
| | | } |
| | | |
| | | // // 处理可能的JSON格式问题 |
| | | // String cleanedJson = cleanJsonString(decrypt); |
| | |
| | | // 提取所需字段 |
| | | // String name = root.get("name").asText(); |
| | | |
| | | return ResponseEntity.ok(decrypt); |
| | | // } catch (JsonProcessingException e) { |
| | | // } catch (JsonProcessingException e) { |
| | | // // 处理JSON解析异常 |
| | | // return ResponseEntity.badRequest().body("JSON解析失败: " + e.getMessage()); |
| | | // } catch (Exception e) { |