Skip to content
Snippets Groups Projects
Commit d32a6e64 authored by Holzheu Hannah's avatar Holzheu Hannah
Browse files

fixed sort by date created (descending order) and fixed createdAt field in WishlistEntry Model

parent 69e54834
No related branches found
No related tags found
1 merge request!31Frontend advanced
...@@ -53,7 +53,8 @@ GET http://localhost:8080/api/v1/wishlist?sort=createdAt ...@@ -53,7 +53,8 @@ GET http://localhost:8080/api/v1/wishlist?sort=createdAt
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsdWthcy5rYXJzY2hAZ214LmRlIiwiaWF0IjoxNzAzNjIzNzAzLCJleHAiOjE3MDM3MTAxMDN9.D06wA6SdGQQzln55DK8pMO6cowbA9iL_-EfmGbVMT14 Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsdWthcy5rYXJzY2hAZ214LmRlIiwiaWF0IjoxNzAzNjIzNzAzLCJleHAiOjE3MDM3MTAxMDN9.D06wA6SdGQQzln55DK8pMO6cowbA9iL_-EfmGbVMT14
### Get amount of plants in wishlist ### Get amount of plants in wishlist
GET http://localhost:8080/api/v1/wishlist/count GET http://localhost:8080/api/v1/garden?sort=createdAt
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsdWthcy5rYXJzY2hAZ214LmRlIiwiaWF0IjoxNzAzNjIzNzAzLCJleHAiOjE3MDM3MTAxMDN9.D06wA6SdGQQzln55DK8pMO6cowbA9iL_-EfmGbVMT14
### Add plant to wishlist ### Add plant to wishlist
POST http://localhost:8080/api/v1/wishlist/add/1 POST http://localhost:8080/api/v1/wishlist/add/1
......
...@@ -3,16 +3,17 @@ package hdm.mi.growbros.models; ...@@ -3,16 +3,17 @@ package hdm.mi.growbros.models;
import hdm.mi.growbros.models.plant.Plant; import hdm.mi.growbros.models.plant.Plant;
import hdm.mi.growbros.models.user.User; import hdm.mi.growbros.models.user.User;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.util.Date; import java.util.Date;
@Entity @Entity
@Data @EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class WishListEntry { public class WishListEntry {
......
...@@ -59,7 +59,7 @@ public class GardenService { ...@@ -59,7 +59,7 @@ public class GardenService {
private List<Plant> getAllPlantsOrderedByCreatedDate(User user) { private List<Plant> getAllPlantsOrderedByCreatedDate(User user) {
return mapGardenEntriesToPlants( return mapGardenEntriesToPlants(
gardenRepository.findByUser(user, Sort.by("createdDate")) gardenRepository.findByUser(user, Sort.by("createdAt").descending())
); );
} }
......
...@@ -64,7 +64,7 @@ public class WishListService { ...@@ -64,7 +64,7 @@ public class WishListService {
private List<Plant> getAllPlantsOrderedByCreatedDate(User user) { private List<Plant> getAllPlantsOrderedByCreatedDate(User user) {
return mapWishListEntriesToPlants( return mapWishListEntriesToPlants(
wishListRepository.findByUser(user, Sort.by("createdAt")) wishListRepository.findByUser(user, Sort.by("createdAt").descending())
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment