-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1374 from academic-relations/1372-feat-api-fnd-007
1372 feat api fnd 007
- Loading branch information
Showing
28 changed files
with
368 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/api/src/feature/activity/model/activity.duration.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IActivityDuration } from "@sparcs-clubs/interface/api/activity/type/activity.duration.type"; | ||
|
||
export class MActivityDuration implements IActivityDuration { | ||
id: number; | ||
|
||
year: number; | ||
|
||
name: string; | ||
|
||
startTerm: Date; | ||
|
||
endTerm: Date; | ||
|
||
createdAt: Date; | ||
|
||
deletedAt: Date | null; | ||
|
||
constructor(data: IActivityDuration) { | ||
Object.assign(this, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
packages/api/src/feature/funding/model/funding.deadline.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IFundingDeadline } from "@sparcs-clubs/interface/api/funding/type/funding.deadline.type"; | ||
import { FundingDeadlineEnum } from "@sparcs-clubs/interface/common/enum/funding.enum"; | ||
|
||
export class MFundingDeadline implements IFundingDeadline { | ||
id: number; | ||
|
||
deadlineEnum: FundingDeadlineEnum; | ||
|
||
startDate: Date; | ||
|
||
endDate: Date; | ||
|
||
createdAt: Date; | ||
|
||
deletedAt: Date | null; | ||
|
||
constructor(data: IFundingDeadline) { | ||
Object.assign(this, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/api/src/feature/funding/repository/funding.deadline.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Inject, Injectable, NotFoundException } from "@nestjs/common"; | ||
import { and, gt, isNull, lte } from "drizzle-orm"; | ||
import { MySql2Database } from "drizzle-orm/mysql2"; | ||
|
||
import { DrizzleAsyncProvider } from "@sparcs-clubs/api/drizzle/drizzle.provider"; | ||
import { FundingDeadlineD } from "@sparcs-clubs/api/drizzle/schema/funding.schema"; | ||
|
||
import { MFundingDeadline } from "../model/funding.deadline.model"; | ||
|
||
@Injectable() | ||
export default class FundingDeadlineRepository { | ||
constructor(@Inject(DrizzleAsyncProvider) private db: MySql2Database) {} | ||
|
||
/** | ||
* @param date 날짜를 받습니다. | ||
* @returns 해당 날짜가 포함된 자금 지원 신청 마감 기한 정보를 리턴합니다. | ||
*/ | ||
async fetch(date: Date): Promise<MFundingDeadline> { | ||
const result = await this.db | ||
.select() | ||
.from(FundingDeadlineD) | ||
.where( | ||
and( | ||
lte(FundingDeadlineD.startDate, date), | ||
gt(FundingDeadlineD.endDate, date), | ||
isNull(FundingDeadlineD.deletedAt), | ||
), | ||
); | ||
|
||
if (result.length === 0) { | ||
throw new NotFoundException("Funding deadline not found"); | ||
} | ||
|
||
return result[0]; | ||
} | ||
} |
Oops, something went wrong.