11
11
delete_student
12
12
)
13
13
14
- from app .utils .json_encoder import JSONEncoder
14
+ from app .utils .json_encoder import json_encoder
15
15
16
16
17
17
router = APIRouter ()
@@ -24,13 +24,12 @@ async def create_student_data(student: StudentModel = Body(...)) -> JSONResponse
24
24
new_student = await create_student (student_json )
25
25
return JSONResponse (
26
26
status_code = status .HTTP_201_CREATED ,
27
- content = JSONEncoder (). encode (new_student )
27
+ content = json_encoder (new_student )
28
28
)
29
29
except HTTPException as error :
30
30
return JSONResponse (
31
31
status_code = error .status_code ,
32
- content = JSONEncoder ().encode ({'message' : error .detail })
33
- )
32
+ content = json_encoder ({'message' : error .detail }))
34
33
35
34
36
35
@router .get (
@@ -43,12 +42,12 @@ async def read_student_data(student_id: str) -> JSONResponse:
43
42
student = await read_student (student_id )
44
43
return JSONResponse (
45
44
status_code = status .HTTP_200_OK ,
46
- content = JSONEncoder (). encode (student )
45
+ content = json_encoder (student )
47
46
)
48
47
except HTTPException as error :
49
48
return JSONResponse (
50
49
status_code = error .status_code ,
51
- content = JSONEncoder (). encode ({'message' : error .detail })
50
+ content = json_encoder ({'message' : error .detail })
52
51
)
53
52
54
53
@@ -63,14 +62,14 @@ async def update_student_data(student_id: str, student: StudentModel = Body(...)
63
62
await update_student (student_id , student_json )
64
63
return JSONResponse (
65
64
status_code = status .HTTP_200_OK ,
66
- content = JSONEncoder (). encode (
65
+ content = json_encoder (
67
66
{'message' : f'Student with id { student_id } updated successfully' }
68
67
)
69
68
)
70
69
except HTTPException as error :
71
70
return JSONResponse (
72
71
status_code = error .status_code ,
73
- content = JSONEncoder (). encode ({'message' : error .detail })
72
+ content = json_encoder ({'message' : error .detail })
74
73
)
75
74
76
75
@@ -84,12 +83,12 @@ async def delete_student_data(student_id: str) -> JSONResponse:
84
83
await delete_student (student_id )
85
84
return JSONResponse (
86
85
status_code = status .HTTP_200_OK ,
87
- content = JSONEncoder (). encode (
86
+ content = json_encoder (
88
87
{'message' : f'Student with id { student_id } deleted successfully' }
89
88
)
90
89
)
91
90
except HTTPException as error :
92
91
return JSONResponse (
93
92
status_code = error .status_code ,
94
- content = JSONEncoder (). encode ({'message' : error .detail })
93
+ content = json_encoder ({'message' : error .detail })
95
94
)
0 commit comments