Compare commits
No commits in common. "a8a0b4b6bf420f6fc492f6ef59b1257c05605948" and "b526f8700a8e2e5115dd3497b784d048b02e5adf" have entirely different histories.
a8a0b4b6bf
...
b526f8700a
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
namespace App\api;
|
||||
|
||||
require_once '../app/models/ReportsModel.php';
|
||||
|
||||
use App\Models\ReportsModel;
|
||||
|
||||
|
||||
use Models\ReportsModel;
|
||||
use Nyholm\Psr7\Response;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
|
@ -14,33 +10,8 @@ use Psr\Http\Message\ResponseInterface;
|
|||
|
||||
class ReportController
|
||||
{
|
||||
|
||||
public function __construct(public ReportsModel $reportsModel) {}
|
||||
public function show(ServerRequestInterface $request, $queryParams)
|
||||
{
|
||||
$connection = $this->reportsModel->dbConnect();
|
||||
|
||||
try {
|
||||
$sql = 'SELECT * FROM queue_stats_mv WHERE datetime LIKE :receivedDate';
|
||||
$stmt = $connection->prepare($sql);
|
||||
|
||||
$data = $queryParams['data'] . '%';
|
||||
$stmt->bindParam(':receivedDate', $data, \PDO::PARAM_STR);
|
||||
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
return new Response(
|
||||
200,
|
||||
['Content-Type' => 'application/json'],
|
||||
json_encode(['success' => true, 'data' => $result], JSON_UNESCAPED_UNICODE)
|
||||
);
|
||||
} catch (\PDOException $e) {
|
||||
return new Response(
|
||||
500,
|
||||
['Content-Type' => 'application/json'],
|
||||
json_encode(['error' => 'Erro ao executar a consulta: ' . $e->getMessage()])
|
||||
);
|
||||
}
|
||||
return new Response(200, ['Content-Type' => 'application/json'], json_encode(['success' => 'data']));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class ReportsModel
|
||||
{
|
||||
private $hostname = 'produs.linepbx.com.br';
|
||||
private $username = 'produs-api';
|
||||
private $password = '*Ingline.Sys#9420%SECURITY#';
|
||||
private $database = 'qstats';
|
||||
private static $connection = null;
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
public function dbConnect()
|
||||
{
|
||||
|
||||
if (self::$connection === null) {
|
||||
try {
|
||||
self::$connection = new \PDO('mysql:host=produs.linepbx.com.br;dbname=qstats;charset=utf8mb4', $this->username, $this->password);
|
||||
self::$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
} catch (\PDOException $e) {
|
||||
return json_encode(['error' => 'Erro na conexão com o banco ' . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
return self::$connection;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
"name": "administrador/linepbx-api",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"app\\": "app/",
|
||||
"core\\": "core/"
|
||||
"app\\": "app/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
|
|
@ -15,7 +14,6 @@
|
|||
"require": {
|
||||
"psr/http-message": "^2.0",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"nyholm/psr7-server": "^1.1",
|
||||
"php-di/php-di": "^7.1"
|
||||
"nyholm/psr7-server": "^1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,69 +4,8 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "2bab835ea30f0b34fd12f9cb0086d45b",
|
||||
"content-hash": "9c15ad4fc717c578191a8cd9b9095bd0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
"version": "v2.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/serializable-closure.git",
|
||||
"reference": "038ce42edee619599a1debb7e81d7b3759492819"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/038ce42edee619599a1debb7e81d7b3759492819",
|
||||
"reference": "038ce42edee619599a1debb7e81d7b3759492819",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/support": "^10.0|^11.0|^12.0",
|
||||
"nesbot/carbon": "^2.67|^3.0",
|
||||
"pestphp/pest": "^2.36|^3.0",
|
||||
"phpstan/phpstan": "^2.0",
|
||||
"symfony/var-dumper": "^6.2.0|^7.0.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\SerializableClosure\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
},
|
||||
{
|
||||
"name": "Nuno Maduro",
|
||||
"email": "nuno@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.",
|
||||
"keywords": [
|
||||
"closure",
|
||||
"laravel",
|
||||
"serializable"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/serializable-closure/issues",
|
||||
"source": "https://github.com/laravel/serializable-closure"
|
||||
},
|
||||
"time": "2025-10-09T13:42:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nyholm/psr7",
|
||||
"version": "1.8.2",
|
||||
|
|
@ -211,187 +150,6 @@
|
|||
],
|
||||
"time": "2023-11-08T09:30:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-di/invoker",
|
||||
"version": "2.3.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-DI/Invoker.git",
|
||||
"reference": "3c1ddfdef181431fbc4be83378f6d036d59e81e1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/3c1ddfdef181431fbc4be83378f6d036d59e81e1",
|
||||
"reference": "3c1ddfdef181431fbc4be83378f6d036d59e81e1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.3",
|
||||
"psr/container": "^1.0|^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"athletic/athletic": "~0.1.8",
|
||||
"mnapoli/hard-mode": "~0.3.0",
|
||||
"phpunit/phpunit": "^9.0 || ^10 || ^11 || ^12"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Invoker\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Generic and extensible callable invoker",
|
||||
"homepage": "https://github.com/PHP-DI/Invoker",
|
||||
"keywords": [
|
||||
"callable",
|
||||
"dependency",
|
||||
"dependency-injection",
|
||||
"injection",
|
||||
"invoke",
|
||||
"invoker"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-DI/Invoker/issues",
|
||||
"source": "https://github.com/PHP-DI/Invoker/tree/2.3.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/mnapoli",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-08-30T10:22:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-di/php-di",
|
||||
"version": "7.1.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-DI/PHP-DI.git",
|
||||
"reference": "f88054cc052e40dbe7b383c8817c19442d480352"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/f88054cc052e40dbe7b383c8817c19442d480352",
|
||||
"reference": "f88054cc052e40dbe7b383c8817c19442d480352",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"laravel/serializable-closure": "^1.0 || ^2.0",
|
||||
"php": ">=8.0",
|
||||
"php-di/invoker": "^2.0",
|
||||
"psr/container": "^1.1 || ^2.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/container-implementation": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3",
|
||||
"friendsofphp/proxy-manager-lts": "^1",
|
||||
"mnapoli/phpunit-easymock": "^1.3",
|
||||
"phpunit/phpunit": "^9.6 || ^10 || ^11",
|
||||
"vimeo/psalm": "^5|^6"
|
||||
},
|
||||
"suggest": {
|
||||
"friendsofphp/proxy-manager-lts": "Install it if you want to use lazy injection (version ^1)"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"DI\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "The dependency injection container for humans",
|
||||
"homepage": "https://php-di.org/",
|
||||
"keywords": [
|
||||
"PSR-11",
|
||||
"container",
|
||||
"container-interop",
|
||||
"dependency injection",
|
||||
"di",
|
||||
"ioc",
|
||||
"psr11"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-DI/PHP-DI/issues",
|
||||
"source": "https://github.com/PHP-DI/PHP-DI/tree/7.1.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/mnapoli",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/php-di/php-di",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-08-16T11:10:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/container",
|
||||
"version": "2.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/container.git",
|
||||
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
|
||||
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Container\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common Container Interface (PHP FIG PSR-11)",
|
||||
"homepage": "https://github.com/php-fig/container",
|
||||
"keywords": [
|
||||
"PSR-11",
|
||||
"container",
|
||||
"container-interface",
|
||||
"container-interop",
|
||||
"psr"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-fig/container/issues",
|
||||
"source": "https://github.com/php-fig/container/tree/2.0.2"
|
||||
},
|
||||
"time": "2021-11-05T16:47:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-factory",
|
||||
"version": "1.1.0",
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
use Core\Router;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
Router::class => function (ContainerInterface $container) {
|
||||
return new Router($container); // ou passe dependências se houver
|
||||
}
|
||||
];
|
||||
|
|
@ -4,8 +4,6 @@ namespace Core;
|
|||
|
||||
require_once '../app/api/ReportController.php';
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use DI\Container;
|
||||
use Nyholm\Psr7\Response;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
|
@ -14,10 +12,8 @@ use Nyholm\Psr7Server\ServerRequestCreatorInterface;
|
|||
|
||||
class Router
|
||||
{
|
||||
|
||||
|
||||
protected $routes = [];
|
||||
public function __construct(protected ContainerInterface $container ) {}
|
||||
public function __construct() {}
|
||||
|
||||
public function setRoute($method, $uri, $action)
|
||||
{
|
||||
|
|
@ -75,7 +71,7 @@ class Router
|
|||
return new Response(500, ['Content-Type' => 'application/json', 'Accept' => 'application/json'], json_encode(['error' => 'Recurso não foi encontrado']));
|
||||
}
|
||||
|
||||
$controllerInstance = $this->container->get($controllerClass);
|
||||
$controllerInstance = new $controllerClass();
|
||||
|
||||
if (empty($queryParams)) {
|
||||
return new Response(403, ['Content-Type' => 'application/json', 'Accept' => 'application/json'], json_encode(['error' => 'O parâmetro de data não foi enviado.']));
|
||||
|
|
|
|||
|
|
@ -10,13 +10,7 @@ use App\Controllers\ReportController;
|
|||
|
||||
use Core\Router;
|
||||
|
||||
use DI\ContainerBuilder;
|
||||
|
||||
$containerBuilder = new ContainerBuilder();
|
||||
$containerBuilder->addDefinitions('../config/config.php');
|
||||
$container = $containerBuilder->build();
|
||||
|
||||
$router = $container->get(Router::class);
|
||||
$router = new Router();
|
||||
|
||||
require_once '../routes/api.php';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue