v2
xiaojunnuo 2025-01-19 01:21:58 +08:00
parent 7f6d03c02a
commit 3b2107a4f1
2 changed files with 7 additions and 1 deletions

View File

@ -63,7 +63,7 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
}
@Post('/getApiToken', { summary: Constants.per.authOnly })
async getApiToken(@Query('id') id: number) {
async getApiToken(@Body('id') id: number) {
await this.service.checkUserId(id, this.getUserId());
const token = await this.service.getApiToken(id);
return this.ok(token);

View File

@ -47,6 +47,9 @@ export class OpenKeyService extends BaseService<OpenKeyEntity> {
}
async getByKeyId(keyId: string) {
if (!keyId) {
throw new Error('keyId不能为空');
}
return this.repository.findOne({ where: { keyId } });
}
@ -91,6 +94,9 @@ export class OpenKeyService extends BaseService<OpenKeyEntity> {
}
async getApiToken(id: number) {
if (!id) {
throw new Error('id不能为空');
}
const entity = await this.repository.findOne({ where: { id } });
if (!entity) {
throw new Error('id不存在');