package com.linghu.controller;
|
|
|
import com.linghu.model.common.ResponseResult;
|
import com.linghu.model.dto.TokenRequest;
|
import com.linghu.service.AuthService;
|
import com.linghu.utils.OpenCryptUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
|
import javax.validation.Valid;
|
|
@Api(value = "认证接口", tags = "认证管理")
|
@RestController
|
@RequestMapping("/auth")
|
public class AuthController {
|
|
@Autowired
|
private AuthService authService;
|
|
//open-crypt解析token
|
@PostMapping("/parseToken")
|
@ApiOperation(value = "解析token")
|
public ResponseResult<?> parseToken(@Valid @RequestBody TokenRequest tokenRequest) {
|
return authService.parseTokenAuth(tokenRequest);
|
}
|
@GetMapping("/getToken")
|
@ApiOperation(value = "获取token")
|
public ResponseEntity<?> getToken(@RequestParam(value = "user" ) String user) {
|
// 创建JwtUtils对象,并生成JWT令牌
|
OpenCryptUtil openCryptUtil = new OpenCryptUtil();
|
String decrypt = openCryptUtil.encrypt(user);
|
// 返回JWT令牌
|
return ResponseEntity.ok(decrypt);
|
}
|
}
|