Merge branch 'main' of https://gitea.bkdhome.p-e.kr/baekyangdan/scheduler-back
All checks were successful
Test CI / build (push) Successful in 1m21s
All checks were successful
Test CI / build (push) Successful in 1m21s
This commit is contained in:
@@ -1,2 +1,6 @@
|
|||||||
yarnPath: .yarn/releases/yarn-4.11.0.cjs
|
yarnPath: .yarn/releases/yarn-4.11.0.cjs
|
||||||
|
npmScopes:
|
||||||
|
baekyangdan:
|
||||||
|
npmRegistryServer: "https://gitea.bkdhome.p-e.kr/api/packages/baekyangdan/npm/"
|
||||||
|
npmAuthToken: "d39c7d88c52806df7522ce2b340b6577c5ec5082"
|
||||||
nodeLinker: node-modules
|
nodeLinker: node-modules
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
"drizzle-pull:prod": "dotenv -e .env.prod -- drizzle-kit pull"
|
"drizzle-pull:prod": "dotenv -e .env.prod -- drizzle-kit pull"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@baekyangdan/core-utils": "^1.0.4",
|
||||||
"@fastify/cookie": "^11.0.2",
|
"@fastify/cookie": "^11.0.2",
|
||||||
"@nestjs/class-transformer": "^0.4.0",
|
"@nestjs/class-transformer": "^0.4.0",
|
||||||
"@nestjs/class-validator": "^0.13.4",
|
"@nestjs/class-validator": "^0.13.4",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { JsonWebTokenError, TokenExpiredError } from '@nestjs/jwt';
|
import { JsonWebTokenError, TokenExpiredError } from '@nestjs/jwt';
|
||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
|
import { UnauthorizedCode, UnauthorizedMessage, BadRequestCode, BadRequestMessage, InternalServerErrorCode, InternalServerErrorMessage } from '@baekyangdan/core-utils';
|
||||||
|
|
||||||
@Catch()
|
@Catch()
|
||||||
export class AllExceptionsFilter implements ExceptionFilter {
|
export class AllExceptionsFilter implements ExceptionFilter {
|
||||||
@@ -22,8 +23,8 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
|||||||
|
|
||||||
const responseBody = {
|
const responseBody = {
|
||||||
statusCode: status,
|
statusCode: status,
|
||||||
message: 'Access Token Expired',
|
message: UnauthorizedMessage.ACCESS_TOKEN_EXPIRED,
|
||||||
code: 'AccessTokenExpired',
|
code: UnauthorizedCode.ACCESS_TOKEN_EXPIRED,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
path: ctx.getRequest().url
|
path: ctx.getRequest().url
|
||||||
};
|
};
|
||||||
@@ -38,8 +39,8 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
|||||||
|
|
||||||
const responseBody = {
|
const responseBody = {
|
||||||
statusCode: status,
|
statusCode: status,
|
||||||
message: 'Invalid Token',
|
message: UnauthorizedMessage.INVALID_TOKEN,
|
||||||
code: 'InvalidToken',
|
code: UnauthorizedCode.INVALID_TOKEN,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
path: ctx.getRequest().url
|
path: ctx.getRequest().url
|
||||||
};
|
};
|
||||||
@@ -56,7 +57,7 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
|||||||
let message =
|
let message =
|
||||||
exception instanceof HttpException
|
exception instanceof HttpException
|
||||||
? exception.getResponse()
|
? exception.getResponse()
|
||||||
: 'Internal server error';
|
: InternalServerErrorMessage.INTERNAL_SERVER_ERROR;
|
||||||
|
|
||||||
if (typeof message === 'object' && (message as any).message) {
|
if (typeof message === 'object' && (message as any).message) {
|
||||||
message = (message as any).message;
|
message = (message as any).message;
|
||||||
@@ -67,7 +68,8 @@ export class AllExceptionsFilter implements ExceptionFilter {
|
|||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
path: request.url,
|
path: request.url,
|
||||||
statusCode: status,
|
statusCode: status,
|
||||||
error: message
|
message: message,
|
||||||
|
error: InternalServerErrorCode
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
import { IsArray, IsDateString, IsString } from "@nestjs/class-validator";
|
import { IsArray, IsDateString, IsString } from "@nestjs/class-validator";
|
||||||
|
|
||||||
export class ListRequestDto {
|
export class ListRequestDto {
|
||||||
|
@IsDateString()
|
||||||
|
date?: string;
|
||||||
|
|
||||||
@IsDateString()
|
@IsDateString()
|
||||||
startDate?: string;
|
startDate?: string;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class ScheduleRepo {
|
|||||||
constructor(@Inject('DRIZZLE') private readonly db: NodePgDatabase<typeof schema>) {}
|
constructor(@Inject('DRIZZLE') private readonly db: NodePgDatabase<typeof schema>) {}
|
||||||
|
|
||||||
async getList(accountId: string, data: DTO.ListRequest) {
|
async getList(accountId: string, data: DTO.ListRequest) {
|
||||||
const { startDate, endDate, name, status, styleList, typeList } = data;
|
const { date, startDate, endDate, name, status, styleList, typeList } = data;
|
||||||
const schedule = schema.schedule;
|
const schedule = schema.schedule;
|
||||||
|
|
||||||
const result = await this
|
const result = await this
|
||||||
@@ -22,14 +22,24 @@ export class ScheduleRepo {
|
|||||||
endDate: schedule.endDate,
|
endDate: schedule.endDate,
|
||||||
status: schedule.status,
|
status: schedule.status,
|
||||||
style: schedule.style,
|
style: schedule.style,
|
||||||
type: schedule.style,
|
type: schedule.type,
|
||||||
})
|
})
|
||||||
.from(schedule)
|
.from(schedule)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(schedule.owner, accountId),
|
eq(schedule.owner, accountId),
|
||||||
startDate ? gte(schedule.startDate, Converter.formatDateToSqlDate(startDate)) : undefined,
|
(startDate && endDate)
|
||||||
endDate ? lte(schedule.endDate, Converter.formatDateToSqlDate(endDate)) : undefined,
|
? and(
|
||||||
|
lte(schedule.startDate, Converter.formatDateToSqlDate(endDate)),
|
||||||
|
gte(schedule.endDate, Converter.formatDateToSqlDate(startDate))
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
|
date
|
||||||
|
? and(
|
||||||
|
lte(schedule.startDate, Converter.formatDateToSqlDate(date)),
|
||||||
|
gte(schedule.endDate, Converter.formatDateToSqlDate(date))
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
name ? like(schedule.name, `%${name}%`) : undefined,
|
name ? like(schedule.name, `%${name}%`) : undefined,
|
||||||
(typeList && typeList.length > 0) ? inArray(schedule.type, typeList) : undefined,
|
(typeList && typeList.length > 0) ? inArray(schedule.type, typeList) : undefined,
|
||||||
(styleList && styleList.length > 0) ? inArray(schedule.style, styleList) : undefined,
|
(styleList && styleList.length > 0) ? inArray(schedule.style, styleList) : undefined,
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ export class Converter {
|
|||||||
|
|
||||||
static formatDateToSqlDate(date: string): string {
|
static formatDateToSqlDate(date: string): string {
|
||||||
const targetDate = new Date(date);
|
const targetDate = new Date(date);
|
||||||
const year = targetDate.getUTCFullYear();
|
const year = targetDate.getFullYear();
|
||||||
const month = (targetDate.getUTCMonth() + 1).toString().padStart(2, '0');
|
const month = (targetDate.getMonth() + 1).toString().padStart(2, '0');
|
||||||
const day = (targetDate.getUTCDate()).toString().padStart(2, '0');
|
const day = (targetDate.getDate()).toString().padStart(2, '0');
|
||||||
|
|
||||||
return `${year}-${month}-${day}`;
|
return `${year}-${month}-${day}`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user