diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 528b5c0..98252e1 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -545,41 +545,4 @@ class BusinessController extends AbstractController ]; return $this->json($response); } - - #[Route('hooks/setting/SetChangeHook', name: 'api_business_SetChangeHook')] - public function api_business_SetChangeHook(Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): JsonResponse - { - - $api = $entityManager->getRepository(APIToken::class)->findOneBy([ - 'token' => $request->headers->get('api-key'), - ]); - - $params = []; - if ($content = $request->getContent()) { - $params = json_decode($content, true); - } - $hook = $entityManager->getRepository(Hook::class)->findOneBy([ - 'url'=> $params['url'], - 'password'=> $params['hookPassword'], - 'bid' => $api->getBid(), - 'submitter'=>$this->getUser() - ]); - if(!$hook){ - $hook = new Hook(); - $hook->setBid($api->getBid()); - $hook->setSubmitter($this->getUser()); - $hook->setPassword($params['hookPassword']); - $hook->setUrl($params['url']); - $entityManager->persist($hook); - $entityManager->flush(); - } - - $year = $entityManager->getRepository(Year::class)->findOneBy(['bid'=>$api->getBid(),'head'=>true])->getId(); - return $this->json([ - 'Success'=>true, - 'bid' => $api->getBid()->getId(), - 'year' => $year, - 'money' => $api->getBid()->getMoney()->getId() - ]); - } } diff --git a/hesabixCore/src/Controller/HookController.php b/hesabixCore/src/Controller/HookController.php new file mode 100644 index 0000000..534b3b2 --- /dev/null +++ b/hesabixCore/src/Controller/HookController.php @@ -0,0 +1,92 @@ +getRepository(APIToken::class)->findOneBy([ + 'token' => $request->headers->get('api-key'), + ]); + + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + $hook = $entityManager->getRepository(Hook::class)->findOneBy([ + 'url'=> $params['url'], + 'password'=> $params['hookPassword'], + 'bid' => $api->getBid(), + 'submitter'=>$this->getUser() + ]); + if(!$hook){ + $hook = new Hook(); + $hook->setBid($api->getBid()); + $hook->setSubmitter($this->getUser()); + $hook->setPassword($params['hookPassword']); + $hook->setUrl($params['url']); + $entityManager->persist($hook); + $entityManager->flush(); + } + + $year = $entityManager->getRepository(Year::class)->findOneBy(['bid'=>$api->getBid(),'head'=>true])->getId(); + return $this->json([ + 'Success'=>true, + 'bid' => $api->getBid()->getId(), + 'year' => $year, + 'money' => $api->getBid()->getMoney()->getId() + ]); + } + + #[Route('hooks/setting/getCurrency', name: 'api_hooks_getcurrency')] + public function api_hooks_getcurrency(Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): JsonResponse + { + $api = $entityManager->getRepository(APIToken::class)->findOneBy([ + 'token' => $request->headers->get('api-key'), + ]); + if(!$api) + throw $this->createNotFoundException(); + + return $this->json([ + 'Success'=>true, + 'ErrorCode' => 0, + 'ErrorMessage' => '', + 'Result' =>[ + 'moneyId' => $api->getBid()->getMoney()->getId(), + 'moneyName' => $api->getBid()->getMoney()->getName(), + 'moneylabel' => $api->getBid()->getMoney()->getLabel() + ] + ]); + } +} diff --git a/hesabixCore/templates/hook/index.html.twig b/hesabixCore/templates/hook/index.html.twig new file mode 100644 index 0000000..ba08a42 --- /dev/null +++ b/hesabixCore/templates/hook/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello HookController!{% endblock %} + +{% block body %} + + +
src/Controller/HookController.php
templates/hook/index.html.twig