dbms_primeidc/extdbms/lib/Controllers/DBMS/ServerController.php
2025-04-17 19:09:50 +09:00

60 lines
2.1 KiB
PHP

<?php
namespace lib\Controllers\DBMS;
use lib\Services\ClientService;
use lib\Services\ServerService;
use lib\Utils\Pagination;
class ServerController extends DBMSController
{
private ?ServerService $_serverService = null;
private ?ClientService $_clientService = null;
public function __construct(array $params = [])
{
parent::__construct($params);
$this->getView()->setPath('server');
} //
public function getServerService(): ServerService
{
if ($this->_serverService === null) {
$this->_serverService = new ServerService();
}
return $this->_serverService;
}
public function getClientService(): ClientService
{
if ($this->_clientService === null) {
$this->_clientService = new ClientService();
}
return $this->_clientService;
}
//IdcCouponListMK.jsp -> domain_coupon.php
//CLI 접속방법 : php index.php site/client/counpon/index
//WEB 접속방법 : http://localhost/site/client/coupon/index
public function index()
{
//사용자정보
$client_code = $this->request->get('client_code');
// echo "client_code:" . $client_code;
if ($client_code) {
$client = $this->getClientService()->getEntityByCode($client_code);
if (!$client) {
throw new \Exception("[$client_code]에 해당하는 사용자정보가 존재하지 않습니다.");
}
$this->client = $client;
}
//쿠폰내역
$this->curPage = intval($this->request->get('curPage', 1));
$this->perPage = intval($this->request->get('perPage', VIEW_LIST_PERPAGE));
[$this->total, $this->services] = $this->getServerService()->getEntitiesByClient($this->curPage, $this->perPage, $client_code);
$this->pagination = new Pagination($this->total, (int)$this->curPage, (int)$this->perPage);
$total_coupon = 0;
foreach ($this->services as $service) {
$total_coupon += $service->getCoupon();
}
$this->total_coupon = $total_coupon;
return $this->render(__FUNCTION__);
}
} //Class