some progress

This commit is contained in:
Babak Alizadeh 2023-11-11 07:46:50 -08:00
parent 9fd8825a17
commit 6829d77730
6 changed files with 350 additions and 0 deletions

View file

@ -2,7 +2,9 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\ArchiveFile;
use App\Service\Access; use App\Service\Access;
use App\Service\Jdate;
use App\Service\Log; use App\Service\Log;
use App\Service\Provider; use App\Service\Provider;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -24,4 +26,34 @@ class ArchiveController extends AbstractController
'size' => $acc['bid']->getArchiveSize() 'size' => $acc['bid']->getArchiveSize()
]); ]);
} }
#[Route('/api/archive/list/{cat}', name: 'app_archive_list')]
public function app_archive_list(string $cat,Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse
{
$acc = $access->hasRole('archiveUpload');
if(!$acc)
$acc = $access->hasRole('archiveMod');
if(!$acc)
$acc = $access->hasRole('archiveDelete');
if(!$acc)
throw $this->createAccessDeniedException();
if($cat == 'all')
$files = $entityManager->getRepository(ArchiveFile::class)->findBy(['bid'=>$acc['bid']]);
else
$files = $entityManager->getRepository(ArchiveFile::class)->findBy(['bid'=>$acc['bid'],'cat'=>$cat]);
$resp = [];
foreach ($files as $file){
$temp = [];
$temp['filename']=$file->getFilename();
$temp['fileType']=$file->getFileType();
$temp['submitter']=$file->getSubmitter()->getFullName();
$temp['dateSubmit']=$jdate->jdate('Y/n/d H:i',$file->getDateSubmit());
$temp['filePublicls']=$file->isPublic();
$temp['cat']=$file->getCat();
$temp['filesize']=$file->getFileSize();
$resp[] = $temp;
}
return $this->json($resp);
}
} }

View file

@ -48,6 +48,9 @@ class ArchiveFile
#[ORM\Column(length: 255, nullable: true)] #[ORM\Column(length: 255, nullable: true)]
private ?string $relatedDocCode = null; private ?string $relatedDocCode = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $fileSize = null;
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -184,4 +187,16 @@ class ArchiveFile
return $this; return $this;
} }
public function getFileSize(): ?string
{
return $this->fileSize;
}
public function setFileSize(?string $fileSize): static
{
$this->fileSize = $fileSize;
return $this;
}
} }

View file

@ -0,0 +1,187 @@
<?php
namespace App\Entity;
use App\Repository\ArchiveOrdersRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ArchiveOrdersRepository::class)]
class ArchiveOrders
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'archiveOrders')]
#[ORM\JoinColumn(nullable: false)]
private ?Business $bid = null;
#[ORM\ManyToOne(inversedBy: 'archiveOrders')]
#[ORM\JoinColumn(nullable: false)]
private ?User $submitter = null;
#[ORM\Column(length: 255)]
private ?string $dateSubmit = null;
#[ORM\Column(length: 255)]
private ?string $orderSize = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $gatePay = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $price = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $verifyCode = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $status = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $refID = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $cardPan = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $ExpireDate = null;
public function getId(): ?int
{
return $this->id;
}
public function getBid(): ?Business
{
return $this->bid;
}
public function setBid(?Business $bid): static
{
$this->bid = $bid;
return $this;
}
public function getSubmitter(): ?User
{
return $this->submitter;
}
public function setSubmitter(?User $submitter): static
{
$this->submitter = $submitter;
return $this;
}
public function getDateSubmit(): ?string
{
return $this->dateSubmit;
}
public function setDateSubmit(string $dateSubmit): static
{
$this->dateSubmit = $dateSubmit;
return $this;
}
public function getOrderSize(): ?string
{
return $this->orderSize;
}
public function setOrderSize(string $orderSize): static
{
$this->orderSize = $orderSize;
return $this;
}
public function getGatePay(): ?string
{
return $this->gatePay;
}
public function setGatePay(?string $gatePay): static
{
$this->gatePay = $gatePay;
return $this;
}
public function getPrice(): ?string
{
return $this->price;
}
public function setPrice(?string $price): static
{
$this->price = $price;
return $this;
}
public function getVerifyCode(): ?string
{
return $this->verifyCode;
}
public function setVerifyCode(?string $verifyCode): static
{
$this->verifyCode = $verifyCode;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): static
{
$this->status = $status;
return $this;
}
public function getRefID(): ?string
{
return $this->refID;
}
public function setRefID(?string $refID): static
{
$this->refID = $refID;
return $this;
}
public function getCardPan(): ?string
{
return $this->cardPan;
}
public function setCardPan(?string $cardPan): static
{
$this->cardPan = $cardPan;
return $this;
}
public function getExpireDate(): ?string
{
return $this->ExpireDate;
}
public function setExpireDate(?string $ExpireDate): static
{
$this->ExpireDate = $ExpireDate;
return $this;
}
}

View file

@ -193,6 +193,9 @@ class Business
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: ArchiveFile::class, orphanRemoval: true)] #[ORM\OneToMany(mappedBy: 'bid', targetEntity: ArchiveFile::class, orphanRemoval: true)]
private Collection $archiveFiles; private Collection $archiveFiles;
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: ArchiveOrders::class, orphanRemoval: true)]
private Collection $archiveOrders;
public function __construct() public function __construct()
{ {
$this->logs = new ArrayCollection(); $this->logs = new ArrayCollection();
@ -215,6 +218,7 @@ class Business
$this->storeroomTickets = new ArrayCollection(); $this->storeroomTickets = new ArrayCollection();
$this->storeroomItems = new ArrayCollection(); $this->storeroomItems = new ArrayCollection();
$this->archiveFiles = new ArrayCollection(); $this->archiveFiles = new ArrayCollection();
$this->archiveOrders = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
@ -1253,4 +1257,34 @@ class Business
return $this; return $this;
} }
/**
* @return Collection<int, ArchiveOrders>
*/
public function getArchiveOrders(): Collection
{
return $this->archiveOrders;
}
public function addArchiveOrder(ArchiveOrders $archiveOrder): static
{
if (!$this->archiveOrders->contains($archiveOrder)) {
$this->archiveOrders->add($archiveOrder);
$archiveOrder->setBid($this);
}
return $this;
}
public function removeArchiveOrder(ArchiveOrders $archiveOrder): static
{
if ($this->archiveOrders->removeElement($archiveOrder)) {
// set the owning side to null (unless already changed)
if ($archiveOrder->getBid() === $this) {
$archiveOrder->setBid(null);
}
}
return $this;
}
} }

View file

@ -95,6 +95,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\OneToMany(mappedBy: 'Submitter', targetEntity: ArchiveFile::class, orphanRemoval: true)] #[ORM\OneToMany(mappedBy: 'Submitter', targetEntity: ArchiveFile::class, orphanRemoval: true)]
private Collection $archiveFiles; private Collection $archiveFiles;
#[ORM\OneToMany(mappedBy: 'submitter', targetEntity: ArchiveOrders::class, orphanRemoval: true)]
private Collection $archiveOrders;
public function __construct() public function __construct()
{ {
$this->userTokens = new ArrayCollection(); $this->userTokens = new ArrayCollection();
@ -113,6 +116,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
$this->walletTransactions = new ArrayCollection(); $this->walletTransactions = new ArrayCollection();
$this->storeroomTickets = new ArrayCollection(); $this->storeroomTickets = new ArrayCollection();
$this->archiveFiles = new ArrayCollection(); $this->archiveFiles = new ArrayCollection();
$this->archiveOrders = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
@ -736,4 +740,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this; return $this;
} }
/**
* @return Collection<int, ArchiveOrders>
*/
public function getArchiveOrders(): Collection
{
return $this->archiveOrders;
}
public function addArchiveOrder(ArchiveOrders $archiveOrder): static
{
if (!$this->archiveOrders->contains($archiveOrder)) {
$this->archiveOrders->add($archiveOrder);
$archiveOrder->setSubmitter($this);
}
return $this;
}
public function removeArchiveOrder(ArchiveOrders $archiveOrder): static
{
if ($this->archiveOrders->removeElement($archiveOrder)) {
// set the owning side to null (unless already changed)
if ($archiveOrder->getSubmitter() === $this) {
$archiveOrder->setSubmitter(null);
}
}
return $this;
}
} }

View file

@ -0,0 +1,48 @@
<?php
namespace App\Repository;
use App\Entity\ArchiveOrders;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<ArchiveOrders>
*
* @method ArchiveOrders|null find($id, $lockMode = null, $lockVersion = null)
* @method ArchiveOrders|null findOneBy(array $criteria, array $orderBy = null)
* @method ArchiveOrders[] findAll()
* @method ArchiveOrders[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ArchiveOrdersRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ArchiveOrders::class);
}
// /**
// * @return ArchiveOrders[] Returns an array of ArchiveOrders objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('a.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?ArchiveOrders
// {
// return $this->createQueryBuilder('a')
// ->andWhere('a.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}