dbmsv3 init...1
This commit is contained in:
parent
eddcfab51f
commit
1ddf06ff3e
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\AccountEntity;
|
||||
use App\Helpers\Customer\AccountHelper;
|
||||
use App\Services\Customer\AccountService;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\CouponEntity;
|
||||
use App\Helpers\Customer\CouponHelper;
|
||||
use App\Services\Customer\CouponService;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
@ -5,7 +5,6 @@ namespace App\Controllers\Admin\Customer;
|
||||
use App\Entities\Customer\ClientEntity;
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Entities\PaymentEntity;
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -14,7 +13,6 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class PaymentController extends CustomerController
|
||||
{
|
||||
private ?ClientService $_clientService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -30,13 +28,6 @@ class PaymentController extends CustomerController
|
||||
}
|
||||
return $this->_service;
|
||||
}
|
||||
public function getClientService(): ClientService
|
||||
{
|
||||
if (!$this->_clientService) {
|
||||
$this->_clientService = new ClientService();
|
||||
}
|
||||
return $this->_clientService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getService()->getAction()) {
|
||||
@ -88,7 +79,7 @@ class PaymentController extends CustomerController
|
||||
if (array_key_exists($entity->getClientInfoUID(), $clientEntities)) {
|
||||
$clientEntity = $clientEntities[$entity->getClientInfoUID()];
|
||||
} else {
|
||||
$clientEntity = $this->getClientService()->getEntity($entity->getClientInfoUID());
|
||||
$clientEntity = $this->getService()->getClientService()->getEntity($entity->getClientInfoUID());
|
||||
if (!$clientEntity instanceof ClientEntity) {
|
||||
throw new \Exception(__METHOD__ . "에서 {$entity->getClientInfoUID()}에 대한 고객정보를 찾을수 없습니다.");
|
||||
}
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\PointEntity;
|
||||
use App\Helpers\Customer\PointHelper;
|
||||
use App\Services\Customer\PointService;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
@ -4,7 +4,6 @@ namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
@ -3,24 +3,15 @@
|
||||
namespace App\Controllers\Admin\Equipment;
|
||||
|
||||
use App\Controllers\Admin\AdminController;
|
||||
use App\Services\Customer\ClientService;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class EquipmentController extends AdminController
|
||||
{
|
||||
private ?ClientService $_clientService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
final public function getClientService(): ClientService
|
||||
{
|
||||
if (!$this->_clientService) {
|
||||
$this->_clientService = new ClientService();
|
||||
}
|
||||
return $this->_clientService;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -12,7 +11,6 @@ use Psr\Log\LoggerInterface;
|
||||
class Home extends AdminController
|
||||
{
|
||||
private $_service = null;
|
||||
private ?PaymentService $_PaymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -29,13 +27,7 @@ class Home extends AdminController
|
||||
}
|
||||
return $this->_service;
|
||||
}
|
||||
final public function getPaymentService(): PaymentService
|
||||
{
|
||||
if (!$this->_PaymentService) {
|
||||
$this->_PaymentService = new PaymentService();
|
||||
}
|
||||
return $this->_PaymentService;
|
||||
}
|
||||
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getService()->getAction()) {
|
||||
@ -68,16 +60,18 @@ class Home extends AdminController
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
//요청업무
|
||||
|
||||
//Total 서버 현황
|
||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||
$this->interval = intval($this->request->getVar('interval') ?? SERVICE['NEW_INTERVAL']);
|
||||
$this->newServiceEntities = $this->getService()->getEntitiesByNewService($this->interval);
|
||||
$this->newServiceEntities = $this->getService()->getNewServiceEntities($this->interval);
|
||||
$this->newServiceCount = count($this->newServiceEntities);
|
||||
//서비스별 미납 Count
|
||||
$totalUnPaidCount = $totalUnPaidAmount = 0;
|
||||
foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $key => $datas) {
|
||||
$totalUnPaidCount += $datas['cnt'];
|
||||
$totalUnPaidAmount += $datas['amount'];
|
||||
foreach (array_values($this->getService()->getPaymentService()->getUnPaids('serviceinfo_uid')) as $unPaid) {
|
||||
$totalUnPaidCount += $unPaid['cnt'];
|
||||
$totalUnPaidAmount += $unPaid['amount'];
|
||||
}
|
||||
$this->totalUnPaidCount = $totalUnPaidCount;
|
||||
$this->totalUnPaidAmount = $totalUnPaidAmount;
|
||||
|
||||
@ -2,10 +2,7 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Entities\Customer\ServiceEntity;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\PaymentService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
@ -13,8 +10,6 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class SearchController extends AdminController
|
||||
{
|
||||
private ?ServerService $_serverService = null;
|
||||
private ?PaymentService $_paymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -30,20 +25,6 @@ class SearchController extends AdminController
|
||||
}
|
||||
return $this->_service;
|
||||
}
|
||||
public function getServerService(): ServerService
|
||||
{
|
||||
if ($this->_serverService === null) {
|
||||
$this->_serverService = new ServerService();
|
||||
}
|
||||
return $this->_serverService;
|
||||
}
|
||||
public function getPaymentService(): PaymentService
|
||||
{
|
||||
if ($this->_paymentService === null) {
|
||||
$this->_paymentService = new PaymentService();
|
||||
}
|
||||
return $this->_paymentService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getService()->getAction()) {
|
||||
@ -63,7 +44,7 @@ class SearchController extends AdminController
|
||||
throw new \Exception("[{$keyword}] 검색어가 지정되지 않았습니다. ");
|
||||
}
|
||||
//검색어에 따른 서버정보를 검색 후 해당하는 서비스리스트를 가져온다.
|
||||
$rows = $this->getServerService()->getSearchServices($keyword);
|
||||
$rows = $this->getService()->getServerService()->getSearchServices($keyword);
|
||||
$uids = [];
|
||||
foreach ($rows as $row) {
|
||||
$uids[] = "'{$row->serviceinfo_uid}'";
|
||||
|
||||
@ -5,7 +5,6 @@ namespace App\Controllers;
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
use App\Libraries\LogCollector;
|
||||
use App\Services\MyLogService;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
@ -21,7 +20,6 @@ use Psr\Log\LoggerInterface;
|
||||
abstract class CommonController extends BaseController
|
||||
{
|
||||
private $_myAuth = null;
|
||||
private ?MyLogService $_myLogService = null;
|
||||
private $_viewDatas = [];
|
||||
abstract public function getService(): mixed;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
@ -57,13 +55,6 @@ abstract class CommonController extends BaseController
|
||||
{
|
||||
return $this->_viewDatas;
|
||||
}
|
||||
final protected function getMyLogService(): mixed
|
||||
{
|
||||
if (!$this->_myLogService) {
|
||||
$this->_myLogService = new MyLogService();
|
||||
}
|
||||
return $this->_myLogService;
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
//FormDatas 전달값,Default값
|
||||
//FormDatas 검증
|
||||
@ -96,7 +87,6 @@ abstract class CommonController extends BaseController
|
||||
//Process Result처리
|
||||
protected function getResultFail(string $message = MESSAGES["FAILED"]): RedirectResponse
|
||||
{
|
||||
// $this->getMyLogService()->save($this->getService()->getClassName(), $this->getAction(), $message, $this->getMyAuth()->getUIDByAuthInfo());
|
||||
if ($this->request->getMethod() === 'POST') {
|
||||
return redirect()->back()->withInput()->with('error', $message);
|
||||
}
|
||||
|
||||
@ -11,21 +11,4 @@ class BoardHelper extends CommonHelper
|
||||
parent::__construct();
|
||||
$this->setTitleField(BoardModel::TITLE);
|
||||
}
|
||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||
{
|
||||
switch ($field) {
|
||||
case 'content':
|
||||
if (in_array($viewDatas['control']['action'], ['view', 'index'])) {
|
||||
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다");
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ class CommonHelper
|
||||
case 'detail':
|
||||
case 'history':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce';
|
||||
$form = form_textarea($field, $value ?? "", [
|
||||
$form = form_textarea($field, html_entity_decode($value ?? "", ENT_QUOTES, 'UTF-8'), [
|
||||
"class" => "form-control",
|
||||
'style' => 'width:100%;',
|
||||
...$extras
|
||||
@ -347,6 +347,14 @@ class CommonHelper
|
||||
}
|
||||
$value = implode(" , ", $roles);
|
||||
break;
|
||||
case 'description':
|
||||
case 'content':
|
||||
case 'detail':
|
||||
case 'history':
|
||||
if (in_array($viewDatas['control']['action'], ['view', 'index'])) {
|
||||
$value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
break;
|
||||
case 'issue_at':
|
||||
case 'expired_at':
|
||||
case 'billing_at':
|
||||
|
||||
@ -3,8 +3,8 @@ return [
|
||||
'title' => "게시판정보",
|
||||
'label' => [
|
||||
'uid' => "번호",
|
||||
'user_uid' => "작성자",
|
||||
'worker_uid' => "작업자",
|
||||
'user_uid' => "요청자/작성자",
|
||||
'worker_uid' => "업무협조자",
|
||||
'category' => "구분",
|
||||
'title' => "제목",
|
||||
'content' => "내용",
|
||||
@ -13,15 +13,10 @@ return [
|
||||
'created_at' => "작성일",
|
||||
'deleted_at' => "삭제일",
|
||||
],
|
||||
// "CATEGORY" => [
|
||||
// BOARD['CATEGORY']['NOTICE'] => '공지사항',
|
||||
// BOARD['CATEGORY']['WORKING'] => '작업일지',
|
||||
// BOARD['CATEGORY']['REQUESTTASK'] => '요청업무',
|
||||
// ],
|
||||
"CATEGORY" => [
|
||||
'notice' => '공지사항',
|
||||
'working' => '작업일지',
|
||||
'requesttask' => '요청업무',
|
||||
BOARD['CATEGORY']['NOTICE'] => '공지사항',
|
||||
BOARD['CATEGORY']['WORKING'] => '작업일지',
|
||||
BOARD['CATEGORY']['REQUESTTASK'] => '요청업무',
|
||||
],
|
||||
"STATUS" => [
|
||||
STATUS['AVAILABLE'] => "사용중",
|
||||
|
||||
@ -37,10 +37,10 @@ class BoardModel extends CommonModel
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "user_uid":
|
||||
$rule = "required|number";
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "worker_uid":
|
||||
$rule = "permit_empty|number";
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "content":
|
||||
$rule = "permit_empty|string";
|
||||
|
||||
@ -46,6 +46,22 @@ class BoardService extends CommonService
|
||||
{
|
||||
return ['user_uid', 'category', 'status'];
|
||||
}
|
||||
public function getFormOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'worker_uid':
|
||||
$options = $this->getUserService()->getEntities();
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($field, $options);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값들이 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//기본 기능부분
|
||||
public function latest(array $where, int $limit = 3): array
|
||||
{
|
||||
//관리자정보
|
||||
@ -61,5 +77,4 @@ class BoardService extends CommonService
|
||||
}
|
||||
return $datas;
|
||||
}
|
||||
//기본 기능부분
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ class ServiceService extends CustomerService
|
||||
return $this->_serverPartService;
|
||||
}
|
||||
//interval을 기준으로 최근 신규 서비스정보 가져오기
|
||||
final public function getEntitiesByNewService(int $interval, string $status = ServiceEntity::DEFAULT_STATUS): array
|
||||
final public function getNewServiceEntities(int $interval, string $status = ServiceEntity::DEFAULT_STATUS): array
|
||||
{
|
||||
return $this->getEntities(sprintf("start_at >= NOW()-INTERVAL {$interval} DAY AND status = '%s'", $status));
|
||||
}
|
||||
|
||||
@ -136,9 +136,8 @@ class ServerService extends EquipmentService implements ServiceInterface
|
||||
->groupBy('serverinfo.type')
|
||||
->builder();
|
||||
// echo $builder->getCompiledSelect(false) . "<BR>"; //초기화 없이 SQL만 보고 싶을 때: getCompiledSelect(false) ← 꼭 false!
|
||||
$rows = $builder->get()->getResult();
|
||||
// dd($rows);
|
||||
foreach ($rows as $row) {
|
||||
foreach ($builder->get()->getResult() as $row) {
|
||||
$totalCounts[$row->type]['chiba'] = $row->chiba;
|
||||
$totalCounts[$row->type]['tokyo'] = $row->tokyo;
|
||||
$totalCounts[$row->type]['summary'] += $row->summary;
|
||||
|
||||
@ -12,15 +12,11 @@ use App\Interfaces\Equipment\ServerPartInterface;
|
||||
use App\Models\PaymentModel;
|
||||
use App\Services\CommonService;
|
||||
use App\Services\Customer\AccountService;
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\ServerPartService;
|
||||
use App\Services\UserService;
|
||||
|
||||
class PaymentService extends CommonService implements ServiceInterface, ServerPartInterface
|
||||
{
|
||||
private ?UserService $_userService = null;
|
||||
private ?ClientService $_clientService = null;
|
||||
private ?ServiceService $_serviceService = null;
|
||||
private ?ServerPartService $_serverPartService = null;
|
||||
private ?AccountService $_accountService = null;
|
||||
@ -102,13 +98,14 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
|
||||
//총 미납건수, 금액
|
||||
final public function getUnPaids(string $group, array $where = []): array
|
||||
{
|
||||
$rows = $this->getModel()->groupBy($group)
|
||||
$builder = $this->getModel()->groupBy($group)
|
||||
->select("{$group},COUNT(uid) as cnt, SUM(amount) as amount")
|
||||
->where(['status' => STATUS['UNPAID']])
|
||||
->where($where)
|
||||
->get()->getResult();
|
||||
->builder();
|
||||
// echo $builder->getCompiledSelect(false); //초기화 없이 SQL만 보고 싶을 때: getCompiledSelect(false) ← 꼭 false!
|
||||
$unPaids = [];
|
||||
foreach ($rows as $row) {
|
||||
foreach ($builder->get()->getResult() as $row) {
|
||||
$unPaids[$row->$group] = ['cnt' => $row->cnt, 'amount' => $row->amount];
|
||||
}
|
||||
return $unPaids;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user