示例#1
0
 public function getcirclesAction()
 {
     $re = array("returncode" => ReturnCode::$SUCCESS);
     $request = $this->getRequest();
     $da = $this->get('we_data_access');
     $currUser = $this->get('security.context')->getToken();
     if (!empty($currUser)) {
         $user = $currUser->getUser();
         $eshortname = $user->eshortname;
         //当前登录人企业 号
         $userAccount = $user->getUserName();
     } else {
         //当应用通过api接口调用时,不用登录,只能通过openid获取人员信息
         $ds = $this->getstaffinfo($request->get("Openid") . $request->get("openid"));
         $eshortname = $ds["eshortname"];
         $userAccount = $ds["login_account"];
     }
     //获取朋友圈子数量
     $staffMgr = new \Justsy\BaseBundle\Management\Staff($da, $this->get('we_data_access_im'), $userAccount, $this->container->get("logger"), $this->container);
     $friendList = $staffMgr->getFriendCount();
     $friendListSize = empty($friendList) ? 0 : $friendList;
     $sql = "select a.circle_id, a.circle_name, a.circle_desc, a.logo_path, a.create_staff, a.create_date, a.manager, \n    a.join_method, a.enterprise_no, a.network_domain, a.allow_copy, a.logo_path_small, a.logo_path_big, a.fafa_groupid,";
     $sql .= " ? staff_num ,'' classify_name, '' circle_class_id  from we_circle a where a.circle_id='9999' \n      union select a.circle_id, a.circle_name, a.circle_desc, a.logo_path, a.create_staff, a.create_date, a.manager, \n      a.join_method, a.enterprise_no, a.network_domain, a.allow_copy, a.logo_path_small, a.logo_path_big, a.fafa_groupid,(select count(1) from we_circle_staff c where c.circle_id=a.circle_id) as staff_num ,c.classify_name,a.circle_class_id\n      from we_circle a left join we_circle_staff b on a.circle_id=b.circle_id\n      left join we_circle_class c on a.circle_class_id=c.classify_id\n      where  b.login_account=? and a.circle_id!='9999'";
     $params = array();
     $params[] = (int) $friendListSize;
     $params[] = (string) $userAccount;
     $ds = $da->GetData("we_circle", $sql, $params);
     $re["circles"] = $ds["we_circle"]["rows"];
     $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re));
     $response->headers->set('Content-Type', 'text/json');
     return $response;
 }