smurzz / artconnect

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

Bild Model/Service/Controller in Backend erstellen #19

Closed smurzz closed 1 year ago

smurzz commented 1 year ago

Bild-Model Attribute in Backend:

  1. Image: Bild-Datei in verschiedenen Formaten(.jpg, .png..)
  2. Titel: Der Titel des Bildes.
  3. Beschreibung: Eine detaillierte Beschreibung des Bildes, die den Kontext, die Techniken oder die Bedeutung hinter dem Werk erläutert.
  4. Erstellungsjahr: Das Jahr, in dem das Bild erstellt wurde.
  5. Kunstrichtung/Stil: Die Kunstrichtung oder der Stil, dem das Bild zugeordnet werden kann (z.B. Abstrakt, Realismus, Impressionismus).
  6. Likes: Die Anzahl der Likes oder positiven Bewertungen, die das Bild erhalten hat.
  7. Materialien: Die Materialien, die für die Erstellung des Bildes verwendet wurden (z.B. Ölfarben, Aquarell, digitale Kunst).
  8. Abmessungen: Die Abmessungen des Bildes (Höhe, Breite, Tiefe).
  9. Preis: Der Preis des Bildes, falls es zum Verkauf angeboten wird.
  10. Tags/Kategorien: Schlagwörter oder Kategorien, die das Bild beschreiben und bei der Suche verwendet werden können (z.B. Landschaft, Porträt, Stillleben).
  11. Standort: Der aktuelle Standort des Bildes, falls es sich in einer Galerie oder Ausstellung befindet.
  12. Veröffentlichungsdatum: Das Datum, an dem das Bild auf der Plattform veröffentlicht wurde.

Bitte hinterlasst eure Vorschläge für User-Attribute in den Kommentaren.

smurzz commented 1 year ago

ArtWork Model

  1. ArtWork Attributes:

*Referenzen zu Image-Objekten im Image-Dokument durch ID-Werte _Maximale Größe_ der Liste - 5 Maximale Größe der Collection 10

smurzz commented 1 year ago

Find All ArtWorks:

Öffentlich (für Gäste und Benutzer)

  1. GET http://localhost:8080/artworks

Response Status: 200 Response Body: Array<ArtWork>

Beispiel:

[
    {
  "_id": "649ab0617af2d57328bb0cc6",
  "ownerId": "6499f827716de01a654c37ac",
  "galleryId": "649aaa307af2d57328bb0cc4",
  "ownerName": "user user",
  "galleryTitle": "title3",
  "title": "titleArtwork",
  "imagesIds": [
    "649ab8137af2d57328bb0cc9"
  ],
  "description": "descriptionArtwork",
  "yearOfCreation": 2000,
  "materials": [
    "material1",
    "material2",
    "material3",
    "material4",
    "material5",
    "material6",
    "material7",
    "material8",
    "material9",
    "materials10"
  ],
  "dimension": {
    "height": 23.5,
    "width": 13.7,
    "depth": 2
  },
  "price": 20,
  "tags": [
    "tag1",
    "tag2",
    "tag3",
    "tag4",
    "tag5",
    "tag6",
    "tag7",
    "tag8",
    "tag9",
    "tag10"
  ],
  "location": "Lol",
  "createdAt": "2023-06-27T09:48:17.849Z"
  },
    {
        "id": "649ab1637af2d57328bb0cc7",
        "title": "titleArtwork",
        "images": [],
        "description": null,
        "yearOfCreation": null,
        "materials": null,
        "dimension": null,
        "price": null,
        "location": null,
        "createdAt": "2023-06-27T09:52:35.565+00:00",
        "comments": null,
        "ownerId": "6499f827716de01a654c37ac",
        "galleryId": "649a91377af2d57328bb0ca5",
        "ownerName": "user user",
        "galleryTitle": "title3",
        "likes": 0
    }
]
smurzz commented 1 year ago

Find ArtWork by Id:

Öffentlich (für Gäste und Benutzer)

  1. GET http://localhost:8080/artworks/{id}

Request path variable: id

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

Response Error :

NOT_FOUND 404 Artwork with id is not found.

Beispiel: http://localhost:8080/artworks/649ab0617af2d57328bb0cc6

Response:

{
    "id": "649ab0617af2d57328bb0cc6",
    "title": "titleArtwork",
    "images": [],
    "description": "descriptionArtwork",
    "yearOfCreation": 2000,
    "materials": [
        "material1",
        "material2",
        "material3",
        "material4",
        "material5",
        "material6",
        "material7",
        "material8",
        "material9",
        "materials10"
    ],
    "dimension": {
        "height": 23.5,
        "width": 13.7,
        "depth": 2.0
    },
    "price": 20.0,
    "location": "Lol",
    "createdAt": "2023-06-27T09:48:17.849+00:00",
    "comments": null,
    "ownerId": "6499f827716de01a654c37ac",
    "galleryId": "649a91377af2d57328bb0ca5",
    "ownerName": "user user",
    "galleryTitle": "title3",
    "likes": 0
}
smurzz commented 1 year ago

