This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from sef-global/development
ScholarX - v1.2 Release
- Loading branch information
Showing
18 changed files
with
562 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,3 @@ deploy: | |
repo: sef-global/scholarx | ||
branch: master | ||
skip_cleanup: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/org/sefglobal/scholarx/controller/admin/QuestionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.sefglobal.scholarx.controller.admin; | ||
|
||
import org.sefglobal.scholarx.exception.ResourceNotFoundException; | ||
import org.sefglobal.scholarx.model.Question; | ||
import org.sefglobal.scholarx.service.QuestionService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/admin/questions") | ||
public class QuestionController { | ||
private final QuestionService questionService; | ||
|
||
public QuestionController(QuestionService questionService) { | ||
this.questionService = questionService; | ||
} | ||
|
||
@PutMapping | ||
@ResponseStatus(HttpStatus.OK) | ||
public List<Question> editQuestions(@RequestBody List<Question> questions) throws ResourceNotFoundException { | ||
return questionService.editQuestions(questions); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
public void deleteQuestion(@PathVariable long id) throws ResourceNotFoundException{ | ||
questionService.deleteQuestion(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/org/sefglobal/scholarx/model/MentorResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.sefglobal.scholarx.model; | ||
|
||
import javax.persistence.*; | ||
import java.io.Serializable; | ||
|
||
@Entity | ||
@Table(name = "mentor_response") | ||
public class MentorResponse implements Serializable { | ||
|
||
@EmbeddedId | ||
MentorResponseId id; | ||
|
||
@ManyToOne(cascade = CascadeType.ALL) | ||
@MapsId("questionId") | ||
@JoinColumn(name = "question_id") | ||
private Question question; | ||
|
||
@ManyToOne(cascade = CascadeType.ALL) | ||
@MapsId("mentorId") | ||
@JoinColumn(name = "mentor_id") | ||
private Mentor mentor; | ||
|
||
@Column(nullable = false, columnDefinition = "TEXT") | ||
private String response; | ||
|
||
public MentorResponse() {} | ||
|
||
public MentorResponse(Question question, Mentor mentor, String response) { | ||
this.id = new MentorResponseId(question.getId(), mentor.getId()); | ||
this.question = question; | ||
this.mentor = mentor; | ||
this.response = response; | ||
} | ||
|
||
public MentorResponseId getId() { | ||
return id; | ||
} | ||
|
||
public void setId(MentorResponseId id) { | ||
this.id = id; | ||
} | ||
|
||
public Question getQuestion() { | ||
return question; | ||
} | ||
|
||
public void setQuestion(Question question) { | ||
this.question = question; | ||
} | ||
|
||
public Mentor getMentor() { | ||
return mentor; | ||
} | ||
|
||
public void setMentor(Mentor mentor) { | ||
this.mentor = mentor; | ||
} | ||
|
||
public String getResponse() { | ||
return response; | ||
} | ||
|
||
public void setResponse(String response) { | ||
this.response = response; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/org/sefglobal/scholarx/model/MentorResponseId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.sefglobal.scholarx.model; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
@Embeddable | ||
public class MentorResponseId implements Serializable { | ||
@Column(name = "question_id") | ||
private long questionId; | ||
@Column(name = "mentor_id") | ||
private long mentorId; | ||
|
||
public MentorResponseId() {} | ||
|
||
public MentorResponseId(long questionId, long mentorId) { | ||
this.questionId = questionId; | ||
this.mentorId = mentorId; | ||
} | ||
|
||
public void setQuestionId(long questionId) { | ||
this.questionId = questionId; | ||
} | ||
|
||
public long getQuestionId() { | ||
return questionId; | ||
} | ||
|
||
public void setMentorId(long mentorId) { | ||
this.mentorId = mentorId; | ||
} | ||
|
||
public long getMentorId() { | ||
return mentorId; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(questionId, mentorId); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) return true; | ||
if (obj == null || getClass() != obj.getClass()) return false; | ||
MentorResponseId id = (MentorResponseId) obj; | ||
return id.mentorId == this.mentorId && id.questionId == this.questionId; | ||
} | ||
} |
Oops, something went wrong.