|
@@ -3,6 +3,7 @@ package cn.reghao.tnb.auth.app.controller;
|
|
|
import cn.reghao.tnb.auth.app.model.dto.ApiKeyDto;
|
|
import cn.reghao.tnb.auth.app.model.dto.ApiKeyDto;
|
|
|
import cn.reghao.tnb.auth.app.model.po.ApiKey;
|
|
import cn.reghao.tnb.auth.app.model.po.ApiKey;
|
|
|
import cn.reghao.tnb.auth.app.model.vo.ApiKeyCreateVO;
|
|
import cn.reghao.tnb.auth.app.model.vo.ApiKeyCreateVO;
|
|
|
|
|
+import cn.reghao.tnb.auth.app.service.AccountTokenService;
|
|
|
import cn.reghao.tnb.auth.app.service.ApiKeyService;
|
|
import cn.reghao.tnb.auth.app.service.ApiKeyService;
|
|
|
import cn.reghao.tnb.common.web.WebResult;
|
|
import cn.reghao.tnb.common.web.WebResult;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -18,15 +19,18 @@ import java.util.List;
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/api/account/apikey")
|
|
@RequestMapping("/api/account/apikey")
|
|
|
public class ApiKeyController {
|
|
public class ApiKeyController {
|
|
|
|
|
+ private final AccountTokenService accountTokenService;
|
|
|
private final ApiKeyService apiKeyService;
|
|
private final ApiKeyService apiKeyService;
|
|
|
|
|
|
|
|
- public ApiKeyController(ApiKeyService apiKeyService) {
|
|
|
|
|
|
|
+ public ApiKeyController(AccountTokenService accountTokenService, ApiKeyService apiKeyService) {
|
|
|
|
|
+ this.accountTokenService = accountTokenService;
|
|
|
this.apiKeyService = apiKeyService;
|
|
this.apiKeyService = apiKeyService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
public String createKey(@RequestBody @Validated ApiKeyDto apiKeyDto) {
|
|
public String createKey(@RequestBody @Validated ApiKeyDto apiKeyDto) {
|
|
|
- ApiKeyCreateVO vo = apiKeyService.createApiKey(apiKeyDto);
|
|
|
|
|
|
|
+ long userId = accountTokenService.getAuthToken().getUserId();
|
|
|
|
|
+ ApiKeyCreateVO vo = apiKeyService.createApiKey(apiKeyDto, userId);
|
|
|
return WebResult.success(vo);
|
|
return WebResult.success(vo);
|
|
|
}
|
|
}
|
|
|
|
|
|