You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
4.4 KiB
130 lines
4.4 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\api\library\buiapi\Api;
|
|
use think\Db;
|
|
|
|
class WxCategory extends Api{
|
|
|
|
protected $model = null;
|
|
|
|
protected $noNeedRight = '*';
|
|
protected $noNeedLogin = ['*'];
|
|
protected $_allow_func = ['index'];
|
|
protected $_search_field = '*';
|
|
|
|
use \app\api\library\buiapi\traits\Api;
|
|
|
|
public function _initialize(){
|
|
parent::_initialize();
|
|
$this->model = new \app\api\model\WxCategory;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
//搜索条件
|
|
$searchList = [];
|
|
if($this->request->post('typedata') == 0){ //有筛选条件
|
|
$searchList = Db::table('lx_wx_category')
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','=',0)
|
|
->select();
|
|
|
|
$this->relationSearch = true;
|
|
$this->request->filter('trim,strip_tags,xss_clean');
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
|
|
if($this->request->post('wx_category_id/d') && $this->request->post('wx_category_id/d')>0){
|
|
if($this->request->post('name')){
|
|
$item = $this->model->where($where)
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','=',$this->request->post('wx_category_id/d'))
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where('name','like','%'.$this->request->post('name').'%')
|
|
->where($this->_init_where)
|
|
->order($sort, $order);
|
|
}else{
|
|
$item = $this->model->where($where)
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','=',$this->request->post('wx_category_id/d'))
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where($this->_init_where)
|
|
->order($sort, $order);
|
|
}
|
|
|
|
}else{
|
|
|
|
$ids = [];
|
|
foreach ($searchList as $vo){
|
|
$ids[] = $vo['id'];
|
|
}
|
|
|
|
if($this->request->post('name')){
|
|
$item = $this->model->where($where)
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','in',$ids)
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where('name','like','%'.$this->request->post('name').'%')
|
|
->where($this->_init_where)
|
|
->order($sort, $order);
|
|
}else{
|
|
$item = $this->model->where($where)
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','in',$ids)
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where($this->_init_where)
|
|
->order($sort, $order);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!empty($this->_index_field)) {
|
|
$item->field($this->_index_field);
|
|
}
|
|
$list = $this->__handle_index__($item->paginate($limit));
|
|
$list['searchList'] = $searchList;
|
|
$this->success('数据列表', $list);
|
|
|
|
|
|
}else{
|
|
|
|
$this->relationSearch = true;
|
|
$this->request->filter('trim,strip_tags,xss_clean');
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
if($this->request->post('name')){
|
|
$item = $this->model->where($where)
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','=',0)
|
|
->where('name','like','%'.$this->request->post('name').'%')
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where($this->_init_where)
|
|
->order($sort, $order);
|
|
}else{
|
|
$item = $this->model->where($where)
|
|
->where('catedata','=',1)
|
|
->where('wx_category_id','=',0)
|
|
->where('wx_menu_id','=',$this->request->post('wx_menu_id'))
|
|
->where($this->_init_where)
|
|
->order($sort, $order);
|
|
}
|
|
|
|
if (!empty($this->_index_field)) {
|
|
$item->field($this->_index_field);
|
|
}
|
|
$list = $this->__handle_index__($item->paginate($limit));
|
|
$list['searchList'] = $searchList;
|
|
$this->success('数据列表', $list);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
} |