Commit 8bf2bedd by 冷斌

fix bug

parent 8d8c1e30
......@@ -106,7 +106,7 @@ class IndexAction extends Action
if ($_GET['best']) {
$where['best'] = 1;
}
$list = D('ExamsPaper', 'exams')->getPaperPageList($where, 16, $order, true);
$list = D('ExamsPaper', 'exams')->getPaperPageList($where, 16, $order, true, $_GET['api']);
foreach ($list['data'] as &$v) {
$v['paper_options'] = D('ExamsPaperOptions', 'exams')->where(['exams_paper_id'=>$v['exams_paper_id']])->field('questions_count,score')->find();//getPaperOptionsById($v['exams_paper_id']);
//判断是否需要购买 (管理员)
......
......@@ -25,7 +25,7 @@ class ExamsPaperModel extends Model
* @param integer $limit [description]
* @return array [description]
*/
public function getPaperPageList($map = [], $limit = 20, $order = 'default', $from_front = false)
public function getPaperPageList($map = [], $limit = 20, $order = 'default', $from_front = false, $isApi = 0)
{
$map['is_del'] = 0;
if(!is_admin($this->mid) && $from_front){
......@@ -38,7 +38,15 @@ class ExamsPaperModel extends Model
$map['_string'] .= $str.')';
}
$order = isset($this->order_field[$order]) ? $this->order_field[$order] : $order;
$list = $this->where($map)->order($order)->findPage($limit);
$model = $this->where($map)->order($order);
if ((int)$isApi === 1) {
$model->where('EXISTS ( SELECT exams_paper_id from el_exams_paper_options WHERE el_exams_paper_options.exams_paper_id = el_exams_paper.exams_paper_id)');
}
if ((int)$isApi === 2) {
}
$list = $model->findPage($limit);
if ($list['data']) {
$list['data'] = $this->haddleData($list['data']);
}
......
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