Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIS API v1.3.0 Deploy to Live #69

Merged
merged 14 commits into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.graduation-project</groupId>
<artifactId>student-information-system-be</artifactId>
<version>v1.2.0</version>
<version>v1.3.0</version>
<packaging>war</packaging>
<name>Student Information System</name>
<description>Student Information System for Higher Education</description>
Expand Down Expand Up @@ -179,7 +179,8 @@
<appName>sis-be</appName>
<jdkVersion>17.0.1</jdkVersion>
<processTypes>
<web>java -Dserver.port=$PORT -Dspring.profiles.active=mysql-live $JAVA_OPTS -jar target/*.war
<web>
java -Dserver.port=$PORT -Dspring.profiles.active=mysql-live $JAVA_OPTS -jar target/*.war
</web>
</processTypes>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ public class SisSwaggerConfiguration {
public static final String LESSON_API_TAG = "Lesson Controller";
public static final String EXAM_SCHEDULE_FILE_API_TAG = "Exam Schedule File Controller";
public static final String LESSON_SCHEDULE_FILE_API_TAG = "Lesson Schedule File Controller";
public static final String FEATURE_TOGGLE_API_TAG = "Feature Toggle Controller";
public static final String STUDENT_API_TAG = "Student Controller";
public static final String STUDENT_LESSON_API_TAG = "Student Lesson Controller";
public static final String STUDENT_LESSON_REGISTRATION_API_TAG = "Student Lesson Registration Controller";
public static final String STUDENT_LESSON_NOTE_API_TAG = "Student Lesson Note Controller";
public static final String TEACHER_API_TAG = "Teacher Controller";
public static final String TEACHER_LESSON_API_TAG = "Teacher Lesson Controller";
public static final String OFFICER_API_TAG = "Officer Controller";
Expand All @@ -48,9 +50,11 @@ public Docket api() {
new Tag(LESSON_API_TAG, "UNIV_LESSON"),
new Tag(EXAM_SCHEDULE_FILE_API_TAG, "UNIV_EXAM_SCHEDULE_FILE"),
new Tag(LESSON_SCHEDULE_FILE_API_TAG, "UNIV_LESSON_SCHEDULE_FILE"),
new Tag(FEATURE_TOGGLE_API_TAG, "UNIV_FEATURE_TOGGLE"),
new Tag(STUDENT_API_TAG, "STUDENT_ACADEMIC_INFO & STUDENT_PERSONAL_INFO"),
new Tag(STUDENT_LESSON_API_TAG, "STUDENT_LESSON"),
new Tag(STUDENT_LESSON_REGISTRATION_API_TAG, "STUDENT_LESSON_REGISTRATION"),
new Tag(STUDENT_LESSON_NOTE_API_TAG, "STUDENT_LESSON_NOTE"),
new Tag(TEACHER_API_TAG, "TEACHER_ACADEMIC_INFO & TEACHER_PERSONAL_INFO"),
new Tag(TEACHER_LESSON_API_TAG, "TEACHER_LESSON"),
new Tag(OFFICER_API_TAG, "OFFICER_ACADEMIC_INFO & OFFICER_PERSONAL_INFO"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ private Path() {

private static final String REGISTRATION = "/registration";
private static final String PASSWORD_OPERATION = "/password-operation";
private static final String NOTE = "/note";

public static final String FACULTY = "/faculty";
public static final String DEPARTMENT = "/department";
public static final String LESSON = "/lesson";
public static final String EXAM_SCHEDULE_FILE = "/exam-schedule-file";
public static final String LESSON_SCHEDULE_FILE = "/lesson-schedule-file";
public static final String FEATURE_TOGGLE = "/feature-toggle";
public static final String STUDENT = "/student";
public static final String STUDENT_LESSON = STUDENT + LESSON;
public static final String STUDENT_LESSON_REGISTRATION = STUDENT_LESSON + REGISTRATION;
public static final String STUDENT_LESSON_NOTE = STUDENT + LESSON + NOTE;
public static final String TEACHER = "/teacher";
public static final String TEACHER_LESSON = TEACHER + LESSON;
public static final String OFFICER = "/officer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ public static <T> ResponseEntity<SisBaseApiResponse<T>> successResponse(final T
.isSuccess(true)
.response(response).build(), HttpStatus.OK);
}

public static ResponseEntity<SisApiResponse> failResponse() {
return new ResponseEntity<>(
SisApiResponse.builder()
.requestTime(LocalDateTime.now())
.httpStatus(HttpStatus.NOT_FOUND)
.isSuccess(false).build(), HttpStatus.NOT_FOUND);
}

public static ResponseEntity<SisApiResponse> unauthorizedResponse() {
return new ResponseEntity<>(
SisApiResponse.builder()
.requestTime(LocalDateTime.now())
.httpStatus(HttpStatus.UNAUTHORIZED)
.isSuccess(false).build(), HttpStatus.UNAUTHORIZED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public void errorWhenGettingAllByStatus(final String status) {
log.error("Error When Getting {}s by Status! status:{}", apiName, status);
}

public void errorWhenGettingAllByStudentId(final Long studentId) {
log.error("Error When Getting {}s by Student ID! studentId:{}", apiName, studentId);
}

public void errorWhenGettingAllByLessonId(final Long lessonId) {
log.error("Error When Getting {}s by Lesson ID! lessonId:{}", apiName, lessonId);
}

public void errorWhenGettingAllIdsByDepartmentId(final Long departmentId) {
log.error("Error When Getting {} IDs by Department ID! departmentId:{}", apiName, departmentId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public void foundAllIds() {
log.info("{} IDs Found!", apiName);
}

public void foundAllByLessonId(final Long lessonId) {
log.info("{}s Found by Lesson ID! lessonId:{}", apiName, lessonId);
}

public void foundAllByStudentId(final Long studentId) {
log.info("{}s Found by Student ID! studentId:{}", apiName, studentId);
}

public void foundAllByStatus(final String status) {
log.info("{}s Found by Status! status:{}", apiName, status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public void notFoundByIdAndStatus(final Long id, final String status) {
log.warn("{} Not Found by ID! id:{} status:{}", apiName, id, status);
}

public void notFoundAllByStudentId(final Long lessonId) {
log.warn("{}s Not Found By Student ID! lessonId:{}", apiName, lessonId);
}

public void notFoundAllByLessonId(final Long lessonId) {
log.warn("{}s Not Found By Lesson ID! lessonId:{}", apiName, lessonId);
}

public void notFoundAllIds() {
log.warn("{} IDs Not Found!", apiName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.controller;

import com.graduationproject.studentinformationsystem.common.util.controller.response.SisBaseApiResponse;
import com.graduationproject.studentinformationsystem.common.util.exception.SisNotExistException;
import com.graduationproject.studentinformationsystem.university.featuretoggle.controller.endpoint.FeatureToggleControllerEndpoint;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.request.FeatureToggleRequest;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.response.FeatureToggleIsEnabledResponse;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.response.FeatureToggleResponse;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.enums.FeatureToggleName;
import com.graduationproject.studentinformationsystem.university.featuretoggle.service.FeatureToggleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

import static com.graduationproject.studentinformationsystem.common.config.SisSwaggerConfiguration.FEATURE_TOGGLE_API_TAG;
import static com.graduationproject.studentinformationsystem.common.util.controller.endpoint.SisControllerEndpoint.Path.FEATURE_TOGGLE;
import static com.graduationproject.studentinformationsystem.common.util.controller.response.SisResponseUtil.successResponse;

@RestController
@RequestMapping(FEATURE_TOGGLE)
@Api(tags = FEATURE_TOGGLE_API_TAG)
@RequiredArgsConstructor
public class FeatureToggleController {

private final FeatureToggleService featureToggleService;

@GetMapping
@ApiOperation(value = "Get All Feature Toggles")
public ResponseEntity<SisBaseApiResponse<List<FeatureToggleResponse>>> getAllFeatureToggles() {

final List<FeatureToggleResponse> featureToggleResponses = featureToggleService.getAllFeatureToggles();
return successResponse(featureToggleResponses);
}

@GetMapping(FeatureToggleControllerEndpoint.NAME)
@ApiOperation(value = "Get Feature Toggle By Name")
public ResponseEntity<SisBaseApiResponse<FeatureToggleResponse>> getFeatureToggleByName(
@PathVariable final FeatureToggleName name)
throws SisNotExistException {

final FeatureToggleResponse featureToggleResponse = featureToggleService.getFeatureToggleByName(name);
return successResponse(featureToggleResponse);
}

@GetMapping(FeatureToggleControllerEndpoint.ENABLED_BY_NAME)
@ApiOperation(value = "Is Feature Toggle Enabled")
public ResponseEntity<SisBaseApiResponse<FeatureToggleIsEnabledResponse>> isFeatureToggleEnabled(
@PathVariable final FeatureToggleName name)
throws SisNotExistException {

final FeatureToggleIsEnabledResponse featureToggleIsEnabledResponse = featureToggleService.isFeatureToggleEnabled(name);
return successResponse(featureToggleIsEnabledResponse);
}

@PatchMapping(FeatureToggleControllerEndpoint.ENABLE)
@ApiOperation(value = "Enable Feature Toggle")
public ResponseEntity<SisBaseApiResponse<FeatureToggleResponse>> enableFeatureToggle(
@Valid @RequestBody final FeatureToggleRequest featureToggleRequest)
throws SisNotExistException {

final FeatureToggleResponse featureToggleResponse = featureToggleService.enableFeatureToggle(featureToggleRequest);
return successResponse(featureToggleResponse);
}

@PatchMapping(FeatureToggleControllerEndpoint.DISABLE)
@ApiOperation(value = "Disable Feature Toggle")
public ResponseEntity<SisBaseApiResponse<FeatureToggleResponse>> disableFeatureToggle(
@Valid @RequestBody final FeatureToggleRequest featureToggleRequest)
throws SisNotExistException {

final FeatureToggleResponse featureToggleResponse = featureToggleService.disableFeatureToggle(featureToggleRequest);
return successResponse(featureToggleResponse);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.controller.endpoint;

public class FeatureToggleControllerEndpoint {

private FeatureToggleControllerEndpoint() {
}

public static final String NAME = "/{name}";
public static final String ENABLE = "/enable";
public static final String DISABLE = "/disable";
public static final String ENABLED_BY_NAME = "/enabled" + NAME;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.converter;

import com.graduationproject.studentinformationsystem.common.util.SisUtil;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.request.FeatureToggleRequest;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.response.FeatureToggleResponse;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.entity.FeatureToggleEntity;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
public class FeatureToggleInfoConverter {

public FeatureToggleEntity generateEntity(final FeatureToggleRequest featureToggleRequest) {

return FeatureToggleEntity.builder()
.name(featureToggleRequest.getName())
.modifiedUserId(featureToggleRequest.getOperationInfoRequest().getUserId())
.modifiedDate(new Date())
.build();
}

public FeatureToggleResponse entityToResponse(final FeatureToggleEntity featureToggleEntity) {
return FeatureToggleResponse.builder()
.id(featureToggleEntity.getId())
.name(featureToggleEntity.getName())
.isEnabled(featureToggleEntity.getIsEnabled())
.date(featureToggleEntity.getDate())
.createdUserId(featureToggleEntity.getCreatedUserId())
.createdDate(SisUtil.getFormattedDateTime(featureToggleEntity.getCreatedDate()))
.modifiedUserId(featureToggleEntity.getModifiedUserId())
.modifiedDate(SisUtil.getFormattedDateTime(featureToggleEntity.getModifiedDate()))
.build();
}

public List<FeatureToggleResponse> entitiesToResponses(final List<FeatureToggleEntity> facultyEntities) {
List<FeatureToggleResponse> featureToggleResponses = new ArrayList<>();
facultyEntities.forEach(facultyEntity -> featureToggleResponses.add(entityToResponse(facultyEntity)));
return featureToggleResponses;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.request;

import com.graduationproject.studentinformationsystem.common.model.dto.request.SisOperationInfoRequest;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.enums.FeatureToggleName;
import lombok.Getter;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;

@Getter
public class FeatureToggleRequest implements Serializable {

@Serial
private static final long serialVersionUID = -4460192886349312510L;

@NotNull
private FeatureToggleName name;

@Valid
private SisOperationInfoRequest operationInfoRequest;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.response;

import lombok.Getter;
import lombok.experimental.SuperBuilder;

@Getter
@SuperBuilder
public class FeatureToggleIsEnabledResponse {

private Boolean isFeatureToggleEnabled;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.dto.response;

import com.graduationproject.studentinformationsystem.common.model.dto.response.SisBaseResponse;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.enums.FeatureToggleName;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

import java.util.Date;

@Getter
@SuperBuilder
public class FeatureToggleResponse extends SisBaseResponse {

private Long id;
private FeatureToggleName name;
private Boolean isEnabled;
private Date date;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.entity;

import com.graduationproject.studentinformationsystem.common.model.entity.SisBaseEntity;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.enums.FeatureToggleName;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

import java.util.Date;

@Getter
@SuperBuilder
public class FeatureToggleEntity extends SisBaseEntity {

private Long id;
private FeatureToggleName name;
private Boolean isEnabled;
private Date date;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum FeatureToggleName {

LESSON_REGISTRATION_OPERATIONS("Ders Kayıt İşlemleri"),
NOTE_OPERATIONS("Not İşlemleri");

private final String tr;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.exception;

import com.graduationproject.studentinformationsystem.common.util.exception.SisException;
import com.graduationproject.studentinformationsystem.common.util.exception.SisNotExistException;
import com.graduationproject.studentinformationsystem.university.featuretoggle.model.enums.FeatureToggleName;

public class FeatureToggleException extends SisException {

private FeatureToggleException() {
}

public static void throwNotExistException(final FeatureToggleName name) throws SisNotExistException {
SisException.throwNotExistException("FEATURE TOGGLE IS NOT EXIST! name:" + name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.graduationproject.studentinformationsystem.university.featuretoggle.model.mapping;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Getter
@RequiredArgsConstructor
public enum FeatureToggleMapping {

ID("ID", "id"),
NAME("NAME", "name"),
IS_ENABLED("IS_ENABLED", "isEnabled"),
DATE("DATE", "date"),
CREATED_DATE("CREATED_DATE", "createdDate"),
CREATED_USER_ID("CREATED_USER_ID", "createdUserId"),
MODIFIED_DATE("MODIFIED_DATE", "modifiedDate"),
MODIFIED_USER_ID("MODIFIED_USER_ID", "modifiedUserId");

private final String columnName;
private final String modelName;

public static final Map<String, String> COLUMN_MAPPINGS = Stream.of(values())
.collect(Collectors.toMap(FeatureToggleMapping::getColumnName, FeatureToggleMapping::getModelName));
}
Loading