shoppingmallv2 init...
This commit is contained in:
parent
1031285e3f
commit
e96de32a6c
@ -130,7 +130,7 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
$routes->get('view/(:uuid)', 'ProductController::view/$1');
|
||||
});
|
||||
$routes->group('order', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:master,director,cloudflare,manager,gold,silver,brone,vip,user'], static function ($routes) {
|
||||
$routes->group('order', static function ($routes) {
|
||||
$routes->get('', 'OrderController::index');
|
||||
$routes->post('insert', 'OrderController::insert');
|
||||
$routes->get('view/(:uuid)', 'OrderController::view/$1');
|
||||
|
||||
@ -17,4 +17,35 @@ class BoardConfigController extends AdminController
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,18 +6,43 @@ use App\Models\BoardModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\BoardConfigModel;
|
||||
|
||||
class BoardController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new BoardModel();
|
||||
$this->_model = new BoardModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["board_config_uid", 'title', "board_file", "passwd", "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["board_config_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
|
||||
@ -17,4 +17,28 @@ class CategoryController extends AdminController
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['name', "status", "head", "tail",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ['name', "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ['name', "status", "created_at", "head", "tail",];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,22 +2,43 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Entities\OrderEntity;
|
||||
use App\Models\OrderModel;
|
||||
use App\Models\ProductModel;
|
||||
use CodeIgniter\Cookie\Exceptions\CookieException;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class OrderController extends AdminController
|
||||
{
|
||||
private $_product_options = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new OrderModel();
|
||||
$this->_model = new OrderModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
final public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['product_uid', "quantity", "price", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
case "view":
|
||||
return ['product_uid', "user_uid", "quantity", "price", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function getFieldFilters(): array
|
||||
{
|
||||
return ['product_uid', "user_uid", "status"];
|
||||
}
|
||||
final public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,19 +6,43 @@ use App\Models\ProductModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\CategoryModel;
|
||||
|
||||
class ProductController extends AdminController
|
||||
{
|
||||
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new ProductModel();
|
||||
$this->_model = new ProductModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["category_uid", "user_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["category_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ class UserController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new UserModel();
|
||||
$this->_model = new UserModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
@ -32,4 +32,29 @@ class UserController extends AdminController
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["id", "passwd", $this->_model->getTitleField(), "email", "role", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", $this->_model->getTitleField(), "email", "role", "status", 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ["id", $this->_model->getTitleField(), "email", "role", "status", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["role", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,4 +17,28 @@ class UserSNSController extends AdminController
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["site", "id", $this->_model->getTitleField(), "email", "detail", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "site", "id", $this->_model->getTitleField(), "email", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,19 +2,52 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Adapter\Auth\Adapter;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Libraries\Adapter\Auth\Adapter;
|
||||
|
||||
class AuthController extends BaseController
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['Common'];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
private $_session = null;
|
||||
private $_viewDatas = array();
|
||||
private $_adapters = array();
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_session = \Config\Services::session();
|
||||
$this->_viewDatas['title'] = 'Auth';
|
||||
$this->_viewPath .= 'auth';
|
||||
$this->_viewDatas['layout'] = LAYOUTS['empty'];
|
||||
$this->_viewDatas['session'] = $this->_session;
|
||||
$this->initAdapters();
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\UserModel;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
@ -63,6 +64,12 @@ abstract class BaseController extends Controller
|
||||
$this->_viewDatas['session'] = $this->_session;
|
||||
}
|
||||
|
||||
abstract public function getFields(string $action): array;
|
||||
abstract public function getFieldFilters(): array;
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return $this->getFieldFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
@ -119,10 +126,10 @@ abstract class BaseController extends Controller
|
||||
$action = 'update';
|
||||
break;
|
||||
}
|
||||
$this->_viewDatas['fields'] = $fields ?: $this->_model->getFields($action);
|
||||
$this->_viewDatas['fields'] = $fields ?: $this->getFields($action);
|
||||
$this->_viewDatas['fieldFilters'] = $this->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters();
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action);
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->_model->getFieldBatchFilters();
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
return $this->_viewDatas;
|
||||
}
|
||||
|
||||
63
app/Controllers/Front/BoardController.php
Normal file
63
app/Controllers/Front/BoardController.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Models\BoardModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\BoardConfigModel;
|
||||
|
||||
class BoardController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new BoardModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["board_config_uid", 'title', "board_file", "passwd", "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["board_config_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'passwd':
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
|
||||
$this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
|
||||
break;
|
||||
case 'board_file':
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity);
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormData($field, $entity);
|
||||
break;
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FrontController extends BaseController
|
||||
abstract class FrontController extends BaseController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
|
||||
@ -17,7 +17,7 @@ class OrderController extends FrontController
|
||||
private $_cart_cookie_expire = 3600; //1Hour
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new OrderModel();
|
||||
$this->_model = new OrderModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
@ -25,6 +25,29 @@ class OrderController extends FrontController
|
||||
helper('cookie');
|
||||
}
|
||||
|
||||
final public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['product_uid', "quantity", "price", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
case "view":
|
||||
return ['product_uid', "user_uid", "quantity", "price", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function getFieldFilters(): array
|
||||
{
|
||||
return ['product_uid', "user_uid", "status"];
|
||||
}
|
||||
final public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
|
||||
//쿠키에 장바구니에 담긴 Order UID를 추가해준다.
|
||||
private function setOrderCookie(OrderEntity $entity)
|
||||
{
|
||||
|
||||
@ -9,7 +9,6 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class ProductController extends FrontController
|
||||
{
|
||||
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new ProductModel();
|
||||
@ -19,6 +18,30 @@ class ProductController extends FrontController
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["category_uid", "user_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["category_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
|
||||
@ -40,8 +40,8 @@ abstract class BaseModel extends Model
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
private $_className = null;
|
||||
private $_user_options = null;
|
||||
private $_className = null;
|
||||
protected $_session = null;
|
||||
protected function __construct(string $className)
|
||||
{
|
||||
@ -64,8 +64,6 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
abstract public function getTitleField(): string;
|
||||
abstract public function getEntity($conditions): BaseEntity;
|
||||
abstract public function getFieldFilters(): array;
|
||||
abstract public function getFields(string $action): array;
|
||||
final public function getEntitys(array $conditions = array()): array
|
||||
{
|
||||
return $this->where($conditions)->findAll();
|
||||
@ -113,11 +111,6 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return $this->getFieldFilters();
|
||||
}
|
||||
|
||||
//Field별 Form Option용
|
||||
public function getFormOptions(array $conditions = array(), $options = array()): array
|
||||
{
|
||||
@ -131,17 +124,17 @@ abstract class BaseModel extends Model
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
if (is_null($this->_user_options)) {
|
||||
$userModel = new UserModel();
|
||||
$this->_user_options = $userModel->getFormOptions(['status' => 'use']);
|
||||
$userModel = new UserModel([$this->getPrimaryKey(), $this->getTitleField()]);
|
||||
$this->_user_options = $userModel->getFormOptions();
|
||||
}
|
||||
$options = $this->_user_options;
|
||||
break;
|
||||
default:
|
||||
$options = lang($this->_className . '.' . strtoupper($field));
|
||||
$options = lang($this->getClassName() . '.' . strtoupper($field));
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
@ -151,7 +144,7 @@ abstract class BaseModel extends Model
|
||||
$fieldFormOptions = array();
|
||||
foreach ($fields as $field) {
|
||||
if (!is_string($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
|
||||
}
|
||||
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
|
||||
}
|
||||
|
||||
@ -9,46 +9,16 @@ class BoardConfigModel extends BaseModel
|
||||
protected $table = "tw_board_config";
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = BoardConfigEntity::class;
|
||||
public function __construct()
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
parent::__construct('BoardConfig');
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields()];
|
||||
$this->allowedFields = [...$this->allowedFields, ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
$this->getTitleField(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
$this->getTitleField(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
|
||||
@ -9,10 +9,10 @@ class BoardModel extends BaseHierarchyModel
|
||||
private $_boardconfig_options = null;
|
||||
protected $table = "tw_board";
|
||||
protected $returnType = BoardEntity::class;
|
||||
public function __construct()
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
parent::__construct('Board');
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
|
||||
$this->allowedFields = [...$this->allowedFields, "user_uid", ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
@ -23,30 +23,6 @@ class BoardModel extends BaseHierarchyModel
|
||||
{
|
||||
return 'content';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["board_config_uid", $this->getTitleField(), "board_file", "passwd", "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["board_config_uid", "user_uid", $this->getTitleField(), "board_file", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["board_config_uid", "user_uid", $this->getTitleField(), "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["board_config_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -75,7 +51,7 @@ class BoardModel extends BaseHierarchyModel
|
||||
switch ($field) {
|
||||
case 'board_config_uid':
|
||||
if (is_null($this->_boardconfig_options)) {
|
||||
$boardConfigModel = new BoardConfigModel();
|
||||
$boardConfigModel = new BoardConfigModel([$this->getPrimaryKey(), $this->getTitleField()]);
|
||||
$this->_boardconfig_options = $boardConfigModel->getFormOptions();
|
||||
}
|
||||
$options = $this->_boardconfig_options;
|
||||
@ -85,11 +61,10 @@ class BoardModel extends BaseHierarchyModel
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getEntity($conditions): BoardEntity
|
||||
{
|
||||
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
|
||||
@ -9,10 +9,10 @@ class CategoryModel extends BaseHierarchyModel
|
||||
//BaseHierarchyModel를 확장하면 grpno가 숫자이고, primarykey를 대분류 생성시 copy하여 grpno에 넣고 sorting하므로
|
||||
protected $table = "tw_category";
|
||||
protected $returnType = CategoryEntity::class;
|
||||
public function __construct()
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
parent::__construct('Category');
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(),];
|
||||
$this->allowedFields = [...$this->allowedFields, ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
@ -23,30 +23,6 @@ class CategoryModel extends BaseHierarchyModel
|
||||
{
|
||||
return 'head';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [$this->getTitleField(), "status", "head", "tail",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [$this->getTitleField(), "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [$this->getTitleField(), "status", "created_at", "head", "tail",];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Entities\OrderEntity;
|
||||
use App\Entities\ProductEntity;
|
||||
|
||||
class OrderModel extends BaseModel
|
||||
{
|
||||
@ -12,38 +11,16 @@ class OrderModel extends BaseModel
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = OrderEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
public function __construct()
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
parent::__construct('Order');
|
||||
$this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$this->getFields(),];
|
||||
$this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
final public function getTitleField(): string
|
||||
{
|
||||
return 'product_uid';
|
||||
}
|
||||
final public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [$this->getTitleField(), "quantity", "price", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
case "view":
|
||||
return [$this->getTitleField(), "user_uid", "quantity", "price", "status", "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final public function getFieldFilters(): array
|
||||
{
|
||||
return [$this->getTitleField(), "user_uid", "status"];
|
||||
}
|
||||
final public function getFieldBatchFilters(): array
|
||||
{
|
||||
return ["status"];
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -61,14 +38,13 @@ class OrderModel extends BaseModel
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
//Field별 Form Option용
|
||||
public function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'product_uid':
|
||||
if (is_null($this->_product_options)) {
|
||||
$productModel = new productModel();
|
||||
$productModel = new productModel([$this->getPrimaryKey(), 'product_uid']);
|
||||
$this->_product_options = $productModel->getFormOptions();
|
||||
}
|
||||
$options = $this->_product_options;
|
||||
@ -82,7 +58,6 @@ class OrderModel extends BaseModel
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function getEntity($conditions): OrderEntity
|
||||
{
|
||||
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
|
||||
@ -11,40 +11,17 @@ class ProductModel extends BaseModel
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = ProductEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
public function __construct()
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
parent::__construct('Product');
|
||||
$this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$this->getFields(),];
|
||||
$this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", $this->getTitleField(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["category_uid", "user_uid", $this->getTitleField(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["category_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -84,7 +61,7 @@ class ProductModel extends BaseModel
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
if (is_null($this->_category_options)) {
|
||||
$categoryModel = new CategoryModel();
|
||||
$categoryModel = new CategoryModel([$this->getPrimaryKey(), $this->getTitleField()]);
|
||||
$this->_category_options = $categoryModel->getFormOptions();
|
||||
}
|
||||
$options = $this->_category_options;
|
||||
|
||||
@ -10,40 +10,16 @@ class UserModel extends BaseModel
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = UserEntity::class;
|
||||
protected $useSoftDeletes = true;
|
||||
public function __construct()
|
||||
public function __construct(array $fields = array())
|
||||
{
|
||||
parent::__construct('User');
|
||||
$this->allowedFields = ["uid", ...$this->allowedFields, ...$this->getFields()];
|
||||
$this->allowedFields = ["uid", ...$this->allowedFields, ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["id", "passwd", $this->getTitleField(), "email", "role", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", $this->getTitleField(), "email", "role", "status", 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ["id", $this->getTitleField(), "email", "role", "status", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["role", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
|
||||
@ -8,40 +8,17 @@ class UserSNSModel extends BaseModel
|
||||
{
|
||||
protected $table = "tw_user_sns";
|
||||
protected $returnType = UserSNSEntity::class;
|
||||
public function __construct()
|
||||
public function __construct($fields)
|
||||
{
|
||||
parent::__construct('UserSNS');
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
|
||||
$this->allowedFields = [...$this->allowedFields, "user_uid", ...$fields];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["site", "id", $this->getTitleField(), "email", "detail", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "site", "id", $this->getTitleField(), "email", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
|
||||
34
app/Views/front/board/index.php
Normal file
34
app/Views/front/board/index.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<div class="top">
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<ul class="nav">
|
||||
조건검색:<?php foreach ($fieldFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_BoardHelper($field, $$field, $fieldFormOptions) ?></li><?php endforeach; ?>
|
||||
<?= $this->include('templates/front/index_head'); ?>
|
||||
</ul>
|
||||
<?= form_close(); ?>
|
||||
</div>
|
||||
<table class="table table-bordered table-hover table-striped">
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<?php foreach ($fields as $field) : ?><th><?= getFieldIndex_Column_BoardHelper($field, $order_field, $order_value) ?></th><?php endforeach; ?>
|
||||
</tr>
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($entitys as $entity) : ?>
|
||||
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
||||
<td>
|
||||
<?= $total_count - (($page - 1) * $per_page + $i) ?>
|
||||
</td>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_BoardHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<div class="bottom">
|
||||
<?= $pagination ?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
21
app/Views/front/board/insert.php
Normal file
21
app/Views/front/board/insert.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<?= form_open_multipart(current_url(), $forms['attributes'], $forms['hiddens']) ?>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_BoardHelper($field, $fieldRules) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_BoardHelper($field, old($field, DEFAULTS['EMPTY']), $fieldFormOptions) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td valign="bottom" colspan="2"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?= form_close(); ?>
|
||||
<?= $this->endSection() ?>
|
||||
21
app/Views/front/board/reply.php
Normal file
21
app/Views/front/board/reply.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<?= form_open_multipart(current_url(), $forms['attributes'], $forms['hiddens']) ?>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_BoardHelper($field, $fieldRules) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_BoardHelper($field, old($field, $entity->$field), $fieldFormOptions) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td valign="bottom" colspan="2"><?= form_submit('', '답글', array("class" => "btn btn-outline btn-primary")); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?= form_close(); ?>
|
||||
<?= $this->endSection() ?>
|
||||
21
app/Views/front/board/update.php
Normal file
21
app/Views/front/board/update.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<?= form_open_multipart(current_url(), $forms['attributes'], $forms['hiddens']) ?>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_BoardHelper($field, $fieldRules) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_BoardHelper($field, old($field, $entity->$field), $fieldFormOptions) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td valign="bottom" colspan="2"><?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?= form_close(); ?>
|
||||
<?= $this->endSection() ?>
|
||||
16
app/Views/front/board/view.php
Normal file
16
app/Views/front/board/view.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_BoardHelper($field, $fieldRules) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldView_BoardHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
Loading…
Reference in New Issue
Block a user