Skip to content

Commit

Permalink
Merge pull request #1058 from academic-relations/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
pbc1017 authored Sep 11, 2024
2 parents 7214e5f + 9864892 commit e94ca7e
Show file tree
Hide file tree
Showing 22 changed files with 799 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,6 @@ export default class ClubDelegateController {
return {};
}

@Student()
@Get("/student/clubs/delegates/delegate/my")
@UsePipes(new ZodPipe(apiClb015))
async getStudentClubDelegate(
@GetStudent() user: GetStudent,
@Res({ passthrough: true }) res: Response,
): Promise<ApiClb015ResponseOk | ApiClb015ResponseNoContent> {
const result = await this.clubDelegateService.getStudentClubDelegate(
user.studentId,
);

res.status(result.status);
return result.data;
}

@Student()
@Get(
"/student/clubs/club/:clubId/delegates/delegate/:delegateEnumId/candidates",
Expand All @@ -109,4 +94,19 @@ export default class ClubDelegateController {

return result;
}

@Student()
@Get("/student/clubs/delegates/delegate/my")
@UsePipes(new ZodPipe(apiClb015))
async getStudentClubDelegate(
@GetStudent() user: GetStudent,
@Res({ passthrough: true }) res: Response,
): Promise<ApiClb015ResponseOk | ApiClb015ResponseNoContent> {
const result = await this.clubDelegateService.getStudentClubDelegate(
user.studentId,
);

res.status(result.status);
return result.data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Param,
Patch,
Post,
Query,
Res,
UsePipes,
} from "@nestjs/common";
Expand All @@ -32,14 +33,32 @@ import apiReg013, {
ApiReg013RequestParam,
ApiReg013ResponseOk,
} from "@sparcs-clubs/interface/api/registration/endpoint/apiReg013";
import apiReg019 from "@sparcs-clubs/interface/api/registration/endpoint/apiReg019";
import apiReg020 from "@sparcs-clubs/interface/api/registration/endpoint/apiReg020";

import { Response } from "express";

import { ZodPipe } from "@sparcs-clubs/api/common/pipe/zod-pipe";
import { Student } from "@sparcs-clubs/api/common/util/decorators/method-decorator";
import { GetStudent } from "@sparcs-clubs/api/common/util/decorators/param-decorator";
import {
Executive,
Student,
} from "@sparcs-clubs/api/common/util/decorators/method-decorator";
import {
GetExecutive,
GetStudent,
} from "@sparcs-clubs/api/common/util/decorators/param-decorator";

import { MemberRegistrationService } from "../service/member-registration.service";

import type {
ApiReg019RequestQuery,
ApiReg019ResponseOk,
} from "@sparcs-clubs/interface/api/registration/endpoint/apiReg019";
import type {
ApiReg020RequestQuery,
ApiReg020ResponseOk,
} from "@sparcs-clubs/interface/api/registration/endpoint/apiReg020";

@Controller()
export class MemberRegistrationController {
constructor(
Expand Down Expand Up @@ -127,4 +146,39 @@ export class MemberRegistrationController {
);
return result;
}

@Executive()
@Get("/executive/registrations/member-registrations/brief")
@UsePipes(new ZodPipe(apiReg019))
async getExecutiveRegistrationsMemberRegistrationsBrief(
@GetExecutive() user: GetExecutive,
@Query() query: ApiReg019RequestQuery,
): Promise<ApiReg019ResponseOk> {
const result =
await this.memberRegistrationService.getExecutiveRegistrationsMemberRegistrationsBrief(
{
executiveId: user.executiveId,
query,
},
);
return result;
}

@Executive()
@Get("/executive/registrations/member-registrations")
@UsePipes(new ZodPipe(apiReg020))
async getExecutiveRegistrationsMemberRegistrations(
@GetExecutive() user: GetExecutive,
@Query() query: ApiReg020RequestQuery,
): Promise<ApiReg020ResponseOk> {
const result =
await this.memberRegistrationService.getExecutiveRegistrationsMemberRegistrations(
{
executiveId: user.executiveId,
query,
},
);

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from "drizzle-orm";
import { MySql2Database } from "drizzle-orm/mysql2";

import logger from "@sparcs-clubs/api/common/util/logger";
import { getKSTDate, takeUnique } from "@sparcs-clubs/api/common/util/util";
import { DrizzleAsyncProvider } from "@sparcs-clubs/api/drizzle/drizzle.provider";
import { Club, ClubT } from "@sparcs-clubs/api/drizzle/schema/club.schema";
Expand All @@ -34,7 +35,10 @@ import {
RegistrationApplicationStudent,
RegistrationDeadlineD,
} from "@sparcs-clubs/api/drizzle/schema/registration.schema";
import { Student } from "@sparcs-clubs/api/drizzle/schema/user.schema";
import {
Student,
StudentT,
} from "@sparcs-clubs/api/drizzle/schema/user.schema";

interface IRegistrationApplicationStudent {
id: number;
Expand Down Expand Up @@ -292,4 +296,167 @@ export class MemberRegistrationRepository {

return result.length > 0 ? result[0] : null;
}

/**
* @description getExecutiveRegistrationsMemberRegistrations 서비스를 위한
* 전용 쿼리입니다.
*/
async getExecutiveRegistrationsMemberRegistrations(param: {
clubId: number;
pageOffset: number;
itemCount: number;
semesterId: number;
}) {
const today = getKSTDate();
const result = await this.db
.select({
id: RegistrationApplicationStudent.id,
clubId: RegistrationApplicationStudent.clubId,
clubName: Club.name_kr,
clubTypeEnumId: ClubT.clubStatusEnumId,
division: {
id: Division.id,
name: Division.name,
},
student: {
id: StudentT.id,
studentNumber: Student.number,
StudentEnumId: StudentT.studentEnum,
StudentStatusEnumId: StudentT.studentStatusEnum,
name: Student.name,
phoneNumber: Student.phoneNumber,
email: Student.email,
},
registrationApplicationStudentEnumId:
RegistrationApplicationStudent.registrationApplicationStudentEnumId,
permanent: DivisionPermanentClubD,
})
.from(RegistrationApplicationStudent)
.innerJoin(
Club,
and(
eq(RegistrationApplicationStudent.clubId, Club.id),
isNull(Club.deletedAt),
),
)
.innerJoin(
ClubT,
and(
eq(RegistrationApplicationStudent.clubId, ClubT.clubId),
eq(ClubT.semesterId, param.semesterId),
isNull(ClubT.deletedAt),
),
)
.innerJoin(
Division,
and(eq(Club.divisionId, Division.id), isNull(Division.deletedAt)),
)
.innerJoin(
StudentT,
and(
eq(StudentT.studentId, RegistrationApplicationStudent.studentId),
eq(StudentT.semesterId, param.semesterId),
isNull(StudentT.deletedAt),
),
)
.innerJoin(
Student,
and(
eq(RegistrationApplicationStudent.studentId, Student.id),
isNull(Student.deletedAt),
),
)
.leftJoin(
DivisionPermanentClubD,
and(
isNull(DivisionPermanentClubD.deletedAt),
eq(Club.id, DivisionPermanentClubD.clubId),
lte(DivisionPermanentClubD.startTerm, today),
or(
isNull(DivisionPermanentClubD.endTerm),
gte(DivisionPermanentClubD.endTerm, today),
),
),
)
.where(
and(
eq(RegistrationApplicationStudent.clubId, param.clubId),
isNull(RegistrationApplicationStudent.deletedAt),
),
);
logger.debug(result.length);
return result;
}

/**
* @description getExecutiveRegistrationsMemberRegistrationsBrief 서비스를 위한
* 전용 쿼리입니다.
*/
async getExecutiveRegistrationsMemberRegistrationsBrief(param: {
pageOffset: number;
itemCount: number;
semesterId: number;
}) {
const today = getKSTDate();
const result = await this.db
.select({
clubId: RegistrationApplicationStudent.clubId,
clubName: Club.name_kr,
clubTypeEnumId: ClubT.clubStatusEnumId,
division: {
id: Division.id,
name: Division.name,
},
student: {
StudentEnumId: StudentT.studentEnum,
StudentStatusEnumId: StudentT.studentStatusEnum,
},
registrationApplicationStudentEnumId:
RegistrationApplicationStudent.registrationApplicationStudentEnumId,
permanent: DivisionPermanentClubD,
})
.from(RegistrationApplicationStudent)
.innerJoin(
Club,
and(
eq(RegistrationApplicationStudent.clubId, Club.id),
isNull(Club.deletedAt),
),
)
.innerJoin(
ClubT,
and(
eq(RegistrationApplicationStudent.clubId, ClubT.clubId),
eq(ClubT.semesterId, param.semesterId),
isNull(ClubT.deletedAt),
),
)
.innerJoin(
Division,
and(eq(Club.divisionId, Division.id), isNull(Division.deletedAt)),
)
.innerJoin(
StudentT,
and(
eq(StudentT.studentId, RegistrationApplicationStudent.studentId),
eq(StudentT.semesterId, param.semesterId),
isNull(StudentT.deletedAt),
),
)
.leftJoin(
DivisionPermanentClubD,
and(
isNull(DivisionPermanentClubD.deletedAt),
eq(Club.id, DivisionPermanentClubD.clubId),
lte(DivisionPermanentClubD.startTerm, today),
or(
isNull(DivisionPermanentClubD.endTerm),
gte(DivisionPermanentClubD.endTerm, today),
),
),
)
.where(and(isNull(RegistrationApplicationStudent.deletedAt)));
logger.debug(result.length);
return result;
}
}
Loading

0 comments on commit e94ca7e

Please sign in to comment.