Commit 5821792c authored by zhuwei's avatar zhuwei

消息页面--通讯录

parent 6fbd9515
<?php
namespace app\api_broker\controller;
/**
* Created by PhpStorm.
* User: zhuwei
* Date: 2018-11-12
* Time: 10:25:16
*/
use app\api_broker\extend\Basic;
use app\model\AAgents;
class Agent extends Basic
{
protected $aAgents;
public function __construct($request = null)
{
parent::__construct($request);
$this->aAgents = new AAgents();
}
/**
* 消息页面--通讯录
* User: 朱伟
* Date: 2018-11-12
* Time: 10:49:56
* 接口文档 http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=680
*/
public function getPhoneBook()
{
$params = $this->params;
$where = [];
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
if (!empty($params['site_id'])) {
$where['Agents.site_id'] = $params['site_id'] ;
}
$field = 'Agents.id as agent_id,';
$field .= 'Agents.name,';
$field .= 'Agents.phone';
$res = $this->aAgents->getPhoneBookList($field, $where,$pageSize,$pageNo);
$res_total = $this->aAgents->getPhoneBookListTotal($params);
return $this->response("200", "成功",['data'=>$res,'total'=>$res_total]);
}
}
\ No newline at end of file
......@@ -1430,4 +1430,43 @@ class AAgents extends BaseModel
->select();
}
/**
* 消息页面--通讯录
* @param $field
* @param $params
* @param $page_size
* @param $page_no
* @return false|\PDOStatement|string|\think\Collection
*/
public function getPhoneBookList($field, $params,$page_size,$page_no)
{
$params["Agents.status"] = 0;
$result = $this
->field($field)
->alias("Agents")
->where($params)
->limit($page_size)
->page($page_no)
->select();
//echo $this->getLastSql();
return $result;
}
/**
* 消息页面--通讯录
* @param $params
* @return int|string
*/
public function getPhoneBookListTotal($params)
{
$params["Agents.status"] = 0;
$result = $this->alias("Agents")->where($params)->count();
//echo $this->getLastSql();
return $result;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment