-
Notifications
You must be signed in to change notification settings - Fork 308
emplement logic #203
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
qreqit
wants to merge
8
commits into
mate-academy:main
Choose a base branch
from
qreqit:main
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
emplement logic #203
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
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
17 changes: 17 additions & 0 deletions
17
src/main/java/mate/academy/rickandmorty/config/SwaggerConfig.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,17 @@ | ||
//package mate.academy.rickandmorty.config; | ||
// | ||
//import org.springframework.context.annotation.Bean; | ||
//import org.springframework.context.annotation.Configuration; | ||
// | ||
//@Configuration | ||
//public class SwaggerConfig { | ||
// | ||
// @Bean | ||
// public Docket api() { | ||
// return new Docket(DocumentationType.SWAGGER_2) | ||
// .select() | ||
// .apis(RequestHandlerSelectors.basePackage("com.example.rickandmorty")) | ||
// .paths(PathSelectors.any()) | ||
// .build(); | ||
// } | ||
//} |
28 changes: 28 additions & 0 deletions
28
src/main/java/mate/academy/rickandmorty/controller/CharacterController.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,28 @@ | ||
package mate.academy.rickandmorty.controller; | ||
|
||
import java.util.List; | ||
import mate.academy.rickandmorty.model.Character; | ||
import mate.academy.rickandmorty.service.CharacterService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/characters") | ||
public class CharacterController { | ||
|
||
@Autowired | ||
private CharacterService characterService; | ||
|
||
@GetMapping("/random") | ||
public Character getRandomCharacter() { | ||
return characterService.getRandomCharacter(); | ||
} | ||
|
||
@GetMapping("/search") | ||
public List<Character> searchCharactersByName(@RequestParam String name) { | ||
return characterService.searchCharactersByName(name); | ||
} | ||
} |
156 changes: 156 additions & 0 deletions
156
src/main/java/mate/academy/rickandmorty/dto/external/CharacterDto.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,156 @@ | ||
package mate.academy.rickandmorty.dto.external; | ||
|
||
import java.util.List; | ||
|
||
public class CharacterDto { | ||
private int id; | ||
private String name; | ||
private String status; | ||
private String species; | ||
private String type; | ||
private String gender; | ||
private OriginDto origin; | ||
private LocationDto location; | ||
private String image; | ||
private List<String> episodes; | ||
private String url; | ||
private String created; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
public String getSpecies() { | ||
return species; | ||
} | ||
|
||
public void setSpecies(String species) { | ||
this.species = species; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public String getGender() { | ||
return gender; | ||
} | ||
|
||
public void setGender(String gender) { | ||
this.gender = gender; | ||
} | ||
|
||
public OriginDto getOrigin() { | ||
return origin; | ||
} | ||
|
||
public void setOrigin(OriginDto origin) { | ||
this.origin = origin; | ||
} | ||
|
||
public LocationDto getLocation() { | ||
return location; | ||
} | ||
|
||
public void setLocation(LocationDto location) { | ||
this.location = location; | ||
} | ||
|
||
public String getImage() { | ||
return image; | ||
} | ||
|
||
public void setImage(String image) { | ||
this.image = image; | ||
} | ||
|
||
public List<String> getEpisodes() { | ||
return episodes; | ||
} | ||
|
||
public void setEpisodes(List<String> episodes) { | ||
this.episodes = episodes; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getCreated() { | ||
return created; | ||
} | ||
|
||
public void setCreated(String created) { | ||
this.created = created; | ||
} | ||
|
||
public static class OriginDto { | ||
private String name; | ||
private String url; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} | ||
|
||
public static class LocationDto { | ||
private String name; | ||
private String url; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/mate/academy/rickandmorty/dto/external/EpisodeDto.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,69 @@ | ||
package mate.academy.rickandmorty.dto.external; | ||
|
||
import java.util.List; | ||
|
||
public class EpisodeDto { | ||
private int id; | ||
private String name; | ||
private String airDate; | ||
private String episode; | ||
private List<String> characters; | ||
private String url; | ||
private String created; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getAirDate() { | ||
return airDate; | ||
} | ||
|
||
public void setAirDate(String airDate) { | ||
this.airDate = airDate; | ||
} | ||
|
||
public String getEpisode() { | ||
return episode; | ||
} | ||
|
||
public void setEpisode(String episode) { | ||
this.episode = episode; | ||
} | ||
|
||
public List<String> getCharacters() { | ||
return characters; | ||
} | ||
|
||
public void setCharacters(List<String> characters) { | ||
this.characters = characters; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getCreated() { | ||
return created; | ||
} | ||
|
||
public void setCreated(String created) { | ||
this.created = created; | ||
} | ||
} |
Oops, something went wrong.
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.
The base package specified here is
com.example.rickandmorty
, which might not match your actual package structure. Consider changing it tomate.academy.rickandmorty
to ensure Swagger scans the correct package for API documentation.