session = \Config\Services::session(); $this->_model = new UserModel(); } public function index() { // } public function point($id = null, $point = null, string $sign = "+") { try { $entitys = []; if ($id) { $entity = is_numeric($id) ? $this->_model->getEntityByPK(intval($id)) : $this->_model->getEntityByID($id); if (!$entity) { throw new \Exception(sprintf("해당 회원[%s:%s]이 없습니다.", gettype($id), $id)); } if (is_numeric($point)) { $entitys[] = $this->_model->setPoint($entity, $point, $sign); } } else { $entitys = $this->_model->getEntitys(); } foreach ($entitys as $entity) { log_message("debug", __FUNCTION__ . "=>[{$entity}] 회원님의 Point는 {$entity->getPoint()} 입니다."); } return "완료되었습니다."; } catch (\Exception $e) { log_message('error', '[ERROR] {exception}', ['exception' => $e]); return $e->getMessage(); } } public function level($id = null, $level = null) { try { $entitys = []; if ($id) { $entity = is_numeric($id) ? $this->_model->getEntityByPK(intval($id)) : $this->_model->getEntityByID($id); if (!$entity) { throw new \Exception(sprintf("해당 회원[%s:%s]이 없습니다.", gettype($id), $id)); } if (is_numeric($level)) { $entitys[] = $this->_model->checkLevel($entity, $level); } } else { foreach ($this->_model->getEntitys() as $entity) { $entitys[] = $this->_model->checkLevel($entity); } } foreach ($entitys as $entity) { log_message("debug", __FUNCTION__ . "=>[{$entity}] 회원님의 Level은 {$entity->getLevel()} 입니다."); } return "완료되었습니다."; } catch (\Exception $e) { log_message('error', '[ERROR] {exception}', ['exception' => $e]); return $e->getMessage(); } } }