Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

46 products crud_WIP #49

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
422ad07
Merge pull request #45 from Los-nonos/dev
cristianvena18 Jun 10, 2020
dab3dc3
Fix Product Entity
MartinMontanari Jun 17, 2020
fc09512
Finish StoreProduct Action/Adapter/Schema
MartinMontanari Jun 17, 2020
ff618e8
Fix php docs
MartinMontanari Jun 17, 2020
0eac11f
StoreProductAdapter & fixes in Product
MartinMontanari Jun 18, 2020
28c3a1d
fix stock entity //TODO relations
MartinMontanari Jun 18, 2020
3811ac7
Some fixes in Product and Schemas
MartinMontanari Jun 18, 2020
c003bb4
StoreProduct command and validations
MartinMontanari Jun 18, 2020
29fce4a
Create heroku.yml
cristianvena18 Jun 28, 2020
126ae61
Merge branch 'dev' of github.com:Los-nonos/Gryffindor
cristianvena18 Jun 28, 2020
798ba60
added install dependencies script
cristianvena18 Jun 28, 2020
3120940
lack make change password flow
cristianvena18 Jul 4, 2020
515b808
added find employees flow
cristianvena18 Jul 6, 2020
8ca86d9
added show employees and show employee flow
cristianvena18 Jul 6, 2020
d5244b9
added get customer by id flow
cristianvena18 Jul 7, 2020
862f497
finalizated find customer endpoint
cristianvena18 Jul 7, 2020
ed1b98f
finalizated endpoint index customers
cristianvena18 Jul 7, 2020
09edf5a
modify database and added index orders
cristianvena18 Jul 7, 2020
8ff8f98
added index all orders by dashboard endpoint and init with get detail…
cristianvena18 Jul 7, 2020
0edffae
added find order by uuid endpoint
cristianvena18 Jul 7, 2020
1377a44
added rules from endpoints to has make
cristianvena18 Jul 7, 2020
e9e6676
added change password endpoint
cristianvena18 Jul 8, 2020
f400d5b
merge with master
cristianvena18 Jul 8, 2020
8e18376
added search endpoint with query builder
cristianvena18 Jul 8, 2020
c896d9f
added rules in search
cristianvena18 Jul 8, 2020
14df915
finalizated query builder
cristianvena18 Jul 9, 2020
daf71cd
removed commented code
cristianvena18 Jul 9, 2020
d94585f
merge with search branch
cristianvena18 Jul 9, 2020
44addbc
added repositories
cristianvena18 Jul 9, 2020
9aa4c89
It's doesn't shows Welcome view, I'm trying fix It
MartinMontanari Jul 10, 2020
359ebab
Persist products?
MartinMontanari Jul 12, 2020
1db2182
Fix StoreProductSchema validation
MartinMontanari Jul 12, 2020
4ba26de
fix error in adapter/command
cristianvena18 Jul 12, 2020
70ec243
added mock to list products in shopping cart, but lack real implement…
cristianvena18 Jul 12, 2020
1d7e724
Merge branch '46_Products_CRUD' of github.com:Los-nonos/Gryffindor in…
MartinMontanari Jul 12, 2020
7327e1d
Add Provider & PurchaseOrder entities
MartinMontanari Jul 12, 2020
387da9a
Fix Product entity
MartinMontanari Jul 12, 2020
36c00d8
Fix StoreProduct Adapter&Command
MartinMontanari Jul 13, 2020
46ad939
Add ProviderRepository, Mapping & ProviderRepositoryInterfaces
MartinMontanari Jul 13, 2020
bfb9877
Fix name ProviderRepsotitoryInterface
MartinMontanari Jul 13, 2020
4426e0f
ProviderRepository Persist method
MartinMontanari Jul 13, 2020
a02fa29
Add ProviderService
MartinMontanari Jul 13, 2020
16399a4
Add Provider mapping
MartinMontanari Jul 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .env.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=DB_PORT=3306
DB_DATABASE=apizeep
DB_USERNAME=test
DB_PASSWORD=test

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
SENDGRID_API_KEY=

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

JWT_SECRET=
3 changes: 2 additions & 1 deletion app/Exceptions/InvalidBodyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

use Presentation\Http\Enums\HttpCodes;

class InvalidBodyException extends BasePresentationException
class InvalidBodyException extends \Exception
MartinMontanari marked this conversation as resolved.
Show resolved Hide resolved
{
private array $messages;

/**
* InvalidBodyException constructor.
* @param $responseMessage
* @param $statusCode
*/
public function __construct($responseMessage = ""|[])
{
Expand Down
28 changes: 17 additions & 11 deletions application/Commands/Command/Auth/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,38 @@

class ChangePasswordCommand implements CommandInterface
{
private string $password;
private string $email;
private int $id;
private string $oldPassword;
private string $newPassword;

public function __construct($id, $oldPassword, $newPassword)
{
$this->id = $id;
$this->oldPassword = $oldPassword;
$this->newPassword = $newPassword;
}

/**
* ChangePasswordCommand constructor.
* @param string $email
* @param string $password
* @return int
*/
public function __construct(string $email, string $password)
public function getId(): int
{
$this->password = $password;
return $this->id;
}

/**
* @return string
*/
public function getEmail(): string
public function getOldPassword(): string
{
return $this->email;
return $this->oldPassword;
}

/**
* @return string
*/
public function getPassword(): string
public function getNewPassword(): string
{
return $this->password;
return $this->newPassword;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php


namespace Application\Commands\Command\Auth;


use Infrastructure\CommandBus\Command\CommandInterface;

class ChangePasswordFromRecoveryCommand implements CommandInterface
{
private string $password;
private string $email;

/**
* ChangePasswordCommand constructor.
* @param string $email
* @param string $password
*/
public function __construct(string $email, string $password)
{
$this->password = $password;
}

/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}

/**
* @return string
*/
public function getPassword(): string
{
return $this->password;
}
}
100 changes: 100 additions & 0 deletions application/Commands/Command/Products/StoreProductCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php


namespace Application\Commands\Command\Products;


use Infrastructure\CommandBus\Command\CommandInterface;

class StoreProductCommand implements CommandInterface
{

private string $name;
private string $description;
private float $price;
private array $categories;
private int $stock;
private float $taxes;
private array $brands;
private array $characteristics;
private string $purchaseOrder;
private int $providerId;


public function __construct
(
string $name,
string $description,
float $price,
array $categories,
int $stock,
float $taxes,
array $brands,
array $characteristics,
string $purchaseOrder,
int $providerId
)
{
$this->name = $name;
$this->description = $description;
$this->price = $price;
$this->categories = $categories;
$this->stock = $stock;
$this->taxes = $taxes;
$this->brands = $brands;
$this->characteristics = $characteristics;
$this->purchaseOrder = $purchaseOrder;
$this->providerId = $providerId;
}

public function getName(): string
{
return $this->name;
}

public function getDescription(): string
{
return $this->description;
}

public function getPrice(): float
{
return $this->price;
}

public function getCategories(): array
{
return $this->categories;
}

public function getStock(): int
{
return $this->stock;
}

public function getTaxes(): float
{
return $this->taxes;
}

public function getBrands() : array
{
return $this->brands;
}

public function getCharacteristics() : array
{
return $this->characteristics;
}

public function getPurchaseNumber() : string
{
return $this->purchaseOrder;
}

public function getProviderId() : int
{
return $this->providerId;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php


namespace Application\Commands\Handler\Auth;


use Application\Commands\Command\Auth\ChangePasswordFromRecoveryCommand;
use Application\Services\Hash\HashServiceInterface;
use Application\Services\Users\UserServiceInterface;
use Infrastructure\CommandBus\Handler\HandlerInterface;

class ChangePasswordFromRecoveryHandler implements HandlerInterface
{
private UserServiceInterface $userService;

private HashServiceInterface $hashService;

public function __construct(
UserServiceInterface $userService,
HashServiceInterface $hashService
)
{
$this->userService = $userService;
$this->hashService = $hashService;
}

/**
* @param ChangePasswordFromRecoveryCommand $command
*/
public function handle($command): void
{
$user = $this->userService->findOneByEmailOrFail($command->getEmail());

$user->setPassword($this->hashService->make($command->getPassword()));

$this->userService->persist($user);
}
}
18 changes: 15 additions & 3 deletions application/Commands/Handler/Auth/ChangePasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@


use Application\Commands\Command\Auth\ChangePasswordCommand;
use Application\Exceptions\PasswordNotMatch;
use Application\Services\Hash\HashServiceInterface;
use Application\Services\Users\UserServiceInterface;
use Infrastructure\CommandBus\Command\CommandInterface;
use Infrastructure\CommandBus\Handler\HandlerInterface;

class ChangePasswordHandler implements HandlerInterface
{
/**
* @var UserServiceInterface
*/
private UserServiceInterface $userService;

/**
* @var HashServiceInterface
*/
private HashServiceInterface $hashService;

public function __construct(
Expand All @@ -26,12 +33,17 @@ public function __construct(

/**
* @param ChangePasswordCommand $command
* @throws PasswordNotMatch
*/
public function handle($command): void
{
$user = $this->userService->findOneByEmailOrFail($command->getEmail());
$user = $this->userService->findOneByIdOrFail($command->getId());

if(!$this->hashService->check($command->getOldPassword(), $user->getPassword())) {
throw new PasswordNotMatch();
}

$user->setPassword($this->hashService->make($command->getPassword()));
$user->setPassword($this->hashService->make($command->getNewPassword()));

$this->userService->persist($user);
}
Expand Down
54 changes: 54 additions & 0 deletions application/Commands/Handler/Products/StoreProductHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php


namespace Application\Commands\Handler\Products;


use Application\Commands\Command\Products\StoreProductCommand;
use Domain\Entities\Order;
use Domain\Entities\Product;
use Domain\Entities\Provider;
use Domain\Entities\PurchaseOrder;
use Domain\Entities\Stock;
use Domain\Interfaces\Services\Products\ProductServiceInterface;
use Infrastructure\CommandBus\Handler\HandlerInterface;

class StoreProductHandler implements HandlerInterface
{
private ProductServiceInterface $productService;
public function __construct
(
ProductServiceInterface $productServiceInterface
)
{
$this->productService = $productServiceInterface;
}

/**
* @param StoreProductCommand $command
*/
public function handle($command) : void
{
$product = new Product();
$product->setTitle($command->getName());
$product->setDescription($command->getDescription());
$product->setPrice($command->getPrice());
$stock = new Stock();
$stock->setQuantity($command->getStock());
$stock->setRemanentQuantity($command->getStock());
$product->setStock($stock);
$product->setTaxes($command->getTaxes());
//$product->setBrand($command->getBrands()); Corregir BRAND
$purchase = new PurchaseOrder();
$purchase->setPurchaseNumber($command->getPurchaseNumber());
$product->setPurchaseOrder($purchase);
$provider = new Provider();
$provider->setName($command->getProviderId());
$product->setProvider($provider);


$this->productService->persist($product);

}

}
Loading