55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Mangboard\Admin;
|
|
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
use App\Controllers\CommonController;
|
|
use App\Models\Mangboard\UserModel;
|
|
|
|
class UserController extends CommonController
|
|
{
|
|
private $_model = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
}
|
|
|
|
private function getModel(): UserModel
|
|
{
|
|
if ($this->_model === null) {
|
|
$this->_model = new UserModel();
|
|
}
|
|
return $this->_model;
|
|
}
|
|
|
|
public function point(string $id, string $point, string $sign = "+"): string
|
|
{
|
|
try {
|
|
$entity = $this->getModel()->getEntityByID($id);
|
|
if ($entity === null) {
|
|
throw new \Exception("해당 ID{$id}는 사용자가 존재하지 않습니다.");
|
|
}
|
|
$this->getModel()->setPoint($id, intval($point), $sign);
|
|
return "완료되었습니다.";
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
public function level(): string
|
|
{
|
|
try {
|
|
$userModel = new UserModel();
|
|
$userModel->setLevel();
|
|
log_message("notice", "Mangboard->level 작업이 완료되었습니다.");
|
|
return "완료되었습니다.";
|
|
} catch (\Exception $e) {
|
|
log_message("error", $e->getMessage());
|
|
return $e->getMessage();
|
|
}
|
|
}
|
|
}
|