mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-13 12:51:37 +00:00
Finishing initial CollectionController endpoints
This commit is contained in:
parent
6321c76d32
commit
933c4f27e3
1 changed files with 118 additions and 3 deletions
|
|
@ -285,13 +285,13 @@ class CollectionController {
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: '#/components/schemas/collectionExpanded'
|
* $ref: '#/components/schemas/collectionExpanded'
|
||||||
|
* 400:
|
||||||
|
* description: The provided library ID could not be found, is in
|
||||||
|
* a different library, or is already in a collection
|
||||||
* 403:
|
* 403:
|
||||||
* description: A user with update permissions is required to update collections
|
* description: A user with update permissions is required to update collections
|
||||||
* 404:
|
* 404:
|
||||||
* description: No collection with the specified ID exists
|
* description: No collection with the specified ID exists
|
||||||
* 500:
|
|
||||||
* description: The provided library ID could not be found, is in
|
|
||||||
* a different library, or is already in a collection
|
|
||||||
*/
|
*/
|
||||||
async addBook(req, res) {
|
async addBook(req, res) {
|
||||||
const libraryItem = await Database.libraryItemModel.getOldById(req.body.id)
|
const libraryItem = await Database.libraryItemModel.getOldById(req.body.id)
|
||||||
|
|
@ -326,6 +326,39 @@ class CollectionController {
|
||||||
* @param {*} req
|
* @param {*} req
|
||||||
* @param {*} res
|
* @param {*} res
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /api/collections/{id}/book/{bookId}:
|
||||||
|
* delete:
|
||||||
|
* operationId: collectionRemoveBook
|
||||||
|
* summary: Remove a single book from a collection
|
||||||
|
* tags:
|
||||||
|
* - Collections
|
||||||
|
* parameters:
|
||||||
|
* - name: id
|
||||||
|
* in: path
|
||||||
|
* description: Collection ID
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* - name: bookId
|
||||||
|
* in: path
|
||||||
|
* description: Book ID
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: OK
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: '#/components/schemas/collectionExpanded'
|
||||||
|
* 403:
|
||||||
|
* description: A user with update permissions is required to update collections
|
||||||
|
* 404:
|
||||||
|
* description: No collection with the specified ID exists
|
||||||
|
*/
|
||||||
async removeBook(req, res) {
|
async removeBook(req, res) {
|
||||||
const libraryItem = await Database.libraryItemModel.getOldById(req.params.bookId)
|
const libraryItem = await Database.libraryItemModel.getOldById(req.params.bookId)
|
||||||
if (!libraryItem) {
|
if (!libraryItem) {
|
||||||
|
|
@ -370,6 +403,47 @@ class CollectionController {
|
||||||
* @param {*} req
|
* @param {*} req
|
||||||
* @param {*} res
|
* @param {*} res
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /api/collections/{id}/batch/add:
|
||||||
|
* post:
|
||||||
|
* operationId: batchAddToCollection
|
||||||
|
* summary: Batch add books to an existing collection
|
||||||
|
* tags:
|
||||||
|
* - Collections
|
||||||
|
* parameters:
|
||||||
|
* - name: id
|
||||||
|
* in: path
|
||||||
|
* description: Collection ID
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* requestBody:
|
||||||
|
* description: Data for updating an existing collection
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* books:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* type: string
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Collection created successfully
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: '#/components/schemas/collectionExpanded'
|
||||||
|
* 403:
|
||||||
|
* description: A user with update permissions is required to update collections
|
||||||
|
* 404:
|
||||||
|
* description: No collection with the specified ID exists
|
||||||
|
* 500:
|
||||||
|
* description: The provided `books` array must not be empty
|
||||||
|
*/
|
||||||
async addBatch(req, res) {
|
async addBatch(req, res) {
|
||||||
// filter out invalid libraryItemIds
|
// filter out invalid libraryItemIds
|
||||||
const bookIdsToAdd = (req.body.books || []).filter(b => !!b && typeof b == 'string')
|
const bookIdsToAdd = (req.body.books || []).filter(b => !!b && typeof b == 'string')
|
||||||
|
|
@ -428,6 +502,47 @@ class CollectionController {
|
||||||
* @param {*} req
|
* @param {*} req
|
||||||
* @param {*} res
|
* @param {*} res
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @openapi
|
||||||
|
* /api/collections/{id}/batch/remove:
|
||||||
|
* post:
|
||||||
|
* operationId: batchRemoveFromCollection
|
||||||
|
* summary: Batch remove books from a collection
|
||||||
|
* tags:
|
||||||
|
* - Collections
|
||||||
|
* parameters:
|
||||||
|
* - name: id
|
||||||
|
* in: path
|
||||||
|
* description: Collection ID
|
||||||
|
* required: true
|
||||||
|
* schema:
|
||||||
|
* type: string
|
||||||
|
* requestBody:
|
||||||
|
* description: Data for updating an existing collection
|
||||||
|
* required: true
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* books:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* type: string
|
||||||
|
* responses:
|
||||||
|
* 200:
|
||||||
|
* description: Books removed from collection successfully
|
||||||
|
* content:
|
||||||
|
* application/json:
|
||||||
|
* schema:
|
||||||
|
* $ref: '#/components/schemas/collectionExpanded'
|
||||||
|
* 403:
|
||||||
|
* description: A user with update permissions is required to update collections
|
||||||
|
* 404:
|
||||||
|
* description: No collection with the specified ID exists
|
||||||
|
* 500:
|
||||||
|
* description: The provided `books` array must not be empty
|
||||||
|
*/
|
||||||
async removeBatch(req, res) {
|
async removeBatch(req, res) {
|
||||||
// filter out invalid libraryItemIds
|
// filter out invalid libraryItemIds
|
||||||
const bookIdsToRemove = (req.body.books || []).filter(b => !!b && typeof b == 'string')
|
const bookIdsToRemove = (req.body.books || []).filter(b => !!b && typeof b == 'string')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue