| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- // +----------------------------------------------------------------------
- // | Description: 通讯录
- // +----------------------------------------------------------------------
- // | Author: yyk
- // +----------------------------------------------------------------------
-
- namespace app\oa\controller;
-
- use app\admin\controller\ApiCommon;
- use think\Hook;
- use think\Request;
- use think\Db;
- use app\crm\traits\StarTrait;
-
- use app\oa\logic\UserLogic;
- class Addresslist extends ApiCommon
- {
- use StarTrait;
- /**
- * 用于判断权限
- * @permission 无限制
- * @allow 登录用户可访问
- * @other 其他根据系统设置
- **/
- public function _initialize()
- {
- $action = [
- 'permission'=>[''],
- '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' => '设置关注成功!']);
- }
- }
|