Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dfc76fd

Browse files
writing comments for docs
1 parent b073a13 commit dfc76fd

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

‎src/main/java/com/example/randombook/book/Book.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,74 @@ public Book(int id, String title, String author, Date releaseDate, String isbn,
2424
this.images = images;
2525
}
2626

27+
/**
28+
* Gets id.
29+
*
30+
* @return the id
31+
*/
2732
public int getId() {
2833
return id;
2934
}
3035

36+
/**
37+
* Gets title.
38+
*
39+
* @return the title
40+
*/
3141
public String getTitle() {
3242
return title;
3343
}
3444

45+
/**
46+
* Gets author.
47+
*
48+
* @return the author
49+
*/
3550
public String getAuthor() {
3651
return author;
3752
}
3853

54+
/**
55+
* Gets release date.
56+
*
57+
* @return the release date
58+
*/
3959
public Date getReleaseDate() {
4060
return releaseDate;
4161
}
4262

63+
/**
64+
* Gets isbn.
65+
*
66+
* @return the isbn
67+
*/
4368
public String getIsbn() {
4469
return isbn;
4570
}
4671

72+
/**
73+
* Gets category.
74+
*
75+
* @return the ID of the category
76+
*/
4777
public int getCategory() {
4878
return category;
4979
}
5080

81+
/**
82+
* Gets images.
83+
*
84+
* @return the URLs of the images
85+
*/
5186
public String getImages() {
5287
return images;
5388
}
5489

90+
/**
91+
* Gets the string representation of a book
92+
*
93+
* @return the string representation of a book
94+
*/
5595
@Override
5696
public String toString() {
5797
return "Book{" +

‎src/main/java/com/example/randombook/book/BookController.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,78 @@ public BookController(JdbcBookDAO dao) {
1616
this.dao = dao;
1717
}
1818

19+
/**
20+
* Gets all books.
21+
*
22+
* @return the list of books
23+
*/
1924
@GetMapping
2025
public List<Book> findAll() {
2126
return dao.findAll();
2227
}
2328

29+
/**
30+
* Gets books by category ID.
31+
*
32+
* @param id_category the category ID
33+
* @return the books by category ID
34+
*/
2435
@GetMapping("/category/{id_category}")
2536
public List<Book> findAllByCategory(@PathVariable int id_category) {
2637
return dao.findAllByCategory(id_category);
2738
}
2839

40+
/**
41+
* Gets a random book, optionally by category
42+
*
43+
* @param id_category the category ID
44+
* @return a random book by category ID
45+
*/
2946
@GetMapping("/random")
3047
public Optional<Book> findRandomBook(@RequestParam(value = "category", defaultValue = "0") int id_category) {
3148
return dao.findRandomBook(id_category);
3249
}
3350

51+
/**
52+
* Gets a book by ID
53+
*
54+
* @param id the book ID
55+
* @return a book having the given ID
56+
*/
3457
@GetMapping("/{id}")
3558
public Optional<Book> findById(@PathVariable int id) {
3659
return dao.findById(id);
3760
}
3861

62+
/**
63+
* Creates a book
64+
*
65+
* @param book the book to be created
66+
* @return the just created book
67+
*/
3968
@ResponseStatus(HttpStatus.CREATED)
4069
@PostMapping
4170
public Book create(@RequestBody Book book) {
4271
return dao.create(book);
4372
}
4473

74+
/**
75+
* Updates a book
76+
*
77+
* @param book the book to be updated
78+
* @param id the ID of the book to be updated
79+
* @return the just updated book
80+
*/
4581
@PutMapping("/{id}")
4682
public Book update(@RequestBody Book book, @PathVariable int id) {
4783
return dao.update(book, id);
4884
}
4985

86+
/**
87+
* Deletes a book
88+
*
89+
* @param id the ID of the book to be deleted
90+
*/
5091
@DeleteMapping("/{id}")
5192
public void delete(@PathVariable int id) {
5293
dao.delete(id);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /