Skip to content

Commit 748365b

Browse files
committed
add some features view dev log for detail
1 parent 3fa8dc6 commit 748365b

30 files changed

+629
-16
lines changed

.env

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
55
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
66

7-
DATABASE_URL="mysql://admin:12345678@localhost:3306/asco"
7+
DATABASE_URL_SANDBOX="mysql://root:12345678@34.128.67.12:3306/asco"
8+
DATABASE_URL_LOCAL="mysql://admin:12345678@localhost:3306/asco"
89
PORT=7892
910
TESTING_PORT=8889
1011
HOST=127.0.0.1
1112
JWT_SECRET="^[Nk&S,!;5;N9sUFt#,GBlsWdKB,YPaMyTY]zv4SCkNd}aioJ#"
12-
ISSUER=api.jj
13+
ISSUER=api.jj
14+
GCP_PUB_SUB_PROJECTID="asco-app"
15+
GCP_PUB_SUB_TOPICID="publish-card-sync-meeting"
16+
GCP_PUB_SUB_SUBSCRIPTIONID="pull-card-meeting"

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"cors": "^2.8.5",
3535
"dotenv": "^16.0.3",
3636
"express": "^4.18.2",
37-
"joi": "^17.9.1",
37+
"joi": "^17.13.3",
3838
"jsonwebtoken": "^9.0.2",
3939
"multer": "^1.4.5-lts.1",
4040
"mysql": "^2.18.1",

readme.md

+7
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ untuk menambahkan data student pada database
3838

3939
1. (practicums.removeAssistantFromPracticum) /api/practicums/{practicumId}/assistants/{username} -> remove assistants from practicum (authorized for admin)
4040
2. (classrooms.deleteClassroomById) /api/classes/{classId} -> delete classroom by id (authorized for admin)
41+
42+
## DEV LOG <28 July 2024>
43+
44+
1. (assistance groups.removeStudentFromGroup) /api/groups/{groupId}/students/{username} -> remove students from group (authorized for admin)
45+
2. (meetings.getAttendancesByMeetingId) /api/meetings/{meetingId}/attendances -> get students attendance list by meeting id (authorized for admin and assistant)
46+
3. (meetings.insertAttendanceForAllStudentInMeeting) /api/meetings/{meetingId}/attendances/v2 -> add all students attendances in one meeting default status ABSENT (authorized for admin)
47+
4. (practicums.getPracticumAttendances) /api/practicums/{practicumId}/meetings/attendances -> get practicum meetings (authorized for admin)

src/api/assistanceGroup/handler/AssistanceGroupHandler.ts

+8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ export abstract class AssistanceGroupHandler {
55
this.deleteAssistanceGroup = this.deleteAssistanceGroup.bind(this);
66
this.getAssistanceGroup = this.getAssistanceGroup.bind(this);
77
this.putAssistanceGroup = this.putAssistanceGroup.bind(this);
8+
this.deleteStudentFromAssistantGroup =
9+
this.deleteStudentFromAssistantGroup.bind(this);
810
}
911

12+
abstract deleteStudentFromAssistantGroup(
13+
req: Request,
14+
res: Response,
15+
next: NextFunction
16+
): Promise<any>;
17+
1018
abstract putAssistanceGroup(
1119
req: Request,
1220
res: Response,

src/api/assistanceGroup/handler/AssistanceGroupHandlerImpl.ts

+26
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ export class AssistanceGroupHandlerImpl extends AssistanceGroupHandler {
2424
this.schemaValidator = schemaValidator;
2525
}
2626

27+
async deleteStudentFromAssistantGroup(
28+
req: Request,
29+
res: Response,
30+
next: NextFunction
31+
): Promise<any> {
32+
const { username, groupId } = req.params;
33+
34+
try {
35+
await this.assistanceGroupService.removeStudentFromAssistantGroup(
36+
groupId,
37+
username
38+
);
39+
40+
return res
41+
.status(200)
42+
.json(
43+
createResponse(
44+
RESPONSE_MESSAGE.SUCCESS,
45+
"successfully remove student from asssitant group"
46+
)
47+
);
48+
} catch (error) {
49+
return next(error);
50+
}
51+
}
52+
2753
async putAssistanceGroup(
2854
req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>,
2955
res: Response<any, Record<string, any>>,

src/api/assistanceGroup/router/AssistanceGroupRouter.ts

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export class AssistanceGroupRouterImpl extends BaseRouter {
3636
this.handler.putAssistanceGroup
3737
);
3838

39+
// * remove student from assistantGroup
40+
this.router
41+
.route(this.path + "/:groupId/students/:username")
42+
.delete(
43+
this.authorizationMiddlware.authorize([USER_ROLE.ADMIN]),
44+
this.handler.deleteStudentFromAssistantGroup
45+
);
46+
3947
return this.router;
4048
}
4149
}

src/api/meeting/handler/MeetingHandler.ts

+14
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,22 @@ export abstract class MeetingHandler {
66
this.getMeeting = this.getMeeting.bind(this);
77
this.putMeeting = this.putMeeting.bind(this);
88
this.postMeetingAttendance = this.postMeetingAttendance.bind(this);
9+
this.getMeetingAttendances = this.getMeetingAttendances.bind(this);
10+
this.postMeetingAttendances = this.postMeetingAttendances.bind(this);
911
}
1012

13+
abstract postMeetingAttendances(
14+
req: Request,
15+
res: Response,
16+
next: NextFunction
17+
): Promise<any>;
18+
19+
abstract getMeetingAttendances(
20+
req: Request,
21+
res: Response,
22+
next: NextFunction
23+
): Promise<any>;
24+
1125
abstract postMeetingAttendance(
1226
req: Request,
1327
res: Response,

src/api/meeting/handler/MeetingHandlerImpl.ts

+44
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { PracticumMeetingPutPayloadSchema } from "../../../utils/validator/meeti
1515
import { IPostMeetingAttendancePayload } from "../../../utils/interfaces/request/IPostMeetingAttendancePayload";
1616
import { MeetingAttendancePostPayloadSchema } from "../../../utils/validator/attendance/Joi/MeetingAttendancePostPayloadSchema";
1717
import { AttendanceService } from "../../../services/attendance/AttendanceService";
18+
import { ListStudentAttendanceDTO } from "../../../utils/dto/attendances/IListStudentAttendanceDTO";
1819

1920
export class MeetingHandlerImpl extends MeetingHandler {
2021
private meetingService: MeetingService;
@@ -34,6 +35,49 @@ export class MeetingHandlerImpl extends MeetingHandler {
3435
this.schemaValidator = schemaValidator;
3536
}
3637

38+
async postMeetingAttendances(
39+
req: Request,
40+
res: Response,
41+
next: NextFunction
42+
): Promise<any> {
43+
const { id } = req.params;
44+
45+
try {
46+
await this.attendanceService.addAttendancesForAllStudentsByMeetingId(id);
47+
48+
return res
49+
.status(201)
50+
.json(
51+
createResponse(RESPONSE_MESSAGE.SUCCESS, "successfully edit meeting")
52+
);
53+
} catch (error) {
54+
return next(error);
55+
}
56+
}
57+
58+
async getMeetingAttendances(
59+
req: Request,
60+
res: Response,
61+
next: NextFunction
62+
): Promise<any> {
63+
const { id } = req.params;
64+
const { classroom } = req.query;
65+
66+
const attendances = await this.attendanceService.getAttendancesByMeetingId(
67+
id,
68+
classroom
69+
);
70+
71+
return res
72+
.status(200)
73+
.json(
74+
createResponse(
75+
RESPONSE_MESSAGE.SUCCESS,
76+
attendances.map(ListStudentAttendanceDTO)
77+
)
78+
);
79+
}
80+
3781
async postMeetingAttendance(
3882
req: Request,
3983
res: Response,

src/api/meeting/router/MeetingRouterImpl.ts

+19
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,30 @@ export class MeetingRouter extends BaseRouter {
4343
);
4444

4545
// * create attendance of a meeting
46+
// * get attendances by meeting id
4647
this.router
4748
.route(this.path + "/:id/attendances")
4849
.post(
4950
this.authorizationMiddlware.authorize([USER_ROLE.ASSISTANT]),
5051
this.handler.postMeetingAttendance
52+
)
53+
.get(
54+
this.authorizationMiddlware.authorize([
55+
USER_ROLE.ASSISTANT,
56+
USER_ROLE.ADMIN,
57+
]),
58+
this.handler.getMeetingAttendances
59+
);
60+
61+
// * post all student attendances in one meeting
62+
this.router
63+
.route(this.path + "/:id/attendances/v2")
64+
.post(
65+
this.authorizationMiddlware.authorize([
66+
USER_ROLE.ASSISTANT,
67+
USER_ROLE.ADMIN,
68+
]),
69+
this.handler.postMeetingAttendances
5170
);
5271

5372
return this.router;

src/api/practicum/handler/PracticumHandler.ts

+8
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ export abstract class PracticumHandler {
2323
this.getStudentPracticumAttendances.bind(this);
2424
this.deleteAssistantFromPracticum =
2525
this.deleteAssistantFromPracticum.bind(this);
26+
this.getPracticumMeetingAttendances =
27+
this.getPracticumMeetingAttendances.bind(this);
2628
}
2729

30+
abstract getPracticumMeetingAttendances(
31+
req: Request,
32+
res: Response,
33+
next: NextFunction
34+
): Promise<any>;
35+
2836
abstract deleteAssistantFromPracticum(
2937
req: Request,
3038
res: Response,

src/api/practicum/handler/PracticumHandlerImpl.ts

+25
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { USER_ROLE } from "@prisma/client";
3030
import { ControlCardEntity } from "../../../entity/controlCard/ControlCardEntity";
3131
import { ListAttendanceDTO } from "../../../utils/dto/attendances/IListAttendanceDTO";
3232
import { AttendanceService } from "../../../services/attendance/AttendanceService";
33+
import { ListMeetingAttendanceDTO } from "../../../utils/dto/meeting/IListMeetingAttendanceDTO";
3334

3435
export class PracticumHandlerImpl extends PracticumHandler {
3536
private practicumService: PracticumService;
@@ -62,6 +63,30 @@ export class PracticumHandlerImpl extends PracticumHandler {
6263
this.schemaValidator = schemaValidator;
6364
}
6465

66+
async getPracticumMeetingAttendances(
67+
req: Request,
68+
res: Response,
69+
next: NextFunction
70+
): Promise<any> {
71+
const { practicumId } = req.params;
72+
const { classroom } = req.query;
73+
74+
const attendances =
75+
await this.meetingService.getMeetingAttendancesByPracticumId(
76+
practicumId,
77+
classroom
78+
);
79+
80+
return res
81+
.status(200)
82+
.json(
83+
createResponse(
84+
RESPONSE_MESSAGE.SUCCESS,
85+
attendances.map(ListMeetingAttendanceDTO)
86+
)
87+
);
88+
}
89+
6590
async deleteAssistantFromPracticum(
6691
req: Request,
6792
res: Response,

src/api/practicum/router/PracticumRouterImpl.ts

+8
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ export class PracticumRouterImpl extends BaseRouter {
157157
this.handler.getStudentPracticumAttendances
158158
);
159159

160+
// * get practicum meetings attendances
161+
this.router
162+
.route(this.path + "/:practicumId/meetings/attendances")
163+
.get(
164+
this.authorizationMiddlware.authorize([USER_ROLE.ADMIN]),
165+
this.handler.getPracticumMeetingAttendances
166+
);
167+
160168
return this.router;
161169
}
162170
}

src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { ClassroomPrismaRepositoryImpl } from "./repository/classroom/ClassroomP
3131
import { ControlCardPrismaRepositoryImpl } from "./repository/controlCard/ControlCardPrismaRepositoryImpl";
3232
import { AssistanceGroupAssistancePrismaRepositoryImpl } from "./repository/facade/assistanceGroupAssistanceRepository/AssistanceGroupAssistancePrismaRepositoryImpl";
3333
import { AssistanceGroupAssistanceRepository } from "./repository/facade/assistanceGroupAssistanceRepository/AssistanceGroupAssistanceRepository";
34+
import { AssistantGroupControlCardPrismaRepositoryImpl } from "./repository/facade/assistantGroupControlCardRepository/AssistantGroupControlCardPrismaRepositoryImpl";
3435
import { ClassroomAssistantGroupPracticumPrismaRepositoryImpl } from "./repository/facade/classroomAssistantGroupPracticumRepository/ClassroomAssistantGroupPracticumPrismaRepositoryImpl";
3536
import { ClassroomPracticumPrismaRepositoryImpl } from "./repository/facade/classroomPracticumRepository/ClassroomPracticumPrismaRepositoryImpl";
3637
import { ClassroomPracticumStudentsPrismaRepositoryImpl } from "./repository/facade/classroomPracticumStudents/ClassroomPracticumStudentsPrismaRepositoryImpl";
@@ -96,11 +97,14 @@ const meetingService = new MeetingServiceImpl({
9697
meetingRepository,
9798
practicumRepository,
9899
});
100+
const assistantGroupControlCardRepository =
101+
new AssistantGroupControlCardPrismaRepositoryImpl();
99102
const assistanceGroupService = new AssistanceGroupServiceImpl(
100103
{
101104
practicumRepository,
102105
assistanceGroupRepository,
103106
assistanceGroupAssistanceRepository,
107+
assistantGroupControlCardRepository,
104108
},
105109
publisher.googlePubSub
106110
);
@@ -118,6 +122,7 @@ const attendanceService = new AttendanceServiceImpl({
118122
practicumRepository,
119123
attendanceRepository,
120124
meetingRepository,
125+
classroomRepository,
121126
});
122127
// * validators
123128
const schemaValidator = new JoiValidatorImpl();

0 commit comments

Comments
 (0)