RandomSnapshotService.class.php 1.72 KB
<?php
/**
 * 随机题库快照类
 * @author: caijianhua
 * @email:   juxinggaozhao@163.com
 * @date :  2017-07-17
 * @version $Id$
 */

namespace Common\Service;

use Common\Model\RandomSnapshotModel;

class RandomSnapshotService extends AbstractService
{

    // 构造方法
    public function __construct()
    {
        $this->_d = new RandomSnapshotModel();
        parent::__construct();
    }

    /**
     * 获取选题列表
     *
     * @param int    $ep_id 试卷id
     * @param string $fields 返回字段
     *
     * @return array|bool
     */
    public function get_random_snapshot_list($ep_id = 0, $fields = 'et_id,title')
    {
        // 查询选题列表
        $list = $this->_d->list_by_conds(['ep_id' => $ep_id], null, ['order_num' => 'ASC'], $fields);

        // 格式化数据
        foreach ($list as $k => $v) {

            $list[$k]['et_id'] = intval($v['et_id']);
        }

        return $list;
    }
    /**
     * 获取试题快照列表
     *
     * @author  caijianhua
     * @param array $conds 查询条件参数列表
     * @param array $page_option 分页参数
     * @param array $order_option 排序参数
     * @param string $fields 返回字段
     *
     * @return array|bool
     */
    public function conds_random_snapshot_list($conds, $page_option = null, $order_option = [], $fields = '*')
    {
        return $this->_d->conds_random_snapshot_list($conds, $page_option, $order_option, $fields);
    }

    /**
     * 获取试题快照总数
     *
     * @author  caijainhua
     * @param array $conds 查询条件参数列表
     *
     * @return int
     */
    public function conds_random_snapshot_count($conds)
    {
        return $this->_d->conds_random_snapshot_count($conds);
    }

}