smurzz / artconnect

A platform for the exchange of artworks
http://18.195.200.98:3000/
3 stars 1 forks source link

Kommentar-Endpoints im Backend #65

Closed smurzz closed 1 year ago

smurzz commented 1 year ago

EndPoints:

smurzz commented 1 year ago

Create Comment by ArtWork Id:

Privat (nur für Benutzer)

  1. POST http://localhost:8080/artworks/{id}/comments

Request Headers: Authentication: Bearer [access-token] Request body: {"commentText"}

Validierung:

  1. commentText: NotBlank

Request Status: 201 Response Body: {"id", "title", "images", "description", "yearOfCreation", "materials, "dimension" "price", "tags", "artDirections", "location", "createdAt", "comments", "ownerId", "ownerName", "galleryId", "galleryTitle", "likes", "likedByCurrentUser"} Request Error:

400 BAD_REQUEST: commentText: darf nicht leer sein 401 UNAUTHORIZED 404 NOT_FOUND: User is not found. 404 NOT_FOUND: ArtWork is not found.

Beispiel: http://localhost:8080/artworks/64ab084a4819fc3f028c8631/comments

Beispiel Request Body:

{
    "commentText": "Super!"
}

Beispiel Response Body:

{
    "id": "64ab084a4819fc3f028c8631",
    "title": "Mein erstes Bild",
    "description": "description",
    "yearOfCreation": null,
    "materials": [
        "material1",
        "material2"
    ],
    "tags": [],
    "artDirections": [
        "CONCEPTUAL_ART",
        "EXPRESSIONISM"
    ],
    "dimension": {
        "height": 1.0,
        "width": null,
        "depth": null
    },
    "price": 0.0,
    "location": "",
    "createdAt": "2023-07-09T19:19:38.343+00:00",
    "comments": [
        {
            "id": "5eeaf245-c20e-4343-9434-792d3a9fa31d",
            "authorId": "649aa1867af2d57328bb0cb7",
            "authorName": "admin",
            "createdAt": "2023-07-10T00:40:13.560+00:00",
            "updatedAt": null,
            "text": "Super!",
            "updated": false
        }
    ],
    "ownerId": "649aa1867af2d57328bb0cb7",
    "galleryId": "64ab04034819fc3f028c862e",
    "ownerName": "admin admin",
    "galleryTitle": "Meine Galerie",
    "likes": 0,
    "likedByCurrentUser": false
}
smurzz commented 1 year ago

Update Comment by ArtWork Id and Comment Id:

Privat (nur für Benutzer)

  1. PUT http://localhost:8080/artworks/{id}/{commentId}

Request Headers: Authentication: Bearer [access-token] Request body: {"commentText"}

Validierung:

  1. commentText: NotBlankIfSpecified

Request Status: 200 Response Body: {"id", "title", "images", "description", "yearOfCreation", "materials, "dimension" "price", "tags", "artDirections", "location", "createdAt", "comments", "ownerId", "ownerName", "galleryId", "galleryTitle", "likes", "likedByCurrentUser"} Request Error:

400 BAD_REQUEST: commentText: darf nicht leer sein 401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to update a comment for another user 404 NOT_FOUND: User is not found. 404 NOT_FOUND: ArtWork is not found. 404 NOT_FOUND: Comment is not found

Beispiel: http://localhost:8080/artworks/64ab084a4819fc3f028c8631/comments/ec5d54f7-0541-42e1-8437-6677d0cee00c

Beispiel Request Body:

{
    "commentText": "Super! (Edited)"
}

Beispiel Response Body:

{
    "id": "64ab084a4819fc3f028c8631",
    "title": "Mein erstes Bild",
    "description": "description",
    "yearOfCreation": null,
    "materials": [
        "material1",
        "material2"
    ],
    "tags": [],
    "artDirections": [
        "CONCEPTUAL_ART",
        "EXPRESSIONISM"
    ],
    "dimension": {
        "height": 1.0,
        "width": null,
        "depth": null
    },
    "price": 0.0,
    "location": "",
    "createdAt": "2023-07-09T19:19:38.343+00:00",
    "comments": [
        {
            "id": "612cd176-d7d8-421d-92ab-bf9046460f99",
            "authorId": "649aa1867af2d57328bb0cb7",
            "authorName": "admin",
            "createdAt": "2023-07-10T01:41:38.045+00:00",
            "updatedAt": "2023-07-10T01:42:18.418+00:00",
            "text": "Super! (Edited)",
            "updated": true
        }
    ],
    "ownerId": "649aa1867af2d57328bb0cb7",
    "galleryId": "64ab04034819fc3f028c862e",
    "ownerName": "admin admin",
    "galleryTitle": "Meine Galerie",
    "likes": 0,
    "likedByCurrentUser": false
}
smurzz commented 1 year ago

Delete Comment by ArtWork Id and Comment Id:

Privat (nur für Benutzer)

  1. DELETE http://localhost:8080/artworks/{id}/{commentId}

Request Headers: Authentication: Bearer [access-token]

Request Status: 204 Request Error:

401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to delete a comment for another user 404 NOT_FOUND: User is not found. 404 NOT_FOUND: ArtWork is not found. 404 NOT_FOUND: Comment is not found

Beispiel: http://localhost:8080/artworks/64ab084a4819fc3f028c8631/comments/ec5d54f7-0541-42e1-8437-6677d0cee00c