Skip to content

Commit

Permalink
Merge pull request #1173 from academic-relations/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
pbc1017 authored Oct 9, 2024
2 parents 0369a88 + a2f37f3 commit 6cb866c
Show file tree
Hide file tree
Showing 96 changed files with 3,433 additions and 706 deletions.
36 changes: 36 additions & 0 deletions packages/api/src/feature/club/controller/club.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ import apiClb005, {
ApiClb005RequestParam,
ApiClb005ResponseOk,
} from "@sparcs-clubs/interface/api/club/endpoint/apiClb005";
import apiClb009, {
ApiClb009RequestParam,
ApiClb009ResponseOk,
} from "@sparcs-clubs/interface/api/club/endpoint/apiClb009";
import apiClb010, {
ApiClb010RequestParam,
ApiClb010ResponseOk,
} from "@sparcs-clubs/interface/api/club/endpoint/apiClb010";
import apiClb016, {
ApiClb016ResponseOk,
} from "@sparcs-clubs/interface/api/club/endpoint/apiClb016";
Expand Down Expand Up @@ -99,6 +107,34 @@ export class ClubController {
return result;
}

@Student()
@Get("/student/clubs/club/:clubId/members/semesters")
@UsePipes(new ZodPipe(apiClb009))
async getStudentClubSemesters(
@GetStudent() user: GetStudent,
@Param() param: ApiClb009RequestParam,
): Promise<ApiClb009ResponseOk> {
const result = await this.clubService.getStudentClubSemesters(
user.studentId,
param,
);
return result;
}

@Student()
@Get("student/clubs/club/:clubId/members/semesters/semester/:semesterId")
@UsePipes(new ZodPipe(apiClb010))
async getStudentClubMembers(
@GetStudent() user: GetStudent,
@Param() param: ApiClb010RequestParam,
): Promise<ApiClb010ResponseOk> {
const result = await this.clubService.getStudentClubMembers(
user.studentId,
param,
);
return result;
}

@Professor()
@Get("professor/clubs/my")
@UsePipes(new ZodPipe(apiClb016))
Expand Down
12 changes: 8 additions & 4 deletions packages/api/src/feature/club/delegate/delegate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class ClubDelegateService {
name: student.name,
studentId: student.id,
delegateEnumId: e.ClubDelegateEnumId,
studentNumber: student.number,
phoneNumber:
student.phoneNumber === null
? "010-0000-0000"
Expand Down Expand Up @@ -193,7 +194,7 @@ export default class ClubDelegateService {
!this.clubDelegateDRepository.updateDelegate({
clubId: param.clubId,
clubDelegateEnumId: param.clubDelegateEnumId,
studentId: param.studentId,
studentId: param.targetStudentId,
})
)
throw new HttpException(
Expand Down Expand Up @@ -273,11 +274,14 @@ export default class ClubDelegateService {
semesterId,
filterClubDelegateEnum:
param.param.delegateEnumId === ClubDelegateEnum.Representative
? [ClubDelegateEnum.Representative]
? []
: [
ClubDelegateEnum.Representative,
ClubDelegateEnum.Delegate1,
ClubDelegateEnum.Delegate2,
// ClubDelegateEnum.Delegate1,
// ClubDelegateEnum.Delegate2,
param.param.delegateEnumId === ClubDelegateEnum.Delegate1
? ClubDelegateEnum.Delegate2
: ClubDelegateEnum.Delegate1,
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ import {
ClubDelegateEnum,
} from "@sparcs-clubs/interface/common/enum/club.enum";

import { and, count, eq, gte, isNull, lte, notInArray, or } from "drizzle-orm";
import {
and,
count,
eq,
gte,
isNotNull,
isNull,
lte,
not,
notInArray,
or,
} from "drizzle-orm";
import { MySql2Database } from "drizzle-orm/mysql2";

import logger from "@sparcs-clubs/api/common/util/logger";
Expand Down Expand Up @@ -220,12 +231,20 @@ export class ClubDelegateDRepository {
and(
eq(Club.id, param.clubId),
eq(ClubStudentT.semesterId, param.semesterId),
or(
notInArray(
ClubDelegateD.ClubDelegateEnumId,
param.filterClubDelegateEnum,
param.filterClubDelegateEnum.length !== 0
? or(
notInArray(
ClubDelegateD.ClubDelegateEnumId,
param.filterClubDelegateEnum,
),
isNull(ClubDelegateD.ClubDelegateEnumId),
)
: undefined,
not(
and(
not(eq(ClubDelegateD.clubId, param.clubId)),
isNotNull(ClubDelegateD.id),
),
isNull(ClubDelegateD.ClubDelegateEnumId),
),
isNull(Club.deletedAt),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,29 @@ export default class ClubStudentTRepository {

return result;
}

/** NOTE: (@dora)
* 말 그대로 semesterId 기준, 즉 해당 학기에 활동을 했느냐 기준으로 회원 목록을 반환하는 것이므로
* 해당 학기의 활동 기간을 다 채우지 못한 회원에 대해서 (예를 들어 중간 탈퇴) 고려하고 있지 않음.
* 만약 이런 회원들에 대한 처리가 필요해지면 endTerm을 고려하여 로직 수정 필요
*/
async selectMemberByClubIdAndSemesterId(clubId: number, semesterId: number) {
return this.db
.select({
name: Student.name,
studentId: Student.id,
studentNumber: Student.number,
email: Student.email,
phoneNumber: Student.phoneNumber,
})
.from(ClubStudentT)
.innerJoin(Student, eq(Student.id, ClubStudentT.studentId))
.where(
and(
eq(ClubStudentT.clubId, clubId),
eq(ClubStudentT.semesterId, semesterId),
isNull(ClubStudentT.deletedAt),
),
);
}
}
20 changes: 20 additions & 0 deletions packages/api/src/feature/club/repository/club.club-t.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ export default class ClubTRepository {
return result;
}

async findSemesterByClubId(clubId: number) {
return this.db
.select({
id: SemesterD.id,
name: SemesterD.name,
year: SemesterD.year,
})
.from(SemesterD)
.innerJoin(ClubT, eq(SemesterD.id, ClubT.semesterId))
.where(and(eq(ClubT.clubId, clubId), isNull(ClubT.deletedAt)))
.orderBy(desc(SemesterD.id))
.then(result =>
result.map(row => ({
id: row.id,
year: row.year,
name: row.name,
})),
);
}

async findProfessorSemester(professorId: number) {
return this.db
.select({
Expand Down
48 changes: 48 additions & 0 deletions packages/api/src/feature/club/service/club.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import {
NotFoundException,
} from "@nestjs/common";

import {
ApiClb009RequestParam,
ApiClb009ResponseOk,
} from "@sparcs-clubs/interface/api/club/endpoint/apiClb009";
import {
ApiClb010RequestParam,
ApiClb010ResponseOk,
} from "@sparcs-clubs/interface/api/club/endpoint/apiClb010";

import { ClubDelegateDRepository } from "@sparcs-clubs/api/feature/club/repository/club.club-delegate-d.repository";
import { ClubRoomTRepository } from "@sparcs-clubs/api/feature/club/repository/club.club-room-t.repository";

Expand All @@ -15,6 +24,8 @@ import { ClubGetStudentClubBrief } from "../repository/club.get-student-club-bri
import { ClubPutStudentClubBrief } from "../repository/club.put-student-club-brief";
import ClubRepository from "../repository/club.repository";

import ClubPublicService from "./club.public.service";

import type { ApiClb001ResponseOK } from "@sparcs-clubs/interface/api/club/endpoint/apiClb001";
import type {
ApiClb002RequestParam,
Expand Down Expand Up @@ -43,6 +54,7 @@ export class ClubService {
private divisionPermanentClubDRepository: DivisionPermanentClubDRepository,
private clubGetStudentClubBrief: ClubGetStudentClubBrief,
private clubPutStudentClubBrief: ClubPutStudentClubBrief,
private clubPublicService: ClubPublicService,
) {}

async getClubs(): Promise<ApiClb001ResponseOK> {
Expand Down Expand Up @@ -221,6 +233,42 @@ export class ClubService {
return {};
}

async getStudentClubSemesters(
studentId: number,
param: ApiClb009RequestParam,
): Promise<ApiClb009ResponseOk> {
const { clubId } = param;
const isAvailableDelegate = await this.clubPublicService.isStudentDelegate(
studentId,
clubId,
);
if (!isAvailableDelegate) {
throw new HttpException("Delegate not available", HttpStatus.FORBIDDEN);
}
const result = await this.clubTRepository.findSemesterByClubId(clubId);
return { semesters: result };
}

async getStudentClubMembers(
studentId: number,
param: ApiClb010RequestParam,
): Promise<ApiClb010ResponseOk> {
const { clubId, semesterId } = param;
const isAvailableDelegate = await this.clubPublicService.isStudentDelegate(
studentId,
clubId,
);
if (!isAvailableDelegate) {
throw new HttpException("Delegate not available", HttpStatus.FORBIDDEN);
}
const result =
await this.clubStudentTRepository.selectMemberByClubIdAndSemesterId(
clubId,
semesterId,
);
return { members: result };
}

async getProfessorClubsMy(professorId: number): Promise<ApiClb016ResponseOk> {
const professorSemesters =
await this.clubTRepository.findProfessorSemester(professorId);
Expand Down
1 change: 1 addition & 0 deletions packages/interface/src/api/club/endpoint/apiClb006.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const responseBodyMap = {
z.object({
delegateEnumId: z.nativeEnum(ClubDelegateEnum),
studentId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(1),
name: zUserName,
phoneNumber: zKrPhoneNumber,
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/src/api/club/endpoint/apiClb007.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ClubDelegateEnum } from "@sparcs-clubs/interface/common/enum/club.enum"
*/

const url = (clubId: number) =>
`/student/clubs/club/${clubId}/delegates/delegate/`;
`/student/clubs/club/${clubId}/delegates/delegate`;
const method = "PUT";

const requestParam = z.object({
Expand Down
5 changes: 3 additions & 2 deletions packages/interface/src/api/club/endpoint/apiClb010.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ const responseBodyMap = {
[HttpStatusCode.Ok]: z.object({
members: z
.object({
studentNumber: z.coerce.number().int().min(20000000).max(30000000),
name: z.coerce.string().max(30),
studentId: z.coerce.number().int().min(1),
studentNumber: z.coerce.number().int().min(20000000).max(30000000),
email: z.coerce.string().max(50),
krPhoneNumber: zKrPhoneNumber.optional(),
phoneNumber: zKrPhoneNumber.optional(),
})
.array(),
}),
Expand Down
21 changes: 21 additions & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@
"@mui/material-nextjs": "5.15.11",
"@tanstack/react-query": "^5.28.4",
"@tanstack/react-table": "^8.17.3",
"@tiptap/core": "^2.7.2",
"@tiptap/extension-bold": "^2.7.2",
"@tiptap/extension-color": "^2.7.2",
"@tiptap/extension-document": "^2.7.2",
"@tiptap/extension-dropcursor": "^2.7.4",
"@tiptap/extension-image": "^2.7.4",
"@tiptap/extension-italic": "^2.7.2",
"@tiptap/extension-list-item": "^2.7.2",
"@tiptap/extension-paragraph": "^2.7.2",
"@tiptap/extension-placeholder": "^2.7.3",
"@tiptap/extension-table": "^2.7.2",
"@tiptap/extension-table-cell": "^2.7.2",
"@tiptap/extension-table-header": "^2.7.2",
"@tiptap/extension-table-row": "^2.7.2",
"@tiptap/extension-text": "^2.7.2",
"@tiptap/extension-text-style": "^2.7.2",
"@tiptap/react": "^2.7.2",
"@tiptap/starter-kit": "^2.7.2",
"axios": "^1.6.7",
"axios-mock-adapter": "^1.22.0",
"classnames": "^2.3.2",
Expand All @@ -36,8 +54,10 @@
"overlay-kit": "^1.2.1",
"react": "^18",
"react-cookie": "^7.2.0",
"react-datepicker": "^7.4.0",
"react-dom": "^18",
"react-hook-form": "^7.52.1",
"sass": "^1.79.3",
"socket.io": "^4.7.5",
"styled-components": "^6.1.8",
"viewerjs": "^1.11.6",
Expand All @@ -49,6 +69,7 @@
"@tanstack/react-query-devtools": "^5.28.4",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-datepicker": "^7.0.0",
"@types/react-dom": "^18",
"typescript": "^5"
},
Expand Down
Loading

0 comments on commit 6cb866c

Please sign in to comment.