Merge pull request 'feat/report' (#8) from feat/report into development
Reviewed-on: #8pull/13/head
commit
fec27cf294
|
@ -1,7 +1,18 @@
|
||||||
import { Controller, Delete, Get, Post, Put } from '@nestjs/common';
|
import {
|
||||||
|
Body,
|
||||||
|
Controller,
|
||||||
|
Delete,
|
||||||
|
Get,
|
||||||
|
Param,
|
||||||
|
Post,
|
||||||
|
Put,
|
||||||
|
Query,
|
||||||
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
|
import { GetReportBookmarkDto } from '../shared/dto/report-bookmark.get.dto';
|
||||||
|
import { CreateReportBookmarkDto } from '../shared/dto/report-bookmark.create.dto';
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.REPORT_BOOKMARK.split('-').join(' ')}`)
|
@ApiTags(`${MODULE_NAME.REPORT_BOOKMARK.split('-').join(' ')}`)
|
||||||
@Controller(`v1/${MODULE_NAME.REPORT_BOOKMARK}`)
|
@Controller(`v1/${MODULE_NAME.REPORT_BOOKMARK}`)
|
||||||
|
@ -9,27 +20,27 @@ import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
@ApiBearerAuth('JWT')
|
@ApiBearerAuth('JWT')
|
||||||
export class ReportBookmarkController {
|
export class ReportBookmarkController {
|
||||||
@Post()
|
@Post()
|
||||||
async create() {
|
async create(@Body() body: CreateReportBookmarkDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async getAll() {
|
async getAll(@Query() query: GetReportBookmarkDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('applied')
|
@Put('applied/:id')
|
||||||
async applied() {
|
async applied(@Param('id') id: string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('unapplied')
|
@Put('unapplied/:id')
|
||||||
async unapplied() {
|
async unapplied(@Param('id') id: string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
async delete() {
|
async delete(@Param('id') id: string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseReportService } from '../shared/services/base-report.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReportBookmarkService {}
|
export class ReportBookmarkService extends BaseReportService {}
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
import { Controller, Delete, Get, Post, Put } from '@nestjs/common';
|
import {
|
||||||
|
Body,
|
||||||
|
Controller,
|
||||||
|
Delete,
|
||||||
|
Get,
|
||||||
|
Param,
|
||||||
|
Post,
|
||||||
|
Put,
|
||||||
|
Query,
|
||||||
|
} from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
|
import { CreateReportExportDto } from '../shared/dto/report-export.create.dto';
|
||||||
|
import {
|
||||||
|
GetReportExportDto,
|
||||||
|
GetReportExportFileNameDto,
|
||||||
|
GetReportExportProcessingDto,
|
||||||
|
} from '../shared/dto/report-export.get.dto';
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.REPORT_EXPORT.split('-').join(' ')}`)
|
@ApiTags(`${MODULE_NAME.REPORT_EXPORT.split('-').join(' ')}`)
|
||||||
@Controller(`v1/${MODULE_NAME.REPORT_EXPORT}`)
|
@Controller(`v1/${MODULE_NAME.REPORT_EXPORT}`)
|
||||||
|
@ -9,27 +24,27 @@ import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
@ApiBearerAuth('JWT')
|
@ApiBearerAuth('JWT')
|
||||||
export class ReportExportController {
|
export class ReportExportController {
|
||||||
@Post()
|
@Post()
|
||||||
async create() {
|
async create(@Body() body: CreateReportExportDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async getAll() {
|
async getAll(@Query() query: GetReportExportDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
async delete() {
|
async delete(@Param('id') id: string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('processing')
|
@Get('processing')
|
||||||
async getAllProcessing() {
|
async getAllProcessing(@Query() query: GetReportExportProcessingDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('filename-history')
|
@Get('filename-history')
|
||||||
async getListHistoryFileName() {
|
async getListHistoryFileName(@Query() query: GetReportExportFileNameDto) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseReportService } from '../shared/services/base-report.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReportExportService {}
|
export class ReportExportService extends BaseReportService {}
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
import { Controller, Get, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||||
|
import { ReportService } from './report.service';
|
||||||
|
import { GetReportConfigDto } from '../shared/dto/report-config.get.dto';
|
||||||
|
import { GetReportDataDto } from '../shared/dto/report-data.get.dto';
|
||||||
|
|
||||||
@ApiTags(`${MODULE_NAME.REPORT.split('-').join(' ')}`)
|
@ApiTags(`${MODULE_NAME.REPORT.split('-').join(' ')}`)
|
||||||
@Controller(`v1/${MODULE_NAME.REPORT}`)
|
@Controller(`v1/${MODULE_NAME.REPORT}`)
|
||||||
@Public(false)
|
@Public(false)
|
||||||
@ApiBearerAuth('JWT')
|
@ApiBearerAuth('JWT')
|
||||||
export class ReportController {
|
export class ReportController {
|
||||||
|
constructor(private service: ReportService) {}
|
||||||
@Get('config')
|
@Get('config')
|
||||||
async getReportConfig() {
|
async getReportConfig(@Query() query: GetReportConfigDto) {
|
||||||
return;
|
return await this.service.getReportConfig(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('data')
|
@Post('data')
|
||||||
async getReportData() {
|
async getReportData(@Body() body: GetReportDataDto) {
|
||||||
return;
|
return await this.service.getReportData(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { BaseReportService } from '../shared/services/base-report.service';
|
||||||
|
import { GetReportConfigDto } from '../shared/dto/report-config.get.dto';
|
||||||
|
import { GetReportDataDto } from '../shared/dto/report-data.get.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReportService {}
|
export class ReportService extends BaseReportService {
|
||||||
|
async getReportConfig(query: GetReportConfigDto) {
|
||||||
|
return this.getUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
async getReportData(body: GetReportDataDto) {
|
||||||
|
return this.getUser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
export * from './report-config.constant';
|
export * from './report-config.constant';
|
||||||
export * from './report-group.constant';
|
export * from './report-group.constant';
|
||||||
export * from './report-status.constant';
|
export * from './report-status.constant';
|
||||||
|
export * from './report-bookmark-type.constant';
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum REPORT_BOOKMARK_TYPE {
|
||||||
|
table_config = 'table_config',
|
||||||
|
filter = 'filter',
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsBoolean, IsObject, IsString, ValidateIf } from 'class-validator';
|
||||||
|
import { REPORT_BOOKMARK_TYPE } from '../constant';
|
||||||
|
|
||||||
|
export class CreateReportBookmarkDto {
|
||||||
|
@ApiProperty({ name: 'group_name', required: true })
|
||||||
|
@IsString()
|
||||||
|
group_name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'unique_name', required: true })
|
||||||
|
@IsString()
|
||||||
|
unique_name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'label', required: true })
|
||||||
|
@IsString()
|
||||||
|
label: string;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'applied', required: true })
|
||||||
|
@IsBoolean()
|
||||||
|
applied: boolean;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'type', required: true })
|
||||||
|
@IsBoolean()
|
||||||
|
type: REPORT_BOOKMARK_TYPE;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
name: 'configuration',
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsObject()
|
||||||
|
@ValidateIf((body) => body.configuration)
|
||||||
|
configuration: any;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
|
import { REPORT_BOOKMARK_TYPE } from '../constant';
|
||||||
|
|
||||||
|
export class GetReportBookmarkDto {
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
group_names?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
unique_names?: string[];
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
types?: REPORT_BOOKMARK_TYPE[];
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
|
|
||||||
|
export class GetReportConfigDto {
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
group_names?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
unique_names?: string[];
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsObject, IsString, ValidateIf } from 'class-validator';
|
||||||
|
import { QueryModelEntity } from '../entities/query-model.entity';
|
||||||
|
|
||||||
|
export class GetReportDataDto {
|
||||||
|
@ApiProperty({ name: 'group_name', required: true })
|
||||||
|
@IsString()
|
||||||
|
group_name: string;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'unique_name', required: true })
|
||||||
|
@IsString()
|
||||||
|
unique_name: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
name: 'query_model',
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsObject()
|
||||||
|
@ValidateIf((body) => body.query_model)
|
||||||
|
query_model: QueryModelEntity;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { GetReportDataDto } from './report-data.get.dto';
|
||||||
|
import { IsString, IsNumber, IsOptional, IsArray } from 'class-validator';
|
||||||
|
import { ColumnStateEntity } from '../entities/query-model.entity';
|
||||||
|
|
||||||
|
export class CreateReportExportDto extends GetReportDataDto {
|
||||||
|
@ApiProperty({ name: 'time_zone', required: true })
|
||||||
|
@IsString()
|
||||||
|
time_zone: string;
|
||||||
|
|
||||||
|
@ApiProperty({ name: 'file_name', required: true })
|
||||||
|
@IsString()
|
||||||
|
file_name?: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
name: 'column_state',
|
||||||
|
type: [Object],
|
||||||
|
required: true,
|
||||||
|
})
|
||||||
|
@IsOptional()
|
||||||
|
@IsArray()
|
||||||
|
column_state: ColumnStateEntity[];
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Transform } from 'class-transformer';
|
||||||
|
import { IsNumber, ValidateIf } from 'class-validator';
|
||||||
|
|
||||||
|
export class GetReportExportDto {
|
||||||
|
@ApiProperty({ type: Number, required: false, default: 1 })
|
||||||
|
@Transform((body) => Number(body.value))
|
||||||
|
@ValidateIf((body) => body.page)
|
||||||
|
@IsNumber()
|
||||||
|
page = 1;
|
||||||
|
|
||||||
|
@ApiProperty({ type: Number, required: false, default: 10 })
|
||||||
|
@Transform((body) => Number(body.value))
|
||||||
|
@ValidateIf((body) => body.limit)
|
||||||
|
@IsNumber()
|
||||||
|
limit = 10;
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
group_names?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
unique_names?: string[];
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
statuses?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetReportExportProcessingDto {
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
group_names?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
unique_names?: string[];
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
statuses?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetReportExportFileNameDto {
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
group_names?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
@Transform((body) => {
|
||||||
|
return Array.isArray(body.value) ? body.value : [body.value];
|
||||||
|
})
|
||||||
|
unique_names?: string[];
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
export interface QueryModelEntity {
|
||||||
|
startRow: number;
|
||||||
|
endRow: number;
|
||||||
|
rowGroupCols: RowGroupCol[];
|
||||||
|
valueCols: any[];
|
||||||
|
pivotCols: any[];
|
||||||
|
pivotMode: boolean;
|
||||||
|
groupKeys: any[];
|
||||||
|
filterModel: any;
|
||||||
|
sortModel: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RowGroupCol {
|
||||||
|
id: string;
|
||||||
|
displayName: string;
|
||||||
|
field: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ColumnStateEntity {
|
||||||
|
colId: string;
|
||||||
|
width: number;
|
||||||
|
hide: boolean;
|
||||||
|
pinned: any;
|
||||||
|
sort: any;
|
||||||
|
sortIndex: any;
|
||||||
|
aggFunc: any;
|
||||||
|
rowGroup: boolean;
|
||||||
|
rowGroupIndex: any;
|
||||||
|
pivot: boolean;
|
||||||
|
pivotIndex: any;
|
||||||
|
flex: number;
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import { BaseModel } from 'src/core/modules/data/model/base.model';
|
||||||
import { Entity, Column } from 'typeorm';
|
import { Entity, Column } from 'typeorm';
|
||||||
import { ReportBookmarkEntity } from '../entities/report-bookmark.entity';
|
import { ReportBookmarkEntity } from '../entities/report-bookmark.entity';
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
|
import { REPORT_BOOKMARK_TYPE } from '../constant';
|
||||||
|
|
||||||
@Entity(TABLE_NAME.REPORT_BOOKMARK)
|
@Entity(TABLE_NAME.REPORT_BOOKMARK)
|
||||||
export class ReportBookmarkModel
|
export class ReportBookmarkModel
|
||||||
|
@ -22,4 +23,7 @@ export class ReportBookmarkModel
|
||||||
|
|
||||||
@Column('json', { nullable: true })
|
@Column('json', { nullable: true })
|
||||||
configuration: any;
|
configuration: any;
|
||||||
|
|
||||||
|
@Column('varchar')
|
||||||
|
type: REPORT_BOOKMARK_TYPE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { UserProvider } from 'src/core/sessions';
|
||||||
|
import { BLANK_USER } from 'src/core/strings/constants/base.constants';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class BaseReportService {
|
||||||
|
@Inject()
|
||||||
|
protected userProvider: UserProvider;
|
||||||
|
|
||||||
|
getUser() {
|
||||||
|
try {
|
||||||
|
return this.userProvider?.user;
|
||||||
|
} catch (error) {
|
||||||
|
return BLANK_USER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue