feat: get current applied bookmark
parent
2038f0a74f
commit
32ae6481e6
|
@ -35,16 +35,21 @@ export class ReportBookmarkController {
|
||||||
return await this.service.getAll(query);
|
return await this.service.getAll(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('id')
|
// @Get(':id')
|
||||||
async get(@Param('id') id: string) {
|
// async get(@Param('id') id: string) {
|
||||||
return await this.service.getOne(id);
|
// return await this.service.getOne(id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Get('label-history')
|
@Get('label-history')
|
||||||
async getAllLabelHistory(@Query() query: GetLabelReportBookmarkDto) {
|
async getAllLabelHistory(@Query() query: GetLabelReportBookmarkDto) {
|
||||||
return await this.service.getAllLabelHistory(query);
|
return await this.service.getAllLabelHistory(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('applied')
|
||||||
|
async currentApplied(@Query() query: GetLabelReportBookmarkDto) {
|
||||||
|
return await this.service.getCurrentAppliedBookmark(query);
|
||||||
|
}
|
||||||
|
|
||||||
@Put('applied/:id')
|
@Put('applied/:id')
|
||||||
async applied(@Param('id') id: string) {
|
async applied(@Param('id') id: string) {
|
||||||
return await this.service.applied(id);
|
return await this.service.applied(id);
|
||||||
|
|
|
@ -96,6 +96,35 @@ export class ReportBookmarkService extends BaseReportService {
|
||||||
return newData.map((el) => el.ReportBookmarkModel_label);
|
return newData.map((el) => el.ReportBookmarkModel_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getCurrentAppliedBookmark(query: GetLabelReportBookmarkDto) {
|
||||||
|
const modelName = ReportBookmarkModel.name;
|
||||||
|
|
||||||
|
const creator_id = this.getUser().id;
|
||||||
|
const unique_names = query.unique_names;
|
||||||
|
const group_names = query.group_names;
|
||||||
|
const types = query.types;
|
||||||
|
const qb = this.repo
|
||||||
|
.createQueryBuilder(modelName)
|
||||||
|
.where((query) => {
|
||||||
|
if (unique_names) {
|
||||||
|
query.andWhere(`unique_name IN (:...unique_names)`, { unique_names });
|
||||||
|
}
|
||||||
|
if (group_names) {
|
||||||
|
query.andWhere(`group_name IN (:...group_names)`, { group_names });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (types) {
|
||||||
|
query.andWhere(`type IN (:...types)`, { types });
|
||||||
|
}
|
||||||
|
|
||||||
|
query.andWhere(`creator_id = :creator_id`, { creator_id });
|
||||||
|
query.andWhere(`applied = :applied`, { applied: true });
|
||||||
|
})
|
||||||
|
.orderBy(`${modelName}.created_at`, 'DESC');
|
||||||
|
|
||||||
|
return await qb.getMany();
|
||||||
|
}
|
||||||
|
|
||||||
async applied(id: string) {
|
async applied(id: string) {
|
||||||
await this.repo
|
await this.repo
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
|
|
Loading…
Reference in New Issue