-
Notifications
You must be signed in to change notification settings - Fork 0
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 #64 from unsri-hackers/staging
Seamless Vendor Onboarding
- Loading branch information
Showing
58 changed files
with
592 additions
and
160 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
...va/com/unsri/ecommerce/application/behaviours/inventory/commands/AddInventoryCommand.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,5 @@ | ||
package com.unsri.ecommerce.application.behaviours.inventory.commands; | ||
|
||
import com.unsri.ecommerce.presentation.controllers.request.InventoryDTO; | ||
|
||
public class AddInventoryCommand extends InventoryDTO {} |
53 changes: 53 additions & 0 deletions
53
...unsri/ecommerce/application/behaviours/inventory/commands/AddInventoryCommandHandler.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,53 @@ | ||
package com.unsri.ecommerce.application.behaviours.inventory.commands; | ||
|
||
import com.unsri.ecommerce.infrastructure.mediator.Handler; | ||
import com.unsri.ecommerce.infrastructure.mediator.Response; | ||
import com.unsri.ecommerce.application.entities.EnumStateCode; | ||
import com.unsri.ecommerce.application.domain.Inventory; | ||
import com.unsri.ecommerce.application.domain.PhotoInventory; | ||
import com.unsri.ecommerce.infrastructure.repository.InventoryRepository; | ||
import com.unsri.ecommerce.presentation.controllers.request.PhotoDTO; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
public class AddInventoryCommandHandler implements Handler<AddInventoryCommand, Response<Inventory, EnumStateCode>> { | ||
|
||
@Autowired | ||
InventoryRepository _repository; | ||
|
||
@Override | ||
public Response<Inventory, EnumStateCode> handle(AddInventoryCommand addInventoryCommand) { | ||
try { | ||
Inventory inventory = this._repository.save(toInventory(addInventoryCommand)); | ||
return new Response<>(inventory, EnumStateCode.SUCCESS, null); | ||
} catch (Exception ex) { | ||
return new Response<>(null, EnumStateCode.ERROR, ex.getMessage()); | ||
} | ||
} | ||
|
||
private Inventory toInventory(AddInventoryCommand command) { | ||
Inventory inventory = new Inventory(); | ||
|
||
inventory.setItemName(command.getProductName()); | ||
inventory.setPrice(Double.parseDouble(command.getPrice())); | ||
inventory.setFkSellerId(command.getSellerId()); | ||
|
||
List<PhotoInventory> inventories = new ArrayList<>(); | ||
|
||
for (PhotoDTO photoDTO : command.getPhotos()) { | ||
PhotoInventory newInventory = new PhotoInventory(); | ||
newInventory.setName(photoDTO.getName()); | ||
newInventory.setPath(photoDTO.getPath()); | ||
|
||
inventories.add(newInventory); | ||
} | ||
|
||
inventory.setPhotos(inventories); | ||
|
||
return inventory; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...n/java/com/unsri/ecommerce/application/behaviours/inventory/commands/CreateInventory.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
2 changes: 1 addition & 1 deletion
2
...n/java/com/unsri/ecommerce/application/behaviours/inventory/commands/UpdateInventory.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
2 changes: 1 addition & 1 deletion
2
...om/unsri/ecommerce/application/behaviours/inventory/queries/GetInventoriesBySellerId.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
4 changes: 1 addition & 3 deletions
4
...com/unsri/ecommerce/application/behaviours/inventory/queries/GetInventoriesPaginated.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
3 changes: 1 addition & 2 deletions
3
...ecommerce/application/behaviours/inventory/queries/GetInventoriesPaginatedByItemName.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
9 changes: 4 additions & 5 deletions
9
src/main/java/com/unsri/ecommerce/application/behaviours/inventory/queries/GetInventory.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
8 changes: 3 additions & 5 deletions
8
src/main/java/com/unsri/ecommerce/application/behaviours/seller/commands/LoginSeller.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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/unsri/ecommerce/application/behaviours/seller/commands/LogoutSeller.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
10 changes: 5 additions & 5 deletions
10
src/main/java/com/unsri/ecommerce/application/behaviours/seller/commands/RegisterSeller.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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/unsri/ecommerce/application/behaviours/seller/queries/GetSellerById.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,24 @@ | ||
package com.unsri.ecommerce.application.behaviours.seller.queries; | ||
|
||
import com.unsri.ecommerce.application.behaviours.BaseCommand; | ||
import com.unsri.ecommerce.application.domain.Seller; | ||
import com.unsri.ecommerce.infrastructure.repository.SellerRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public class GetSellerById implements BaseCommand<Seller> { | ||
|
||
private final SellerRepository sellerRepository; | ||
|
||
public GetSellerById(SellerRepository sellerRepository){ | ||
this.sellerRepository = sellerRepository; | ||
} | ||
|
||
@Override | ||
public Seller execute(Optional<Seller> sellerId) { | ||
Optional<Seller> seller = sellerRepository.findById(sellerId.get().getId()); | ||
|
||
return seller.get(); | ||
} | ||
|
||
} |
6 changes: 2 additions & 4 deletions
6
...behaviours/seller/query/VerifySeller.java → ...haviours/seller/queries/VerifySeller.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
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
2 changes: 1 addition & 1 deletion
2
...nsri/ecommerce/domain/models/JwtUser.java → ...ecommerce/application/domain/JwtUser.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
2 changes: 1 addition & 1 deletion
2
...ommerce/domain/models/PhotoInventory.java → ...ce/application/domain/PhotoInventory.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
2 changes: 1 addition & 1 deletion
2
.../ecommerce/domain/models/PhotoSeller.java → ...merce/application/domain/PhotoSeller.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
2 changes: 1 addition & 1 deletion
2
...unsri/ecommerce/domain/models/Seller.java → .../ecommerce/application/domain/Seller.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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/unsri/ecommerce/application/entities/EnumStateCode.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,12 @@ | ||
package com.unsri.ecommerce.application.entities; | ||
|
||
public enum EnumStateCode { | ||
SUCCESS("SUCCESS"), | ||
ERROR("ERROR"); | ||
|
||
public final String label; | ||
|
||
private EnumStateCode(String label) { | ||
this.label = label; | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...erce/domain/models/InventoryResponse.java → ...plication/entities/InventoryResponse.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
Oops, something went wrong.