Add Image in ArtWork:

Privat (nut für Benutzer)

  1. POST http://localhost:8080/artworks/add-photo/{id}

Request Headers: Authentication: Bearer [access-token] Request Headers: Content-type: multipart/form-data Request Parameter: file

Response Body: Image saved for ArtWork. Response Status: 201 Request Error:

400 BAD_REQUEST: Maximum number of images reached for the artwork Image is not valid 401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to add an image for another user or artwork 404 NOT_FOUND: Artwork not found 500 INTERNAL_SERVER_ERROR: Error by saving image id for artwork

Validierung: Akzeptable Bildformate: .jpg, .jpeg, .png Maximale Bildgröße: 5Mb

smurzz commented 1 year ago

Create ArtWork by User Id:

Privat (nur für Benutzer)

  1. POST http://localhost:8080/artworks

Request Headers: Authentication: Bearer [access-token] Request body: {"title", "description", "yearOfCreation", "materials", "dimension", "price", "tags", "artDirections", "location"}

Validierung:

  1. title: NotBlank
  2. yearOfCreation: Can not be larger than the actual year
  3. materials: Materials list can have at most 10 strings
  4. price: Price must be a positive or zero value
  5. tags: Tags list can have at most 10 strings
  6. artDirections: One of enum value in the list is not valid, Max size is 10

Response Status: 201 Response Error:

400 BAD_REQUEST: sehe Validierung 401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to create an artwork for another user or gallery 404 NOT_FOUND: User doesn't have a gallery. 500 INTERNAL_SERVER_ERROR: Error by creating artwork**

Beispiel: http://localhost:8080/artworks

Beispiel Request Body:

{
    "title": "titleArtwork",
    "description": "descriptionArtwork",
    "yearOfCreation": 2000,
    "materials": [
        "material1",
        "material2",
        "material3",
        "material4",
        "material5",
        "material6",
        "material7",
        "material8",
        "material9",
        "materials10"
    ],
    "tags": [
        "tag1",
        "tag2",
        "tag3",
        "tag4",
        "tag6",
        "tag7",
        "tag8",
        "tag9",
        "tag10",
        "tag5"
    ],
    "artDirections": ["ABSTRACT", "REALISM", "IMPRESSIONISM", "SURREALISM", "EXPRESSIONISM", "MINIMALISM", "CUBISM", "POP_ART", "CONCEPTUAL_ART", "STREET_ART_GRAFFITI"],
    "dimension": {
        "height": 23.5,
        "width": 13.7,
        "depth": 2.0
    },
    "price": 20.0,
    "location": "Lol"
}
{
    "id": "649ab0617af2d57328bb0cc6",
    "title": "titleArtwork",
    "images": [],
    "description": "descriptionArtwork",
    "yearOfCreation": 2000,
    "materials": [
        "material1",
        "material2",
        "material3",
        "material4",
        "material5",
        "material6",
        "material7",
        "material8",
        "material9",
        "materials10"
    ],
    "tags": [
        "tags1",
        "tags2",
        "tags3",
        "tags4",
        "tags5",
        "tags6",
        "tags7",
        "tags8",
        "tags9",
        "tags10"
    ],
    "dimension": {
        "height": 23.5,
        "width": 13.7,
        "depth": 2.0
    },
    "artDirections": ["ABSTRACT", "REALISM", "IMPRESSIONISM", "SURREALISM", "EXPRESSIONISM", "MINIMALISM", "CUBISM", "POP_ART", "CONCEPTUAL_ART", "STREET_ART_GRAFFITI", "REALISM"],
    "price": 20.0,
    "location": "Lol",
    "createdAt": "2023-06-27T09:48:17.849+00:00",
    "comments": null,
    "ownerId": "6499f827716de01a654c37ac",
    "galleryId": "649a91377af2d57328bb0ca5",
    "ownerName": "user user",
    "galleryTitle": "title3",
    "likes": 0
}
smurzz commented 1 year ago

Add Images in ArtWork:

Privat (nut für Benutzer)

  1. POST http://localhost:8080/artworks/add-photos/{id}

Request Headers: Authentication: Bearer [access-token] Request path variable: id Request Headers: Content-type: multipart/form-data Request Parameter: files

Response Body: Images saved for ArtWork._ Response Status: 201 Request Error:

400 BAD_REQUEST: Maximum number of images reached for the artwork 400 BAD_REQUEST: "Image with name < imageName > is not valid" 400 BAD_REQUEST: "Invalid image(s)" Image is not valid 401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to add an image for another user or artwork 404 NOT_FOUND: Artwork not found 500 INTERNAL_SERVER_ERROR: Error by saving image id for artwork

Validierung: Akzeptable Bildformate: .jpg, .jpeg, .png Maximale Bildgröße: 5Mb

smurzz commented 1 year ago

Update ArtWork by Id:

Privat (nur für Benutzer)

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

