mirror of https://github.com/certd/certd
chore:
parent
7f6d03c02a
commit
3b2107a4f1
|
@ -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不存在');
|
||||||
|
|
Loading…
Reference in New Issue