Automationn init...

This commit is contained in:
최준흠 2024-09-02 21:37:17 +09:00
parent f3f8c0c6cd
commit 8e7d6793c5
3 changed files with 22 additions and 23 deletions

View File

@ -31,7 +31,9 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('insert', 'UserController::insert');
$routes->get('update', 'UserController::form_update');
$routes->post('update', 'UserController::upadate');
$routes->get('delete/', 'UserController::delete', ['filter' => 'authFilter:master']);
$routes->get('view', 'UserController::view');
$routes->get('delete/', 'UserController::delete', ['filter' => 'authFilter:master']);
$routes->post('point', 'UserController::form_point');
$routes->post('point', 'UserController::point', ['filter' => 'authFilter:master']);
});
});

View File

@ -7,20 +7,7 @@ use App\Controllers\BaseController;
abstract class AdminController extends BaseController
{
private $_datas = [];
final public function __get($name)
{
// echo "Getting '$name'\n";
if (array_key_exists($name, $this->_datas)) {
return $this->_datas[$name];
}
return null;
}
final public function __set($name, $value)
{
// echo "Setting '$name' to '$value'\n";
$this->_datas[$name] = $value;
}
protected function __construct()
{
//사용자 기본 Role 지정
@ -33,4 +20,17 @@ abstract class AdminController extends BaseController
$this->_datas['currentRoles'] = is_array($currentRoles) ? $currentRoles : [DEFAULTS["ROLE"]];
}
}
final public function __get($name): array|null
{
if (!array_key_exists($name, $this->_datas)) {
return null;
}
return $this->_datas;
}
final public function __set($name, $value): void
{
$this->_datas[$name] = $value;
}
}

View File

@ -2,10 +2,6 @@
namespace App\Controllers\Admin;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Models\UserModel;
use App\Traits\MangboardTrait;
@ -24,20 +20,21 @@ class UserController extends AdminController
return __METHOD__;
}
public function update()
public function point()
{
try {
$id = $this->request->getPost('id');
$point = $this->request->getPost('point');
$sign = $this->request->getPost('point') ?: "+";
$entity = is_numeric($id) ? $this->_model->getEntityByPK(intval($id)) : $this->_model->getEntityByID($id);
if (!$entity) {
throw new \Exception(sprintf("해당 회원[%s:%s]이 없습니다.", gettype($id), $id));
throw new \Exception("해당 회원[{$id}]이 없습니다.");
}
$point = $this->request->getPost('point');
if (!is_numeric($point)) {
throw new \Exception("포인트 값에 {$point}를 사용할 수 없습니다.");
}
$sign = $this->request->getPost('point') ?: "+";
$entity = $this->setUserPointByMangboardTrait($entity, intval($point), $sign);
return "완료되었습니다.";
} catch (\Exception $e) {