Skip to content

Commit

Permalink
Merge pull request #271 from Roger13579/TS269
Browse files Browse the repository at this point in the history
fix: get ticket filter of expiredAt
  • Loading branch information
y0000ga authored Jun 22, 2024
2 parents ef91941 + 4bfe573 commit e491025
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/dto/ticket/getTicketsDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export class GetTicketsDto {
...(this._userId && { userId: { $eq: this._userId } }),
...(this._ids && { _id: { $in: this._ids } }),
...((this._expiredAtFrom || this._expiredAtTo) && {
startAt: {
...(this._expiredAtFrom && { $lte: this._expiredAtFrom }),
...(this._expiredAtTo && { $gte: this._expiredAtTo }),
expiredAt: {
...(this._expiredAtFrom && { $gte: this._expiredAtFrom }),
...(this._expiredAtTo && { $lte: this._expiredAtTo }),
},
}),
...(this._isPublished && { isPublished: { $eq: this._isPublished } }),
Expand Down
17 changes: 2 additions & 15 deletions src/service/ticketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import log4js from '../config/log4js';
import { IOrder, IOrderProduct } from '../models/order';
import { throwError } from '../utils/errorHandler';
import { CustomResponseType } from '../types/customResponseType';
import { areTimesInOrder } from '../utils/common';
import { TicketRepository } from '../repository/ticketRepository';
import { CreateTicketDto } from '../dto/ticket/createTicketDto';
import { GetTicketsDto } from '../dto/ticket/getTicketsDto';
import { SortOrder } from '../types/common.type';
import { VerifyTicketsDTO } from '../dto/ticket/verifyTicketsDto';
import { EditTicketsDTO } from '../dto/ticket/editTicketsDto';
import { CreateShareCodeDTO } from '../dto/ticket/createShareCodeDto';
Expand All @@ -32,20 +30,9 @@ export class TicketService {
private readonly productRepository: ProductRepository =
new ProductRepository();

public findTickets = async (ticketFilterDto: GetTicketsDto) => {
const { expiredAtFrom, expiredAtTo } = ticketFilterDto;
public findTickets = async (ticketFilterDto: GetTicketsDto) =>
await this.ticketRepository.findTickets(ticketFilterDto);

// 確認時間順序
areTimesInOrder(
[
{ name: 'expiredAtFrom', value: expiredAtFrom },
{ name: 'expiredAtTo', value: expiredAtTo },
],
SortOrder.asc,
);

return await this.ticketRepository.findTickets(ticketFilterDto);
};
public findSharedTickets = async (
getSharedTicketsDto: GetSharedTicketsDto,
) => {
Expand Down

0 comments on commit e491025

Please sign in to comment.