-
Notifications
You must be signed in to change notification settings - Fork 26
ToDo_Solved_By_Hizam #43
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
Open
hizam37
wants to merge
1
commit into
EffectiveMobile:main
Choose a base branch
from
hizam37:dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
65 changes: 65 additions & 0 deletions
65
src/main/java/com/emobile/springtodo/controller/TodoController.java
This file contains hidden or 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,65 @@ | ||
| package com.emobile.springtodo.controller; | ||
|
|
||
|
|
||
| import com.emobile.springtodo.model.Todo; | ||
| import com.emobile.springtodo.service.ToDoService; | ||
| import com.emobile.springtodo.swagger.ITodoController; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @CrossOrigin | ||
| public class TodoController implements ITodoController { | ||
|
|
||
| private final ToDoService toDoService; | ||
|
|
||
|
|
||
| @Override | ||
| public void addToDo(Todo toDo) { | ||
|
|
||
|
|
||
| toDoService.createTodo(toDo); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void updateToDoById(Todo todo, Long id) { | ||
| toDoService.updateToDoById(todo, id); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public List<Todo> findAllToDo() { | ||
| return toDoService.findAllToDo(); | ||
| } | ||
|
|
||
| @Override | ||
| public ResponseEntity<Page<Todo>> getToDo(Todo toDo, int size, int page) { | ||
| Pageable pageable = PageRequest.of(page, size); | ||
| return new ResponseEntity<>(toDoService.findAllToDoByFilter(toDo, pageable),HttpStatus.OK); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public void deleteToDoById(Long id) { | ||
| toDoService.deleteById(id); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteAllToDo() { | ||
| toDoService.deleteAll(); | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/emobile/springtodo/exception/AppError.java
This file contains hidden or 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,16 @@ | ||
| package com.emobile.springtodo.exception; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class AppError { | ||
|
|
||
| private int httpStatus; | ||
| private String message; | ||
|
|
||
| public AppError(int httpStatus, String message) { | ||
| this.httpStatus = httpStatus; | ||
| this.message = message; | ||
| } | ||
|
|
||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/emobile/springtodo/exception/GlobalExceptionHandler.java
This file contains hidden or 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,18 @@ | ||
| package com.emobile.springtodo.exception; | ||
|
|
||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.ControllerAdvice; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
|
||
| @ControllerAdvice | ||
| public class GlobalExceptionHandler { | ||
|
|
||
| @ExceptionHandler(TodoException.class) | ||
| public ResponseEntity<AppError> todoException(TodoException ex) | ||
| { | ||
| return new ResponseEntity<>(new AppError(HttpStatus.NOT_FOUND.value(),ex.getMessage()),HttpStatus.BAD_REQUEST); | ||
| } | ||
|
|
||
| } | ||
9 changes: 9 additions & 0 deletions
9
src/main/java/com/emobile/springtodo/exception/TodoException.java
This file contains hidden or 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 com.emobile.springtodo.exception; | ||
|
|
||
| public class TodoException extends RuntimeException{ | ||
|
|
||
| public TodoException(String message) | ||
| { | ||
| super(message); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/emobile/springtodo/mapper/TodoMapper.java
This file contains hidden or 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,24 @@ | ||
| package com.emobile.springtodo.mapper; | ||
|
|
||
| import com.emobile.springtodo.model.Todo; | ||
| import com.emobile.springtodo.model.TodoPriority; | ||
| import com.emobile.springtodo.model.TodoStatus; | ||
| import org.springframework.jdbc.core.RowMapper; | ||
|
|
||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
|
|
||
| public class TodoMapper implements RowMapper<Todo> { | ||
| @Override | ||
| public Todo mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| Todo toDo = new Todo(); | ||
| toDo.setId(rs.getLong("id")); | ||
| toDo.setToDoTitle((rs.getString("todo_title"))); | ||
| toDo.setDescription(rs.getString("description")); | ||
| toDo.setToDoPriority(TodoPriority.valueOf(rs.getString("todo_priority"))); | ||
| toDo.setToDoStatus(TodoStatus.valueOf(rs.getString("todo_status"))); | ||
| return toDo; | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or 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,17 @@ | ||
| package com.emobile.springtodo.model; | ||
|
|
||
|
|
||
| import lombok.*; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| @Data | ||
| public class Todo implements Serializable { | ||
|
|
||
| private Long id; | ||
| private String toDoTitle; | ||
| private String description; | ||
| private TodoPriority toDoPriority; | ||
| private TodoStatus toDoStatus; | ||
| private String comment; | ||
| } |
This file contains hidden or 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,8 @@ | ||
| package com.emobile.springtodo.model; | ||
|
|
||
| public enum TodoPriority { | ||
| HIGH,MEDIUM,LOW | ||
| } | ||
|
|
||
|
|
||
|
|
This file contains hidden or 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,6 @@ | ||
| package com.emobile.springtodo.model; | ||
|
|
||
| public enum TodoStatus { | ||
| PENDING,IN_PROGRESS, | ||
| COMPLETED | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лушче Implementиться от Rest исключений, т.к. тут ты почти никакие не покрыл