[''], 'allow'=>[ 'userstar', 'querylist', 'starlist' ] ]; Hook::listen('check_auth',$action); $request = Request::instance(); $a = strtolower($request->action()); if (!in_array($a, $action['permission'])) { parent::_initialize(); } } /** * 通讯录列表 * @return mixed */ public function queryList(){ $param = $this->param; $userInfo = $this->userInfo; $param['user_id']=$userInfo['id']; $userLogic=new UserLogic(); $data=$userLogic->getDataList($param); return resultArray(['data' => $data]); } /** * 关注的通讯录列表 * @return mixed */ public function starList(){ $param = $this->param; $userInfo = $this->userInfo; $param['user_id']=$userInfo['id']; $userLogic=new UserLogic(); $data=$userLogic->queryList($param); return resultArray(['data' => $data]); } /** * 设置关注 * * @return \think\response\Json * @throws \think\Exception * @throws \think\exception\PDOException */ public function userStar() { $userInfo = $this->userInfo; $userId = $userInfo['id']; $targetId = $this->param['target_id']; $type = $this->param['type']; if (empty($userId) || empty($targetId) || empty($type)) return resultArray(['error' => '缺少必要参数!']); if (!$this->setStar($type, $userId, $targetId)) { return resultArray(['error' => '设置关注失败!']); } return resultArray(['data' => '设置关注成功!']); } }