65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BaseReportService } from '../shared/services/base-report.service';
|
|
import { CreateReportBookmarkDto } from '../shared/dto/report-bookmark.create.dto';
|
|
import {
|
|
GetLabelReportBookmarkDto,
|
|
GetReportBookmarkDto,
|
|
} from '../shared/dto/report-bookmark.get.dto';
|
|
import { Repository } from 'typeorm';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { ReportBookmarkModel } from '../shared/models/report-bookmark.model';
|
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
|
|
@Injectable()
|
|
export class ReportBookmarkService extends BaseReportService {
|
|
constructor(
|
|
@InjectRepository(ReportBookmarkModel, CONNECTION_NAME.DEFAULT)
|
|
private repo: Repository<ReportBookmarkModel>,
|
|
) {
|
|
super();
|
|
}
|
|
|
|
async create(body: CreateReportBookmarkDto) {
|
|
return 'you hit API for create report bookmark';
|
|
}
|
|
|
|
async getAll(query: GetReportBookmarkDto) {
|
|
const modelName = ReportBookmarkModel.name;
|
|
|
|
const requestor_id = this.userProvider.user.id;
|
|
const unique_names = query.unique_names;
|
|
const group_names = query.group_names;
|
|
|
|
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 });
|
|
}
|
|
query.andWhere(`requestor_id = :requestor_id`, { requestor_id });
|
|
})
|
|
.orderBy(`${modelName}.created_at`, 'DESC');
|
|
|
|
return await qb.getMany();
|
|
}
|
|
|
|
async getAllLabelHistory(query: GetLabelReportBookmarkDto) {
|
|
return 'you hit API for get all label history report bookmark';
|
|
}
|
|
|
|
async applied(id: string) {
|
|
return 'you hit API for applied report bookmark';
|
|
}
|
|
|
|
async unapplied(id: string) {
|
|
return 'you hit API for unapplied report bookmark';
|
|
}
|
|
|
|
async delete(id: string) {
|
|
return 'you hit API for delete report bookmark';
|
|
}
|
|
}
|