GetTotalController.class.php
951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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;
}
}