-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from denomelchenko/feature/admin-panel-item
Feature/admin panel item
- Loading branch information
Showing
31 changed files
with
398 additions
and
63 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/main/java/com/lalabrand/ecommerce/exception/AccessDeniedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.lalabrand.ecommerce.exception; | ||
|
||
public class AccessDeniedException extends RuntimeException { | ||
public AccessDeniedException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/com/lalabrand/ecommerce/exception/UsernameNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.lalabrand.ecommerce.exception; | ||
|
||
public class UsernameNotFoundException extends RuntimeException { | ||
public UsernameNotFoundException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.lalabrand.ecommerce.item; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.Value; | ||
|
||
import java.math.BigDecimal; | ||
|
||
@Getter | ||
@Setter | ||
@Value | ||
public class ItemInput { | ||
String title; | ||
String shortDisc; | ||
String longDisc; | ||
BigDecimal rating; | ||
BigDecimal price; | ||
Integer availableCount; | ||
BigDecimal salePrice; | ||
Integer soldCount; | ||
String categoryId; | ||
|
||
public Item toEntity() { | ||
return Item.builder() | ||
.title(this.title) | ||
.shortDisc(this.shortDisc) | ||
.longDisc(this.longDisc) | ||
.rating(this.rating) | ||
.price(this.price) | ||
.availableCount(this.availableCount) | ||
.salePrice(this.salePrice) | ||
.soldCount(this.soldCount) | ||
.categoryId(categoryId) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/lalabrand/ecommerce/item/item_info/ItemInfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.lalabrand.ecommerce.item.item_info; | ||
|
||
import org.springframework.graphql.data.method.annotation.Argument; | ||
import org.springframework.graphql.data.method.annotation.MutationMapping; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.stereotype.Controller; | ||
|
||
import java.util.Set; | ||
|
||
@Controller | ||
public class ItemInfoController { | ||
private final ItemInfoService itemInfoService; | ||
|
||
public ItemInfoController(ItemInfoService itemInfoService) { | ||
this.itemInfoService = itemInfoService; | ||
} | ||
|
||
@MutationMapping(name = "sizeToItemInfo") | ||
@PreAuthorize("hasAuthority('ADMIN')") | ||
public ItemInfoDTO addSizeToItemInfo(@Argument String itemInfoId, @Argument String sizeId) { | ||
return itemInfoService.addSizeToItemInfo(itemInfoId, sizeId); | ||
} | ||
|
||
@MutationMapping(name = "sizesToItemInfo") | ||
@PreAuthorize("hasAuthority('ADMIN')") | ||
public ItemInfoDTO addSizesToItemInfo(@Argument String itemInfoId, @Argument Set<String> sizeIds) { | ||
return itemInfoService.addSizesToItemInfo(itemInfoId, sizeIds); | ||
} | ||
|
||
@MutationMapping(name = "itemInfo") | ||
@PreAuthorize("hasAuthority('ADMIN')") | ||
public ItemInfoDTO createItemInfo(@Argument ItemInfoInput itemInfoInput) { | ||
return itemInfoService.save(itemInfoInput); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/com/lalabrand/ecommerce/item/item_info/ItemInfoInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.lalabrand.ecommerce.item.item_info; | ||
|
||
import com.lalabrand.ecommerce.item.enums.ColorEnum; | ||
import com.lalabrand.ecommerce.utils.Id; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.Value; | ||
|
||
@Value | ||
@Getter | ||
@Setter | ||
public class ItemInfoInput { | ||
String image; | ||
ColorEnum color; | ||
Boolean isColorAvailable; | ||
@Id | ||
String itemId; | ||
|
||
public ItemInfo toEntity() { | ||
return ItemInfo.builder() | ||
.color(this.color) | ||
.image(this.image) | ||
.isColorAvailable(this.isColorAvailable) | ||
.itemId(this.itemId) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.