public function getUser($id) { $user = EntityUser::findFirst($id); if (empty($user)) { throw new UserNotFoundException("Failed to find user with id ({$id})"); } return $user; }
/** * @Get('/user') */ public function userAction() { $user = User::findFirst(); echo $user->name; $this->view->disable(); }
/** * @Get("/index") */ public function indexAction() { $user = User::findFirst(1); $this->userAction($user); echo 'wechat_be2/wechat2/index/index'; }
public function signAction(WechatController $weObj) { $info = $weObj->getRevFrom(); $user = User::findFirst("open_id='{$info}'"); $open_id = $user->open_id; $id = $user->id; if (!empty($open_id)) { $sign = Sign::findFirst("user_id='{$user->id}'"); if (!empty($sign)) { $weObj->text("你今天已经签过到了")->reply(); } else { $user_id = new Sign(); $user_id->save(array("time" => date("Y:m:d H:i:s"), "count" => 1, "user_id" => $id, "date" => date("Y:m:d"))); $weObj->text("签到成功")->reply(); } } else { $weObj->text("没数据" . $open_id)->reply(); } }
/** * @Get("/add") */ public function addAction() { $user = User::findFirst(); echo $user->appid; $this->view->disable(); }