mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
chore:
This commit is contained in:
@@ -63,7 +63,7 @@ export class OpenKeyController extends CrudController<OpenKeyService> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('/getApiToken', { summary: Constants.per.authOnly })
|
@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());
|
await this.service.checkUserId(id, this.getUserId());
|
||||||
const token = await this.service.getApiToken(id);
|
const token = await this.service.getApiToken(id);
|
||||||
return this.ok(token);
|
return this.ok(token);
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ export class OpenKeyService extends BaseService<OpenKeyEntity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getByKeyId(keyId: string) {
|
async getByKeyId(keyId: string) {
|
||||||
|
if (!keyId) {
|
||||||
|
throw new Error('keyId不能为空');
|
||||||
|
}
|
||||||
return this.repository.findOne({ where: { keyId } });
|
return this.repository.findOne({ where: { keyId } });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +94,9 @@ export class OpenKeyService extends BaseService<OpenKeyEntity> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getApiToken(id: number) {
|
async getApiToken(id: number) {
|
||||||
|
if (!id) {
|
||||||
|
throw new Error('id不能为空');
|
||||||
|
}
|
||||||
const entity = await this.repository.findOne({ where: { id } });
|
const entity = await this.repository.findOne({ where: { id } });
|
||||||
if (!entity) {
|
if (!entity) {
|
||||||
throw new Error('id不存在');
|
throw new Error('id不存在');
|
||||||
|
|||||||
Reference in New Issue
Block a user