Backup
Some checks failed
Gitea Actions / Run-Tests-On-Arm64 (push) Failing after 8m16s
Gitea Actions / Run-Tests-On-Amd64 (push) Failing after 12m40s
Gitea Actions / Merge (push) Successful in 5m13s

This commit is contained in:
Thomas Peterson 2025-09-04 16:59:41 +02:00
parent 1199cc6901
commit 9aa0056bac
23 changed files with 502 additions and 422 deletions

View File

@ -8,8 +8,11 @@ use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent; use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response; use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag; use OpenApi\Attributes\Tag;
use PSC\Shop\MediaBundle\Document\Media as PSCMedia;
use PSC\Shop\MediaBundle\Model\Media; use PSC\Shop\MediaBundle\Model\Media;
use PSC\Shop\MediaBundle\Transformer\Media as AliasedMedia;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
class One extends AbstractController class One extends AbstractController
@ -17,13 +20,19 @@ class One extends AbstractController
public function __construct( public function __construct(
private readonly DocumentManager $dm, private readonly DocumentManager $dm,
private readonly PaginatorInterface $paginator, private readonly PaginatorInterface $paginator,
private readonly AliasedMedia $mediaTransformer,
) {} ) {}
#[Response(response: 200, description: 'get media', content: new JsonContent(ref: new Model(type: Media::class)))] #[Response(response: 200, description: 'get media', content: new JsonContent(ref: new Model(type: Media::class)))]
#[Route(path: '/media/{uuid}', methods: ['GET'])] #[Route(path: '/{uuid}', methods: ['GET'])]
#[Tag('Media')] #[Tag('Media')]
public function one(string $uuid): string public function one(string $uuid): SymfonyResponse
{ {
return $this->json(new Media()); $media = $this->dm->getRepository(PSCMedia::class)->find($uuid);
$model = new Media();
$this->mediaTransformer->fromDb($model, $media);
return $this->json($model);
} }
} }

View File

