diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/model/dto/response/BaseResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/common/model/dto/response/BaseResponse.java deleted file mode 100644 index 61f6034b..00000000 --- a/src/main/java/com/graduationproject/studentinformationsystem/common/model/dto/response/BaseResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.graduationproject.studentinformationsystem.common.model.dto.response; - -import lombok.Getter; -import lombok.Setter; - -import java.util.Date; - -@Getter -@Setter -public class BaseResponse { - - private Date createdDate; - private Long createdUserId; - private Date modifiedDate; - private Long modifiedUserId; -} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/model/dto/response/SisBaseResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/common/model/dto/response/SisBaseResponse.java new file mode 100644 index 00000000..bf1a2b48 --- /dev/null +++ b/src/main/java/com/graduationproject/studentinformationsystem/common/model/dto/response/SisBaseResponse.java @@ -0,0 +1,16 @@ +package com.graduationproject.studentinformationsystem.common.model.dto.response; + +import lombok.Getter; +import lombok.Setter; + +import java.util.Date; + +@Getter +@Setter +public abstract class SisBaseResponse { + + protected Date createdDate; + protected Long createdUserId; + protected Date modifiedDate; + protected Long modifiedUserId; +} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBaseAcademicInfoResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBaseAcademicInfoResponse.java new file mode 100644 index 00000000..bb3473d9 --- /dev/null +++ b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBaseAcademicInfoResponse.java @@ -0,0 +1,12 @@ +package com.graduationproject.studentinformationsystem.common.util.controller.response; + +import com.graduationproject.studentinformationsystem.common.model.dto.response.SisBaseResponse; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public abstract class SisBaseAcademicInfoResponse extends SisBaseResponse { + + protected String email; +} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBaseApiResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBaseApiResponse.java new file mode 100644 index 00000000..5fc0be4f --- /dev/null +++ b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBaseApiResponse.java @@ -0,0 +1,20 @@ +package com.graduationproject.studentinformationsystem.common.util.controller.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Builder; +import lombok.Getter; +import org.springframework.http.HttpStatus; + +import java.time.LocalDateTime; + +import static com.graduationproject.studentinformationsystem.common.util.constant.SisConstants.DATE_TIME_PATTERN; + +@Getter +@Builder +public class SisBaseApiResponse { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_TIME_PATTERN) + private LocalDateTime requestTime; + private HttpStatus httpStatus; + private T result; + private boolean isSuccess; +} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBasePersonalInfoResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBasePersonalInfoResponse.java new file mode 100644 index 00000000..94c92186 --- /dev/null +++ b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisBasePersonalInfoResponse.java @@ -0,0 +1,22 @@ +package com.graduationproject.studentinformationsystem.common.util.controller.response; + +import com.graduationproject.studentinformationsystem.common.model.dto.response.SisBaseResponse; +import lombok.Getter; +import lombok.Setter; + +import java.util.Date; + +@Getter +@Setter +public abstract class SisBasePersonalInfoResponse extends SisBaseResponse { + + protected Long tcNo; + protected String name; + protected String surname; + protected String email; + protected Long phoneNumber; + // protected Byte[] profilePhoto; // TODO: Added Profile Photo +// protected String profilePhotoUrl; // TODO: Added Profile Photo URL + protected Date birthday; + protected String address; +} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisResponseUtil.java b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisResponseUtil.java new file mode 100644 index 00000000..8e005291 --- /dev/null +++ b/src/main/java/com/graduationproject/studentinformationsystem/common/util/controller/response/SisResponseUtil.java @@ -0,0 +1,21 @@ +package com.graduationproject.studentinformationsystem.common.util.controller.response; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.time.LocalDateTime; + +public class SisResponseUtil { + + private SisResponseUtil() { + } + + public static ResponseEntity> successResponse(T result) { + return new ResponseEntity<>( + SisBaseApiResponse.builder() + .requestTime(LocalDateTime.now()) + .httpStatus(HttpStatus.OK) + .isSuccess(true) + .result(result).build(), HttpStatus.OK); + } +} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/util/response/SisBaseResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/common/util/response/SisBaseResponse.java deleted file mode 100644 index b4a057a7..00000000 --- a/src/main/java/com/graduationproject/studentinformationsystem/common/util/response/SisBaseResponse.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.graduationproject.studentinformationsystem.common.util.response; - -import com.fasterxml.jackson.annotation.JsonFormat; -import lombok.Getter; -import lombok.Setter; -import org.springframework.http.HttpStatus; - -import java.time.LocalDateTime; - -@Getter -@Setter -public class SisBaseResponse { - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss") - private LocalDateTime timestamp = LocalDateTime.now(); - private HttpStatus httpStatus; - private String message; - private T result; -} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/common/util/response/SisBaseResponseUtil.java b/src/main/java/com/graduationproject/studentinformationsystem/common/util/response/SisBaseResponseUtil.java deleted file mode 100644 index 975432e5..00000000 --- a/src/main/java/com/graduationproject/studentinformationsystem/common/util/response/SisBaseResponseUtil.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.graduationproject.studentinformationsystem.common.util.response; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -public class SisBaseResponseUtil { - - private SisBaseResponseUtil() { - } - - public static final String SUCCESS = "Success"; - - public static ResponseEntity> generateSisResponse(HttpStatus status, String message, T response) { - SisBaseResponse sisResponse = new SisBaseResponse<>(); - sisResponse.setHttpStatus(status); - sisResponse.setMessage(message); - sisResponse.setResult(response); - - return new ResponseEntity<>(sisResponse, status); - } - - public static ResponseEntity> successResponse(T response) { - return generateSisResponse(HttpStatus.OK, SUCCESS, response); - } -} diff --git a/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentAcademicInfoResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentAcademicInfoResponse.java index bce420ae..345e4344 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentAcademicInfoResponse.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentAcademicInfoResponse.java @@ -1,6 +1,6 @@ package com.graduationproject.studentinformationsystem.student.model.dto.response; -import com.graduationproject.studentinformationsystem.common.model.dto.response.BaseResponse; +import com.graduationproject.studentinformationsystem.common.util.controller.response.SisBaseAcademicInfoResponse; import com.graduationproject.studentinformationsystem.student.model.enums.StudentClassLevel; import com.graduationproject.studentinformationsystem.student.model.enums.StudentDegree; import com.graduationproject.studentinformationsystem.student.model.enums.StudentStatus; @@ -11,13 +11,12 @@ @Getter @Setter -public class StudentAcademicInfoResponse extends BaseResponse { +public class StudentAcademicInfoResponse extends SisBaseAcademicInfoResponse { private Long studentId; private Long departmentId; private StudentDegree degree; private StudentClassLevel classLevel; - private String email; private StudentStatus status; private Date registrationDate; } diff --git a/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentPersonalInfoResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentPersonalInfoResponse.java index 5b4d731a..b295ff1b 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentPersonalInfoResponse.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/student/model/dto/response/StudentPersonalInfoResponse.java @@ -1,22 +1,10 @@ package com.graduationproject.studentinformationsystem.student.model.dto.response; -import com.graduationproject.studentinformationsystem.common.model.dto.response.BaseResponse; +import com.graduationproject.studentinformationsystem.common.util.controller.response.SisBasePersonalInfoResponse; import lombok.Getter; import lombok.Setter; -import java.util.Date; - @Getter @Setter -public class StudentPersonalInfoResponse extends BaseResponse { - - private Long tcNo; - private String name; - private String surname; - private String email; - private Long phoneNumber; - // private Byte[] profilePhoto; // TODO: Added Profile Photo -// private String profilePhotoUrl; // TODO: Added Profile Photo URL - private Date birthday; - private String address; +public class StudentPersonalInfoResponse extends SisBasePersonalInfoResponse { } diff --git a/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherAcademicInfoResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherAcademicInfoResponse.java index 074a5cd1..9078e555 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherAcademicInfoResponse.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherAcademicInfoResponse.java @@ -1,6 +1,6 @@ package com.graduationproject.studentinformationsystem.teacher.model.dto.response; -import com.graduationproject.studentinformationsystem.common.model.dto.response.BaseResponse; +import com.graduationproject.studentinformationsystem.common.util.controller.response.SisBaseAcademicInfoResponse; import com.graduationproject.studentinformationsystem.teacher.model.enums.TeacherDegree; import com.graduationproject.studentinformationsystem.teacher.model.enums.TeacherRole; import com.graduationproject.studentinformationsystem.teacher.model.enums.TeacherStatus; @@ -11,7 +11,7 @@ @Getter @Setter -public class TeacherAcademicInfoResponse extends BaseResponse { +public class TeacherAcademicInfoResponse extends SisBaseAcademicInfoResponse { private Long teacherId; private Long departmentId; @@ -19,7 +19,6 @@ public class TeacherAcademicInfoResponse extends BaseResponse { private TeacherRole role; private String fieldOfStudy; private String phoneNumber; - private String email; private TeacherStatus status; private Date registrationDate; } diff --git a/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherPersonalInfoResponse.java b/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherPersonalInfoResponse.java index 9aa74471..bebd0f5b 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherPersonalInfoResponse.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/teacher/model/dto/response/TeacherPersonalInfoResponse.java @@ -1,6 +1,6 @@ package com.graduationproject.studentinformationsystem.teacher.model.dto.response; -import com.graduationproject.studentinformationsystem.common.model.dto.response.BaseResponse; +import com.graduationproject.studentinformationsystem.common.model.dto.response.SisBaseResponse; import com.graduationproject.studentinformationsystem.teacher.model.enums.TeacherStatus; import lombok.Getter; import lombok.Setter; @@ -9,7 +9,7 @@ @Getter @Setter -public class TeacherPersonalInfoResponse extends BaseResponse { +public class TeacherPersonalInfoResponse extends SisBaseResponse { private Long teacherId; private Long tcNo;