<?php /** * 【考试中心-后台】 获取题目数和类型数 * GetTotalController.class.php * User: heyuelong * Date: 2017年10月19日11:46:01 */ namespace Apicp\Controller\Paper; use Common\Service\CategoryService; use Common\Service\TopicService; class GetTotalController extends AbstractController { public function Index_post() { // 初始化题目表 $topic_service = new TopicService(); // 获取题目总数 $topic_total = $topic_service->count(); // 初始化类型表 $category_service = new CategoryService(); // 获取已开启分类总数 $category_total = $category_service->count_by_conds(['ec_status' => CategoryService::EC_OPEN_STATES]); // 组装返回数据 $this->_result = [ 'topic_total' => intval($topic_total), 'category_total' => intval($category_total) ]; return true; } }