64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\CLI\Mangboard;
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Entities\Mangboard\UserEntity;
|
|
use App\Models\Mangboard\UserModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class UserController extends BaseController
|
|
{
|
|
private $_model = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
// Do Not Edit This Line
|
|
parent::initController($request, $response, $logger);
|
|
// Preload any models, libraries, etc, here.
|
|
// E.g.: $this->session = \Config\Services::session();
|
|
$this->_model = new UserModel();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
public function point(string $uid, int $point, string $sign = "plus")
|
|
{
|
|
$msg = [];
|
|
try {
|
|
|
|
$entity = $this->_model->getEntity($uid);
|
|
if (!$entity) {
|
|
throw new \Exception("해당 회원[{$uid}]이 없습니다.");
|
|
}
|
|
$old_point = $entity->getPoint();
|
|
$entity->setPoint($point, $sign);
|
|
$entity = $this->_model->setEntity($entity);
|
|
$msg[] = "[{$entity}] 회원님의 포인트는 {$old_point}->{$entity->getPoint()} 입니다.";
|
|
} catch (\Exception $e) {
|
|
$msg[] = $e->getMessage();
|
|
}
|
|
return implode("\n", $msg);
|
|
}
|
|
|
|
public function level(string $uid)
|
|
{
|
|
$msg = [];
|
|
try {
|
|
$entity = $this->_model->getEntity($uid);
|
|
if (!$entity) {
|
|
throw new \Exception("해당 회원[{$uid}]이 없습니다.");
|
|
}
|
|
$old_level = $entity->getLevel();
|
|
$entity = $this->_model->setLevel($entity);
|
|
$msg[] = "[{$entity}] 회원님의 레벨은 {$old_level}->{$entity->getLevel()} 입니다.";
|
|
} catch (\Exception $e) {
|
|
$msg[] = $e->getMessage();
|
|
}
|
|
return implode("\n", $msg);
|
|
}
|
|
}
|