TopController.class.php
1.03 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: liyifei2012it
* Date: 17/4/11
* Time: 18:16
*/
namespace Apicp\Controller\News;
use Com\PackageValidate;
use Common\Service\ArticleService;
class TopController extends \Apicp\Controller\AbstractController
{
/**
* Top
*
* @author zhonglei
* @desc 新闻置顶/取消置顶
* @param Int article_id:true 新闻ID
* @return mixed
*/
public function Index_post()
{
// 验证规则
$rules = [
'article_id' => 'require|integer',
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$postData = $validate->postData;
$article_id = $postData['article_id'];
$artServ = new ArticleService();
$article = $artServ->get($article_id);
if (empty($article)) {
E('_ERR_ARTICLE_NOT_FOUND');
}
$top_time = $article['top_time'] > 0 ? 0 : MILLI_TIME;
$artServ->update($article_id, ['top_time' => $top_time]);
}
}