@ -12,26 +12,23 @@ use PSC\Shop\VoucherBundle\Service\Calc as CalcVoucher;
use PSC\Shop\VoucherBundle\Transformer\Voucher as PSCVoucher; use PSC\Shop\VoucherBundle\Transformer\Voucher as PSCVoucher;
use PSC\System\PluginBundle\Service\ProductType; use PSC\System\PluginBundle\Service\ProductType;
class Calc readonly class Calc
{ {
public function __construct( public function __construct(
private readonly Price $pricePayment, private Price $pricePayment,
private readonly Shop $shopTransformer, private Shop $shopTransformer,
private readonly \PSC\Shop\ShippingBundle\Service\Price $priceShipping, private \PSC\Shop\ShippingBundle\Service\Price $priceShipping,
private readonly ProductType $productTypeRegistry, private ProductType $productTypeRegistry,
private readonly Shipping $shippingTransformer, private Shipping $shippingTransformer,
private readonly Payment $paymentTransformer, private Payment $paymentTransformer,
private readonly VatCalc $vatCalcService, private VatCalc $vatCalcService,
private readonly CalcVoucher $voucherCalcService, private CalcVoucher $voucherCalcService,
private readonly PSCVoucher $voucherTransformer private PSCVoucher $voucherTransformer,
) { ) {}
}
public function calcOrder(\PSC\Shop\OrderBundle\Model\Base $order) public function calcOrder(\PSC\Shop\OrderBundle\Model\Base $order)
{ {
if ($order->getShop()->getUuid() != '') {
if ($order->getShop()->getUuid() != "") {
$this->shopTransformer->parseModel($order->getShop()); $this->shopTransformer->parseModel($order->getShop());
} }
$priceNet = Money::ofMinor(0, 'EUR'); $priceNet = Money::ofMinor(0, 'EUR');
@ -45,19 +42,33 @@ class Calc
$priceVat = $priceVat->plus(Money::ofMinor($order->getPayment()->getCalcPrice()->vat, 'EUR')); $priceVat = $priceVat->plus(Money::ofMinor($order->getPayment()->getCalcPrice()->vat, 'EUR'));
$priceGross = $priceGross->plus(Money::ofMinor($order->getPayment()->getCalcPrice()->gross, 'EUR')); $priceGross = $priceGross->plus(Money::ofMinor($order->getPayment()->getCalcPrice()->gross, 'EUR'));
$order->setPaymentCosts(Money::ofMinor($order->getPayment()->getCalcPrice()->net, 'EUR')->getMinorAmount()->toInt()); $order->setPaymentCosts(
Money::ofMinor($order->getPayment()->getCalcPrice()->net, 'EUR')->getMinorAmount()->toInt(),
);
$order->addTax($order->getPayment()->getCalcPrice()->tax); $order->addTax($order->getPayment()->getCalcPrice()->tax);
$this->shippingTransformer->parseModel($order->getShipping()); $this->shippingTransformer->parseModel($order->getShipping());
$this->priceShipping->getPrice($order->getShipping(), $order->getNet(), $order->getWeight(), (string)$order->getDeliveryAddress()->getCountry(), (int)$order->getDeliveryAddress()->getZip()); $this->priceShipping->getPrice(
$order->getShipping(),
$order->getNet(),
$order->getWeight(),
(string) $order->getDeliveryAddress()->getCountry(),
(int) $order->getDeliveryAddress()->getZip(),
);
$priceNet = $priceNet->plus(Money::ofMinor($order->getShipping()->getCalcPrice()->net, 'EUR')); $priceNet = $priceNet->plus(Money::ofMinor($order->getShipping()->getCalcPrice()->net, 'EUR'));
$priceVat = $priceVat->plus(Money::ofMinor($order->getShipping()->getCalcPrice()->vat, 'EUR')); $priceVat = $priceVat->plus(Money::ofMinor($order->getShipping()->getCalcPrice()->vat, 'EUR'));
$priceGross = $priceGross->plus(Money::ofMinor($order->getShipping()->getCalcPrice()->gross, 'EUR')); $priceGross = $priceGross->plus(Money::ofMinor($order->getShipping()->getCalcPrice()->gross, 'EUR'));
$order->setShippingCosts(Money::ofMinor($order->getShipping()->getCalcPrice()->net, 'EUR')->getMinorAmount()->toInt()); $order->setShippingCosts(
Money::ofMinor($order->getShipping()->getCalcPrice()->net, 'EUR')->getMinorAmount()->toInt(),
);
$order->addTax($order->getShipping()->getCalcPrice()->tax); $order->addTax($order->getShipping()->getCalcPrice()->tax);
foreach ($order->getPositions() as $position) { foreach ($order->getPositions() as $position) {
$position->getProduct()->setShopUuid($order->getShop()->getUuid()); $position->getProduct()->setShopUuid($order->getShop()->getUuid());
if ($this->productTypeRegistry->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())) { if (
$specialProductTransformer = $this->productTypeRegistry->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())->getProducer(); $this->productTypeRegistry->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())
) {
$specialProductTransformer = $this->productTypeRegistry
->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())
->getProducer();
if ($specialProductTransformer) { if ($specialProductTransformer) {
if ($specialProductTransformer instanceof ICalcNeedContact) { if ($specialProductTransformer instanceof ICalcNeedContact) {
$specialProductTransformer->setContact($order->getContact()); $specialProductTransformer->setContact($order->getContact());

View File

@ -27,15 +27,21 @@ class Position extends Base
private ProductType $productTypeRegistry; private ProductType $productTypeRegistry;
#[\Symfony\Contracts\Service\Attribute\Required] #[\Symfony\Contracts\Service\Attribute\Required]
public function setProductService(\PSC\Shop\ProductBundle\Service\Product $productService, ProductType $productTypeRegistry, \PSC\Shop\ProductBundle\Hydrate\Product $productHydrate) public function setProductService(
{ \PSC\Shop\ProductBundle\Service\Product $productService,
ProductType $productTypeRegistry,
\PSC\Shop\ProductBundle\Hydrate\Product $productHydrate,
) {
$this->productService = $productService; $this->productService = $productService;
$this->productTypeRegistry = $productTypeRegistry; $this->productTypeRegistry = $productTypeRegistry;
$this->productHydrate = $productHydrate; $this->productHydrate = $productHydrate;
} }
public function toDb(\PSC\Shop\OrderBundle\Model\Order\Position $position, Orderpos $positionEntity, \PSC\Shop\EntityBundle\Document\Position $positionDoc): void public function toDb(
{ \PSC\Shop\OrderBundle\Model\Order\Position $position,
Orderpos $positionEntity,
\PSC\Shop\EntityBundle\Document\Position $positionDoc,
): void {
$positionEntity->setPos($position->getPos()); $positionEntity->setPos($position->getPos());
$positionEntity->setUuid($position->getUuid()); $positionEntity->setUuid($position->getUuid());
$positionEntity->setTyp($position->getProduct()->getSpecialProductTypeObject()->getTyp()); $positionEntity->setTyp($position->getProduct()->getSpecialProductTypeObject()->getTyp());
@ -50,15 +56,16 @@ class Position extends Base
$positionEntity->setPriceAllSteuer($position->getPrice()->getAllVat() / 100); $positionEntity->setPriceAllSteuer($position->getPrice()->getAllVat() / 100);
$positionEntity->setPriceOneSteuer($position->getPrice()->getVat() / 100); $positionEntity->setPriceOneSteuer($position->getPrice()->getVat() / 100);
$positionEntity->setResalePrice(0); $positionEntity->setResalePrice(0);
$positionEntity->setBasketField1((string)$position->getBasketField1()); $positionEntity->setBasketField1((string) $position->getBasketField1());
$positionEntity->setBasketField2((string)$position->getBasketField2()); $positionEntity->setBasketField2((string) $position->getBasketField2());
if ($position->getProduct()->getUuid()) { if ($position->getProduct()->getUuid()) {
/** /**
* @var Product $product * @var Product $product
*/ */
$product = $this->entityManager $product = $this->entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Product')->findOneBy(array('uuid' => $position->getProduct()->getUuid())); ->getRepository('PSC\Shop\EntityBundle\Entity\Product')
->findOneBy(['uuid' => $position->getProduct()->getUuid()]);
if ($position->isCopyProduct()) { if ($position->isCopyProduct()) {
$product = $this->productService->copy($product, false, true); $product = $this->productService->copy($product, false, true);
@ -69,7 +76,7 @@ class Position extends Base
/** /**
* DOC * DOC
*/ */
$temp = []; $temp = [];
foreach ($position->getAdditionalInfos() as $key => $info) { foreach ($position->getAdditionalInfos() as $key => $info) {
if (is_object($info) && method_exists($info, 'asArray')) { if (is_object($info) && method_exists($info, 'asArray')) {
@ -81,13 +88,19 @@ class Position extends Base
$positionDoc->setAdditionalInfos($temp); $positionDoc->setAdditionalInfos($temp);
$positionDoc->setCustomerInfo($position->getCustomerInfo()); $positionDoc->setCustomerInfo($position->getCustomerInfo());
$positionDoc->setExternalOrderNumber($position->getExternalOrderNumber()); $positionDoc->setExternalOrderNumber($position->getExternalOrderNumber());
$positionDoc->setSpecialProductTypeObject($position->getProduct()->getSpecialProductTypeObject()->getPositionData()); $positionDoc->setSpecialProductTypeObject(
$position->getProduct()->getSpecialProductTypeObject()->getPositionData(),
);
/** /**
* Plugin Special Savings * Plugin Special Savings
*/ */
if ($this->productTypeRegistry->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())) { if (
$specialProductTransformer = $this->productTypeRegistry->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())->getPositionProductTransformer(); $this->productTypeRegistry->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())
) {
$specialProductTransformer = $this->productTypeRegistry
->getProductType($position->getProduct()->getSpecialProductTypeObject()->getTyp())
->getPositionProductTransformer();
$specialProductTransformer->toDb($position, $positionEntity, $positionDoc); $specialProductTransformer->toDb($position, $positionEntity, $positionDoc);
} else { } else {
$position->getProduct()->setSpecialProductTypeObject(new DummyProductTypeObject()); $position->getProduct()->setSpecialProductTypeObject(new DummyProductTypeObject());
@ -95,50 +108,49 @@ class Position extends Base
$positionEntity->setWeight($position->getWeight()); $positionEntity->setWeight($position->getWeight());
} }
public function fromDb(\PSC\Shop\OrderBundle\Model\Order\Position $position, Orderpos $pos, \PSC\Shop\EntityBundle\Document\Position $positionDoc): void public function fromDb(
{ \PSC\Shop\OrderBundle\Model\Order\Position $position,
Orderpos $pos,
\PSC\Shop\EntityBundle\Document\Position $positionDoc,
): void {
$position->setProduct(new \PSC\Shop\ProductBundle\Model\Product()); $position->setProduct(new \PSC\Shop\ProductBundle\Model\Product());
if ($pos->getProduct()) { if ($pos->getProduct()) {
$position->setProduct($this->productHydrate->hydrateToModel($pos->getProduct())); $position->setProduct($this->productHydrate->hydrateToModel($pos->getProduct()));
$tax = new Tax(); $tax = new Tax();
$tax->setName((int)$pos->getProduct()->getMwert() * 100); $tax->setName(((int) $pos->getProduct()->getMwert()) * 100);
$tax->setBasisAmount((int)$pos->getPriceAllNetto() * 100); $tax->setBasisAmount(((int) $pos->getPriceAllNetto()) * 100);
$tax->setCalculatedAmount((int)$pos->getPriceAllSteuer() * 100); $tax->setCalculatedAmount(((int) $pos->getPriceAllSteuer()) * 100);
$position->getPrice()->setTax($tax); $position->getPrice()->setTax($tax);
} else { } else {
$tax = new Tax(); $tax = new Tax();
$position->getPrice()->setTax($tax); $position->getPrice()->setTax($tax);
} }
$position->setPos($pos->getPos()); $position->setPos($pos->getPos());
$position->setUuid($pos->getUuid()); $position->setUuid($pos->getUuid());
$position->setUid($pos->getId()); $position->setUid($pos->getId());
$position->getPrice()->setCount($pos->getCount()); $position->getPrice()->setCount($pos->getCount());
$position->getPrice()->setNet((int)($pos->getPriceOneNetto() * 100)); $position->getPrice()->setNet((int) ($pos->getPriceOneNetto() * 100));
$position->getPrice()->setAllNet((int)($pos->getPriceAllNetto() * 100)); $position->getPrice()->setAllNet((int) ($pos->getPriceAllNetto() * 100));
$position->getPrice()->setVat((int)($pos->getPriceOneSteuer() * 100)); $position->getPrice()->setVat((int) ($pos->getPriceOneSteuer() * 100));
$position->getPrice()->setAllVat((int)($pos->getPriceAllSteuer() * 100)); $position->getPrice()->setAllVat((int) ($pos->getPriceAllSteuer() * 100));
$position->getPrice()->setGross((int)($pos->getPriceOneBrutto() * 100)); $position->getPrice()->setGross((int) ($pos->getPriceOneBrutto() * 100));
$position->getPrice()->setAllGross((int)($pos->getPriceAllBrutto() * 100)); $position->getPrice()->setAllGross((int) ($pos->getPriceAllBrutto() * 100));
$position->setReOrder($positionDoc->isReOrder()); $position->setReOrder($positionDoc->isReOrder());
$position->setReOrderOrder($positionDoc->getReOrderOrder()); $position->setReOrderOrder($positionDoc->getReOrderOrder());
$position->setReOrderPos($positionDoc->getReOrderPos()); $position->setReOrderPos($positionDoc->getReOrderPos());
$position->setStatus($pos->getStatus()); $position->setStatus($pos->getStatus());
$position->setData($pos->getData()); $position->setData($pos->getData());
$position->setDownloadAllowed($positionDoc->isDownloadAllowed()); $position->setDownloadAllowed($positionDoc->isDownloadAllowed());
$position->setBasketField1((string)$pos->getBasketField1()); $position->setBasketField1((string) $pos->getBasketField1());
$position->setBasketField2((string)$pos->getBasketField2()); $position->setBasketField2((string) $pos->getBasketField2());
$position->setLayouterMode((int)$pos->getLayouterMode()); $position->setLayouterMode((int) $pos->getLayouterMode());
$position->setWeight((int)$pos->getWeight()); $position->setWeight((int) $pos->getWeight());
$position->setUploadMode((string)$positionDoc->getUploadMode()); $position->setUploadMode((string) $positionDoc->getUploadMode());
/** /**
* @var \PSC\Shop\EntityBundle\Document\Tracking $tracking * @var \PSC\Shop\EntityBundle\Document\Tracking $tracking
*/ */
foreach ($positionDoc->getTrackings() as $tracking) { foreach ($positionDoc->getTrackings() as $tracking) {
$tr = new Tracking(); $tr = new Tracking();
$tr->setShippingProvider($tracking->getShippingProvider()); $tr->setShippingProvider($tracking->getShippingProvider());
@ -149,20 +161,20 @@ class Position extends Base
/** /**
* @var \PSC\Shop\EntityBundle\Entity\Upload $up * @var \PSC\Shop\EntityBundle\Entity\Upload $up
*/ */
foreach ($pos->getUploads() as $up) { foreach ($pos->getUploads() as $up) {
$upload = new Upload(); $upload = new Upload();
$upload->setFileName((string)$up->getName()); $upload->setFileName((string) $up->getName());
$upload->setChunkTitle((string)$up->getChunktitle()); $upload->setChunkTitle((string) $up->getChunktitle());
$upload->setTyp((string)$up->getTyp()); $upload->setTyp((string) $up->getTyp());
$upload->setUuid((string)$up->getUuid()); $upload->setUuid((string) $up->getUuid());
$upload->setPath((string)$up->getPath()); $upload->setPath((string) $up->getPath());
$position->addUpload($upload); $position->addUpload($upload);
} }
/** /**
* DOC * DOC
*/ */
if ($positionDoc->getExternalOrderNumber()) { if ($positionDoc->getExternalOrderNumber()) {
$position->setExternalOrderNumber($positionDoc->getExternalOrderNumber()); $position->setExternalOrderNumber($positionDoc->getExternalOrderNumber());
@ -170,18 +182,22 @@ class Position extends Base
if (is_array($positionDoc->getAdditionalInfos())) { if (is_array($positionDoc->getAdditionalInfos())) {
$position->setAdditionalInfos($positionDoc->getAdditionalInfos()); $position->setAdditionalInfos($positionDoc->getAdditionalInfos());
} }
$position->setCustomerInfo((string)$positionDoc->getCustomerInfo()); $position->setCustomerInfo((string) $positionDoc->getCustomerInfo());
if ($pos->getProduct()) { if ($pos->getProduct()) {
if ($this->productTypeRegistry->getProductType($pos->getProduct()->getType())) { if ($this->productTypeRegistry->getProductType($pos->getProduct()->getType())) {
$specialProductTransformer = $this->productTypeRegistry->getProductType($pos->getProduct()->getType())->getPositionProductTransformer(); $specialProductTransformer = $this->productTypeRegistry
->getProductType($pos->getProduct()->getType())
->getPositionProductTransformer();
$specialProductTransformer->fromDb($position, $pos, $positionDoc); $specialProductTransformer->fromDb($position, $pos, $positionDoc);
} else { } else {
$position->getProduct()->setSpecialProductTypeObject(new DummyProductTypeObject()); $position->getProduct()->setSpecialProductTypeObject(new DummyProductTypeObject());
} }
} else { } else {
if ($this->productTypeRegistry->getProductType($pos->getTyp())) { if ($this->productTypeRegistry->getProductType($pos->getTyp())) {
$specialProductTransformer = $this->productTypeRegistry->getProductType($pos->getTyp())->getPositionProductTransformer(); $specialProductTransformer = $this->productTypeRegistry
->getProductType($pos->getTyp())
->getPositionProductTransformer();
$specialProductTransformer->fromDb($position, $pos, $positionDoc); $specialProductTransformer->fromDb($position, $pos, $positionDoc);
} else { } else {
$position->getProduct()->setSpecialProductTypeObject(new DummyProductTypeObject()); $position->getProduct()->setSpecialProductTypeObject(new DummyProductTypeObject());

View File

@ -14,21 +14,30 @@ use PSC\Shop\ProductBundle\Model\OriginalProduct;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class Product readonly class Product
{ {
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly DocumentManager $documentManager, private readonly \PSC\Shop\MediaBundle\Transformer\Media $mediaTransformer) public function __construct(
{ private EntityManagerInterface $entityManager,
private DocumentManager $documentManager,
private \PSC\Shop\MediaBundle\Transformer\Media $mediaTransformer,
) {}
public function toDb(
\PSC\Shop\ProductBundle\Model\Product $product,
\PSC\Shop\EntityBundle\Entity\Product $productEntity,
\PSC\Shop\EntityBundle\Document\Product $productDoc,
): void {
} }
public function toDb(\PSC\Shop\ProductBundle\Model\Product $product, \PSC\Shop\EntityBundle\Entity\Product $productEntity, \PSC\Shop\EntityBundle\Document\Product $productDoc): void public function fromDb(
{ \PSC\Shop\ProductBundle\Model\Product $product,
\PSC\Shop\EntityBundle\Entity\Product $productEntity,
} null|\PSC\Shop\EntityBundle\Document\Product $productDoc = null,
): void {
public function fromDb(\PSC\Shop\ProductBundle\Model\Product $product, \PSC\Shop\EntityBundle\Entity\Product $productEntity, ?\PSC\Shop\EntityBundle\Document\Product $productDoc = null): void if ($productDoc === null) {
{ $productDoc = $this->documentManager
if($productDoc === null) { ->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)
$productDoc = $this->documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)->findOneBy(['uid' => $productEntity->getUid()]); ->findOneBy(['uid' => $productEntity->getUid()]);
} }
$product->setUid($productEntity->getUID()); $product->setUid($productEntity->getUID());
@ -36,61 +45,68 @@ class Product
$product->setUuid($productEntity->getUUID()); $product->setUuid($productEntity->getUUID());
$product->setLanguage($productEntity->getLanguage()); $product->setLanguage($productEntity->getLanguage());
$product->setLangData($productEntity->getLangData()); $product->setLangData($productEntity->getLangData());
$product->setTextArt((string)$productEntity->getTextArt()); $product->setTextArt((string) $productEntity->getTextArt());
$product->setPrice((int)$productEntity->getPrice()); $product->setPrice((int) $productEntity->getPrice());
$product->setPackageFormat($productEntity->getPackageFormat()); $product->setPackageFormat($productEntity->getPackageFormat());
$product->setDescription((string)$productEntity->getDescription()); $product->setDescription((string) $productEntity->getDescription());
$product->setShopUuid($productEntity->getShop()->getUuid()); $product->setShopUuid($productEntity->getShop()->getUuid());
$product->setNrIntern((string)$productEntity->getNrIntern()); $product->setNrIntern((string) $productEntity->getNrIntern());
$product->setNrExtern((string)$productEntity->getNrExtern()); $product->setNrExtern((string) $productEntity->getNrExtern());
$product->setCustom1((string)$productDoc->getCustom1()); $product->setCustom1((string) $productDoc->getCustom1());
$product->setCustom2((string)$productDoc->getCustom2()); $product->setCustom2((string) $productDoc->getCustom2());
$product->setCustom3((string)$productDoc->getCustom3()); $product->setCustom3((string) $productDoc->getCustom3());
$product->setCustom4((string)$productDoc->getCustom4()); $product->setCustom4((string) $productDoc->getCustom4());
$product->setCustom5((string)$productDoc->getCustom5()); $product->setCustom5((string) $productDoc->getCustom5());
$product->setCustom6((string)$productDoc->getCustom6()); $product->setCustom6((string) $productDoc->getCustom6());
$product->setCustom7((string)$productDoc->getCustom7()); $product->setCustom7((string) $productDoc->getCustom7());
$product->setCustom8((string)$productDoc->getCustom8()); $product->setCustom8((string) $productDoc->getCustom8());
$product->setCustom9((string)$productDoc->getCustom9()); $product->setCustom9((string) $productDoc->getCustom9());
$product->setCustom10((string)$productDoc->getCustom10()); $product->setCustom10((string) $productDoc->getCustom10());
if($productDoc->getUploadProvidedFile() != "") { if ($productDoc->getUploadProvidedFile() != '') {
$mediaDoc = $this->documentManager->getRepository(Media::class)->find(new ObjectId($productDoc->getUploadProvidedFile())); $mediaDoc = $this->documentManager
if($mediaDoc) { ->getRepository(Media::class)
->find(new ObjectId($productDoc->getUploadProvidedFile()));
if ($mediaDoc) {
$media = new \PSC\Shop\MediaBundle\Model\Media(); $media = new \PSC\Shop\MediaBundle\Model\Media();
$this->mediaTransformer->fromDb($media, $mediaDoc); $this->mediaTransformer->fromDb($media, $mediaDoc);
$product->setUploadProvidedFile($media); $product->setUploadProvidedFile($media);
} }
} }
if ($productEntity->getImage1() != "") { if ($productEntity->getImage1() != '') {
$file1 = $this->entityManager $file1 = $this->entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Image')->findOneBy(['uid' => $productEntity->getImage1()]); ->getRepository('PSC\Shop\EntityBundle\Entity\Image')
->findOneBy(['uid' => $productEntity->getImage1()]);
if ($file1) { if ($file1) {
$media = new \PSC\Shop\MediaBundle\Model\Media(); $media = new \PSC\Shop\MediaBundle\Model\Media();
$media->setUrl($file1->getPath()); $media->setUrl($file1->getPath());
$product->setImage1($media); $product->setImage1($media);
}else{ } else {
$mediaDoc = $this->documentManager->getRepository(Media::class)->find(new ObjectId($productEntity->getImage1())); $mediaDoc = $this->documentManager
if($mediaDoc) { ->getRepository(Media::class)
->find(new ObjectId($productEntity->getImage1()));
if ($mediaDoc) {
$media = new \PSC\Shop\MediaBundle\Model\Media(); $media = new \PSC\Shop\MediaBundle\Model\Media();
$this->mediaTransformer->fromDb($media, $mediaDoc); $this->mediaTransformer->fromDb($media, $mediaDoc);
$product->setImage1($media); $product->setImage1($media);
} }
} }
} }
if ($productEntity->getImage2() != "") { if ($productEntity->getImage2() != '') {
$file2 = $this->entityManager $file2 = $this->entityManager
->getRepository('PSC\Shop\EntityBundle\Entity\Image')->findOneBy(['uid' => $productEntity->getImage2()]); ->getRepository('PSC\Shop\EntityBundle\Entity\Image')
->findOneBy(['uid' => $productEntity->getImage2()]);
if ($file2) { if ($file2) {
$media = new \PSC\Shop\MediaBundle\Model\Media(); $media = new \PSC\Shop\MediaBundle\Model\Media();
$media->setUrl($file2->getPath()); $media->setUrl($file2->getPath());
$product->setImage2($media); $product->setImage2($media);
}else{ } else {
$mediaDoc = $this->documentManager->getRepository(Media::class)->find(new ObjectId($productEntity->getImage2())); $mediaDoc = $this->documentManager
if($mediaDoc) { ->getRepository(Media::class)
->find(new ObjectId($productEntity->getImage2()));
if ($mediaDoc) {
$media = new \PSC\Shop\MediaBundle\Model\Media(); $media = new \PSC\Shop\MediaBundle\Model\Media();
$this->mediaTransformer->fromDb($media, $mediaDoc); $this->mediaTransformer->fromDb($media, $mediaDoc);
$product->setImage2($media); $product->setImage2($media);
@ -98,11 +114,13 @@ class Product
} }
} }
if($productEntity->getOriginalProduct() != 0) { if ($productEntity->getOriginalProduct() != 0) {
/** @var PSCProduct $subProduct */ /** @var PSCProduct $subProduct */
$subProduct = $this->entityManager->getRepository(\PSC\Shop\EntityBundle\Entity\Product::class)->find($productEntity->getOriginalProduct()); $subProduct = $this->entityManager
->getRepository(\PSC\Shop\EntityBundle\Entity\Product::class)
->find($productEntity->getOriginalProduct());
if($subProduct) { if ($subProduct) {
$subProductObj = new OriginalProduct(); $subProductObj = new OriginalProduct();
$subProductObj->setTitle($subProduct->getTitle()); $subProductObj->setTitle($subProduct->getTitle());
$subProductObj->setUuid($subProduct->getUUID()); $subProductObj->setUuid($subProduct->getUUID());
@ -111,6 +129,5 @@ class Product
$product->setOriginalProduct($subProductObj); $product->setOriginalProduct($subProductObj);
} }
} }
} }
} }

View File

@ -3,18 +3,20 @@
namespace PSC\Shop\ShippingBundle\Api; namespace PSC\Shop\ShippingBundle\Api;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Shop\EntityBundle\Entity\Shipping; use PSC\Shop\EntityBundle\Entity\Shipping;
use PSC\Shop\ShippingBundle\Dto\All\Output; use PSC\Shop\ShippingBundle\Dto\All\Output;
use PSC\Shop\ShippingBundle\Model\Shipping as PSCShipping; use PSC\Shop\ShippingBundle\Model\Shipping as PSCShipping;
use PSC\System\SettingsBundle\Service\Shop; use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Nelmio\ApiDocBundle\Annotation\Security; use Symfony\Component\Security\Http\Attribute\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
class All extends AbstractController class All extends AbstractController
{ {
@ -24,28 +26,29 @@ class All extends AbstractController
private TokenStorageInterface $tokenStorage; private TokenStorageInterface $tokenStorage;
public function __construct(EntityManagerInterface $entityManager, Shop $shopService, TokenStorageInterface $tokenStorage) public function __construct(
{ EntityManagerInterface $entityManager,
Shop $shopService,
TokenStorageInterface $tokenStorage,
) {
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->shopService = $shopService; $this->shopService = $shopService;
$this->tokenStorage = $tokenStorage; $this->tokenStorage = $tokenStorage;
} }
/** #[Response(
* get all shipments response: 200,
* description: 'get shippments',
* @OA\Response( content: new JsonContent(ref: new Model(type: Output::class)),
* response=200, )]
* description="shipments", #[Tag(name: 'Shipping')]
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\ShippingBundle\Dto\All\Output::class))
* )
* @OA\Tag(name="Shipping")
*/
#[Route(path: '/', methods: ['GET'])] #[Route(path: '/', methods: ['GET'])]
public function all(): JsonResponse public function all(): JsonResponse
{ {
$output = []; $output = [];
$result = $this->entityManager->getRepository(Shipping::class)->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]); $result = $this->entityManager
->getRepository(Shipping::class)
->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]);
foreach ($result as $shipping) { foreach ($result as $shipping) {
$shipObj = new PSCShipping(); $shipObj = new PSCShipping();
$shipObj->setUid($shipping->getUid()); $shipObj->setUid($shipping->getUid());
@ -56,17 +59,13 @@ class All extends AbstractController
return $this->json(new Output($output)); return $this->json(new Output($output));
} }
/** #[Response(
* get all shipments for shop Uuid response: 200,
* description: 'get shippments by shop uuid',
* @OA\Response( content: new JsonContent(ref: new Model(type: Output::class)),
* response=200, )]
* description="shipments", #[Tag(name: 'Shipping')]
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\ShippingBundle\Dto\All\Output::class)) #[Security(name: 'Bearer')]
* )
* @OA\Tag(name="Shipping")
* @Security(name="Bearer")
*/
#[Route(path: '/by/shop/{shopUuid}', methods: ['GET'])] #[Route(path: '/by/shop/{shopUuid}', methods: ['GET'])]
#[IsGranted('ROLE_SHOP')] #[IsGranted('ROLE_SHOP')]
public function byShops(string $shopUuid): JsonResponse public function byShops(string $shopUuid): JsonResponse
@ -85,23 +84,20 @@ class All extends AbstractController
return $this->json(new Output($output)); return $this->json(new Output($output));
} }
/** #[Response(
* get all shipments response: 200,
* description: 'get my shipments',
* @OA\Response( content: new JsonContent(ref: new Model(type: Output::class)),
* response=200, )]
* description="shipments", #[Tag(name: 'Shipping')]
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\ShippingBundle\Dto\All\Output::class)) #[Security(name: 'Bearer')]
* )
* @OA\Tag(name="Shipping")
* @Security(name="Bearer")
*/
#[Route(path: '/my', methods: ['GET'])] #[Route(path: '/my', methods: ['GET'])]
#[IsGranted('ROLE_USER')]
public function my(): JsonResponse public function my(): JsonResponse
{ {
$output = []; $output = [];
$result = $this->entityManager->getRepository(Shipping::class)->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]); $result = $this->entityManager
->getRepository(Shipping::class)
->findBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0]);
foreach ($result as $shipping) { foreach ($result as $shipping) {
$shipObj = new PSCShipping(); $shipObj = new PSCShipping();
$shipObj->setUid($shipping->getUid()); $shipObj->setUid($shipping->getUid());

View File

@ -3,15 +3,17 @@
namespace PSC\Shop\ShippingBundle\Api; namespace PSC\Shop\ShippingBundle\Api;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\EntityBundle\Entity\Shipping as PSCShipping; use PSC\Shop\EntityBundle\Entity\Shipping as PSCShipping;
use PSC\Shop\ShippingBundle\Model\Shipping; use PSC\Shop\ShippingBundle\Model\Shipping;
use PSC\System\SettingsBundle\Service\Shop; use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
class One extends AbstractController class One extends AbstractController
{ {
@ -25,20 +27,18 @@ class One extends AbstractController
$this->shopService = $shopService; $this->shopService = $shopService;
} }
/** #[Response(
* get all shipment response: 200,
* description: 'get one shipping',
* @OA\Response( content: new JsonContent(ref: new Model(type: Shipping::class)),
* response=200, )]
* description="shippings", #[Tag(name: 'Shipping')]
* @OA\JsonContent(ref=@Model(type=\PSC\Shop\ShippingBundle\Model\Shipping::class))
* )
* @OA\Tag(name="Shipping")
*/
#[Route(path: '/{id}', methods: ['GET'])] #[Route(path: '/{id}', methods: ['GET'])]
public function one(string $id): JsonResponse public function one(string $id): JsonResponse
{ {
$result = $this->entityManager->getRepository(PSCShipping::class)->findOneBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0, 'uid' => $id]); $result = $this->entityManager
->getRepository(PSCShipping::class)
->findOneBy(['shop' => $this->shopService->getShopByDomain(), 'private' => 0, 'uid' => $id]);
if ($result) { if ($result) {
$output = new Shipping(); $output = new Shipping();

View File

@ -4,34 +4,33 @@ namespace PSC\System\SettingsBundle\Api\Paper;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Shop\EntityBundle\Entity\Paper; use PSC\Shop\EntityBundle\Entity\Paper;
use PSC\System\SettingsBundle\Service\Shop; use PSC\System\SettingsBundle\Dto\Paper\All\Output;
use PSC\System\SettingsBundle\Model\Paper as PSCPaper;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA; use Symfony\Component\Security\Http\Attribute\IsGranted;
use PSC\System\SettingsBundle\Dto\Paper\All\Output;
use Nelmio\ApiDocBundle\Annotation\Model;
use PSC\System\SettingsBundle\Model\Paper as PSCPaper;
use Nelmio\ApiDocBundle\Annotation\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
class All extends AbstractController class All extends AbstractController
{ {
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly DocumentManager $documentManager) public function __construct(
{ private readonly EntityManagerInterface $entityManager,
} private readonly DocumentManager $documentManager,
/** ) {}
* get all paper
* #[Response(
* @OA\Response( response: 200,
* response=200, description: 'get all paper',
* description="get all paper", content: new JsonContent(ref: new Model(type: Output::class)),
* @OA\JsonContent(ref=@Model(type=\PSC\System\SettingsBundle\Dto\Paper\All\Output::class)) )]
* ) #[Tag(name: 'PaperDB')]
* @OA\Tag(name="PaperDB") #[Security(name: 'ApiKeyAuth')]
* @Security(name="ApiKeyAuth")
*/
#[Route(path: '/paperdb', methods: ['GET'])] #[Route(path: '/paperdb', methods: ['GET'])]
#[IsGranted('ROLE_API')] #[IsGranted('ROLE_API')]
public function all(): JsonResponse public function all(): JsonResponse
@ -42,7 +41,7 @@ class All extends AbstractController
/** @var \PSC\Shop\EntityBundle\Document\Paper $paperDoc */ /** @var \PSC\Shop\EntityBundle\Document\Paper $paperDoc */
$paperDoc = $this->documentManager $paperDoc = $this->documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Paper') ->getRepository('PSC\Shop\EntityBundle\Document\Paper')
->findOneBy(array('uid' => (string)$paper->getId())); ->findOneBy(['uid' => (string) $paper->getId()]);
$paperObj = new PSCPaper(); $paperObj = new PSCPaper();
if ($paperDoc) { if ($paperDoc) {
if ($paperDoc->isPapierTyp1()) { if ($paperDoc->isPapierTyp1()) {
@ -111,9 +110,9 @@ class All extends AbstractController
} }
$paperObj->setId($paper->getId()); $paperObj->setId($paper->getId());
$paperObj->setArtNr($paper->getArtNr()); $paperObj->setArtNr($paper->getArtNr());
$paperObj->setDescription1((string)$paper->getDescription1()); $paperObj->setDescription1((string) $paper->getDescription1());
$paperObj->setDescription2((string)$paper->getDescription2()); $paperObj->setDescription2((string) $paper->getDescription2());
$paperObj->setGrammatur((int)$paper->getGrammatur()); $paperObj->setGrammatur((int) $paper->getGrammatur());
$paperObj->setPrice($paper->getPreis()); $paperObj->setPrice($paper->getPreis());
$output[] = $paperObj; $output[] = $paperObj;
} }

View File

@ -4,34 +4,33 @@ namespace PSC\System\SettingsBundle\Api\Paper;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\EntityBundle\Entity\Paper; use PSC\Shop\EntityBundle\Entity\Paper;
use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use OpenApi\Annotations as OA;
use Nelmio\ApiDocBundle\Annotation\Model;
use PSC\System\SettingsBundle\Model\Paper as PSCPaper; use PSC\System\SettingsBundle\Model\Paper as PSCPaper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Nelmio\ApiDocBundle\Annotation\Security; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
class One extends AbstractController class One extends AbstractController
{ {
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly DocumentManager $documentManager) public function __construct(
{ private readonly EntityManagerInterface $entityManager,
} private readonly DocumentManager $documentManager,
/** ) {}
* get one paper
* #[Response(
* @OA\Response( response: 200,
* response=200, description: 'get one paper',
* description="get one paper", content: new JsonContent(ref: new Model(type: Paper::class)),
* @OA\JsonContent(ref=@Model(type=\PSC\System\SettingsBundle\Model\Paper::class)) )]
* ) #[Tag(name: 'PaperDB')]
* @Security(name="ApiKeyAuth") #[Security(name: 'ApiKeyAuth')]
* @OA\Tag(name="PaperDB")
*/
#[Route(path: '/paperdb/{artNr}', methods: ['GET'])] #[Route(path: '/paperdb/{artNr}', methods: ['GET'])]
#[IsGranted('ROLE_API')] #[IsGranted('ROLE_API')]
public function one(string $artNr): JsonResponse public function one(string $artNr): JsonResponse
@ -41,7 +40,7 @@ class One extends AbstractController
/** @var \PSC\Shop\EntityBundle\Document\Paper $paperDoc */ /** @var \PSC\Shop\EntityBundle\Document\Paper $paperDoc */
$paperDoc = $this->documentManager $paperDoc = $this->documentManager
->getRepository('PSC\Shop\EntityBundle\Document\Paper') ->getRepository('PSC\Shop\EntityBundle\Document\Paper')
->findOneBy(array('uid' => (string)$paper->getId())); ->findOneBy(['uid' => (string) $paper->getId()]);
$paperObj = new PSCPaper(); $paperObj = new PSCPaper();
if ($paperDoc) { if ($paperDoc) {
if ($paperDoc->isPapierTyp1()) { if ($paperDoc->isPapierTyp1()) {
@ -111,12 +110,12 @@ class One extends AbstractController
$paperObj->setId($paper->getId()); $paperObj->setId($paper->getId());
$paperObj->setArtNr($paper->getArtNr()); $paperObj->setArtNr($paper->getArtNr());
$paperObj->setDescription1((string)$paper->getDescription1()); $paperObj->setDescription1((string) $paper->getDescription1());
$paperObj->setDescription2((string)$paper->getDescription2()); $paperObj->setDescription2((string) $paper->getDescription2());
$paperObj->setGrammatur((int)$paper->getGrammatur()); $paperObj->setGrammatur((int) $paper->getGrammatur());
$paperObj->setPrice($paper->getPreis()); $paperObj->setPrice($paper->getPreis());
} else { } else {
$paperObj = new NotFound("paper not found"); $paperObj = new NotFound('paper not found');
} }
return $this->json($paperObj); return $this->json($paperObj);
} }

View File

@ -2,19 +2,22 @@
namespace PSC\System\SettingsBundle\Api\Paper; namespace PSC\System\SettingsBundle\Api\Paper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use PSC\Component\ApiBundle\Dto\Error\NotFound;
use PSC\Shop\EntityBundle\Entity\Paper as PSCPaper; use PSC\Shop\EntityBundle\Entity\Paper as PSCPaper;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use PSC\System\SettingsBundle\Model\Paper; use PSC\System\SettingsBundle\Model\Paper;
use Symfony\Component\HttpFoundation\JsonResponse;
use Nelmio\ApiDocBundle\Annotation\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use OpenApi\Annotations as OA; use Symfony\Component\HttpFoundation\JsonResponse;
use Nelmio\ApiDocBundle\Annotation\Model; use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
class Update extends AbstractController class Update extends AbstractController
{ {
@ -25,25 +28,17 @@ class Update extends AbstractController
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
} }
/** #[Response(
* change paper response: 200,
* description: 'update paper',
* @OA\Response( content: new JsonContent(ref: new Model(type: Paper::class)),
* response=200, )]
* description="update paper", #[RequestBody(ref: new Model(type: Paper::class))]
* @OA\JsonContent(ref=@Model(type=\PSC\System\SettingsBundle\Model\Paper::class)) #[Tag(name: 'PaperDB')]
* ) #[Security(name: 'ApiKeyAuth')]
* @OA\RequestBody(
* description="This is a request body",
* @Model(type=\PSC\System\SettingsBundle\Model\Paper::class)
* )
* @OA\Tag(name="PaperDB")
* @Security(name="ApiKeyAuth")
*/
#[Route(path: '/paperdb/update/{artNr}', methods: ['PUT'])] #[Route(path: '/paperdb/update/{artNr}', methods: ['PUT'])]
#[ParamConverter('paperObj', class: '\PSC\System\SettingsBundle\Model\Paper', converter: 'psc_rest.request_body')]
#[IsGranted('ROLE_API')] #[IsGranted('ROLE_API')]
public function update(string $artNr, Paper $paperObj): JsonResponse public function update(string $artNr, #[MapRequestPayload] Paper $paperObj): JsonResponse
{ {
$paper = $this->entityManager->getRepository(PSCPaper::class)->findOneBy(['artNr' => $artNr]); $paper = $this->entityManager->getRepository(PSCPaper::class)->findOneBy(['artNr' => $artNr]);

View File

@ -2,38 +2,34 @@
namespace PSC\System\SettingsBundle\Api\Papercontainer; namespace PSC\System\SettingsBundle\Api\Papercontainer;
use Doctrine\ORM\EntityManagerInterface; use Nelmio\ApiDocBundle\Attribute\Model;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use Nelmio\ApiDocBundle\Attribute\Security;
use PSC\Shop\EntityBundle\Entity\Paper; use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\System\SettingsBundle\Model\Papercontainer; use PSC\System\SettingsBundle\Model\Papercontainer;
use PSC\System\SettingsBundle\Service\Shop; use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA; use Symfony\Component\Security\Http\Attribute\IsGranted;
use Nelmio\ApiDocBundle\Annotation\Model;
use PSC\System\SettingsBundle\Model\Paper as PSCPaper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Nelmio\ApiDocBundle\Annotation\Security;
class Get extends AbstractController class Get extends AbstractController
{ {
private Shop $shopService; private Shop $shopService;
public function __construct(Shop $shopService) public function __construct(Shop $shopService)
{ {
$this->shopService = $shopService; $this->shopService = $shopService;
} }
/**
* get papercontainer #[Response(
* response: 200,
* @OA\Response( description: 'get papercontainer',
* response=200, content: new JsonContent(ref: new Model(type: Papercontainer::class)),
* description="get papercontainer", )]
* @OA\JsonContent(ref=@Model(type=\PSC\System\SettingsBundle\Model\Papercontainer::class)) #[Tag(name: 'PaperDB')]
* ) #[Security(name: 'Bearer')]
* @Security(name="Bearer")
* @OA\Tag(name="PaperDB")
*/
#[Route(path: '/papercontainer', methods: ['GET'])] #[Route(path: '/papercontainer', methods: ['GET'])]
#[IsGranted('ROLE_USER')] #[IsGranted('ROLE_USER')]
public function getPapercontainer(): JsonResponse public function getPapercontainer(): JsonResponse

View File

@ -2,20 +2,20 @@
namespace PSC\System\SettingsBundle\Api\Papercontainer; namespace PSC\System\SettingsBundle\Api\Papercontainer;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use PSC\Component\ApiBundle\Dto\Error\NotFound; use Nelmio\ApiDocBundle\Attribute\Model;
use PSC\Shop\EntityBundle\Entity\Paper; use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\System\SettingsBundle\Model\Papercontainer; use PSC\System\SettingsBundle\Model\Papercontainer;
use PSC\System\SettingsBundle\Service\Shop; use PSC\System\SettingsBundle\Service\Shop;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA; use Symfony\Component\Security\Http\Attribute\IsGranted;
use Nelmio\ApiDocBundle\Annotation\Model;
use PSC\System\SettingsBundle\Model\Paper as PSCPaper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Nelmio\ApiDocBundle\Annotation\Security;
class Update extends AbstractController class Update extends AbstractController
{ {
@ -28,24 +28,22 @@ class Update extends AbstractController
$this->shopService = $shopService; $this->shopService = $shopService;
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
} }
/**
* update papercontainer #[Response(
* response: 200,
* @OA\Response( description: 'update papercontainer',
* response=200, content: new JsonContent(ref: new Model(type: Papercontainer::class)),
* description="update papercontainer", )]
* @OA\JsonContent(ref=@Model(type=\PSC\System\SettingsBundle\Model\Papercontainer::class)) #[Tag(name: 'PaperDB')]
* ) #[Security(name: 'Bearer')]
* @OA\RequestBody(
* description="This is a request body",
* @Model(type=\PSC\System\SettingsBundle\Model\Papercontainer::class))
* )
* @IsGranted("ROLE_USER")
* @Security(name="Bearer")
* @OA\Tag(name="PaperDB")
*/
#[Route(path: '/papercontainer', methods: ['PUT'])] #[Route(path: '/papercontainer', methods: ['PUT'])]
#[ParamConverter('papercontainer', class: '\PSC\System\SettingsBundle\Model\Papercontainer', converter: 'psc_rest.request_body')] #[RequestBody(ref: new Model(type: Papercontainer::class))]
#[ParamConverter(
'papercontainer',
class: '\PSC\System\SettingsBundle\Model\Papercontainer',
converter: 'psc_rest.request_body',
)]
#[IsGranted('ROLE_USER')]
public function updatePapercontainer(Papercontainer $papercontainer): JsonResponse public function updatePapercontainer(Papercontainer $papercontainer): JsonResponse
{ {
$install = $this->shopService->getShopByDomain()->getInstall(); $install = $this->shopService->getShopByDomain()->getInstall();

View File

@ -3,16 +3,18 @@
namespace PSC\System\SettingsBundle\Api\Status; namespace PSC\System\SettingsBundle\Api\Status;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Nelmio\ApiDocBundle\Attribute\Model;
use Nelmio\ApiDocBundle\Attribute\Security;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use PSC\System\SettingsBundle\Document\Status as StatusDoc;
use PSC\System\SettingsBundle\Dto\Status\All\Output;
use PSC\System\SettingsBundle\Model\Status;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Attribute\Route;
use OpenApi\Annotations as OA; use Symfony\Component\Security\Http\Attribute\IsGranted;
use PSC\System\SettingsBundle\Dto\Status\All\Output;
use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security;
use PSC\System\SettingsBundle\Model\Status;
use PSC\System\SettingsBundle\Document\Status as StatusDoc;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
class All extends AbstractController class All extends AbstractController
{ {
@ -22,18 +24,14 @@ class All extends AbstractController
{ {
$this->documentManager = $documentManager; $this->documentManager = $documentManager;
} }
/**
* get all statuse #[Response(
* response: 200,
* @OA\Response( description: 'get all paper',
* response=200, content: new JsonContent(ref: new Model(type: Output::class)),
* description="get all paper", )]
* @OA\JsonContent(ref=@Model(type=\PSC\System\SettingsBundle\Dto\Status\All\Output::class)) #[Tag(name: 'Status')]
* ) #[Security(name: 'ApiKeyAuth')]
* @OA\Tag(name="Status")
* @Security(name="ApiKeyAuth")
* @Security(name="Bearer")
*/
#[Route(path: '/status', methods: ['GET'])] #[Route(path: '/status', methods: ['GET'])]
#[IsGranted('ROLE_SHOP')] #[IsGranted('ROLE_SHOP')]
public function all(): JsonResponse public function all(): JsonResponse
@ -50,11 +48,11 @@ class All extends AbstractController
foreach ($statusOrder as $status) { foreach ($statusOrder as $status) {
$tmp = new Status(); $tmp = new Status();
$tmp->setCode((int)$status->getCode()); $tmp->setCode((int) $status->getCode());
$tmp->setColor((string)$status->getColor()); $tmp->setColor((string) $status->getColor());
$tmp->setExternalName((string)$status->getExternalName()); $tmp->setExternalName((string) $status->getExternalName());
$tmp->setInternalName((string)$status->getInternalName()); $tmp->setInternalName((string) $status->getInternalName());
$tmp->setUuid((string)$status->getId()); $tmp->setUuid((string) $status->getId());
$tmpOrder[] = $tmp; $tmpOrder[] = $tmp;
} }
@ -62,11 +60,11 @@ class All extends AbstractController
foreach ($statusPosition as $status) { foreach ($statusPosition as $status) {
$tmp = new Status(); $tmp = new Status();
$tmp->setCode((int)$status->getCode()); $tmp->setCode((int) $status->getCode());
$tmp->setColor((string)$status->getColor()); $tmp->setColor((string) $status->getColor());
$tmp->setExternalName((string)$status->getExternalName()); $tmp->setExternalName((string) $status->getExternalName());
$tmp->setInternalName((string)$status->getInternalName()); $tmp->setInternalName((string) $status->getInternalName());
$tmp->setUuid((string)$status->getId()); $tmp->setUuid((string) $status->getId());
$tmpPos[] = $tmp; $tmpPos[] = $tmp;
} }

View File

@ -52,5 +52,8 @@ class UploadTest extends WebTestCase
$client->request('GET', '/api/media/' . $media['uuid'], [], []); $client->request('GET', '/api/media/' . $media['uuid'], [], []);
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$media = json_decode($client->getResponse()->getContent(), true);
self::assertSame('kenney.jpg', $media['title']);
} }
} }

View File

@ -2,11 +2,10 @@
namespace App\Tests\PSC\Shop\Order\Service; namespace App\Tests\PSC\Shop\Order\Service;
use PSC\Shop\ContactBundle\Model\AccountType;
use PSC\Shop\ContactBundle\Model\Contact;
use Tests\RefreshDatabaseTrait;
use PSC\Component\ApiBundle\Model\Shop; use PSC\Component\ApiBundle\Model\Shop;
use PSC\Shop\ContactBundle\Model\AccountType;
use PSC\Shop\ContactBundle\Model\Address; use PSC\Shop\ContactBundle\Model\Address;
use PSC\Shop\ContactBundle\Model\Contact;
use PSC\Shop\OrderBundle\Model\Order\Position; use PSC\Shop\OrderBundle\Model\Order\Position;
use PSC\Shop\OrderBundle\Service\Calc; use PSC\Shop\OrderBundle\Service\Calc;
use PSC\Shop\PaymentBundle\Model\Payment; use PSC\Shop\PaymentBundle\Model\Payment;
@ -14,6 +13,7 @@ use PSC\Shop\ProductBundle\Model\Product;
use PSC\Shop\ProductBundle\Model\ProductSpecialObject; use PSC\Shop\ProductBundle\Model\ProductSpecialObject;
use PSC\Shop\ShippingBundle\Model\Shipping; use PSC\Shop\ShippingBundle\Model\Shipping;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Tests\RefreshDatabaseTrait;
class CalcContactAccountTypeTest extends KernelTestCase class CalcContactAccountTypeTest extends KernelTestCase
{ {
@ -29,7 +29,7 @@ class CalcContactAccountTypeTest extends KernelTestCase
$calcService = $container->get(Calc::class); $calcService = $container->get(Calc::class);
$shop = new Shop(); $shop = new Shop();
$shop->setUuid('shop1'); $shop->setUuid('771a1176-d531-48ed-93b8-eec1fd4b917f');
$order = new \PSC\Shop\OrderBundle\Model\Order(); $order = new \PSC\Shop\OrderBundle\Model\Order();
$order->setShop($shop); $order->setShop($shop);
@ -132,7 +132,7 @@ class CalcContactAccountTypeTest extends KernelTestCase
$calcService = $container->get(Calc::class); $calcService = $container->get(Calc::class);
$shop = new Shop(); $shop = new Shop();
$shop->setUuid('shop1'); $shop->setUuid('771a1176-d531-48ed-93b8-eec1fd4b917f');
$order = new \PSC\Shop\OrderBundle\Model\Order(); $order = new \PSC\Shop\OrderBundle\Model\Order();
$order->setShop($shop); $order->setShop($shop);
@ -232,7 +232,7 @@ class CalcContactAccountTypeTest extends KernelTestCase
$calcService = $container->get(Calc::class); $calcService = $container->get(Calc::class);
$shop = new Shop(); $shop = new Shop();
$shop->setUuid('shop1'); $shop->setUuid('771a1176-d531-48ed-93b8-eec1fd4b917f');
$order = new \PSC\Shop\OrderBundle\Model\Order(); $order = new \PSC\Shop\OrderBundle\Model\Order();
$order->setShop($shop); $order->setShop($shop);

View File

@ -2,7 +2,6 @@
namespace App\Tests\PSC\Shop\Order\Service; namespace App\Tests\PSC\Shop\Order\Service;
use Tests\RefreshDatabaseTrait;
use PSC\Component\ApiBundle\Model\Shop; use PSC\Component\ApiBundle\Model\Shop;
use PSC\Shop\ContactBundle\Model\Address; use PSC\Shop\ContactBundle\Model\Address;
use PSC\Shop\OrderBundle\Model\Order\Position; use PSC\Shop\OrderBundle\Model\Order\Position;
@ -12,6 +11,7 @@ use PSC\Shop\ProductBundle\Model\Product;
use PSC\Shop\ProductBundle\Model\ProductSpecialObject; use PSC\Shop\ProductBundle\Model\ProductSpecialObject;
use PSC\Shop\ShippingBundle\Model\Shipping; use PSC\Shop\ShippingBundle\Model\Shipping;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Tests\RefreshDatabaseTrait;
class CalcTest extends KernelTestCase class CalcTest extends KernelTestCase
{ {
@ -27,7 +27,7 @@ class CalcTest extends KernelTestCase
$calcService = $container->get(Calc::class); $calcService = $container->get(Calc::class);
$shop = new Shop(); $shop = new Shop();
$shop->setUuid('shop1'); $shop->setUuid('771a1176-d531-48ed-93b8-eec1fd4b917f');
$order = new \PSC\Shop\OrderBundle\Model\Order(); $order = new \PSC\Shop\OrderBundle\Model\Order();
$order->setShop($shop); $order->setShop($shop);
@ -54,7 +54,7 @@ class CalcTest extends KernelTestCase
$specialProductSettingsW0 = new ProductSpecialObject(); $specialProductSettingsW0 = new ProductSpecialObject();
$specialProductSettingsW0->setCent(true); $specialProductSettingsW0->setCent(true);
$specialProductSettingsW0->setNet(13.12*100); $specialProductSettingsW0->setNet(13.12 * 100);
$productW0->setSpecialProductTypeObject($specialProductSettingsW0); $productW0->setSpecialProductTypeObject($specialProductSettingsW0);
@ -117,3 +117,4 @@ class CalcTest extends KernelTestCase
$this->assertSame(24749, $order->getGross()); $this->assertSame(24749, $order->getGross());
} }
} }

View File

@ -14,12 +14,17 @@ class GetPriceTest extends WebTestCase
{ {
$client = static::createClient(); $client = static::createClient();
$client->jsonRequest('POST', '/api/plugin/system/psc/xmlcalc/price', ['product' => '01938686-0e4d-7da9-bae3-b2e1b1681f9f'], []); $client->jsonRequest(
'POST',
'/api/plugin/system/psc/xmlcalc/price',
['product' => '01938686-0e4d-7da9-bae3-b2e1b1681f9f'],
[],
);
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true);
self::assertSame(2600, $data['netto']); self::assertSame(260, $data['netto']);
} }
public function testGetPriceWithCompany(): void public function testGetPriceWithCompany(): void
@ -31,12 +36,17 @@ class GetPriceTest extends WebTestCase
$client->loginUser($testUser, 'api'); $client->loginUser($testUser, 'api');
$client->jsonRequest('POST', '/api/plugin/system/psc/xmlcalc/price', ['product' => '01938686-0e4d-7da9-bae3-b2e1b1681f9f'], []); $client->jsonRequest(
'POST',
'/api/plugin/system/psc/xmlcalc/price',
['product' => '01938686-0e4d-7da9-bae3-b2e1b1681f9f'],
[],
);
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true);
self::assertSame(16640, $data['netto']); self::assertSame(1664, $data['netto']);
} }
public function testGetPriceWithAssociation(): void public function testGetPriceWithAssociation(): void
@ -48,11 +58,16 @@ class GetPriceTest extends WebTestCase
$client->loginUser($testUser, 'api'); $client->loginUser($testUser, 'api');
$client->jsonRequest('POST', '/api/plugin/system/psc/xmlcalc/price', ['product' => '01938686-0e4d-7da9-bae3-b2e1b1681f9f'], []); $client->jsonRequest(
'POST',
'/api/plugin/system/psc/xmlcalc/price',
['product' => '01938686-0e4d-7da9-bae3-b2e1b1681f9f'],
[],
);
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true);
self::assertSame(1300, $data['netto']); self::assertSame(130, $data['netto']);
} }
} }

View File

@ -8,6 +8,7 @@ import HiddenElement from './elements/HiddenElement.vue';
import HeadlineElement from './elements/HeadlineElement.vue'; import HeadlineElement from './elements/HeadlineElement.vue';
import SelectElement from './elements/SelectElement.vue'; import SelectElement from './elements/SelectElement.vue';
import RowElement from './elements/RowElement.vue'; import RowElement from './elements/RowElement.vue';
import MediaElement from './elements/MediaElement.vue';
const props = defineProps<{ const props = defineProps<{
items: PreviewElement[] items: PreviewElement[]
@ -28,6 +29,11 @@ const handleUpdate = (payload: { elementId: string, newValue: any }) => {
:item="item" :item="item"
@update:value="handleUpdate" @update:value="handleUpdate"
/> />
<MediaElement
v-if="item.valid && item.htmlType === 'media'"
:item="item"
@update:value="handleUpdate"
/>
<HiddenElement <HiddenElement
v-if="item.valid && item.htmlType === 'hidden'" v-if="item.valid && item.htmlType === 'hidden'"
:item="item" :item="item"

View File

@ -0,0 +1,28 @@
<script lang="ts" setup>
import type { PreviewElement } from '../../../../model/preview/types';
import { ref, onMounted } from 'vue'
import { fetchMediaUrl } from '../../../../lib/api';
const props = defineProps<{
item: PreviewElement
}>()
let src = ref('')
onMounted(async () => {
if (props.item.value) {
try {
src = await fetchMediaUrl(props.item.value);
} catch (error) {
console.error('Failed to fetch media URL', error);
}
}
});
</script>
<template>
<div class="flex gap-2 flex-row">
<img v-if="src != ''" class="" :src="src"/>
</div>
</template>

View File

@ -177,8 +177,8 @@ export const fetchPreview = async (shopUuid: string, json: object[], values?: Re
export const fetchMediaUrl = async (uuid: string) => { export const fetchMediaUrl = async (uuid: string) => {
try { try {
const response = await api.get(`api/media/${uuid}`); const response = await api.get(`api/media/${uuid}`);
const data:any = await response.json(); const data: any = await response.json();
return data.data.attributes.url; return data.url;
} catch (error) { } catch (error) {
console.error(`Error fetching media url for ${uuid}:`, error); console.error(`Error fetching media url for ${uuid}:`, error);
throw error; throw error;

View File

@ -33,7 +33,7 @@ export default defineConfig({
changeOrigin: true, changeOrigin: true,
configure: (proxy) => { configure: (proxy) => {
proxy.on('proxyReq', (proxyReq) => { proxy.on('proxyReq', (proxyReq) => {
proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTY3MzE1MDEsImV4cCI6MTc1NjczNTEwMSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfVVNFUiIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9FZGl0IiwiUk9MRV9QU0NfQ29sbGVjdF9Db250YWN0X0FkZCIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9EZWxldGUiLCJST0xFX1BTQ19Db2xsZWN0X0NvbnRhY3RfTG9jayIsIlJPTEVfUFNDX1IyX1NlbmRjbG91ZF9TaG93Il0sInVpZCI6MX0.Krs-TxmU9J3-p9Tt9cgFbm94wNz7wG9zRUe6yGMFG5USngDNzg4f3FL46JAWUx1liZBiU5K_Qnir5ol1--T6o2MNWIqxj3DTMgx6weWscv0Uw0eXOvhXhZp3wjaFnaqnqdN-vDqdEljs4V8ZA7RmbrL4SNgH-XoKrn0GEI9uVUYtd3wwR4SZFDEvZC1MTRi17zVMdpAxNaZ5KWTvcaARmUmDT5uKmgFOaM0z0mUT9mbL9KetqdId4aq_o6o6cPI--CDVmGNElvh4b3Ogf4yFe1hSuh9Yt1jM9rhqA7JDMpTRm3Ffx1nEdOyuA02hFFttuGICLc4NFTLbsY8qfp0H5A'); proxyReq.setHeader('Authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE3NTY5OTYyODUsImV4cCI6MTc1Njk5OTg4NSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU0hPUF9PUEVSQVRPUiIsIlJPTEVfVVNFUiIsIlJPTEVfVVNFUiIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9FZGl0IiwiUk9MRV9QU0NfQ29sbGVjdF9Db250YWN0X0FkZCIsIlJPTEVfUFNDX0NvbGxlY3RfQ29udGFjdF9EZWxldGUiLCJST0xFX1BTQ19Db2xsZWN0X0NvbnRhY3RfTG9jayIsIlJPTEVfUFNDX1IyX1NlbmRjbG91ZF9TaG93Il0sInVpZCI6MX0.GscgpB_vAN_oq4LHqzQ4K8vU0j4U9S4xLh0hCgRaAGTQuYpdHRzO21fCXob4-maN8njEtsHLq7Jpez4k0u47QhRknYrtDT_vw0EKilLpnTYFtxErAY7XqGgitam_C4BtjXKGybGkLrwfSFmlZh1yR_dJA2-hPcOlBjfpjLgOPGmpqClgLH3uv2kBn5E39kveNL5AtEOz18l--At6-UgGQDOXoKPxNNYokUK9_yaWEOezf7LThfBqgeKwOFzKlcbBNGkPWyQjbOaexWfv4DwVUtFuSJrJRYYAMbjPbx0sOThBI-AgpzooiXpLbEZFYOjkCXgyPBVBwp9JI-d0DbpGvA');
}); });
}, },
}, },

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,8 @@
{{ parent() }} {{ parent() }}
{% autoescape 'js' %} {% autoescape 'js' %}
<script> <script type="module">
import $ from 'jquery';
var wto; var wto;
window.addEventListener('bindForm', (event) => { window.addEventListener('bindForm', (event) => {
bindForm(); bindForm();

View File

@ -4,8 +4,11 @@ namespace Plugin\System\PSC\XmlCalc\Api;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Annotations as OA; use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\RequestBody;
use OpenApi\Attributes\Response;
use OpenApi\Attributes\Tag;
use Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput; use Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput;
use Plugin\System\PSC\XmlCalc\Dto\Output\Display\Group as DisplayGroup; use Plugin\System\PSC\XmlCalc\Dto\Output\Display\Group as DisplayGroup;
use Plugin\System\PSC\XmlCalc\Dto\Output\PreCalc\Group; use Plugin\System\PSC\XmlCalc\Dto\Output\PreCalc\Group;
@ -15,6 +18,7 @@ use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Element;
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Option; use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Option;
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Max as PluginMax; use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Max as PluginMax;
use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Min; use Plugin\System\PSC\XmlCalc\Dto\Output\Price\Validation\Input\Min;
use Plugin\System\PSC\XmlCalc\Dto\Output\PriceOutput;
use PSC\Library\Calc\Engine; use PSC\Library\Calc\Engine;
use PSC\Library\Calc\Error\Validation\Input\Max; use PSC\Library\Calc\Error\Validation\Input\Max;
use PSC\Library\Calc\Error\Validation\Input\Min as PSCMin; use PSC\Library\Calc\Error\Validation\Input\Min as PSCMin;
@ -28,15 +32,10 @@ use PSC\Shop\ContactBundle\Transformer\Model\Contact as ContactTransformer;
use PSC\Shop\EntityBundle\Entity\Product; use PSC\Shop\EntityBundle\Entity\Product;
use PSC\System\SettingsBundle\Service\Help; use PSC\System\SettingsBundle\Service\Help;
use PSC\System\SettingsBundle\Service\PaperDB; use PSC\System\SettingsBundle\Service\PaperDB;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Yaml\Yaml;
class GetPrice extends AbstractController class GetPrice extends AbstractController
{ {
@ -77,20 +76,13 @@ class GetPrice extends AbstractController
$this->helpService = $helpService; $this->helpService = $helpService;
} }
/** #[Response(
* get price response: 200,
* description: 'get price',
* @OA\Response( content: new JsonContent(ref: new Model(type: PriceOutput::class)),
* response=200, )]
* description="orders", #[RequestBody(ref: new Model(type: PriceInput::class))]
* @OA\JsonContent(ref=@Model(type=\Plugin\System\PSC\XmlCalc\Dto\Output\PriceOutput::class)) #[Tag(name: 'Plugin/System/psc/Xmlcalc/Price')]
* )
* @OA\RequestBody(
*
* @Model(type=\Plugin\System\PSC\XmlCalc\Dto\Input\PriceInput::class))
* )
* @OA\Tag(name="Plugin/System/psc/Xmlcalc/Price")
*/
#[Route(path: '/price', methods: ['POST'])] #[Route(path: '/price', methods: ['POST'])]
#[ParamConverter( #[ParamConverter(
'data', 'data',