-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8cf236
commit a429ff1
Showing
10 changed files
with
194 additions
and
36 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
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 |
---|---|---|
@@ -1,81 +1,104 @@ | ||
import { InferSelectModel } from "drizzle-orm"; | ||
import { int, varchar, timestamp, mysqlTable } from "drizzle-orm/mysql-core"; | ||
|
||
export const OrganizationTypeEnum = mysqlTable("org_typ_e", { | ||
export const OrganizationTypeEnum = mysqlTable("organization_type_enum", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
|
||
export const OrganizationPresidentTypeEnum = mysqlTable("org_pre_typ_e", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
export const OrganizationPresidentTypeEnum = mysqlTable( | ||
"organization_president_type_enum", | ||
{ | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}, | ||
); | ||
|
||
export const BudgetDomainEnum = mysqlTable("bud_dom_e", { | ||
export const BudgetDomainEnum = mysqlTable("budget_domain_enum", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
|
||
export const BudgetDivisionIncomeEnum = mysqlTable("bud_div_inc_e", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
export const BudgetDivisionIncomeEnum = mysqlTable( | ||
"budget_division_income_enum", | ||
{ | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}, | ||
); | ||
|
||
export const BudgetDivisionExpenseEnum = mysqlTable("bud_div_exp_e", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
export const BudgetDivisionExpenseEnum = mysqlTable( | ||
"budget_division_expense_enum", | ||
{ | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}, | ||
); | ||
|
||
export const BudgetClassExpenseEnum = mysqlTable("bud_cla_exp_e", { | ||
export const BudgetClassExpenseEnum = mysqlTable("budget_class_expense_enum", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
|
||
export const TransactionTypeEnum = mysqlTable("tra_typ_e", { | ||
export const TransactionTypeEnum = mysqlTable("transaction_type_enum", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
|
||
export const ReportFileTypeEnum = mysqlTable("rep_fil_typ_e", { | ||
export const ReportFileTypeEnum = mysqlTable("report_file_type_enum", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
|
||
export const AssistantPermissionEnum = mysqlTable("ass_per_e", { | ||
export const AssistantPermissionEnum = mysqlTable("assistant_permission_enum", { | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}); | ||
|
||
export const AgendaAcceptedStatusEnum = mysqlTable( | ||
"agenda_accepted_status_enum", | ||
{ | ||
id: int("id").autoincrement().primaryKey().notNull(), | ||
name: varchar("name", { length: 30 }).notNull(), | ||
createdAt: timestamp("created_at").defaultNow().notNull(), | ||
updatedAt: timestamp("updated_at").defaultNow().onUpdateNow().notNull(), | ||
deletedAt: timestamp("deleted_at"), | ||
}, | ||
); | ||
|
||
export type OrganizationTypeEnumT = InferSelectModel< | ||
typeof OrganizationTypeEnum | ||
>; | ||
export type OrganizationPresidentTypeEnumT = InferSelectModel< | ||
typeof OrganizationPresidentTypeEnum | ||
>; | ||
export type AgendaAcceptedStatusEnumT = InferSelectModel< | ||
typeof AgendaAcceptedStatusEnum | ||
>; |
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
64 changes: 64 additions & 0 deletions
64
packages/api/src/feature/organization/service/organization.public.service.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,64 @@ | ||
import { Injectable, NotFoundException } from "@nestjs/common"; | ||
import { OrganizationT } from "src/drizzle/schema"; | ||
import { SemesterPublicService } from "src/feature/semester/semester.public.service"; | ||
import { | ||
OrganizationRepository, | ||
OrganizationWithPresidentT, | ||
} from "../repository/organization.repository"; | ||
|
||
@Injectable() | ||
export class OrganizationPublicService { | ||
constructor( | ||
private readonly organizationRepository: OrganizationRepository, | ||
private readonly semesterPublicService: SemesterPublicService, | ||
) {} | ||
|
||
/** | ||
* @param id organization id | ||
* @returns OrganizationT id에 해당하는 OrganizationT 객체를 리턴합니다. | ||
* @description 해당 id의 organization이 없으면 404 exception을 throw 합니다. | ||
*/ | ||
async getOrganizationById(id: number): Promise<OrganizationT> { | ||
const organizations = | ||
await this.organizationRepository.getOrganizationById(id); | ||
if (organizations.length === 0) { | ||
throw new NotFoundException(`Organization with ID ${id} not found.`); | ||
} | ||
return organizations[0]; | ||
} | ||
|
||
/** | ||
* @param id organizationId, date | ||
* @returns OrganizationT id에 해당하는 OrganizationT 객체를 리턴합니다. | ||
* @description 해당 id의 organization이 없으면 404 exception을 throw 합니다. | ||
*/ | ||
async getOrganizationWithPresidentByIdAndDate( | ||
id: number, | ||
date: Date, | ||
): Promise<OrganizationWithPresidentT> { | ||
const organizations = | ||
await this.organizationRepository.getOrganizationWithPresidentById( | ||
id, | ||
date, | ||
); | ||
if (organizations.length === 0) { | ||
throw new NotFoundException(`Organization with ID ${id} not found.`); | ||
} | ||
return organizations[0]; | ||
} | ||
|
||
/** | ||
* @param id organizationId, semesterId | ||
* @returns OrganizationT id에 해당하는 semester의 마지막 OrganizationWithPresidentT 객체를 리턴합니다. | ||
* @description 해당 id의 organization이 없으면 404 exception을 throw 합니다. | ||
*/ | ||
async getOrganizationWithPresidentByIdAndSemester( | ||
id: number, | ||
semesterId: number, | ||
): Promise<OrganizationWithPresidentT> { | ||
const { endTerm } = | ||
await this.semesterPublicService.getSemesterById(semesterId); | ||
|
||
return this.getOrganizationWithPresidentByIdAndDate(id, endTerm); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { DrizzleModule } from "@sparcs-students/api/drizzle/drizzle.module"; | ||
import { SemesterRepository } from "./semester.repository"; | ||
import { SemesterPublicService } from "./semester.public.service"; | ||
|
||
@Module({ exports: [SemesterRepository], imports: [DrizzleModule] }) | ||
@Module({ | ||
providers: [SemesterRepository, SemesterPublicService], | ||
exports: [SemesterPublicService], | ||
imports: [DrizzleModule], | ||
}) | ||
export class SemesterModule {} |
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