46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Models\UserModel;
|
|
use App\Traits\MangboardTrait;
|
|
|
|
class UserController extends AdminController
|
|
{
|
|
use MangboardTrait;
|
|
|
|
private $_model = null;
|
|
public function __construct()
|
|
{
|
|
$this->_model = new UserModel();
|
|
}
|
|
|
|
public function index(): string
|
|
{
|
|
return __METHOD__;
|
|
}
|
|
|
|
public function point(): string
|
|
{
|
|
try {
|
|
$id = $this->request->getPost('id');
|
|
$entity = is_numeric($id) ? $this->_model->getEntityByPK(intval($id)) : $this->_model->getEntityByID($id);
|
|
if (!$entity) {
|
|
throw new \Exception("해당 회원[{$id}]이 없습니다.");
|
|
}
|
|
|
|
$point = $this->request->getPost('point');
|
|
if (!is_numeric($point)) {
|
|
throw new \Exception("포인트 값에 {$point}를 사용할 수 없습니다.");
|
|
}
|
|
|
|
$sign = $this->request->getPost('point') ?: "+";
|
|
$entity = $this->setUserPointByMangboard($entity, intval($point), $sign);
|
|
return "완료되었습니다.";
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
}
|