Request Headers: Authentication: Bearer [access-token] Request body: {"title", "description", "yearOfCreation", "materials", "dimension", "price", "tags", "artDirections", "location"}

Validierung:

  1. title: NotBlankIfSpecified
  2. yearOfCreation: Can not be larger than the actual year
  3. materials: Materials list can have at most 10 strings
  4. price: Price must be a positive or zero value
  5. tags: Tags list can have at most 10 strings
  6. artDirections: One of enum value in the list is not valid, Max size is 10

Request Status: 200 Request Error:

400 BAD_REQUEST: sehe Validierung 401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to update an artwork for another user 404 NOT_FOUND: ArtWork is not found.

Beispiel: http://localhost:8080/artworks/64a96661f0ffe638a2509647

Beispiel Request Body:

{
    "title": "titleArtworkEdited",
    "description": "titleArtworkEdited",
    "yearOfCreation": 2009,
    "materials": [
        "material1",
        "material2",
        "material3"
    ],
    "tags": [],
    "artDirections": ["ABSTRACT", "REALISM", "IMPRESSIONISM", "SURREALISM", "EXPRESSIONISM", "MINIMALISM", "CUBISM"],
    "dimension": {
        "height": 23.7,
        "width": 13.7,
        "depth": 3.0
    },
    "price": 20.0,
    "location": "Nowhere"
}

Beispiel Response Body:

{
    "id": "64a96661f0ffe638a2509647",
    "title": "titleArtworkEdited",
    "images": [],
    "description": "titleArtworkEdited",
    "yearOfCreation": 2009,
    "materials": [
        "material1",
        "material2",
        "material3"
    ],
    "tags": [],
    "artDirections": [
        "REALISM",
        "MINIMALISM",
        "SURREALISM",
        "EXPRESSIONISM",
        "ABSTRACT",
        "IMPRESSIONISM",
        "CUBISM"
    ],
    "dimension": {
        "height": 23.7,
        "width": 13.7,
        "depth": 3.0
    },
    "price": 20.0,
    "location": "Nowhere",
    "createdAt": "2023-07-08T13:36:33.343+00:00",
    "comments": null,
    "ownerId": "6499f827716de01a654c37ac",
    "galleryId": "64a96650f0ffe638a2509646",
    "ownerName": "user user",
    "galleryTitle": "title2",
    "likes": 1
}
smurzz commented 1 year ago

Add/Remove Like by ArtWork:

Privat (nut für Benutzer)

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

Request Headers: Authentication: Bearer [access-token] Request path variable: id

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

Response Status: 200 Request Error:

401 UNAUTHORIZED 404 NOT_FOUND: Artwork not found

Wenn der Benutzer noch kein "Like" hinzugefügt hat, wird es hinzugefügt, andernfalls wird sein "Like" entfernt.

Beispiel: http://localhost:8080/artworks/64a96661f0ffe638a2509647/like

{
    "id": "64a96661f0ffe638a2509647",
    "title": "titleArtworkEdited",
    "images": [],
    "description": "titleArtworkEdited",
    "yearOfCreation": 2009,
    "materials": [
        "material1",
        "material2",
        "material3"
    ],
    "tags": [],
    "artDirections": [
        "SURREALISM",
        "ABSTRACT",
        "MINIMALISM",
        "CUBISM",
        "EXPRESSIONISM",
        "REALISM",
        "IMPRESSIONISM"
    ],
    "dimension": {
        "height": 23.7,
        "width": 13.7,
        "depth": 3.0
    },
    "price": 20.0,
    "location": "Nowhere",
    "createdAt": "2023-07-08T13:36:33.343+00:00",
    "comments": null,
    "ownerId": "6499f827716de01a654c37ac",
    "galleryId": "64a96650f0ffe638a2509646",
    "ownerName": "user user",
    "galleryTitle": "title2",
    "likes": 1,
    "likedByCurrentUser": true
}
smurzz commented 1 year ago

Delete ArtWork by Id:

Privat (nur für Benutzer)

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

Request Headers: Authentication: Bearer [access-token] Request path variable: id

Response Status: 204 Response Error:

401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to remove an artwork for another user 404 NOT_FOUND: User is not found. 404 NOT_FOUND: Artwork is not found.

Beispiel: http://localhost:8080/artworks/649a91377af2d57328bb0ca5

smurzz commented 1 year ago

Delete Image at ArtWork by Id:

Privat (nur für Benutzer)

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

Request Headers: Authentication: Bearer [access-token] Request path variable: id Request path variable: imageId

Response Status: 204 Response Error:

401 UNAUTHORIZED 403 FORBIDDEN: You are not allowed to remove an image for another user or artwork 404 NOT_FOUND: User is not found. 404 NOT_FOUND: Artwork is not found. 404 NOT_FOUND: Image is not found by ArtWork

Beispiel: http://localhost:8080/artworks/64a95f5df0ffe638a250963b/images/64a96012f0ffe638a250963d