ClickController.class.php
1.22 KB
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
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 2017/10/11
* Time: 16:41
*/
namespace Api\Controller\Doc;
use Com\PackageValidate;
use Common\Common\Constant;
use Common\Common\DataCenter;
use Common\Service\FileService;
class ClickController extends \Api\Controller\AbstractController
{
/**
* Click
* @author zhonglei
* @desc 记录文件点击数据接口
* @param Int file_id:true 文件ID
* @return void
*/
public function Index_post()
{
// 验证规则
$rules = [
'file_id' => 'require|integer',
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$postData = $validate->postData;
$file_id = $postData['file_id'];
// 获取文件
$fileServ = new FileService();
$file = $fileServ->get_by_conds(['file_id' => $file_id, 'file_type' => Constant::FILE_TYPE_IS_DOC]);
if (empty($file)) {
E('_ERR_FILE_DATA_IS_NULL');
}
// 数据中心点击量埋点
$user = $this->_login->user;
$dataCenter = &DataCenter::instance();
$dataCenter->addClick($user, $file_id);
// 数据中心点击量埋点
}
}