-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
101d04c
commit d6d1acb
Showing
8 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/in/backend/core/question/application/QuestionSaveCommand.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,12 @@ | ||
package in.backend.core.question.application; | ||
|
||
import in.backend.global.entity.ActionType; | ||
|
||
public record QuestionSaveCommand( | ||
ActionType action, | ||
Long questionId, | ||
Long questionSetId, | ||
Integer sequence, | ||
String question | ||
) { | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/main/java/in/backend/core/question/application/QuestionService.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,21 @@ | ||
package in.backend.core.question.application; | ||
|
||
|
||
import in.backend.core.question.application.QuestionWriter.QuestionInfo; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class QuestionService { | ||
private final QuestionWriter questionWriter; | ||
|
||
public Long save(QuestionSaveCommand command) { | ||
return switch (command.action()) { | ||
case CREATE -> questionWriter.write(new QuestionInfo(command)); | ||
case UPDATE -> questionWriter.write(command.questionId(), new QuestionInfo(command)); | ||
case DELETE -> throw new UnsupportedOperationException(); | ||
}; | ||
} | ||
|
||
} |
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
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/in/backend/core/question/presentation/QuestionApi.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,26 @@ | ||
package in.backend.core.question.presentation; | ||
|
||
|
||
import in.backend.core.auth.domain.Visitor; | ||
import in.backend.core.auth.domain.attributes.Auth; | ||
import in.backend.core.question.presentation.payload.QuestionSaveRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/questions") | ||
public class QuestionApi { | ||
|
||
|
||
@PostMapping | ||
public void save( | ||
@RequestBody QuestionSaveRequest questionSaveRequest, | ||
@Auth Visitor visitor | ||
) { | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...d/src/main/java/in/backend/core/question/presentation/payload/QuestionDetailResponse.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,9 @@ | ||
package in.backend.core.question.presentation.payload; | ||
|
||
public record QuestionDetailResponse( | ||
Long questionId, | ||
Long questionSetId, | ||
String question, | ||
Integer sequence | ||
) { | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/in/backend/core/question/presentation/payload/QuestionSaveRequest.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,12 @@ | ||
package in.backend.core.question.presentation.payload; | ||
|
||
import in.backend.global.entity.ActionType; | ||
|
||
public record QuestionSaveRequest( | ||
ActionType action, | ||
Long questionId, | ||
Long questionSetId, | ||
Integer sequence, | ||
String question | ||
) { | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/in/backend/global/entity/ActionType.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,7 @@ | ||
package in.backend.global.entity; | ||
|
||
public enum ActionType { | ||
CREATE, | ||
UPDATE, | ||
DELETE | ||
} |