ADD:添加后台管理端接口;
DEL:删除不必要的头部注释; FIX:修正若干已知错误;
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace api\controllers\client\v1;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use addons\models\AcWeituoren;
|
||||
use common\models\Member as User;
|
||||
use addons\models\AcUserExt;
|
||||
|
||||
class WeituorenController extends Common
|
||||
{
|
||||
public function beforeAction($action)
|
||||
{
|
||||
if (!$this->pid) {
|
||||
// $this->result('您正使用本系统内部接口,禁止非法链接使用!');
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$apis = [
|
||||
'list'=>'搜索委托单位清单',
|
||||
'detail'=>'委托单位详情'
|
||||
];
|
||||
$this->result('您正使用CMTS系统委托单位管理接口!', $apis, 200);
|
||||
}
|
||||
|
||||
//列表
|
||||
public function actionList()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$return = [];
|
||||
$model = new AcWeituoren();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = $this->postdata;
|
||||
$search = isset($post['search']) ? $post['search'] : null;
|
||||
if (!$search) {
|
||||
$search = [];
|
||||
}
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if (!empty($search['title'])) {
|
||||
$where2[] = ['LIKE','company',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->asArray()->where($where); //asArray() 放在find后,可让查询结果以数组形式呈现
|
||||
if ($search['title']) {
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$page = $this->page;
|
||||
$pageSize = $this->pageSize;
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => $pageSize]);
|
||||
$pages->setPage($page-1, true); //设置分页的当前页面值
|
||||
$_orderby = 'orderby DESC,id ASC';
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
|
||||
if (!$res) {
|
||||
$this->result('没有符合条件的结果');
|
||||
}
|
||||
|
||||
$status = Yii::$app->params['CommonStatus'];
|
||||
$return['code'] = 200;
|
||||
$return['msg'] = '委托单位查询成功!';
|
||||
$return['data']= ['total'=>$data->count(),
|
||||
'data'=>[
|
||||
'weituoren' => $res
|
||||
],
|
||||
'page'=>$this->page];
|
||||
exit(json_encode($return, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT));
|
||||
}
|
||||
|
||||
public function actionDetail()
|
||||
{
|
||||
$pid = $this->pid;
|
||||
$post = $this->postdata;
|
||||
|
||||
$id = isset($post['id']) ? $post['id'] : 0;
|
||||
if ($id<=0) {
|
||||
$this->result('查询参数错误!');
|
||||
}
|
||||
$model = new AcWeituoren();
|
||||
$weituo = $model->findOne($id);
|
||||
$detail = $weituo->toArray();
|
||||
|
||||
$this->result('查询成功!', $detail, 200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user