cfmgrv4 init...10
This commit is contained in:
parent
33948d56c1
commit
30839cbc7f
@ -53,14 +53,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
|||||||
$routes->post('batchjob_delete', 'UserController::batchjob_delete');
|
$routes->post('batchjob_delete', 'UserController::batchjob_delete');
|
||||||
$routes->get('download/(:alpha)', 'UserController::download/$1');
|
$routes->get('download/(:alpha)', 'UserController::download/$1');
|
||||||
});
|
});
|
||||||
$routes->group('usersns', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:master'], function ($routes) {
|
|
||||||
$routes->get('/', 'UserSNSController::index');
|
|
||||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1');
|
|
||||||
$routes->get('toggle/(:num)/(:any)', 'UserSNSController::toggle/$1/$2');
|
|
||||||
$routes->post('batchjob', 'UserSNSController::batchjob');
|
|
||||||
$routes->post('batchjob_delete', 'UserSNSController::batchjob_delete');
|
|
||||||
$routes->get('download/(:alpha)', 'UserSNSController::download/$1');
|
|
||||||
});
|
|
||||||
$routes->group('mapurl', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
|
$routes->group('mapurl', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
|
||||||
$routes->get('/', 'MapurlController::index');
|
$routes->get('/', 'MapurlController::index');
|
||||||
$routes->get('create', 'MapurlController::create_form');
|
$routes->get('create', 'MapurlController::create_form');
|
||||||
|
|||||||
@ -1,62 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controllers\Admin;
|
|
||||||
|
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use App\Helpers\UserSNSHelper;
|
|
||||||
use App\Models\UserModel;
|
|
||||||
use App\Services\UserSNSService;
|
|
||||||
|
|
||||||
class UserSNSController extends AdminController
|
|
||||||
{
|
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
||||||
{
|
|
||||||
parent::initController($request, $response, $logger);
|
|
||||||
$this->title = lang("{$this->getService()->getClassPath()}.title");
|
|
||||||
$this->helper = new UserSNSHelper();
|
|
||||||
}
|
|
||||||
protected function getService(): UserSNSService
|
|
||||||
{
|
|
||||||
if ($this->service === null) {
|
|
||||||
$this->service = new UserSNSService();
|
|
||||||
$this->class_name = $this->service->getClassName();
|
|
||||||
$this->class_path = $this->service->getClassPath();
|
|
||||||
}
|
|
||||||
return $this->service;
|
|
||||||
}
|
|
||||||
protected function getFormFieldOption(string $field, array $options = []): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case $this->getService()->getModel()::PARENT:
|
|
||||||
$userModel = model(UserModel::class);
|
|
||||||
// $this->getUserModel()->where('status', DEFAULTS['STATUS']);
|
|
||||||
$options[$field] = $userModel->getFormFieldOption($field);
|
|
||||||
// echo $this->getUserModel()->getLastQuery();
|
|
||||||
// dd($options);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$options = parent::getFormFieldOption($field, $options);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $options;
|
|
||||||
}
|
|
||||||
|
|
||||||
//생성
|
|
||||||
protected function create_init(string $action, $fields = []): void
|
|
||||||
{
|
|
||||||
$fields = [
|
|
||||||
'fields' => [$this->getService()->getModel()::PARENT, 'site', 'id', $this->getService()->getModel()::TITLE, 'email'],
|
|
||||||
];
|
|
||||||
parent::create_init($action, fields: $fields);
|
|
||||||
}
|
|
||||||
//수정
|
|
||||||
protected function modify_init(string $action, $fields = []): void
|
|
||||||
{
|
|
||||||
$fields = [
|
|
||||||
'fields' => [$this->getService()->getModel()::PARENT, 'site', 'id', $this->getService()->getModel()::TITLE, 'email', 'status'],
|
|
||||||
];
|
|
||||||
parent::modify_init($action, $fields);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entities;
|
|
||||||
|
|
||||||
use App\Entities\CommonEntity;
|
|
||||||
use App\Models\UserSNSModel;
|
|
||||||
|
|
||||||
class UserSNSEntity extends CommonEntity
|
|
||||||
{
|
|
||||||
public function __toString(): string
|
|
||||||
{
|
|
||||||
return "{$this->getPK()}|{$this->getID()}|{$this->getTitle()}";
|
|
||||||
}
|
|
||||||
public function getPK(): int
|
|
||||||
{
|
|
||||||
return $this->attributes[UserSNSModel::PK];
|
|
||||||
}
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return $this->attributes[UserSNSModel::TITLE];
|
|
||||||
}
|
|
||||||
public function setTitle(string $title): void
|
|
||||||
{
|
|
||||||
$this->attributes[UserSNSModel::TITLE] = $title;
|
|
||||||
}
|
|
||||||
//Common Function
|
|
||||||
public function getParent(): int|null
|
|
||||||
{
|
|
||||||
return $this->attributes[UserSNSModel::PARENT];
|
|
||||||
}
|
|
||||||
public function getID(): string
|
|
||||||
{
|
|
||||||
return $this->attributes['id'];
|
|
||||||
}
|
|
||||||
public function getSite(): string
|
|
||||||
{
|
|
||||||
return $this->attributes['site'];
|
|
||||||
}
|
|
||||||
public function getEmail(): string
|
|
||||||
{
|
|
||||||
return $this->attributes['email'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,92 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Helpers;
|
|
||||||
|
|
||||||
use App\Models\UserSNSModel;
|
|
||||||
|
|
||||||
class UserSNSHelper extends CommonHelper
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
|
||||||
{
|
|
||||||
if (in_array($viewDatas['action'], ['create', 'modify'])) {
|
|
||||||
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
|
|
||||||
}
|
|
||||||
$value = $value ?: DEFAULTS['EMPTY'];
|
|
||||||
switch ($field) {
|
|
||||||
case UserSNSModel::PARENT:
|
|
||||||
$extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
|
|
||||||
$form = form_dropdown($field, [
|
|
||||||
"" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택',
|
|
||||||
] + $viewDatas['field_options'][$field], $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
|
|
||||||
break;
|
|
||||||
case 'id':
|
|
||||||
case UserSNSModel::TITLE:
|
|
||||||
$form = form_input($field, $value, $extras);
|
|
||||||
break;
|
|
||||||
case 'email':
|
|
||||||
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]);
|
|
||||||
break;
|
|
||||||
case 'detail':
|
|
||||||
$form = form_textarea($field, $value == DEFAULTS['EMPTY'] ? "@\n*\nm\nwww" : $value, [
|
|
||||||
'rows' => '20',
|
|
||||||
...$extras
|
|
||||||
]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $form;
|
|
||||||
} //
|
|
||||||
public function getFieldView(string $field, array $viewDatas, array $extras = []): string
|
|
||||||
{
|
|
||||||
$value = $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'];
|
|
||||||
switch ($field) {
|
|
||||||
case UserSNSModel::TITLE:
|
|
||||||
$value = form_label(
|
|
||||||
$value,
|
|
||||||
'view',
|
|
||||||
[
|
|
||||||
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
|
|
||||||
"data-bs-toggle" => "modal",
|
|
||||||
"data-bs-target" => "#index_action_form",
|
|
||||||
"style" => "color: blue; cursor: pointer; font-weight:bold;",
|
|
||||||
...$extras,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$value = parent::getFieldView($field, $viewDatas, $extras);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
} //
|
|
||||||
public function getListButton(string $action, array $viewDatas, array $extras = []): string
|
|
||||||
{
|
|
||||||
switch ($action) {
|
|
||||||
case 'create':
|
|
||||||
$action = "";
|
|
||||||
break;
|
|
||||||
case 'modify':
|
|
||||||
$action = $viewDatas['cnt'];
|
|
||||||
break;
|
|
||||||
case 'delete':
|
|
||||||
$action = "";
|
|
||||||
break;
|
|
||||||
case 'batchjob':
|
|
||||||
$action = "";
|
|
||||||
break;
|
|
||||||
case 'batchjob_delete':
|
|
||||||
$action = "";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$action = parent::getListButton($action, $viewDatas, $extras);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
return [
|
|
||||||
'title' => "SNS 계정정보",
|
|
||||||
'label' => [
|
|
||||||
'uid' => "번호",
|
|
||||||
'user_uid' => "local계정",
|
|
||||||
'site' => "사이트",
|
|
||||||
'id' => "계정",
|
|
||||||
'name' => "이름",
|
|
||||||
'email' => "메일",
|
|
||||||
'detail' => "상세정보",
|
|
||||||
'status' => "상태",
|
|
||||||
'updated_at' => "수정일",
|
|
||||||
'created_at' => "작성일",
|
|
||||||
],
|
|
||||||
"STATUS" => [
|
|
||||||
"use" => "사용",
|
|
||||||
"unuse" => "승인대기",
|
|
||||||
],
|
|
||||||
];
|
|
||||||
@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use App\Entities\UserSNSEntity;
|
|
||||||
use App\Models\CommonModel;
|
|
||||||
|
|
||||||
class UserSNSModel extends CommonModel
|
|
||||||
{
|
|
||||||
const TABLE = "user_sns";
|
|
||||||
const PK = "uid";
|
|
||||||
const TITLE = "name";
|
|
||||||
const PARENT = "user_uid";
|
|
||||||
const SITE = "site";
|
|
||||||
protected $table = self::TABLE;
|
|
||||||
protected $primaryKey = self::PK;
|
|
||||||
protected $returnType = UserSNSEntity::class;
|
|
||||||
protected $allowedFields = [
|
|
||||||
"site",
|
|
||||||
"user_uid",
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"email",
|
|
||||||
"detail",
|
|
||||||
"status"
|
|
||||||
];
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
public function getTitleField(): string
|
|
||||||
{
|
|
||||||
return self::TITLE;
|
|
||||||
}
|
|
||||||
public function getFields(): array
|
|
||||||
{
|
|
||||||
return [self::PARENT, 'site', 'id', self::TITLE, 'email'];
|
|
||||||
}
|
|
||||||
public function getFilterFields(): array
|
|
||||||
{
|
|
||||||
return [self::PARENT, 'status'];
|
|
||||||
}
|
|
||||||
public function getBatchJobFields(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
public function getFieldRule(string $action, string $field): string
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case "id":
|
|
||||||
$rule = "required|trim|min_length[4]|is_unique[{$this->table}.{$field}]";
|
|
||||||
break;
|
|
||||||
case $this->getTitleField():
|
|
||||||
$rule = "required|trim|string";
|
|
||||||
break;
|
|
||||||
case "site":
|
|
||||||
$rule = "required|trim|string";
|
|
||||||
break;
|
|
||||||
case "email":
|
|
||||||
$rule = "required|trim|valid_email";
|
|
||||||
break;
|
|
||||||
case "detail":
|
|
||||||
$rule = "required|trim|string";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$rule = parent::getFieldRule($action, $field);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $rule;
|
|
||||||
}
|
|
||||||
protected function convertEntityData(string $field, array $formDatas): mixed
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case "detail": //content등 textarea를 사용한 Field
|
|
||||||
$value = htmlentities($formDatas[$field], ENT_QUOTES);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$value = parent::convertEntityData($field, $formDatas);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
public function getEntityByPK(string $uid): null|UserSNSEntity
|
|
||||||
{
|
|
||||||
$this->where($this->getPKField(), intval($uid));
|
|
||||||
return $this->getEntity();
|
|
||||||
}
|
|
||||||
public function getEntityByID(string $id): null|UserSNSEntity
|
|
||||||
{
|
|
||||||
$this->where('id', $id);
|
|
||||||
return $this->getEntity();
|
|
||||||
}
|
|
||||||
//create용
|
|
||||||
public function create(array $formDatas = []): UserSNSEntity
|
|
||||||
{
|
|
||||||
return $this->create_process(new UserSNSEntity(), $formDatas);
|
|
||||||
}
|
|
||||||
//modify용
|
|
||||||
public function modify(UserSNSEntity $entity, array $formDatas): UserSNSEntity
|
|
||||||
{
|
|
||||||
return $this->modify_process($entity, $formDatas);
|
|
||||||
}
|
|
||||||
//List 검색용
|
|
||||||
public function setList_WordFilter(string $word): void
|
|
||||||
{
|
|
||||||
$this->orLike(self::TABLE . '.id', $word, 'both');
|
|
||||||
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
|
|
||||||
$this->orLike(self::TABLE . '.email', $word, 'both');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -18,7 +18,7 @@ class ZoneService extends CloudflareService
|
|||||||
'ipv6' => 'off',
|
'ipv6' => 'off',
|
||||||
'security_level' => 'medium',
|
'security_level' => 'medium',
|
||||||
'ssl' => 'flexible',
|
'ssl' => 'flexible',
|
||||||
'always_use_https' => 'off'
|
// 'always_use_https' => 'off'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services;
|
|
||||||
|
|
||||||
use App\Models\UserSNSModel;
|
|
||||||
use App\Entities\UserSNSEntity;
|
|
||||||
use Google\Service\AndroidEnterprise\Resource\Users;
|
|
||||||
|
|
||||||
class UserSNSService extends CommonService
|
|
||||||
{
|
|
||||||
private ?UserSNSModel $_model = null;
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
final public function getClassName(): string
|
|
||||||
{
|
|
||||||
return "UserSNS";
|
|
||||||
}
|
|
||||||
final public function getClassPath(): string
|
|
||||||
{
|
|
||||||
return $this->getClassName();
|
|
||||||
}
|
|
||||||
public function getModel(): UserSNSModel
|
|
||||||
{
|
|
||||||
if ($this->_model === null) {
|
|
||||||
$this->_model = new UserSNSModel();
|
|
||||||
}
|
|
||||||
return $this->_model;
|
|
||||||
}
|
|
||||||
public function create(array $formDatas): UserSNSEntity
|
|
||||||
{
|
|
||||||
return $this->getModel()->create($formDatas);
|
|
||||||
}
|
|
||||||
public function modify(UserSNSEntity $entity, array $formDatas): UserSNSEntity
|
|
||||||
{
|
|
||||||
return $this->getModel()->modify($entity, $formDatas);
|
|
||||||
}
|
|
||||||
public function delete(UserSNSEntity $entity): void
|
|
||||||
{
|
|
||||||
$this->getModel()->delete($entity->getPK());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,9 +1,6 @@
|
|||||||
<div class="accordion-item">
|
<div class="accordion-item">
|
||||||
<a href="/admin/user"><?= ICONS['MEMBER'] ?>계정 관리</a>
|
<a href="/admin/user"><?= ICONS['MEMBER'] ?>계정 관리</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="accordion-item">
|
|
||||||
<a href="/admin/usersns"><?= ICONS['GOOGLE'] ?> SNS 계정 관리</a>
|
|
||||||
</div>
|
|
||||||
<div class="accordion-item">
|
<div class="accordion-item">
|
||||||
<a href="/admin/mylog"><?= ICONS['FLAG'] ?> Log 관리</a>
|
<a href="/admin/mylog"><?= ICONS['FLAG'] ?> Log 관리</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user