feat: setup argument function module report
parent
35b3cfac8c
commit
c0f8d5ad9d
|
@ -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 { Public } from 'src/core/guards';
|
||||
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(' ')}`)
|
||||
@Controller(`v1/${MODULE_NAME.REPORT_BOOKMARK}`)
|
||||
|
@ -9,27 +20,27 @@ import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|||
@ApiBearerAuth('JWT')
|
||||
export class ReportBookmarkController {
|
||||
@Post()
|
||||
async create() {
|
||||
async create(@Body() body: CreateReportBookmarkDto) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async getAll() {
|
||||
async getAll(@Query() query: GetReportBookmarkDto) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Put('applied')
|
||||
async applied() {
|
||||
@Put('applied/:id')
|
||||
async applied(@Param('id') id: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Put('unapplied')
|
||||
async unapplied() {
|
||||
@Put('unapplied/:id')
|
||||
async unapplied(@Param('id') id: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete() {
|
||||
async delete(@Param('id') id: string) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseReportService } from '../shared/services/base-report.service';
|
||||
|
||||
@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 { Public } from 'src/core/guards';
|
||||
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(' ')}`)
|
||||
@Controller(`v1/${MODULE_NAME.REPORT_EXPORT}`)
|
||||
|
@ -9,27 +24,27 @@ import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|||
@ApiBearerAuth('JWT')
|
||||
export class ReportExportController {
|
||||
@Post()
|
||||
async create() {
|
||||
async create(@Body() body: CreateReportExportDto) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Get()
|
||||
async getAll() {
|
||||
async getAll(@Query() query: GetReportExportDto) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete() {
|
||||
async delete(@Param('id') id: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Get('processing')
|
||||
async getAllProcessing() {
|
||||
async getAllProcessing(@Query() query: GetReportExportProcessingDto) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Get('filename-history')
|
||||
async getListHistoryFileName() {
|
||||
async getListHistoryFileName(@Query() query: GetReportExportFileNameDto) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { BaseReportService } from '../shared/services/base-report.service';
|
||||
|
||||
@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 { Public } from 'src/core/guards';
|
||||
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(' ')}`)
|
||||
@Controller(`v1/${MODULE_NAME.REPORT}`)
|
||||
@Public(false)
|
||||
@ApiBearerAuth('JWT')
|
||||
export class ReportController {
|
||||
constructor(private service: ReportService) {}
|
||||
@Get('config')
|
||||
async getReportConfig() {
|
||||
return;
|
||||
async getReportConfig(@Query() query: GetReportConfigDto) {
|
||||
return await this.service.getReportConfig(query);
|
||||
}
|
||||
|
||||
@Post('data')
|
||||
async getReportData() {
|
||||
return;
|
||||
async getReportData(@Body() body: GetReportDataDto) {
|
||||
return await this.service.getReportData(body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,15 @@
|
|||
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()
|
||||
export class ReportService {}
|
||||
export class ReportService extends BaseReportService {
|
||||
async getReportConfig(query: GetReportConfigDto) {
|
||||
return this.getUser();
|
||||
}
|
||||
|
||||
async getReportData(body: GetReportDataDto) {
|
||||
return this.getUser();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsBoolean, IsObject, IsString, ValidateIf } from 'class-validator';
|
||||
|
||||
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: 'table_config' | 'filter';
|
||||
|
||||
@ApiProperty({
|
||||
name: 'configuration',
|
||||
type: Object,
|
||||
required: true,
|
||||
})
|
||||
@IsObject()
|
||||
@ValidateIf((body) => body.configuration)
|
||||
configuration: any;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
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?: string[];
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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