Commit eb9d33d1 authored by nanahira's avatar nanahira

support simple for get app

parent 6add9e4c
Pipeline #23854 passed with stages
in 4 minutes and 27 seconds
...@@ -36,9 +36,10 @@ export class AppController { ...@@ -36,9 +36,10 @@ export class AppController {
description: '管理员可以查询全部的,其他用户可以查属于自己的', description: '管理员可以查询全部的,其他用户可以查属于自己的',
}) })
@ApiQuery({ name: 'id', description: 'app 的 id,没有就是查全部' }) @ApiQuery({ name: 'id', description: 'app 的 id,没有就是查全部' })
@ApiQuery({ name: 'simple', description: '只获取 apps.json 的内容' })
@ApiOkResponse({ type: GetAppReturnMessageDto }) @ApiOkResponse({ type: GetAppReturnMessageDto })
getApp(@FetchMyCardUser() user: MyCardUser, @Query('id') id?: string) { getApp(@FetchMyCardUser() user: MyCardUser, @Query('id') id?: string, @Query('simple') simple?: string) {
return this.appService.getApp(user, id); return this.appService.getApp(user, id, simple);
} }
@Post('app') @Post('app')
......
...@@ -81,7 +81,7 @@ export class AppService extends ConsoleLogger { ...@@ -81,7 +81,7 @@ export class AppService extends ConsoleLogger {
}, 201); }, 201);
} }
async getApp(user: MyCardUser, id?: string) { async getApp(user: MyCardUser, id?: string, simple?: string) {
if (!user) { if (!user) {
throw new BlankReturnMessageDto(401, 'Needs login').toException(); throw new BlankReturnMessageDto(401, 'Needs login').toException();
} }
...@@ -92,11 +92,13 @@ export class AppService extends ConsoleLogger { ...@@ -92,11 +92,13 @@ export class AppService extends ConsoleLogger {
if (id) { if (id) {
query.andWhere('app.id = :id', { id }); query.andWhere('app.id = :id', { id });
} }
if (!simple) {
query query
.leftJoinAndSelect('app.history', 'history') .leftJoinAndSelect('app.history', 'history')
.leftJoinAndSelect('app.depots', 'depot') .leftJoinAndSelect('app.depots', 'depot')
.leftJoin('depot.builds', 'build') .leftJoin('depot.builds', 'build')
.addSelect(['build.id', 'build.version']); .addSelect(['build.id', 'build.version']);
}
return new ReturnMessageDto(200, 'success', await query.getMany()); return new ReturnMessageDto(200, 'success', await query.getMany());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment