Commit 9011d217f8d95f36b37be7e4657d1ced3172ea02
1 parent
46c419ee
【留言板】手机端获取留言列表实现
Showing
34 changed files
with
185 additions
and
2649 deletions
trunk/Message/Api/Controller/Message/MessInputController.class.php
@@ -9,35 +9,63 @@ | @@ -9,35 +9,63 @@ | ||
9 | namespace Api\Controller\Message; | 9 | namespace Api\Controller\Message; |
10 | 10 | ||
11 | use Common\Model\MessagesModel; | 11 | use Common\Model\MessagesModel; |
12 | +use Common\Model\AttachmentModel; | ||
12 | 13 | ||
13 | class MessInputController extends \Api\Controller\AbstractController | 14 | class MessInputController extends \Api\Controller\AbstractController |
14 | { | 15 | { |
15 | - /** | ||
16 | - * 是否需要登录 | ||
17 | - * | ||
18 | - * @var bool | ||
19 | - */ | 16 | + // 禁止系统自动登录 |
20 | protected $_require_login = false; | 17 | protected $_require_login = false; |
21 | 18 | ||
22 | - | 19 | + /** |
20 | + * 发表留言 | ||
21 | + */ | ||
23 | public function Index_post() | 22 | public function Index_post() |
24 | { | 23 | { |
25 | - | ||
26 | session_start(); | 24 | session_start(); |
27 | - | ||
28 | - $data = $this->checkFields( I('post.') ); | ||
29 | - | ||
30 | - if( !$data ){ | 25 | + $data = $this->checkFields(I('post.')); |
26 | + if (!$data) { | ||
31 | $this->_result = "数据验证失败"; | 27 | $this->_result = "数据验证失败"; |
32 | die; | 28 | die; |
33 | } | 29 | } |
34 | 30 | ||
35 | $messagesModel = new MessagesModel(); | 31 | $messagesModel = new MessagesModel(); |
36 | 32 | ||
37 | - $messagesModel->m_uid = $_SESSION['userid']; | ||
38 | - $messagesModel->m_title = $data['title']; | ||
39 | - $messagesModel->m_content = $data['message']; | ||
40 | - $messagesModel->m_ip = $_SERVER['REMOTE_ADDR']; | 33 | + $data['m_uid'] = $_SESSION['userid']; |
34 | + $data['m_title'] = $data['title']; | ||
35 | + $data['m_content'] = $data['message']; | ||
36 | + $data['m_ip'] = $_SERVER['REMOTE_ADDR']; | ||
37 | + | ||
38 | + /* | ||
39 | + * 上传图片 取得图片路径 $path_img | ||
40 | + * $data['m_imgs'] = $path_img; | ||
41 | + * | ||
42 | + */ | ||
43 | + if ($_FILES['myImg']) { | ||
44 | + // coding... | ||
45 | + } | ||
46 | + | ||
47 | + $mid = $messagesModel->insert($data); | ||
48 | + var_dump($mid); | ||
49 | + die; | ||
50 | + | ||
51 | + if (($mid = $messagesModel->insert($data)) != null && $_FILES['myFile']) { | ||
52 | + // 留言成功后开始上传附件 | ||
53 | + $attachmentModel = new AttachmentModel(); | ||
54 | + unset($data); | ||
55 | + $data['a_mid'] = $mid; | ||
56 | + | ||
57 | + /** | ||
58 | + * 附件上传实现 取得附件路径 $path_att | ||
59 | + * $data['a_path'] = $path_att; | ||
60 | + */ | ||
61 | + if (($aid = $attachmentModel->insert($data)) != null) { | ||
62 | + $this->_result = "留言成功,上传附件成功。"; | ||
63 | + }else{ | ||
64 | + // 上传附件失败后 进行相应的处理 | ||
65 | + $this->_result = "上传附件失败。"; | ||
66 | + } | ||
67 | + | ||
68 | + } | ||
41 | 69 | ||
42 | //$this->_result = "您已留言成功,请等待审核。"; | 70 | //$this->_result = "您已留言成功,请等待审核。"; |
43 | 71 | ||
@@ -54,19 +82,19 @@ class MessInputController extends \Api\Controller\AbstractController | @@ -54,19 +82,19 @@ class MessInputController extends \Api\Controller\AbstractController | ||
54 | $parrent = "/\ |\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\\' | \`|\-|\=|\\\|\|/"; | 82 | $parrent = "/\ |\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\\' | \`|\-|\=|\\\|\|/"; |
55 | $data = []; | 83 | $data = []; |
56 | 84 | ||
57 | - if( empty($postData['title']) || strlen($postData['title'])>80 ){ | 85 | + if (empty($postData['title']) || strlen($postData['title'])>80) { |
58 | $this->_result = "标题不能为空且标题长度必须小于80。"; | 86 | $this->_result = "标题不能为空且标题长度必须小于80。"; |
59 | return false; | 87 | return false; |
60 | 88 | ||
61 | - }else{ | ||
62 | - $data['title'] = preg_replace( $parrent, "", $postData['title']); | 89 | + } else { |
90 | + $data['title'] = preg_replace($parrent, "", $postData['title']); | ||
63 | } | 91 | } |
64 | 92 | ||
65 | - if( empty($postData['message']) || strlen($postData['message'])>500 ){ | 93 | + if (empty($postData['message']) || strlen($postData['message'])>500) { |
66 | $this->_result = "留言内容不能为空且长度必须小于500。"; | 94 | $this->_result = "留言内容不能为空且长度必须小于500。"; |
67 | return false; | 95 | return false; |
68 | - }else{ | ||
69 | - $data['message'] = preg_replace( $parrent, "", $postData['message'] ); | 96 | + } else { |
97 | + $data['message'] = preg_replace($parrent, "", $postData['message']); | ||
70 | } | 98 | } |
71 | 99 | ||
72 | return $data; | 100 | return $data; |
trunk/Message/Api/Controller/Message/MessListController.class.php
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | 8 | ||
9 | namespace Api\Controller\Message; | 9 | namespace Api\Controller\Message; |
10 | 10 | ||
11 | +use Common\Model\MessagesModel; | ||
11 | 12 | ||
12 | class MessListController extends \Api\Controller\AbstractController | 13 | class MessListController extends \Api\Controller\AbstractController |
13 | { | 14 | { |
@@ -15,11 +16,13 @@ class MessListController extends \Api\Controller\AbstractController | @@ -15,11 +16,13 @@ class MessListController extends \Api\Controller\AbstractController | ||
15 | protected $_require_login = false; | 16 | protected $_require_login = false; |
16 | 17 | ||
17 | /** | 18 | /** |
18 | - * 构造方法 | 19 | + * 获取留言列表 |
19 | */ | 20 | */ |
20 | - public function getList_post() | 21 | + public function getList_get() |
21 | { | 22 | { |
22 | - $this->_result = '留言列表'; | 23 | + $messagesModel = new MessagesModel(); |
24 | + | ||
25 | + $this->_result = $messagesModel->list_all_without_domain([intval(I('get.page'))*10,10]); | ||
23 | } | 26 | } |
24 | 27 | ||
25 | } | 28 | } |
trunk/Message/Apicp/Controller/Message/MessAuditController.class.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Dell | ||
5 | + * Date: 2018/9/5 | ||
6 | + * Time: 14:22 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Apicp\Controller\Message; | ||
10 | + | ||
11 | +use Common\Model\MessagesModel; | ||
12 | + | ||
13 | +/** | ||
14 | + * 留言审核 | ||
15 | + * Class MessAuditController | ||
16 | + * @package Apicp\Controller\Message | ||
17 | + */ | ||
18 | +class MessAuditController extends \Apicp\Controller\AbstractController | ||
19 | +{ | ||
20 | + public function Audit_post(){ | ||
21 | + | ||
22 | + } | ||
23 | +} |
trunk/Message/Apicp/Controller/Message/MessDelController.class.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Dell | ||
5 | + * Date: 2018/9/5 | ||
6 | + * Time: 14:25 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Apicp\Controller\Message; | ||
10 | + | ||
11 | +use Common\Model\MessagesModel; | ||
12 | +use Common\Model\AttachmentModel; | ||
13 | + | ||
14 | +/** | ||
15 | + * 删除留言 | ||
16 | + * Class MessDelController | ||
17 | + * @package Apicp\Controller\Message | ||
18 | + */ | ||
19 | +class MessDelController extends \Apicp\Controller\AbstractController | ||
20 | +{ | ||
21 | + public function Del_post() | ||
22 | + { | ||
23 | + | ||
24 | + } | ||
25 | +} |
trunk/Message/Apicp/Controller/Message/MessDetailController.class.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Dell | ||
5 | + * Date: 2018/9/5 | ||
6 | + * Time: 14:28 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Apicp\Controller\Message; | ||
10 | + | ||
11 | +use Common\Model\MessagesModel; | ||
12 | +use Common\Model\AttachmentModel; | ||
13 | + | ||
14 | +/** | ||
15 | + * 获取留言详情 | ||
16 | + * Class MessDetailController | ||
17 | + * @package Apicp\Controller\Message | ||
18 | + */ | ||
19 | +class MessDetailController extends \Apicp\Controller\AbstractController | ||
20 | +{ | ||
21 | + public function getDetail() | ||
22 | + { | ||
23 | + | ||
24 | + } | ||
25 | +} |
trunk/Message/Apicp/Controller/Message/MessListController.class.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Dell | ||
5 | + * Date: 2018/9/5 | ||
6 | + * Time: 14:15 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Apicp\Controller\Message; | ||
10 | + | ||
11 | +use Common\Model\MessagesModel; | ||
12 | + | ||
13 | +/** | ||
14 | + * 获取留言列表 | ||
15 | + * Class MessListController | ||
16 | + * @package Apicp\Controller\Message | ||
17 | + */ | ||
18 | +class MessListController extends \Apicp\Controller\AbstractController | ||
19 | +{ | ||
20 | + public function getList() | ||
21 | + { | ||
22 | + $messagesModel = new MessagesModel(); | ||
23 | + $this->_result = $messagesModel->list_all([intval(I('get.page')*10),10]); | ||
24 | + } | ||
25 | +} |
trunk/Message/Apicp/Controller/News/CommentController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -namespace Apicp\Controller\News; | ||
3 | - | ||
4 | -use Common\Common\Comment; | ||
5 | -use Common\Service\ArticleService; | ||
6 | - | ||
7 | -class CommentController extends \Apicp\Controller\AbstractController | ||
8 | -{ | ||
9 | - | ||
10 | - /** | ||
11 | - | ||
12 | - * DeleteComment | ||
13 | - * | ||
14 | - * @author tangxingguo | ||
15 | - | ||
16 | - * @desc 删除新闻 | ||
17 | - | ||
18 | - * @param int data_id:true 数据标识 | ||
19 | - | ||
20 | - * @return null | ||
21 | - | ||
22 | - */ | ||
23 | - public function Index_post() | ||
24 | - { | ||
25 | - $data_id = I('post.data_id', 0, 'trim'); | ||
26 | - | ||
27 | - // 数据标识不能为空 | ||
28 | - if (empty($data_id)) { | ||
29 | - E('_ERR_ARTICLE_DATA_ID_NOT_FOUND'); | ||
30 | - } | ||
31 | - | ||
32 | - $articleServ = new ArticleService(); | ||
33 | - $article = $articleServ->get_by_conds(['data_id' => $data_id]); | ||
34 | - if (empty($article)) { | ||
35 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
36 | - } | ||
37 | - | ||
38 | - // UC获取当前评论总数 | ||
39 | - $commentServ = &Comment::instance(); | ||
40 | - $commentList = $commentServ->listAll(['cmtObjid' => $data_id]); | ||
41 | - | ||
42 | - // 修改课程主表数据 | ||
43 | - if (isset($commentList['cmttlNums'])) { | ||
44 | - $total = $commentList['cmttlNums']; | ||
45 | - $articleServ->update_by_conds(['data_id' => $data_id], ['comment_total' => $total]); | ||
46 | - } | ||
47 | - } | ||
48 | -} |
trunk/Message/Apicp/Controller/News/CompanyQrcodeController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * 获取公司二维码 | ||
4 | - * User: wangjiayu | ||
5 | - * Date: 2017-12-28 | ||
6 | - */ | ||
7 | -namespace Apicp\Controller\News; | ||
8 | - | ||
9 | -use Common\Common\CompanyQrcode; | ||
10 | - | ||
11 | -class CompanyQrcodeController extends \Apicp\Controller\AbstractController | ||
12 | -{ | ||
13 | - | ||
14 | - // 免登录 | ||
15 | - protected $_require_login = false; | ||
16 | - | ||
17 | - public function Index() | ||
18 | - { | ||
19 | - // 实例化类 | ||
20 | - $CompanyQrcode = &CompanyQrcode::instance(); | ||
21 | - | ||
22 | - // 获取二维码 | ||
23 | - $qr_code = $CompanyQrcode->showCompanyQrcode(); | ||
24 | - | ||
25 | - // 返回二维码 | ||
26 | - $this->_result = $qr_code; | ||
27 | - } | ||
28 | -} |
trunk/Message/Apicp/Controller/News/DeleteController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 18:24 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\AttachOperation; | ||
12 | -use Common\Common\DataCenter; | ||
13 | -use Common\Common\Constant; | ||
14 | -use Common\Common\RpcFavoriteHelper; | ||
15 | -use Common\Service\ArticleService; | ||
16 | -use Common\Service\TaskService; | ||
17 | -use Common\Service\AttachService; | ||
18 | -use VcySDK\Service; | ||
19 | -use VcySDK\Cron; | ||
20 | - | ||
21 | -class DeleteController extends \Apicp\Controller\AbstractController | ||
22 | -{ | ||
23 | - /** | ||
24 | - * Delete | ||
25 | - * @author zhonglei | ||
26 | - * @desc 删除新闻 | ||
27 | - * @param Array article_ids:true 新闻ID数组 | ||
28 | - * @return mixed | ||
29 | - */ | ||
30 | - public function Index_post() | ||
31 | - { | ||
32 | - // 验证规则 | ||
33 | - $rules = [ | ||
34 | - 'article_ids' => 'require|array', | ||
35 | - ]; | ||
36 | - | ||
37 | - // 验证数据 | ||
38 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
39 | - $postData = $validate->postData; | ||
40 | - $article_ids = $postData['article_ids']; | ||
41 | - | ||
42 | - $artServ = new ArticleService(); | ||
43 | - $list = $artServ->list_by_conds(['article_id' => $article_ids]); | ||
44 | - | ||
45 | - if (empty($list)) { | ||
46 | - return true; | ||
47 | - } | ||
48 | - | ||
49 | - // 删除首页推送 | ||
50 | - foreach ($article_ids as $article_id) { | ||
51 | - $artServ->delNewsRpc($article_id); | ||
52 | - } | ||
53 | - | ||
54 | - // 删除新闻 | ||
55 | - $artServ->delete_by_conds(['article_id' => $article_ids]); | ||
56 | - | ||
57 | - // 删除新闻附件 | ||
58 | - $attachServ = new AttachService(); | ||
59 | - | ||
60 | - // 从UC附件服务器删除 | ||
61 | - $attach_serv = new AttachOperation(); | ||
62 | - $attach_serv->delete_attach( | ||
63 | - APP_DIR, | ||
64 | - 'article', | ||
65 | - $article_ids | ||
66 | - ); | ||
67 | - | ||
68 | - // 删除业务数据库附件 | ||
69 | - $attachServ->delete_by_conds(['article_id' => $article_ids]); | ||
70 | - | ||
71 | - // 删除应用数据时,RPC同步收藏状态 | ||
72 | - $rpcFavorite = &RpcFavoriteHelper::instance(); | ||
73 | - $rpcFavorite->updateStatus($postData['article_ids']); | ||
74 | - | ||
75 | - // 数据中心删除点赞埋点 | ||
76 | - $dataCenter = &DataCenter::instance(); | ||
77 | - $dataCenter->delLike($article_ids); | ||
78 | - // 数据中心删除点赞埋点 | ||
79 | - | ||
80 | - // 数据中心删除评论埋点 | ||
81 | - $dataCenter->delComment($article_ids); | ||
82 | - // 数据中心删除评论埋点 | ||
83 | - | ||
84 | - // 数据中心删除点击量埋点 | ||
85 | - $dataCenter->delClick($article_ids); | ||
86 | - // 数据中心删除点击量埋点 | ||
87 | - | ||
88 | - $taskServ = new TaskService(); | ||
89 | - $task_list = $taskServ->list_by_conds(['article_id' => $article_ids]); | ||
90 | - | ||
91 | - if (empty($task_list)) { | ||
92 | - return true; | ||
93 | - } | ||
94 | - | ||
95 | - $cron_ids = array_filter(array_column($task_list, 'cron_id')); | ||
96 | - $cronSdk = new Cron(Service::instance()); | ||
97 | - | ||
98 | - // 删除计划任务 | ||
99 | - foreach ($cron_ids as $cron_id) { | ||
100 | - $cronSdk->delete($cron_id); | ||
101 | - } | ||
102 | - | ||
103 | - return true; | ||
104 | - } | ||
105 | -} |
trunk/Message/Apicp/Controller/News/ExportLikeListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 18/7/6 | ||
6 | - * Time: 10:53 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Com\PythonExcel; | ||
12 | -use Common\Common\ExportDownload; | ||
13 | -use Common\Common\NewsHelper; | ||
14 | -use Common\Common\User; | ||
15 | -use Common\Service\LikeService; | ||
16 | -use Common\Service\ArticleService; | ||
17 | - | ||
18 | -class ExportLikeListController extends \Apicp\Controller\AbstractController | ||
19 | -{ | ||
20 | - /** | ||
21 | - * LikeList | ||
22 | - * @desc 导出点赞列表 | ||
23 | - * @param int article_id:true 新闻ID | ||
24 | - * @return mixed | ||
25 | - */ | ||
26 | - public function Index_post() | ||
27 | - { | ||
28 | - // 验证规则 | ||
29 | - $rules = [ | ||
30 | - 'article_id' => 'require|integer', | ||
31 | - ]; | ||
32 | - | ||
33 | - // 验证数据 | ||
34 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
35 | - $postData = $validate->postData; | ||
36 | - | ||
37 | - // 取新闻信息 | ||
38 | - $articleServ = new ArticleService(); | ||
39 | - $article = $articleServ->get($postData['article_id']); | ||
40 | - if (empty($article)) { | ||
41 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
42 | - } | ||
43 | - | ||
44 | - // 点赞列表 | ||
45 | - $likeServ = new LikeService(); | ||
46 | - $likeList = $likeServ->list_by_conds(['article_id' => $postData['article_id']]); | ||
47 | - | ||
48 | - if ($likeList) { | ||
49 | - // UC人员信息 | ||
50 | - $uids = array_column($likeList, 'uid'); | ||
51 | - $userServ = &User::instance(); | ||
52 | - $userList = $userServ->listAll(['memUids' => $uids]); | ||
53 | - $userList = array_combine_by_key($userList, 'memUid'); | ||
54 | - | ||
55 | - // Excel文件名前缀 | ||
56 | - $titleSuffix = '_点赞人员'; | ||
57 | - | ||
58 | - // Excel列名 | ||
59 | - $columns = ['姓名', '组织', '岗位', '角色', '手机号']; | ||
60 | - | ||
61 | - // Excel行数据 | ||
62 | - $rows = []; | ||
63 | - if ($userList) { | ||
64 | - $newsHelper = &NewsHelper::instance(); | ||
65 | - | ||
66 | - foreach ($likeList as $k => $v) { | ||
67 | - $uid = $v['uid']; | ||
68 | - if (isset($userList[$uid])) { | ||
69 | - $user = $userList[$uid]; | ||
70 | - | ||
71 | - $rows[] = [ | ||
72 | - $user['memUsername'], | ||
73 | - $newsHelper->getDpPath($user), | ||
74 | - $user['memJob'], | ||
75 | - $user['memRole'], | ||
76 | - $user['memMobile'], | ||
77 | - ]; | ||
78 | - } | ||
79 | - } | ||
80 | - } | ||
81 | - | ||
82 | - $title = $article['title'] . $titleSuffix . rgmdate(MILLI_TIME, '_ymdHis'); | ||
83 | - $filename = ExportDownload::get_down_dir($this->_login->user['eaId']) . $title . '.xls'; | ||
84 | - $result = PythonExcel::instance()->write($filename, $columns, $rows); | ||
85 | - | ||
86 | - if ($result === true) { | ||
87 | - // 写入数据到下载中心 | ||
88 | - $conditon = [ | ||
89 | - 'title' => $title, | ||
90 | - 'ea_id' => $this->_login->user['eaId'], | ||
91 | - 'type' => ExportDownload::EXCEL_TYPE, | ||
92 | - 'size' => filesize($filename), | ||
93 | - 'username' => $this->_login->user['eaRealname'], | ||
94 | - 'url' => $filename, | ||
95 | - 'app_dir' => APP_DIR | ||
96 | - ]; | ||
97 | - | ||
98 | - ExportDownload::insert_down_load($conditon); | ||
99 | - } | ||
100 | - } | ||
101 | - | ||
102 | - return true; | ||
103 | - } | ||
104 | -} |
trunk/Message/Apicp/Controller/News/ExportReadListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 18/7/5 | ||
6 | - * Time: 11:22 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PythonExcel; | ||
11 | -use Common\Common\ExportDownload; | ||
12 | -use Common\Common\NewsHelper; | ||
13 | -use Com\PackageValidate; | ||
14 | -use Common\Common\Constant; | ||
15 | -use Common\Common\User; | ||
16 | -use Common\Service\ArticleService; | ||
17 | -use Common\Service\RightService; | ||
18 | -use Common\Service\ReadService; | ||
19 | - | ||
20 | -class ExportReadListController extends \Apicp\Controller\AbstractController | ||
21 | -{ | ||
22 | - /** | ||
23 | - * ExportReadList | ||
24 | - * @desc 导出阅读列表 | ||
25 | - * @param Int article_id:true 新闻ID | ||
26 | - * @param Int read_type:true:1 阅读类型(1=未读,2=已读) | ||
27 | - * @param String username 姓名 | ||
28 | - * @param Array dp_ids 部门ID | ||
29 | - * @param Array job_ids 职位ID | ||
30 | - * @param Array role_ids 角色ID | ||
31 | - * @return mixed | ||
32 | - */ | ||
33 | - public function Index_post() | ||
34 | - { | ||
35 | - // 验证规则 | ||
36 | - $rules = [ | ||
37 | - 'article_id' => 'require|integer', | ||
38 | - 'read_type' => 'require|integer', | ||
39 | - 'username' => 'max:64', | ||
40 | - 'dp_ids' => 'array', | ||
41 | - 'job_ids' => 'array', | ||
42 | - 'role_ids' => 'array', | ||
43 | - ]; | ||
44 | - | ||
45 | - // 验证数据 | ||
46 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
47 | - $postData = $validate->postData; | ||
48 | - | ||
49 | - // 取新闻信息 | ||
50 | - $articleServ = new ArticleService(); | ||
51 | - $article = $articleServ->get($postData['article_id']); | ||
52 | - if (empty($article)) { | ||
53 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
54 | - } | ||
55 | - | ||
56 | - // UC筛选uid | ||
57 | - $uidCond = $this->formatConds($postData); | ||
58 | - | ||
59 | - // 获取人员ID | ||
60 | - $newsHelper = &NewsHelper::instance(); | ||
61 | - list(, $uids_study, $uids_unstudy) = $newsHelper->getReadData($article['article_id'], $uidCond); | ||
62 | - | ||
63 | - // Excel列名 | ||
64 | - $columns = ['姓名', '组织', '岗位', '角色', '手机号']; | ||
65 | - | ||
66 | - // 实例化对象 | ||
67 | - $userServ = &User::instance(); | ||
68 | - | ||
69 | - $rows = []; | ||
70 | - if ($postData['read_type'] == Constant::READ_STATUS_IS_YES) { | ||
71 | - $titleSuffix = '_已学人员'; | ||
72 | - $columns[] = '阅读时间'; | ||
73 | - | ||
74 | - // 已读人员列表 | ||
75 | - $readConds = [ | ||
76 | - 'uid' => $uids_study, | ||
77 | - 'article_id' => $postData['article_id'], | ||
78 | - ]; | ||
79 | - $readServ = new ReadService(); | ||
80 | - $readList = $readServ->list_by_conds($readConds); | ||
81 | - | ||
82 | - // 人员详情列表 | ||
83 | - $userList = $userServ->listByUid(array_column($readList, 'uid')); | ||
84 | - $userList = array_combine_by_key($userList, 'memUid'); | ||
85 | - foreach ($readList as $item) { | ||
86 | - $uid = $item['uid']; | ||
87 | - $user = $userList[$uid]; | ||
88 | - | ||
89 | - // Excel行数据 | ||
90 | - $rows[] = [ | ||
91 | - $user['memUsername'], | ||
92 | - $newsHelper->getDpPath($user), | ||
93 | - $user['memJob'], | ||
94 | - $user['memRole'], | ||
95 | - $user['memMobile'], | ||
96 | - rgmdate($item['created'], 'Y/m/d H:i'), | ||
97 | - ]; | ||
98 | - } | ||
99 | - | ||
100 | - } else { | ||
101 | - $titleSuffix = '_未学人员'; | ||
102 | - | ||
103 | - if ($uids_unstudy) { | ||
104 | - $userServ = &User::instance(); | ||
105 | - $userList = $userServ->listUsersAll(['memUids' => $uids_unstudy]); | ||
106 | - | ||
107 | - if ($userList) { | ||
108 | - foreach ($userList as $user) { | ||
109 | - $rows[] = [ | ||
110 | - $user['memUsername'], | ||
111 | - $newsHelper->getDpPath($user), | ||
112 | - $user['memJob'], | ||
113 | - $user['memRole'], | ||
114 | - $user['memMobile'], | ||
115 | - ]; | ||
116 | - } | ||
117 | - } | ||
118 | - } | ||
119 | - } | ||
120 | - | ||
121 | - $title = $article['title'] . $titleSuffix . rgmdate(MILLI_TIME, '_ymdHis'); | ||
122 | - $filename = ExportDownload::get_down_dir($this->_login->user['eaId']) . $title . '.xls'; | ||
123 | - $result = PythonExcel::instance()->write($filename, $columns, $rows); | ||
124 | - | ||
125 | - if ($result === true) { | ||
126 | - // 写入数据到下载中心 | ||
127 | - $conditon = [ | ||
128 | - 'title' => $title, | ||
129 | - 'ea_id' => $this->_login->user['eaId'], | ||
130 | - 'type' => ExportDownload::EXCEL_TYPE, | ||
131 | - 'size' => filesize($filename), | ||
132 | - 'username' => $this->_login->user['eaRealname'], | ||
133 | - 'url' => $filename, | ||
134 | - 'app_dir' => APP_DIR | ||
135 | - ]; | ||
136 | - | ||
137 | - ExportDownload::insert_down_load($conditon); | ||
138 | - } | ||
139 | - | ||
140 | - return true; | ||
141 | - } | ||
142 | - | ||
143 | - /** | ||
144 | - * 将搜索条件转化为用户UID | ||
145 | - * @author tangxingguo | ||
146 | - * @param array $postData 用户提交的数据 | ||
147 | - * @return array|bool | ||
148 | - */ | ||
149 | - private function formatConds($postData) | ||
150 | - { | ||
151 | - $condUids = []; | ||
152 | - | ||
153 | - $userServ = &User::instance(); | ||
154 | - if (isset($postData['username'])) { | ||
155 | - // UC | ||
156 | - $userConds = ['memUsername' => $postData['username']]; | ||
157 | - $list = $userServ->listAll($userConds); | ||
158 | - $condUids = array_column($list, 'memUid'); | ||
159 | - } | ||
160 | - | ||
161 | - // 部门、岗位、角色搜索交集 | ||
162 | - $right = array_intersect_key_reserved($postData, ['dp_ids', 'job_ids', 'role_ids'], true); | ||
163 | - if (!empty($right)) { | ||
164 | - $rightServ = new RightService(); | ||
165 | - $rights = $rightServ->formatPostData($right); | ||
166 | - $unitUids = $rightServ->getUidsByRight($rights); | ||
167 | - if (!empty($condUids)) { | ||
168 | - // 筛选已经有值,取交集 | ||
169 | - $condUids = array_intersect($condUids, $unitUids); | ||
170 | - } else { | ||
171 | - $condUids = $unitUids; | ||
172 | - } | ||
173 | - } | ||
174 | - | ||
175 | - // 如果有查询 并且 结果为空 | ||
176 | - if ((!empty($right) || !empty($postData['username'])) && empty($condUids)) { | ||
177 | - return false; | ||
178 | - } | ||
179 | - | ||
180 | - return $condUids; | ||
181 | - } | ||
182 | -} |
trunk/Message/Apicp/Controller/News/InfoController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 17:06 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Common\Service\ArticleService; | ||
11 | -use Common\Service\RightService; | ||
12 | -use Common\Service\AttachService; | ||
13 | - | ||
14 | -class InfoController extends \Apicp\Controller\AbstractController | ||
15 | -{ | ||
16 | - /** | ||
17 | - * Info | ||
18 | - * @author liyifei | ||
19 | - * @desc 新闻详情 | ||
20 | - * @param int article_id:true 新闻公告ID | ||
21 | - * @return array 新闻详情 | ||
22 | - * array( | ||
23 | - 'news_status' => 1, // 新闻状态(1=草稿,2=已发布,3=预发布) | ||
24 | - 'convert_status' => 1, // 转码状态(1=转码中,2=转码成功,3=转码失败) | ||
25 | - 'article_id' => 123, // 新闻ID | ||
26 | - 'title' => '重大新闻', // 新闻标题 | ||
27 | - 'cover_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 封面图片ID | ||
28 | - 'cover_url' => 'http://qy.vchangyi.org', // 封面图片地址 | ||
29 | - 'is_show_cover' => 1, // 是否正文显示封面图片(1=不显示,2=显示) | ||
30 | - 'summary' => '零食增加卫龙系列', // 摘要 | ||
31 | - 'parent_id' => 1, // 父分类ID | ||
32 | - 'parent_name' => '一级分类', // 父分类名称 | ||
33 | - 'class_id' => 2, // 分类ID | ||
34 | - 'class_name' => '内部公告', // 分类名称 | ||
35 | - 'author' => '张三', // 作者 | ||
36 | - 'at_video' => array( // 视频附件 | ||
37 | - array( | ||
38 | - 'at_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 附件ID | ||
39 | - 'at_name' => '小视频.mp4', // 附件名 | ||
40 | - 'at_time' => '123456543000', // 音、视频类型的播放时长(单位:毫秒) | ||
41 | - 'at_size' => 10240.12, // 附件尺寸(单位KB) | ||
42 | - 'at_url' => 'http://qy.vchangyi.com', // 附件地址 | ||
43 | - 'at_convert_url' => 'http://qy.vchangyi.com', // 视频转码后url | ||
44 | - 'at_suffix' => '.xml', // 附件后缀 | ||
45 | - 'convert_status' => 1, // 转码状态(1=转码中,2=转码成功,3=转码失败) | ||
46 | - ), | ||
47 | - ), | ||
48 | - 'at_audio' => array( // 音频附件 | ||
49 | - array( | ||
50 | - 'at_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 附件ID | ||
51 | - 'at_name' => '音频.mp3', // 附件名 | ||
52 | - 'at_time' => '123456543000', // 音、视频类型的播放时长(单位:毫秒) | ||
53 | - 'at_size' => 1024.12, // 附件尺寸(单位KB) | ||
54 | - 'at_url' => 'http://qy.vchangyi.com', // 附件地址 | ||
55 | - 'at_convert_url' => '', // 转码后url,音频附件为空 | ||
56 | - 'at_suffix' => '.txt', // 附件后缀 | ||
57 | - 'convert_status' => 2, // 转码状态(1=转码中,2=转码成功,3=转码失败) | ||
58 | - ), | ||
59 | - ), | ||
60 | - 'at_file' => array( // 文件附件 | ||
61 | - array( | ||
62 | - 'at_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 附件ID | ||
63 | - 'at_name' => '文档.doc', // 附件名 | ||
64 | - 'at_size' => 123.12, // 附件大小(单位:字节) | ||
65 | - 'at_url' => 'http://qy.vchangyi.com', // 附件地址 | ||
66 | - 'at_convert_url' => 'http://qy.vchangyi.com', // 文件转码后url | ||
67 | - 'at_suffix' => '.xml', // 附件后缀 | ||
68 | - 'convert_status' => 3, // 转码状态(1=转码中,2=转码成功,3=转码失败) | ||
69 | - ), | ||
70 | - ), | ||
71 | - 'right' => array( // 新闻阅读权限 | ||
72 | - 'is_all' => 1, // 是否全公司(1=否,2=是) | ||
73 | - 'tag_list' => array( | ||
74 | - array( | ||
75 | - 'tag_id' => '3CDBB2867F0000012C7F8D28432943BB', | ||
76 | - 'tag_name' => 'liyifei001' | ||
77 | - ), | ||
78 | - ), | ||
79 | - 'dp_list' => array( | ||
80 | - array( | ||
81 | - 'dp_id' => 'B65085507F0000017D3965FCB20CA747', | ||
82 | - 'dp_name' => '一飞冲天' | ||
83 | - ), | ||
84 | - ), | ||
85 | - 'user_list' => array( | ||
86 | - array( | ||
87 | - 'uid' => 'B4B3BA5B7F00000173E870DA6ADFEA2A', | ||
88 | - 'username' => '缘来素雅', | ||
89 | - 'face' => 'http://shp.qpic.cn/bizmp/gdZUibR6BHrmiar6pZ6pLfRyZSVaXJicn2CsvKRdI9gccXRfP2NrDvJ8A/' | ||
90 | - ), | ||
91 | - ) | ||
92 | - 'job_list' => array(// 职位 | ||
93 | - array( | ||
94 | - 'job_id' => '62C316437F0000017AE8E6ACC7EFAC22',// 职位ID | ||
95 | - 'job_name' => '攻城狮',// 职位名称 | ||
96 | - ), | ||
97 | - ), | ||
98 | - 'role_list' => array(// 角色 | ||
99 | - array( | ||
100 | - 'role_id' => '62C354B97F0000017AE8E6AC4FD6F429',// 角色ID | ||
101 | - 'role_name' => '国家元首',// 角色名称 | ||
102 | - ), | ||
103 | - ), | ||
104 | - ), | ||
105 | - 'is_download' => 1, // 附件是否支持下载(1=不支持,2=支持) | ||
106 | - 'is_secret' => 1, // 是否保密(1=不保密,2=保密) | ||
107 | - 'is_share' => 1, // 允许分享(1=不允许,2=允许) | ||
108 | - 'is_notice' => 1, // 消息通知(1=不开启,2=开启) | ||
109 | - 'is_comment' => 1, // 评论功能(1=不开启,2=开启) | ||
110 | - 'is_like' => 1, // 点赞功能(1=不开启,2=开启) | ||
111 | - 'is_recommend' => 1, // 首页推荐(1=不开启,2=开启) | ||
112 | - 'content' => '语言是民族的重要特征之一', // 新闻内容 | ||
113 | - 'strategy_setting' => 3, // 积分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) | ||
114 | - 'strategys' => array( // 自定义策略数据(积分策略设置=2时,返回空字符串) | ||
115 | - array( | ||
116 | - 'action_key' => 'one_learning', // 触发行为key | ||
117 | - 'strategy_id' => '123', // 策略ID | ||
118 | - ), | ||
119 | - ), | ||
120 | - 'credit_strategy_setting' => 3, // 学分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) | ||
121 | - 'credit_strategys' => array( // 自定义策略数据(学分策略设置=2时,返回空字符串) | ||
122 | - array( | ||
123 | - 'action_key' => 'one_learning', // 触发行为key | ||
124 | - 'strategy_id' => '123', // 策略ID | ||
125 | - ), | ||
126 | - ), | ||
127 | - ) | ||
128 | - */ | ||
129 | - public function Index_post() | ||
130 | - { | ||
131 | - $article_id = I('post.article_id', 0, 'intval'); | ||
132 | - $articleServ = new ArticleService(); | ||
133 | - $article = $articleServ->get($article_id); | ||
134 | - if (empty($article)) { | ||
135 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
136 | - } | ||
137 | - | ||
138 | - // 格式化新闻数据 | ||
139 | - $formatArticle = $articleServ->formatData($article); | ||
140 | - | ||
141 | - // 格式化附件数据 | ||
142 | - $user = $this->_login->user; | ||
143 | - $attachServ = new AttachService(); | ||
144 | - $formatAttach = $attachServ->formatData($article['article_id'], $user); | ||
145 | - | ||
146 | - // 将格式化后的附件数据格式,从对象转为数组 | ||
147 | - $formatAttach['at_audio'] = isset($formatAttach['at_audio']) ? array_values($formatAttach['at_audio']) : []; | ||
148 | - $formatAttach['at_video'] = isset($formatAttach['at_video']) ? array_values($formatAttach['at_video']) : []; | ||
149 | - $formatAttach['at_file'] = isset($formatAttach['at_file']) ? array_values($formatAttach['at_file']) : []; | ||
150 | - | ||
151 | - // 格式化新闻权限数据 | ||
152 | - $rightServ = new RightService(); | ||
153 | - $formatRight['right'] = $rightServ->getData(['article_id' => $article_id]); | ||
154 | - | ||
155 | - // 组合数据 | ||
156 | - $data = array_merge($formatArticle, $formatRight, $formatAttach); | ||
157 | - | ||
158 | - $this->_result = $data; | ||
159 | - } | ||
160 | -} |
trunk/Message/Apicp/Controller/News/LikeListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 19:10 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\User; | ||
12 | -use Common\Service\LikeService; | ||
13 | - | ||
14 | -class LikeListController extends \Apicp\Controller\AbstractController | ||
15 | -{ | ||
16 | - /** | ||
17 | - * LikeList | ||
18 | - * @desc 点赞列表 | ||
19 | - * @param int article_id:true 新闻ID | ||
20 | - * @return array 点赞列表 | ||
21 | - * array( | ||
22 | - 'list' => array( // 点赞列表 | ||
23 | - 'uid' => 'B4B3BAFE7F00000173E870DA83A9751E', // 人员ID | ||
24 | - 'username' => '张三', // 人员姓名 | ||
25 | - 'face' => 'http://shp.qpic.cn/bizmp/gdZUibR6BHrkuqSjvCzX33qvZpCIOaYZiaFRnciae9WgxiaWXqxkqIOyeg/', // 头像 | ||
26 | - 'created' => 1434567890000, // 点赞时间 | ||
27 | - ), | ||
28 | - ); | ||
29 | - */ | ||
30 | - | ||
31 | - public function Index_post() | ||
32 | - { | ||
33 | - // 验证规则 | ||
34 | - $rules = [ | ||
35 | - 'article_id' => 'require|integer', | ||
36 | - 'page' => 'integer', | ||
37 | - 'limit' => 'integer', | ||
38 | - ]; | ||
39 | - | ||
40 | - // 验证数据 | ||
41 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
42 | - $postData = $validate->postData; | ||
43 | - | ||
44 | - // 点赞列表 | ||
45 | - $likeServ = new LikeService(); | ||
46 | - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); | ||
47 | - $likeList = $likeServ->list_by_conds(['article_id' => $postData['article_id']], [$start, $perpage]); | ||
48 | - $total = $likeServ->count_by_conds(['article_id' => $postData['article_id']]); | ||
49 | - | ||
50 | - if ($likeList) { | ||
51 | - // 人员信息 | ||
52 | - $uids = array_column($likeList, 'uid'); | ||
53 | - $userServ = &User::instance(); | ||
54 | - $userList = $userServ->listAll(['memUids' => $uids]); | ||
55 | - $userList = array_combine_by_key($userList, 'memUid'); | ||
56 | - | ||
57 | - // 合并头像 | ||
58 | - if ($userList) { | ||
59 | - foreach ($likeList as $k => $v) { | ||
60 | - if (isset($userList[$v['uid']])) { | ||
61 | - $likeList[$k]['username'] = isset($userList[$v['uid']]) ? $userList[$v['uid']]['memUsername'] : ''; | ||
62 | - $likeList[$k]['face'] = isset($userList[$v['uid']]) ? $userList[$v['uid']]['memFace'] : ''; | ||
63 | - } | ||
64 | - } | ||
65 | - } | ||
66 | - | ||
67 | - } | ||
68 | - | ||
69 | - $this->_result = [ | ||
70 | - 'list' => $likeList, | ||
71 | - 'total' => $total, | ||
72 | - 'page' => $postData['page'], | ||
73 | - 'limit' => $postData['limit'] | ||
74 | - ]; | ||
75 | - } | ||
76 | -} |
trunk/Message/Apicp/Controller/News/ListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 15:07 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\Constant; | ||
12 | -use Common\Service\ArticleService; | ||
13 | -use Common\Service\ClassService; | ||
14 | - | ||
15 | -class ListController extends \Apicp\Controller\AbstractController | ||
16 | -{ | ||
17 | - /** | ||
18 | - * List | ||
19 | - * @desc 新闻列表 | ||
20 | - * @ahthor liyifei | ||
21 | - * @param Int page:1 当前页(默认第一页) | ||
22 | - * @param Int limit:20 当前页条数 | ||
23 | - * @param string start_time 更新开始时间(毫秒级时间戳) | ||
24 | - * @param string end_time 更新结束时间(毫秒级时间戳) | ||
25 | - * @param string title 标题关键词 | ||
26 | - * @param Int class_id 分类ID | ||
27 | - * @param Int news_status 发布状态(1=草稿;2=已发布;3=预发布) | ||
28 | - * @return array | ||
29 | - * array( | ||
30 | - * 'total' => 100, // 总条数 | ||
31 | - * 'page' => 1, // 当前页 | ||
32 | - * 'limit' => 20, // 当前页条数 | ||
33 | - * 'list' => array( // 列表数据 | ||
34 | - * 'article_id' => 1, // 新闻ID | ||
35 | - * 'title' => '电商冲击,实体店靠什么赢', // 标题 | ||
36 | - * 'class_name' => '导购FM', // 栏目 | ||
37 | - * 'is_secret' => 1, // 是否保密(1=不保密,2=保密) | ||
38 | - * 'read_total' => 1, // 已阅读人数 | ||
39 | - * 'allow_read_total' => 30, // 可阅读人数 | ||
40 | - * 'news_status' => 1, // 发布状态(1=草稿,2=已发布,3=预发布) | ||
41 | - * 'convert_status' => 1, // 转码状态(1=转码中,2=转码成功,3=转码失败) | ||
42 | - * 'like_total' => 12, // 点赞人数 | ||
43 | - * 'comment_total' => 34, // 评论人数 | ||
44 | - * 'send_time' => '1491897290000', // 最后更新时间(毫秒级时间戳) | ||
45 | - * 'top_time' => '1491897290000', // 置顶时间(毫秒级时间戳,0为未置顶) | ||
46 | - * 'qr_code' => 'awddwdad.awddadad?awdadwad=awdada', // 二维码链接 | ||
47 | - * ), | ||
48 | - * ) | ||
49 | - */ | ||
50 | - public function Index_post() | ||
51 | - { | ||
52 | - // 验证规则 | ||
53 | - $rules = [ | ||
54 | - 'page' => 'integer', | ||
55 | - 'limit' => 'integer', | ||
56 | - 'start_time' => 'integer', | ||
57 | - 'end_time' => 'integer', | ||
58 | - 'title' => 'max:64', | ||
59 | - 'class_id' => 'integer', | ||
60 | - 'news_status' => 'integer', | ||
61 | - ]; | ||
62 | - | ||
63 | - // 验证数据 | ||
64 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
65 | - $postData = $validate->postData; | ||
66 | - | ||
67 | - // 默认值 | ||
68 | - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; | ||
69 | - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; | ||
70 | - | ||
71 | - // 组合条件 | ||
72 | - $conds = []; | ||
73 | - if (isset($postData['start_time'])) { | ||
74 | - $conds['send_time > ?'] = $postData['start_time']; | ||
75 | - } | ||
76 | - if (isset($postData['end_time'])) { | ||
77 | - $conds['send_time < ?'] = $postData['end_time']; | ||
78 | - } | ||
79 | - if (isset($postData['title'])) { | ||
80 | - // 查询%化需要转义 | ||
81 | - $postData['title'] = str_replace("%", '\%', $postData['title']); | ||
82 | - $conds['title like ?'] = '%' . $postData['title'] . '%'; | ||
83 | - } | ||
84 | - if (isset($postData['class_id'])) { | ||
85 | - $classServ = new ClassService(); | ||
86 | - $childList = $classServ->list_by_conds(['parent_id' => $postData['class_id']]); | ||
87 | - $class_ids = array_column($childList, 'class_id'); | ||
88 | - $class_ids[] = $postData['class_id']; | ||
89 | - $conds['class_id in (?)'] = $class_ids; | ||
90 | - } | ||
91 | - if (isset($postData['news_status'])) { | ||
92 | - if ($postData['news_status'] == Constant::NEWS_STATUS_READY_SEND) { | ||
93 | - $conds['news_status in (?)'] = [Constant::NEWS_STATUS_READY_SEND, Constant::NEWS_STATUS_TIMING_RELEASE]; | ||
94 | - } else { | ||
95 | - $conds['news_status = ?'] = $postData['news_status']; | ||
96 | - } | ||
97 | - } | ||
98 | - | ||
99 | - // 分页 | ||
100 | - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); | ||
101 | - | ||
102 | - // 排序 | ||
103 | - $order_option = ['top_time' => 'desc', 'send_time' => 'desc']; | ||
104 | - | ||
105 | - // 列表 | ||
106 | - $articleServ = new ArticleService(); | ||
107 | - $list = $articleServ->list_by_conds($conds, [$start, $perpage], $order_option); | ||
108 | - if ($list) { | ||
109 | - // 可阅读人数 | ||
110 | - foreach ($list as $k => $v) { | ||
111 | - $list[$k]['allow_read_total'] = $v['read_total'] + $v['unread_total']; | ||
112 | - // 加入二维码链接 | ||
113 | - $list[$k]['qr_code'] = oaUrl('Frontend/Index/NewsQrcode/index', ['article_id' => $v['article_id']]); | ||
114 | - } | ||
115 | - } | ||
116 | - | ||
117 | - // 数据总数 | ||
118 | - $total = $articleServ->count_by_conds($conds); | ||
119 | - | ||
120 | - $this->_result = [ | ||
121 | - 'page' => $postData['page'], | ||
122 | - 'limit' => $postData['limit'], | ||
123 | - 'total' => intval($total), | ||
124 | - 'list' => $list, | ||
125 | - ]; | ||
126 | - } | ||
127 | -} |
trunk/Message/Apicp/Controller/News/ReadListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/13 | ||
6 | - * Time: 11:48 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\Constant; | ||
12 | -use Common\Common\User; | ||
13 | -use Common\Service\ArticleService; | ||
14 | -use Common\Service\ReadService; | ||
15 | -use Common\Service\RightService; | ||
16 | - | ||
17 | -class ReadListController extends \Apicp\Controller\AbstractController | ||
18 | -{ | ||
19 | - | ||
20 | - /** | ||
21 | - * ReadList | ||
22 | - * @desc 阅读列表 | ||
23 | - * @param Int article_id:true 新闻ID | ||
24 | - * @param Int read_type:true 阅读类型(1=未读,2=已读) | ||
25 | - * @param Int page 页码 | ||
26 | - * @param Int limit 每页数据条数 | ||
27 | - * @return array 阅读列表 | ||
28 | - * array( | ||
29 | - 'article_id' => 123, // 新闻ID | ||
30 | - 'read_type' => 1, // 阅读类型(1=未读,2=已读) | ||
31 | - 'title' => '', // 新闻标题 | ||
32 | - 'send_time' => '', // 更新时间 | ||
33 | - 'page' => '', // 页码 | ||
34 | - 'limit' => '', // 每页数据条数 | ||
35 | - 'read_total' => '', // 已读总数 | ||
36 | - 'unread_total' => '', // 未读总数 | ||
37 | - 'list' => array( | ||
38 | - 'username' => '张三', // 姓名 | ||
39 | - 'dp_name' => array('技术部'), // 所属部门 | ||
40 | - 'job' => 'PHP', // 职位 | ||
41 | - 'mobile' => '15821392414', // 手机号码 | ||
42 | - 'created' => '1234566898988', // 阅读时间(毫秒级时间戳) | ||
43 | - ), | ||
44 | - ); | ||
45 | - */ | ||
46 | - public function Index_post() | ||
47 | - { | ||
48 | - // 验证规则 | ||
49 | - $rules = [ | ||
50 | - 'article_id' => 'require|integer', | ||
51 | - 'read_type' => 'require|integer', | ||
52 | - 'page' => 'integer', | ||
53 | - 'limit' => 'integer', | ||
54 | - 'dp_ids' => 'array', | ||
55 | - 'job_ids' => 'array', | ||
56 | - 'role_ids' => 'array', | ||
57 | - 'username' => 'max:64', | ||
58 | - ]; | ||
59 | - | ||
60 | - // 验证数据 | ||
61 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
62 | - $postData = $validate->postData; | ||
63 | - | ||
64 | - // 默认值 | ||
65 | - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; | ||
66 | - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; | ||
67 | - // 查询条件 | ||
68 | - $uidCond = $this->formatConds($postData); | ||
69 | - | ||
70 | - // 取新闻信息 | ||
71 | - $articleServ = new ArticleService(); | ||
72 | - $newsInfo = $articleServ->get($postData['article_id']); | ||
73 | - if (empty($newsInfo)) { | ||
74 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
75 | - } | ||
76 | - | ||
77 | - $list = []; | ||
78 | - $total = 0; | ||
79 | - $readServ = new ReadService(); | ||
80 | - | ||
81 | - $read_total = 0; | ||
82 | - $unread_total = 0; | ||
83 | - if ($uidCond !== false) { | ||
84 | - // 已读 | ||
85 | - $readConds = ['article_id' => $postData['article_id']]; | ||
86 | - $read_total = $readServ->count_by_conds($readConds); | ||
87 | - | ||
88 | - if (!empty($uidCond)) { | ||
89 | - $readConds['uid'] = $uidCond; | ||
90 | - } | ||
91 | - if ($postData['read_type'] == Constant::READ_STATUS_IS_YES) { | ||
92 | - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); | ||
93 | - $readList = $readServ->list_by_conds($readConds, [$start, $perpage]); | ||
94 | - $userServ = &User::instance(); | ||
95 | - $userlist = $userServ->listByUid(array_column($readList, 'uid')); | ||
96 | - $userlist = array_combine_by_key($userlist, 'memUid'); | ||
97 | - foreach ($readList as &$item) { | ||
98 | - $uid = $item['uid']; | ||
99 | - $list[] = [ | ||
100 | - 'username' => $userlist[$uid]['memUsername'], | ||
101 | - 'dp_name' => empty($userlist[$uid]['dpName']) ? | ||
102 | - [] : array_column($userlist[$uid]['dpName'], 'dpName'), | ||
103 | - 'job' => $userlist[$uid]['memJob'], | ||
104 | - 'role' => $userlist[$uid]['memRole'], | ||
105 | - 'mobile' => $userlist[$uid]['memMobile'], | ||
106 | - 'created' => $item['created'] | ||
107 | - ]; | ||
108 | - } | ||
109 | - | ||
110 | - $total = $read_total; | ||
111 | - } | ||
112 | - | ||
113 | - // 未读 | ||
114 | - list($uids_all, $uids_read, $uids_unread, $unread_total) = | ||
115 | - $this->getReadData($postData['article_id'], $uidCond); | ||
116 | - | ||
117 | - if ($postData['read_type'] == Constant::READ_STATUS_IS_NO) { | ||
118 | - $total = count($uids_unread); | ||
119 | - // 取未读人员信息 | ||
120 | - if ($uids_unread) { | ||
121 | - $userServ = &User::instance(); | ||
122 | - $userList = $userServ->listByConds(['memUids' => $uids_unread], $postData['page'], $postData['limit']); | ||
123 | - if ($userList) { | ||
124 | - foreach ($userList['list'] as $v) { | ||
125 | - $list[] = [ | ||
126 | - 'uid' => $v['memUid'], | ||
127 | - 'username' => $v['memUsername'], | ||
128 | - 'dp_name' => empty($v['dpName']) ? [] : array_column($v['dpName'], 'dpName'), | ||
129 | - 'job' => $v['memJob'], | ||
130 | - 'role' => $v['memRole'], | ||
131 | - 'mobile' => $v['memMobile'], | ||
132 | - ]; | ||
133 | - } | ||
134 | - } | ||
135 | - | ||
136 | - } | ||
137 | - } | ||
138 | - } | ||
139 | - | ||
140 | - $this->_result = [ | ||
141 | - 'article_id' => $postData['article_id'], | ||
142 | - 'read_type' => $postData['read_type'], | ||
143 | - 'limit' => $postData['limit'], | ||
144 | - 'page' => $postData['page'], | ||
145 | - 'title' => $newsInfo['title'], | ||
146 | - 'send_time' => $newsInfo['send_time'], | ||
147 | - 'read_total' => $read_total, | ||
148 | - 'unread_total' => $unread_total, | ||
149 | - 'total' => $total, | ||
150 | - 'list' => $list, | ||
151 | - ]; | ||
152 | - } | ||
153 | - | ||
154 | - /** | ||
155 | - * 将搜索条件转化为用户UID | ||
156 | - * @author tangxingguo | ||
157 | - * @param array $postData 用户提交的数据 | ||
158 | - * @return array|bool | ||
159 | - */ | ||
160 | - private function formatConds($postData) | ||
161 | - { | ||
162 | - $condUids = []; | ||
163 | - | ||
164 | - $userServ = &User::instance(); | ||
165 | - if (isset($postData['username'])) { | ||
166 | - // UC | ||
167 | - $userConds = ['memUsername' => $postData['username']]; | ||
168 | - $list = $userServ->listAll($userConds); | ||
169 | - $condUids = array_column($list, 'memUid'); | ||
170 | - } | ||
171 | - // 部门、岗位、角色搜索交集 | ||
172 | - $right = array_intersect_key_reserved($postData, ['dp_ids', 'job_ids', 'role_ids'], true); | ||
173 | - | ||
174 | - // 部门/岗位存在 名字存在 | ||
175 | - if (!empty($right) && isset($postData['username'])) { | ||
176 | - $rightServ = new RightService(); | ||
177 | - $rights = $rightServ->formatPostData($right); | ||
178 | - $unitUids = $rightServ->getUidsByRight($rights); | ||
179 | - if (!empty($condUids)) { | ||
180 | - // 筛选已经有值,取交集 | ||
181 | - $condUids = array_intersect($condUids, $unitUids); | ||
182 | - } else { | ||
183 | - //$condUids = $unitUids; | ||
184 | - return false; | ||
185 | - } | ||
186 | - } | ||
187 | - | ||
188 | - // 部门/岗位存在 名字存在 人名不存在 | ||
189 | - if (!empty($right) && !isset($postData['username'])) { | ||
190 | - $rightServ = new RightService(); | ||
191 | - $rights = $rightServ->formatPostData($right); | ||
192 | - $unitUids = $rightServ->getUidsByRight($rights); | ||
193 | - $condUids = $unitUids; | ||
194 | - } | ||
195 | - | ||
196 | - // 如果有查询 并且 结果为空 | ||
197 | - if ((!empty($right) || !empty($postData['username'])) && empty($condUids)) { | ||
198 | - return false; | ||
199 | - } | ||
200 | - | ||
201 | - return $condUids; | ||
202 | - } | ||
203 | - | ||
204 | - /** | ||
205 | - * 获取新闻可读、已读、未读人员ID数组 | ||
206 | - * @author zhonglei | ||
207 | - * @param int $article_id 新闻ID | ||
208 | - * @return array [0 => 可读人员ID, 1 => 已读人员ID, 2 => 未读人员ID] | ||
209 | - */ | ||
210 | - public function getReadData($article_id, $uidCond) | ||
211 | - { | ||
212 | - $uids_all = []; | ||
213 | - $uids_read = []; | ||
214 | - $uids_unread = []; | ||
215 | - | ||
216 | - // 查询条件 | ||
217 | - $conds = ['article_id' => $article_id]; | ||
218 | - // 获取权限数据 | ||
219 | - $rightServ = new RightService(); | ||
220 | - $right_list = $rightServ->list_by_conds($conds); | ||
221 | - $rights = $rightServ->formatDBData($right_list); | ||
222 | - | ||
223 | - if (empty($rights)) { | ||
224 | - return [$uids_all, $uids_read, $uids_unread]; | ||
225 | - } | ||
226 | - | ||
227 | - // 获取可读数据 | ||
228 | - $uids_all = $rightServ->getUidsByRight($rights); | ||
229 | - // 获取已读数据 | ||
230 | - $readServ = new ReadService(); | ||
231 | - if (!empty($uidCond)) { | ||
232 | - $conds['uid'] = $uidCond; | ||
233 | - } | ||
234 | - $study_list = $readServ->list_by_conds($conds); | ||
235 | - $uids_read = array_column($study_list, 'uid'); | ||
236 | - $uids_unread = array_values( | ||
237 | - array_diff( | ||
238 | - // 如果外部传了条件 | ||
239 | - !empty($uidCond) ? array_intersect($uids_all, $uidCond) : $uids_all, | ||
240 | - $uids_read | ||
241 | - ) | ||
242 | - ); | ||
243 | - // 已经学习人数 (跟传入条件无关) | ||
244 | - $studyListWithOutConds = $readServ->list_by_conds(['article_id' => $article_id]); | ||
245 | - $studyListWithOutConds = array_column($studyListWithOutConds, 'uid'); | ||
246 | - | ||
247 | - // 未读数据 | ||
248 | - return [$uids_all, $uids_read, $uids_unread, count(array_diff($uids_all, $studyListWithOutConds))]; | ||
249 | - } | ||
250 | -} |
trunk/Message/Apicp/Controller/News/ReleaseController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: 大熊 | ||
5 | - * Date: 2018/5/17 | ||
6 | - * Time: 15:05 | ||
7 | - */ | ||
8 | - | ||
9 | -namespace Apicp\Controller\News; | ||
10 | - | ||
11 | -use Apicp\Controller\AbstractController; | ||
12 | -use Common\Common\Constant; | ||
13 | -use Common\Common\NewsHelper; | ||
14 | -use Common\Service\ArticleService; | ||
15 | -use Common\Service\ClassService; | ||
16 | -use Think\Log; | ||
17 | - | ||
18 | -class ReleaseController extends AbstractController | ||
19 | -{ | ||
20 | - public function index_post() | ||
21 | - { | ||
22 | - $param = I('post.'); | ||
23 | - | ||
24 | - // 获取数据信息 | ||
25 | - $service = new ArticleService(); | ||
26 | - $data = $service->get($param['article_id']); | ||
27 | - | ||
28 | - // 不为定时发布时不做处理 | ||
29 | - if ($data['news_status'] != Constant::NEWS_STATUS_TIMING_RELEASE) { | ||
30 | - $this->_result = ['state' => true]; | ||
31 | - return true; | ||
32 | - } | ||
33 | - | ||
34 | - // 判断素材状态,若转码成功则为发布状态,否则为预发布状态 | ||
35 | - $updateData = ['news_status' => Constant::NEWS_STATUS_SEND]; | ||
36 | - if ($data['convert_status'] == Constant::FILE_STATUS_CONVERT) { | ||
37 | - $updateData['news_status'] = Constant::NEWS_STATUS_READY_SEND; | ||
38 | - } | ||
39 | - | ||
40 | - $service->update($param['article_id'], $updateData); | ||
41 | - | ||
42 | - // 当为发布时 | ||
43 | - if ($updateData['news_status'] == Constant::NEWS_STATUS_SEND) { | ||
44 | - try { | ||
45 | - // 获取顶级分类名称 | ||
46 | - $classServ = new ClassService(); | ||
47 | - $class = $classServ->getTopClass($data['class_id']); | ||
48 | - $data['class_name'] = $class['class_name']; | ||
49 | - | ||
50 | - // 发送未读提醒 | ||
51 | - if ($data['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) { | ||
52 | - $newsHelper = &NewsHelper::instance(); | ||
53 | - list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($param['article_id']); | ||
54 | - $newsHelper->sendUnreadMsg($uids_unread, $data); | ||
55 | - } | ||
56 | - | ||
57 | - // RPC推送到运营中心 | ||
58 | - if ($data['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { | ||
59 | - $service->addNewsRpc($param['article_id'], []); | ||
60 | - } | ||
61 | - } catch (\Exception $e) { | ||
62 | - Log::record('头条立即发布错误'.$e->getMessage()); | ||
63 | - } | ||
64 | - } | ||
65 | - | ||
66 | - $this->_result = ['state' => true]; | ||
67 | - return true; | ||
68 | - } | ||
69 | -} | ||
70 | \ No newline at end of file | 0 | \ No newline at end of file |
trunk/Message/Apicp/Controller/News/RemindController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 18:20 | ||
7 | - */ | ||
8 | - | ||
9 | -namespace Apicp\Controller\News; | ||
10 | - | ||
11 | -use Com\PackageValidate; | ||
12 | -use Common\Common\Constant; | ||
13 | -use Common\Common\NewsHelper; | ||
14 | -use Common\Service\ClassService; | ||
15 | -use Common\Service\ArticleService; | ||
16 | - | ||
17 | -class RemindController extends \Apicp\Controller\AbstractController | ||
18 | -{ | ||
19 | - /** | ||
20 | - * Remind | ||
21 | - * @author liyifei | ||
22 | - * @desc 未读提醒 | ||
23 | - * @param Int article_id:true 新闻ID | ||
24 | - * @param array uids:false 用户UIDS集合格式(array[1,2,3]) | ||
25 | - * @return array | ||
26 | - */ | ||
27 | - public function Index_post() | ||
28 | - { | ||
29 | - $uids = I('post.uids'); | ||
30 | - // 验证规则 | ||
31 | - $rules = [ | ||
32 | - 'article_id' => 'require|integer', | ||
33 | - ]; | ||
34 | - | ||
35 | - // 验证数据 | ||
36 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
37 | - $postData = $validate->postData; | ||
38 | - | ||
39 | - // 获取新闻详情 | ||
40 | - $articleServ = new ArticleService(); | ||
41 | - $article = $articleServ->get($postData['article_id']); | ||
42 | - | ||
43 | - if (empty($article)) { | ||
44 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
45 | - } | ||
46 | - | ||
47 | - | ||
48 | - // 草稿和预发布不允许发送提醒 | ||
49 | - if (in_array($article['news_status'], [Constant::NEWS_STATUS_DRAFT, Constant::NEWS_STATUS_READY_SEND])) { | ||
50 | - E('_ERR_ARTICLE_STATUS_FAIL'); | ||
51 | - } | ||
52 | - | ||
53 | - // 获取顶级分类名称 | ||
54 | - $classServ = new ClassService(); | ||
55 | - $class = $classServ->getTopClass($article['class_id']); | ||
56 | - $article['class_name'] = $class['class_name']; | ||
57 | - | ||
58 | - // 获取未读人员列表 | ||
59 | - $newsHelper = &NewsHelper::instance(); | ||
60 | - list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($postData['article_id']); | ||
61 | - | ||
62 | - // 提醒人员UID | ||
63 | - if (!empty($uids)) { | ||
64 | - $uids_unread = array_intersect($uids_unread, $uids); | ||
65 | - } | ||
66 | - // 发送未读提醒 | ||
67 | - $newsHelper->sendUnreadMsg($uids_unread, $article); | ||
68 | - } | ||
69 | -} |
trunk/Message/Apicp/Controller/News/SaveController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 18:33 | ||
7 | - */ | ||
8 | - | ||
9 | -namespace Apicp\Controller\News; | ||
10 | - | ||
11 | -use Common\Common\ArticleHelper; | ||
12 | -use Common\Common\Attach; | ||
13 | -use Com\PackageValidate; | ||
14 | -use Common\Common\Constant; | ||
15 | -use Common\Common\NewsHelper; | ||
16 | -use Common\Service\AttachService; | ||
17 | -use Common\Service\ClassService; | ||
18 | -use Common\Service\ReadService; | ||
19 | -use Common\Service\RightService; | ||
20 | -use Common\Service\ArticleService; | ||
21 | -use Common\Service\TaskService; | ||
22 | -use phpDocumentor\Reflection\Types\String_; | ||
23 | -use VcySDK\Cron; | ||
24 | -use VcySDK\Service; | ||
25 | - | ||
26 | -class SaveController extends \Apicp\Controller\AbstractController | ||
27 | -{ | ||
28 | - /** | ||
29 | - * Save | ||
30 | - * @author liyifei | ||
31 | - * @desc 新闻保存(创建、修改) | ||
32 | - * @param Int article_id 新闻ID | ||
33 | - * @param String title:true 标题 | ||
34 | - * @param Int class_id:true 分类ID | ||
35 | - * @param String author:true 作者 | ||
36 | - * @param String content 内容 | ||
37 | - * @param String cover_id:true 封面图片ID | ||
38 | - * @param String is_show_cover:true:2 是否正文显示封面图片(1=不显示,2=显示) | ||
39 | - * @param array file_at_ids 文件附件ID数组 | ||
40 | - * @param array audio_at_ids 音频附件ID数组 | ||
41 | - * @param array video_at_info 视频附件详情 | ||
42 | - * @param String video_at_info[].at_id:true 视频附件ID | ||
43 | - * @param String video_at_info[].at_name:true 视频名称 | ||
44 | - * @param String video_at_info[].at_size:true 视频大小(单位:字节) | ||
45 | - * @param String video_at_info[].at_time:true 视频时长 | ||
46 | - * @param array is_download:true:1 附件是否支持下载(1=不支持,2=支持) | ||
47 | - * @param String summary:true 摘要(最多输入150字符) | ||
48 | - * @param array right:true 阅读范围 | ||
49 | - * @param Int right.is_all 是否全公司(1=否;2=是) | ||
50 | - * @param array right.uids 人员ID | ||
51 | - * @param array right.dp_ids 部门ID | ||
52 | - * @param array right.tag_ids 标签ID | ||
53 | - * @param array right.job_ids 职位ID | ||
54 | - * @param array right.role_ids 角色ID | ||
55 | - * @param String link 外部链接 | ||
56 | - * @param Int is_jump 是否直接跳转外链(1=不直接跳转,2=直接跳转) | ||
57 | - * @param Int is_secret:true:1 是否保密(1=不保密,2=保密) | ||
58 | - * @param Int is_share:true:1 允许分享(1=不允许,2=允许) | ||
59 | - * @param Int is_notice:true:2 消息通知(1=不开启,2=开启) | ||
60 | - * @param Int is_comment:true:2 评论功能(1=不开启,2=开启) | ||
61 | - * @param Int is_like:true:2 点赞功能(1=不开启,2=开启) | ||
62 | - * @param Int is_recommend:true:2 首页推荐(1=不开启,2=开启) | ||
63 | - * @param Int news_status:true:1 新闻状态(1=草稿与保存并预览,2=已发布) | ||
64 | - * @param Int strategy_setting:true:2 积分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) | ||
65 | - * @param array strategys 自定义策略数据 | ||
66 | - * @param String strategys[].action_key 触发行为key | ||
67 | - * @param String strategys[].strategy_id 策略ID | ||
68 | - * @param Int credit_strategy_setting:true:2 学分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) | ||
69 | - * @param array credit_strategys 自定义策略数据 | ||
70 | - * @param String credit_strategys[].action_key 触发行为key | ||
71 | - * @param String credit_strategys[].strategy_id 策略ID | ||
72 | - * @return array 二维码链接 | ||
73 | - * array( | ||
74 | - * 'qr_code' => 'asdadsdasdad.asdsadasdsa?asdasdds=adasdadad', | ||
75 | - * ) | ||
76 | - */ | ||
77 | - public function Index_post() | ||
78 | - { | ||
79 | - // 验证规则 | ||
80 | - $rules = [ | ||
81 | - // 非必填 | ||
82 | - 'article_id' => 'integer', | ||
83 | - 'summary' => 'max:120', | ||
84 | - 'audio_at_ids' => 'array', | ||
85 | - 'file_at_ids' => 'array', | ||
86 | - 'video_at_info' => 'array', | ||
87 | - 'link' => 'max:500', | ||
88 | - 'is_jump' => 'integer|in:1,2', | ||
89 | - 'strategys' => 'array', | ||
90 | - 'credit_strategys' => 'array', | ||
91 | - 'cron_time' => 'max:20', | ||
92 | - // 必填 | ||
93 | - 'title' => 'require|max:64', | ||
94 | - 'class_id' => 'require|integer', | ||
95 | - 'author' => 'require|max:20', | ||
96 | - 'cover_id' => 'require', | ||
97 | - 'right' => 'require|array', | ||
98 | - 'is_show_cover' => 'require|integer|in:1,2', | ||
99 | - 'is_download' => 'require|integer|in:1,2', | ||
100 | - 'is_secret' => 'require|integer|in:1,2', | ||
101 | - 'is_share' => 'require|integer|in:1,2', | ||
102 | - 'is_notice' => 'require|integer|in:1,2', | ||
103 | - 'is_comment' => 'require|integer|in:1,2', | ||
104 | - 'comment_anonymous' => 'require|integer|in:1,2', | ||
105 | - 'is_like' => 'require|integer|in:1,2', | ||
106 | - 'is_recommend' => 'require|integer|in:1,2', | ||
107 | - 'news_status' => 'require|integer|in:1,2,4', | ||
108 | - 'strategy_setting' => 'require|integer|in:1,2,3', | ||
109 | - 'credit_strategy_setting' => 'require|integer|in:1,2,3', | ||
110 | - ]; | ||
111 | - | ||
112 | - // 验证请求数据 | ||
113 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
114 | - $postData = $validate->postData; | ||
115 | - | ||
116 | - // 完整请求参数 | ||
117 | - $postData['content'] = I('post.content', '', 'trim'); | ||
118 | - $fixData = $this->_fixData($postData); | ||
119 | - | ||
120 | - // 格式化权限数据 | ||
121 | - $rightServ = new RightService(); | ||
122 | - $formatRights = $rightServ->formatPostData($postData['right']); | ||
123 | - if (empty($formatRights)) { | ||
124 | - | ||
125 | - E('_ERR_ARTICLE_RIGHT_PARAM'); | ||
126 | - } | ||
127 | - | ||
128 | - // 校验传参(验证器无法验证的部分) | ||
129 | - $this->_checkData($fixData); | ||
130 | - | ||
131 | - // 组合写入article表的数据 | ||
132 | - $sqlData = $this->_fixSqlData($fixData); | ||
133 | - | ||
134 | - // 保存新闻 | ||
135 | - $articleServ = new ArticleService(); | ||
136 | - if ($fixData['article_id'] == 0) { | ||
137 | - // 创建新闻 | ||
138 | - $articleId = $articleServ->insert($sqlData); | ||
139 | - if (!$articleId) { | ||
140 | - | ||
141 | - E('_ERR_ARTICLE_SAVE_FAILED'); | ||
142 | - } | ||
143 | - | ||
144 | - // 二维码的链接 | ||
145 | - $qr_code = oaUrl('Frontend/Index/NewsQrcode/index', ['article_id' => $articleId]); | ||
146 | - | ||
147 | - // RPC推送到运营中心 | ||
148 | - if ($sqlData['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { | ||
149 | - | ||
150 | - $articleServ->addNewsRpc($articleId, $postData['right']); | ||
151 | - } | ||
152 | - | ||
153 | - } else { | ||
154 | - // 修改前的新闻数据 | ||
155 | - $articleOld = $articleServ->get($fixData['article_id']); | ||
156 | - $articleId = $articleOld['article_id']; | ||
157 | - | ||
158 | - // 如果存在定时发布,删除定时发布 | ||
159 | - if ($articleOld['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { | ||
160 | - // 实例化定时任务类 | ||
161 | - $cron_serv = new Cron(Service::instance()); | ||
162 | - $cron_serv->delete($articleOld['release_crid']); | ||
163 | - } | ||
164 | - | ||
165 | - // 二维码的链接 | ||
166 | - $qr_code = oaUrl('Frontend/Index/NewsQrcode/index', ['article_id' => $articleId]); | ||
167 | - | ||
168 | - if (!in_array($fixData['news_status'], [Constant::NEWS_STATUS_DRAFT, Constant::NEWS_STATUS_READY_SEND, Constant::NEWS_STATUS_TIMING_RELEASE])) { | ||
169 | - $this->_operationRpc($fixData['article_id'], $sqlData, $postData['right']); | ||
170 | - } | ||
171 | - // RPC推送到运营中心 | ||
172 | - | ||
173 | - | ||
174 | - // 修改新闻 | ||
175 | - $articleServ->update_by_conds(['article_id' => $fixData['article_id']], $sqlData); | ||
176 | - } | ||
177 | - | ||
178 | - // 定时发布, 增加定时任务 | ||
179 | - if ($sqlData['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { | ||
180 | - $articleServ->cronAdd($articleId, $sqlData['cron_time']); | ||
181 | - } | ||
182 | - | ||
183 | - // 推送未读消息(草稿、预发布除外;新建已发布新闻、草稿新闻修改为已发布新闻时,也推送消息;) | ||
184 | - $newsHelper = &NewsHelper::instance(); | ||
185 | - if (!in_array($sqlData['news_status'], [ | ||
186 | - Constant::NEWS_STATUS_DRAFT, | ||
187 | - Constant::NEWS_STATUS_READY_SEND, | ||
188 | - Constant::NEWS_STATUS_TIMING_RELEASE | ||
189 | - ]) && $sqlData['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) { | ||
190 | - // 发布过就不推消息了 | ||
191 | - if ($fixData['article_id'] == 0 || (isset($articleOld) && $articleOld['news_status'] == Constant::NEWS_STATUS_DRAFT && $sqlData['news_status'] == Constant::NEWS_STATUS_SEND)) { | ||
192 | - // 新闻所在顶级分类信息 | ||
193 | - $classServ = new ClassService(); | ||
194 | - $class = $classServ->getTopClass($sqlData['class_id']); | ||
195 | - $sqlData['class_name'] = $class['class_name']; | ||
196 | - | ||
197 | - $sqlData['article_id'] = $articleId; | ||
198 | - $newsHelper->sendNotice($sqlData, $formatRights); | ||
199 | - } | ||
200 | - } | ||
201 | - | ||
202 | - // 创建计划任务(预发布新闻:视频、文件附件) 添加定时任务 | ||
203 | - if ($sqlData['news_status'] == Constant::NEWS_STATUS_READY_SEND || $sqlData['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { | ||
204 | - | ||
205 | - $taskServ = new TaskService(); | ||
206 | - $taskServ->createCheckAttachTask($articleId); | ||
207 | - } | ||
208 | - | ||
209 | - // 保存阅读范围 | ||
210 | - $rightServ->saveData(['article_id' => $articleId], $postData['right']); | ||
211 | - | ||
212 | - // 修改新闻未读人数 | ||
213 | - list($uids_all, ,) = $newsHelper->getReadData($articleId); | ||
214 | - sort($uids_all); | ||
215 | - // 兼容多次编辑文章未读人数变化问题 | ||
216 | - $readServ = new ReadService(); | ||
217 | - $read_list = $readServ->list_by_conds([ | ||
218 | - 'article_id' => $articleId, | ||
219 | - 'uid' => $uids_all, | ||
220 | - ]); | ||
221 | - | ||
222 | - // 如果存在已读取过的人员 | ||
223 | - if (!empty($read_list)) { | ||
224 | - // 获取已读取人员的uids | ||
225 | - $read_uids = array_column($read_list, 'uid'); | ||
226 | - $uids_all = array_diff($uids_all, $read_uids); | ||
227 | - } | ||
228 | - | ||
229 | - $articleServ->update($articleId, ['unread_total' => count($uids_all)]); | ||
230 | - | ||
231 | - // 保存附件(已发布、预发布的新闻,不可修改附件) | ||
232 | - if ($fixData['article_id'] == 0 || (isset($articleOld) && $articleOld['news_status'] == Constant::NEWS_STATUS_DRAFT)) { | ||
233 | - | ||
234 | - $attachServ = new AttachService(); | ||
235 | - $attachServ->saveData($articleId, $fixData); | ||
236 | - } | ||
237 | - | ||
238 | - $this->_result = ['qr_code' => $qr_code]; | ||
239 | - } | ||
240 | - | ||
241 | - /** | ||
242 | - * 补全请求数据 | ||
243 | - * @param array $postData 请求数据 | ||
244 | - * @return array | ||
245 | - */ | ||
246 | - private function _fixData($postData) | ||
247 | - { | ||
248 | - // 非必填参数,补全默认值 | ||
249 | - $postData['article_id'] = isset($postData['article_id']) ? $postData['article_id'] : 0; | ||
250 | - $postData['summary'] = isset($postData['summary']) ? $postData['summary'] : ''; | ||
251 | - $postData['audio_at_ids'] = isset($postData['audio_at_ids']) ? $postData['audio_at_ids'] : ''; | ||
252 | - $postData['file_at_ids'] = isset($postData['file_at_ids']) ? $postData['file_at_ids'] : []; | ||
253 | - $postData['video_at_info'] = isset($postData['video_at_info']) ? $postData['video_at_info'] : []; | ||
254 | - $postData['link'] = isset($postData['link']) ? $postData['link'] : ''; | ||
255 | - $postData['is_jump'] = isset($postData['is_jump']) ? $postData['is_jump'] : Constant::NEWS_IS_JUMP_FALSE; | ||
256 | - | ||
257 | - return $postData; | ||
258 | - } | ||
259 | - | ||
260 | - /** | ||
261 | - * 校验传参 | ||
262 | - * @author liyifei | ||
263 | - * @param array $fixData 补全后的请求参数 | ||
264 | - * @return mixed | ||
265 | - */ | ||
266 | - private function _checkData($fixData) | ||
267 | - { | ||
268 | - // 为定时发布时,定时发布时间不能为空且大于当前时间 | ||
269 | - if ($fixData['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { | ||
270 | - if (!$fixData['cron_time'] || $fixData['cron_time'] <= MILLI_TIME) { | ||
271 | - E('_ERR_CREDIT_CRON_TIME_ERR'); | ||
272 | - } | ||
273 | - | ||
274 | - } | ||
275 | - // 文件最多上传5个 | ||
276 | - if (isset($fixData['file_at_ids']) && count($fixData['file_at_ids']) > Constant::UPLOAD_FILE_ATTACH_LIMIT) { | ||
277 | - | ||
278 | - E(L('_ERR_ARTICLE_FILE_ATTACH_MORE', ['at_type' => '文件'])); | ||
279 | - } | ||
280 | - | ||
281 | - // 音频最多上传5个 | ||
282 | - if (isset($fixData['audio_at_ids']) && count($fixData['audio_at_ids']) > Constant::UPLOAD_FILE_ATTACH_LIMIT) { | ||
283 | - | ||
284 | - E(L('_ERR_ARTICLE_FILE_ATTACH_MORE', ['at_type' => '音频'])); | ||
285 | - } | ||
286 | - | ||
287 | - // 视频最多上传5个 | ||
288 | - if (isset($fixData['video_at_info']) && count($fixData['video_at_info']) > Constant::UPLOAD_FILE_ATTACH_LIMIT) { | ||
289 | - | ||
290 | - E(L('_ERR_ARTICLE_FILE_ATTACH_MORE', ['at_type' => '视频'])); | ||
291 | - } | ||
292 | - | ||
293 | - // 视频附件参数不正确 | ||
294 | - if (!empty($fixData['video_at_info'])) { | ||
295 | - foreach ($fixData['video_at_info'] as $video) { | ||
296 | - if (!isset($video['at_id'], $video['at_name'], $video['at_size'], $video['at_time'])) { | ||
297 | - | ||
298 | - E('_ERR_ARTICLE_ATTACH_PARAM'); | ||
299 | - } | ||
300 | - } | ||
301 | - } | ||
302 | - | ||
303 | - // 保存自定义积分策略时,策略数据必传 | ||
304 | - $allow_key = [ | ||
305 | - 'action_key', | ||
306 | - 'strategy_id', | ||
307 | - ]; | ||
308 | - if ($fixData['strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM) { | ||
309 | - if (!isset($fixData['strategys']) || empty($fixData['strategys'])) { | ||
310 | - E('_ERR_ARTICLE_STRATEGY_ID_EMPTY'); | ||
311 | - } | ||
312 | - | ||
313 | - foreach ($fixData['strategys'] as $strategys) { | ||
314 | - if (!is_array($strategys) || empty($strategys)) { | ||
315 | - E('_ERR_ARTICLE_STRATEGY_PARAM_FORMAT'); | ||
316 | - } | ||
317 | - | ||
318 | - $strategy_key = array_keys($strategys); | ||
319 | - if (array_diff($allow_key, $strategy_key)) { | ||
320 | - E('_ERR_ARTICLE_STRATEGY_PARAM_LOSE'); | ||
321 | - } | ||
322 | - } | ||
323 | - } | ||
324 | - | ||
325 | - // 保存自定义学分策略时,策略数据必传 | ||
326 | - if ($fixData['credit_strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM) { | ||
327 | - if (!isset($fixData['credit_strategys']) || empty($fixData['credit_strategys'])) { | ||
328 | - E('_ERR_CREDIT_STRATEGY_ID_EMPTY'); | ||
329 | - } | ||
330 | - | ||
331 | - foreach ($fixData['credit_strategys'] as $credit_strategys) { | ||
332 | - if (!is_array($credit_strategys) || empty($credit_strategys)) { | ||
333 | - E('_ERR_CREDIT_STRATEGY_PARAM_FORMAT'); | ||
334 | - } | ||
335 | - | ||
336 | - $strategy_key = array_keys($credit_strategys); | ||
337 | - if (array_diff($allow_key, $strategy_key)) { | ||
338 | - E('_ERR_CREDIT_STRATEGY_PARAM_LOSE'); | ||
339 | - } | ||
340 | - } | ||
341 | - } | ||
342 | - | ||
343 | - return true; | ||
344 | - } | ||
345 | - | ||
346 | - /** | ||
347 | - * 补全写入article表的数据 | ||
348 | - * @author liyifei | ||
349 | - * @param array $fixData 补全后的请求参数 | ||
350 | - * @return array | ||
351 | - */ | ||
352 | - private function _fixSqlData($fixData) | ||
353 | - { | ||
354 | - // 补全data_id | ||
355 | - $articleServ = new ArticleService(); | ||
356 | - if ($fixData['article_id'] == 0) { | ||
357 | - | ||
358 | - $fixData['data_id'] = $articleServ->buildDataID(); | ||
359 | - } | ||
360 | - | ||
361 | - // 补全管理员信息 | ||
362 | - $fixData['ea_id'] = $this->_login->user['eaId']; | ||
363 | - $fixData['ea_name'] = $this->_login->user['eaRealname']; | ||
364 | - | ||
365 | - // 补全class_name | ||
366 | - $classServ = new ClassService(); | ||
367 | - $class = $classServ->get($fixData['class_id']); | ||
368 | - if (empty($class)) { | ||
369 | - E('_ERR_CLASS_DATA_NOT_FOUND'); | ||
370 | - } | ||
371 | - $fixData['class_name'] = $class['class_name']; | ||
372 | - | ||
373 | - // 补全summary | ||
374 | - if (empty($fixData['summary']) && !empty($fixData['content'])) { | ||
375 | - // 去除html格式,自动从内容中抓取54个字符 | ||
376 | - $content = htmlspecialchars(strip_tags($fixData['content'])); | ||
377 | - $fixData['summary'] = mb_substr($content, 0, Constant::AUTO_SUMMARY_LENGTH, 'UTF-8'); | ||
378 | - } | ||
379 | - | ||
380 | - // 补全cover_url | ||
381 | - $attachServ = &Attach::instance(); | ||
382 | - $fixData['cover_url'] = $attachServ->getAttachUrl($fixData['cover_id']); | ||
383 | - | ||
384 | - // 补全send_time | ||
385 | - $fixData['send_time'] = MILLI_TIME; | ||
386 | - | ||
387 | - // 补全news_status、convert_status | ||
388 | - $fixData['convert_status'] = Constant::FILE_STATUS_NORMAL; | ||
389 | - if ($fixData['news_status'] == Constant::NEWS_STATUS_SEND) { | ||
390 | - if ($fixData['article_id'] == 0) { | ||
391 | - // 新建新闻,有附件(预发布、转码中)(视频现在必须转码完成后才能提交,因此不会在保存后进行转码) | ||
392 | - if (!empty($fixData['file_at_ids'])) { | ||
393 | - $fixData['news_status'] = Constant::NEWS_STATUS_READY_SEND; | ||
394 | - $fixData['convert_status'] = Constant::FILE_STATUS_CONVERT; | ||
395 | - } | ||
396 | - | ||
397 | - } else { | ||
398 | - $article = $articleServ->get($fixData['article_id']); | ||
399 | - if (empty($article)) { | ||
400 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
401 | - } | ||
402 | - // 原草稿->现已发布,有附件(预发布、转码中)(视频现在必须转码完成后才能提交,因此不会在保存后进行转码) | ||
403 | - if ($article['news_status'] == Constant::NEWS_STATUS_DRAFT && (!empty($fixData['file_at_ids']))) { | ||
404 | - $fixData['news_status'] = Constant::NEWS_STATUS_READY_SEND; | ||
405 | - $fixData['convert_status'] = Constant::FILE_STATUS_CONVERT; | ||
406 | - } | ||
407 | - // 原已发布->现已发布(不修改附件) | ||
408 | - if ($article['news_status'] == Constant::NEWS_STATUS_SEND) { | ||
409 | - $fixData['news_status'] = Constant::NEWS_STATUS_SEND; | ||
410 | - $fixData['convert_status'] = Constant::FILE_STATUS_NORMAL; | ||
411 | - } | ||
412 | - } | ||
413 | - } | ||
414 | - | ||
415 | - // 序列化存储积分策略数据 | ||
416 | - if ($fixData['strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM && !empty($fixData['strategys'])) { | ||
417 | - $strategys = []; | ||
418 | - foreach ($fixData['strategys'] as $v) { | ||
419 | - $action_key = $v['action_key']; | ||
420 | - $strategys[$action_key] = $v['strategy_id']; | ||
421 | - } | ||
422 | - $fixData['strategys'] = serialize($strategys); | ||
423 | - } else { | ||
424 | - $fixData['strategys'] = ''; | ||
425 | - } | ||
426 | - | ||
427 | - // 序列化存储学分策略数据 | ||
428 | - if ($fixData['credit_strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM && !empty($fixData['credit_strategys'])) { | ||
429 | - $strategys = []; | ||
430 | - foreach ($fixData['credit_strategys'] as $v) { | ||
431 | - $action_key = $v['action_key']; | ||
432 | - $strategys[$action_key] = $v['strategy_id']; | ||
433 | - } | ||
434 | - $fixData['credit_strategys'] = serialize($strategys); | ||
435 | - } else { | ||
436 | - $fixData['credit_strategys'] = ''; | ||
437 | - } | ||
438 | - | ||
439 | - // 去掉postData请求参数中,不在article主表中的字段 | ||
440 | - $removeKeys = [ | ||
441 | - 'article_id', | ||
442 | - 'audio_at_ids', | ||
443 | - 'file_at_ids', | ||
444 | - 'video_at_info', | ||
445 | - 'right', | ||
446 | - ]; | ||
447 | - foreach ($fixData as $k => $v) { | ||
448 | - if (in_array($k, $removeKeys)) { | ||
449 | - unset($fixData[$k]); | ||
450 | - } | ||
451 | - } | ||
452 | - | ||
453 | - return $fixData; | ||
454 | - } | ||
455 | - | ||
456 | - /** | ||
457 | - * @desc 更新数据时,数据库与提交数据对比,判断推送接口 | ||
458 | - * @author tangxingguo | ||
459 | - * @param int $article_id 新闻ID | ||
460 | - * @param array $newInfo 更新的新闻数据 | ||
461 | - * @param array $postRight 用户提交的权限数据 | ||
462 | - */ | ||
463 | - private function _operationRpc($article_id, $newInfo, $postRight) | ||
464 | - { | ||
465 | - $articleServ = new ArticleService(); | ||
466 | - $articleDBInfo = $articleServ->get($article_id); | ||
467 | - if (($articleDBInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE && $newInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_FALSE) || ($articleDBInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE && $newInfo['news_status'] == Constant::NEWS_STATUS_READY_SEND)) { | ||
468 | - // 有推送过取消推送 或 计划任务,删除接口 | ||
469 | - $articleServ->delNewsRpc($article_id); | ||
470 | - } elseif ($articleDBInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_FALSE && $newInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { | ||
471 | - // 第一次推送,添加接口 | ||
472 | - $articleServ->addNewsRpc($article_id, $postRight); | ||
473 | - } elseif ($articleDBInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE && $newInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { | ||
474 | - // 有推送过,更新接口 | ||
475 | - $articleServ->updateNewsRpc($article_id, $newInfo, $postRight); | ||
476 | - } | ||
477 | - } | ||
478 | -} |
trunk/Message/Apicp/Controller/News/TopController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 18:16 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Service\ArticleService; | ||
12 | - | ||
13 | -class TopController extends \Apicp\Controller\AbstractController | ||
14 | -{ | ||
15 | - /** | ||
16 | - | ||
17 | - * Top | ||
18 | - * | ||
19 | - * @author zhonglei | ||
20 | - | ||
21 | - * @desc 新闻置顶/取消置顶 | ||
22 | - | ||
23 | - * @param Int article_id:true 新闻ID | ||
24 | - | ||
25 | - * @return mixed | ||
26 | - | ||
27 | - */ | ||
28 | - public function Index_post() | ||
29 | - { | ||
30 | - // 验证规则 | ||
31 | - $rules = [ | ||
32 | - 'article_id' => 'require|integer', | ||
33 | - ]; | ||
34 | - | ||
35 | - // 验证数据 | ||
36 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
37 | - $postData = $validate->postData; | ||
38 | - $article_id = $postData['article_id']; | ||
39 | - | ||
40 | - $artServ = new ArticleService(); | ||
41 | - $article = $artServ->get($article_id); | ||
42 | - | ||
43 | - if (empty($article)) { | ||
44 | - E('_ERR_ARTICLE_NOT_FOUND'); | ||
45 | - } | ||
46 | - | ||
47 | - $top_time = $article['top_time'] > 0 ? 0 : MILLI_TIME; | ||
48 | - $artServ->update($article_id, ['top_time' => $top_time]); | ||
49 | - } | ||
50 | -} |
trunk/Message/Apicp/Controller/News/UpdateUnreadController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 19:12 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\Constant; | ||
12 | -use Common\Common\NewsHelper; | ||
13 | -use Common\Service\ArticleService; | ||
14 | - | ||
15 | -class UpdateUnreadController extends \Apicp\Controller\AbstractController | ||
16 | -{ | ||
17 | - /** | ||
18 | - * UpdateUnread | ||
19 | - * @author zhonglei | ||
20 | - * @desc 更新未读总数 | ||
21 | - * @param Array article_ids:true 新闻ID数组 | ||
22 | - * @return mixed | ||
23 | - */ | ||
24 | - public function Index_post() | ||
25 | - { | ||
26 | - // 验证规则 | ||
27 | - $rules = [ | ||
28 | - 'article_ids' => 'require|array', | ||
29 | - ]; | ||
30 | - | ||
31 | - // 验证数据 | ||
32 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
33 | - $postData = $validate->postData; | ||
34 | - $article_ids = $postData['article_ids']; | ||
35 | - | ||
36 | - $artServ = new ArticleService(); | ||
37 | - $list = $artServ->list_by_conds([ | ||
38 | - 'article_id' => $article_ids, | ||
39 | - 'update_time < ?' => MILLI_TIME - Constant::NEWS_UNREAD_TIME, | ||
40 | - ]); | ||
41 | - | ||
42 | - if (empty($list)) { | ||
43 | - return true; | ||
44 | - } | ||
45 | - | ||
46 | - $newsHelper = &NewsHelper::instance(); | ||
47 | - | ||
48 | - foreach ($list as $article) { | ||
49 | - list(, $uids_read, $uids_unread) = $newsHelper->getReadData($article['article_id']); | ||
50 | - $unread_total = count($uids_unread); | ||
51 | - $read_total = count($uids_read); | ||
52 | - if ($article['unread_total'] != $unread_total || $article['read_total'] != $read_total) { | ||
53 | - $artServ->update($article['article_id'], [ | ||
54 | - 'unread_total' => $unread_total, | ||
55 | - 'read_total' => $read_total, | ||
56 | - 'update_time' => MILLI_TIME, | ||
57 | - ]); | ||
58 | - } | ||
59 | - } | ||
60 | - } | ||
61 | -} |
trunk/Message/Apicp/Controller/News/VideoInfoController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/9/20 | ||
6 | - * Time: 15:05 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\News; | ||
9 | - | ||
10 | -use VcySDK\Service; | ||
11 | -use VcySDK\FileConvert; | ||
12 | - | ||
13 | -class VideoInfoController extends \Apicp\Controller\AbstractController | ||
14 | -{ | ||
15 | - /** | ||
16 | - * VideoInfo | ||
17 | - * @author liyifei | ||
18 | - * @desc 视频详情 | ||
19 | - * @param String at_id 视频附件ID | ||
20 | - * @return array | ||
21 | - array( | ||
22 | - 'coverUrl' => 'http://1251064102.vod2.myqcloud.com/3f09017dvodtransgzp1251064102/a1c2a89f9031868223244026455/snapshot/1505805642_4281657565.100_0.jpg', // 封面地址(5秒内会生成) | ||
23 | - 'sd' =>'http://1251064102.vod2.myqcloud.com/3f09017dvodtransgzp1251064102/a1c2a89f9031868223244026455/v.f20.mp4', // 标清 (如果值为空,说明腾讯云后台还在转码中) | ||
24 | - 'default' =>'http://1251064102.vod2.myqcloud.com/8ae15ed5vodgzp1251064102/a1c2a89f9031868223244026455/f0.avi', // 原始视频 (实时,上传视频成功之后就会有) | ||
25 | - 'url' =>'http://1251064102.vod2.myqcloud.com/3f09017dvodtransgzp1251064102/a1c2a89f9031868223244026455/v.f20.mp4', // 播放地址 (如果值为空,说明腾讯云后台还在转码中, 下次迭代会删除此参数,建议使用sd代替) | ||
26 | - 'fileId' =>'9031868223244026455', // 视频fileId | ||
27 | - ) | ||
28 | - */ | ||
29 | - public function Index() | ||
30 | - { | ||
31 | - $atId = I('post.at_id', '', 'trim'); | ||
32 | - if (empty($atId)) { | ||
33 | - E('_ERR_VIDEO_ID_IS_EMPTY'); | ||
34 | - } | ||
35 | - | ||
36 | - $convertServ = new FileConvert(Service::instance()); | ||
37 | - $videoInfo = $convertServ->getVodPlayUrl($atId); | ||
38 | - | ||
39 | - $videoInfo['sd'] = $videoInfo['sd'] ?? ''; | ||
40 | - $videoInfo['hd'] = $videoInfo['hd'] ?? ''; | ||
41 | - $videoInfo['coverUrl'] = $videoInfo['coverUrl'] ?? ''; | ||
42 | - | ||
43 | - $this->_result = $videoInfo; | ||
44 | - } | ||
45 | -} |
trunk/Message/Apicp/Controller/NewsClass/DeleteController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 18:36 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\NewsClass; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Service\ArticleService; | ||
12 | -use Common\Service\ClassService; | ||
13 | - | ||
14 | -class DeleteController extends \Apicp\Controller\AbstractController | ||
15 | -{ | ||
16 | - /** | ||
17 | - * Delete | ||
18 | - * @author tangxingguo | ||
19 | - * @desc 删除分类 | ||
20 | - * @param int class_id:true 分类ID | ||
21 | - * @return null | ||
22 | - */ | ||
23 | - public function Index_post() | ||
24 | - { | ||
25 | - // 验证规则 | ||
26 | - $rules = [ | ||
27 | - 'class_id' => 'require|integer', | ||
28 | - ]; | ||
29 | - | ||
30 | - // 验证数据 | ||
31 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
32 | - $postData = $validate->postData; | ||
33 | - | ||
34 | - $classServ = new ClassService(); | ||
35 | - $classInfo = $classServ->get($postData['class_id']); | ||
36 | - if (empty($classInfo)) { | ||
37 | - E('_ERR_CLASS_DATA_NOT_FOUND'); | ||
38 | - } | ||
39 | - | ||
40 | - // 一级分类检查有无子分类 | ||
41 | - if ($classInfo['parent_id'] == 0) { | ||
42 | - $child = $classServ->get_by_conds(['parent_id' => $classInfo['class_id']]); | ||
43 | - if ($child) { | ||
44 | - E('_ERR_CLASS_CONTAIN_CHILD'); | ||
45 | - } | ||
46 | - } | ||
47 | - | ||
48 | - // 检查分类下有无新闻 | ||
49 | - $articleServ = new ArticleService(); | ||
50 | - $articleCount = $articleServ->count_by_conds(['class_id' => $postData['class_id']]); | ||
51 | - if ($articleCount > 0) { | ||
52 | - E('_ERR_CLASS_CONTAIN_ARTICLE'); | ||
53 | - } | ||
54 | - | ||
55 | - // 删除分类 | ||
56 | - $classServ->delete($postData['class_id']); | ||
57 | - } | ||
58 | -} |
trunk/Message/Apicp/Controller/NewsClass/InfoController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/13 | ||
6 | - * Time: 17:02 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\NewsClass; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Service\ClassService; | ||
12 | -use Common\Service\RightService; | ||
13 | - | ||
14 | -class InfoController extends \Apicp\Controller\AbstractController | ||
15 | -{ | ||
16 | - /** | ||
17 | - * Info | ||
18 | - * @author tangxingguo | ||
19 | - * @desc 分类详情 | ||
20 | - * @param int class_id:true 分类ID | ||
21 | - * @return array 分类信息 | ||
22 | - array ( | ||
23 | - 'class_id' => 2 // 当前分类ID | ||
24 | - 'parent_id' => 1 // 这是父级分类ID(仅二级分类存在) | ||
25 | - 'parent_name' => 分类1 // 这是父级分类名称(仅二级分类存在) | ||
26 | - 'class_name' => 分类标题 // 这是分类标题 | ||
27 | - 'description' => 分类描述 // 这是分类描述 | ||
28 | - 'is_open' => 1 // 启用分类(1=禁用,2=启用)(仅二级分类存在) | ||
29 | - 'right' => array( // 权限详情 | ||
30 | - 'is_all' => 1, // 是否全公司(1=否,2=是) | ||
31 | - 'tag_list' => array( // 标签信息(仅二级分类存在) | ||
32 | - 'tag_id' => '0E19B0B47F0000012652058BA42EEEDE', // 标签ID | ||
33 | - 'tag_name' => '吃货', // 标签名称 | ||
34 | - ), | ||
35 | - 'dp_list' => array( // 部门信息(仅二级分类存在) | ||
36 | - 'dp_id' => '0E19B0B47F0000012652058BA42EEEDE', // 部门ID | ||
37 | - 'dp_name' => '技术部', // 部门名称 | ||
38 | - ), | ||
39 | - 'user_list' => array( // 人员信息(仅二级分类存在) | ||
40 | - 'uid' => '0E19B0B47F0000012652058BA42EEEDE', // 人员ID | ||
41 | - 'username' => '张三', // 人员姓名 | ||
42 | - 'face' => 'http://qy.vchangyi.com', // 人员姓名 | ||
43 | - ), | ||
44 | - 'job_list' => array( // 职位(仅二级分类存在) | ||
45 | - array( | ||
46 | - 'job_id' => '62C316437F0000017AE8E6ACC7EFAC22', // 职位ID | ||
47 | - 'job_name' => '攻城狮', // 职位名称 | ||
48 | - ), | ||
49 | - ), | ||
50 | - 'role_list' => array( // 角色(仅二级分类存在) | ||
51 | - array( | ||
52 | - 'role_id' => '62C354B97F0000017AE8E6AC4FD6F429', // 角色ID | ||
53 | - 'role_name' => '国家元首', // 角色名称 | ||
54 | - ), | ||
55 | - ), | ||
56 | - ), | ||
57 | - ); | ||
58 | - */ | ||
59 | - public function Index_post() | ||
60 | - { | ||
61 | - // 验证规则 | ||
62 | - $rules = [ | ||
63 | - 'class_id' => 'require|integer', | ||
64 | - ]; | ||
65 | - | ||
66 | - // 验证数据 | ||
67 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
68 | - $postData = $validate->postData; | ||
69 | - | ||
70 | - $classServ = new ClassService(); | ||
71 | - $classInfo = $classServ->get($postData['class_id']); | ||
72 | - if (empty($classInfo)) { | ||
73 | - E('_ERR_CLASS_DATA_NOT_FOUND'); | ||
74 | - } | ||
75 | - $info = [ | ||
76 | - 'class_id' => $classInfo['class_id'], | ||
77 | - 'class_name' => $classInfo['class_name'], | ||
78 | - 'description' => $classInfo['description'], | ||
79 | - 'right' => [], | ||
80 | - ]; | ||
81 | - | ||
82 | - // 二级分类 | ||
83 | - $level = $classServ->classLevel($postData['class_id']); | ||
84 | - if ($level == 2) { | ||
85 | - $pInfo = $classServ->get($classInfo['parent_id']); | ||
86 | - if ($pInfo) { | ||
87 | - $info['parent_name'] = $pInfo['class_name']; | ||
88 | - $info['is_open'] = $classInfo['is_open']; | ||
89 | - } | ||
90 | - | ||
91 | - // 取权限 | ||
92 | - $rightServ = new RightService(); | ||
93 | - $right = $rightServ->getData(['class_id' => $postData['class_id']]); | ||
94 | - $info['right'] = $right; | ||
95 | - } | ||
96 | - | ||
97 | - $this->_result = $info; | ||
98 | - } | ||
99 | -} |
trunk/Message/Apicp/Controller/NewsClass/ListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 16:31 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\NewsClass; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\Constant; | ||
12 | -use Common\Service\ClassService; | ||
13 | - | ||
14 | -class ListController extends \Apicp\Controller\AbstractController | ||
15 | -{ | ||
16 | - /** | ||
17 | - | ||
18 | - * List | ||
19 | - | ||
20 | - * @desc 分类列表 | ||
21 | - | ||
22 | - * @param int is_open 获取的分类启禁用类型(1=禁用,2=启用) | ||
23 | - | ||
24 | - * @return array | ||
25 | - | ||
26 | - * array( | ||
27 | - | ||
28 | - * 'list' => array( | ||
29 | - | ||
30 | - * array( | ||
31 | - | ||
32 | - * 'class_id' => 1, // 分类ID | ||
33 | - | ||
34 | - * 'class_name' => '分类1', // 分类名称 | ||
35 | - | ||
36 | - * 'is_open' => 1, // 启用分类(1=禁用,2=启用) | ||
37 | - | ||
38 | - * 'order' => 1, // 排序 | ||
39 | - | ||
40 | - * 'child' => array( // 子分类 | ||
41 | - | ||
42 | - * array( | ||
43 | - | ||
44 | - * 'class_id' => 2, // 分类ID | ||
45 | - | ||
46 | - * 'class_name' => '分类2', // 分类名称 | ||
47 | - | ||
48 | - * 'is_open' => 1, // 启用分类(1=禁用,2=启用) | ||
49 | - | ||
50 | - * 'order' => 1, // 排序 | ||
51 | - | ||
52 | - * ) | ||
53 | - | ||
54 | - * ) | ||
55 | - | ||
56 | - * ) | ||
57 | - | ||
58 | - * ) | ||
59 | - | ||
60 | - * ) | ||
61 | - | ||
62 | - */ | ||
63 | - public function Index_post() | ||
64 | - { | ||
65 | - // 验证规则 | ||
66 | - $rules = [ | ||
67 | - 'is_open' => 'integer', | ||
68 | - ]; | ||
69 | - | ||
70 | - // 验证数据 | ||
71 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
72 | - $postData = $validate->postData; | ||
73 | - | ||
74 | - $classServ = new ClassService(); | ||
75 | - | ||
76 | - // 排序规则 | ||
77 | - $order_option = ['`order`' => 'asc']; | ||
78 | - | ||
79 | - // 取一级分类 | ||
80 | - $classList = $classServ->list_by_conds(['parent_id' => 0], [], $order_option); | ||
81 | - if (empty($classList)) { | ||
82 | - return $this->_result = ['list' => []]; | ||
83 | - } | ||
84 | - | ||
85 | - // 取二级分类 | ||
86 | - if (isset($postData['is_open']) && in_array($postData['is_open'], [Constant::CLASS_IS_OPEN_FALSE, Constant::CLASS_IS_OPEN_TRUE])) { | ||
87 | - $conds = [ | ||
88 | - 'parent_id > ?' => 0, | ||
89 | - 'is_open' => $postData['is_open'], | ||
90 | - ]; | ||
91 | - $childList = $classServ->list_by_conds($conds, [], $order_option); | ||
92 | - } else { | ||
93 | - $childList = $classServ->list_by_conds(['parent_id > ?' => 0], [], $order_option); | ||
94 | - } | ||
95 | - | ||
96 | - | ||
97 | - // 组合数据 | ||
98 | - foreach ($classList as $k => $v) { | ||
99 | - if ($childList) { | ||
100 | - foreach ($childList as $index => $info) { | ||
101 | - if ($v['class_id'] == $info['parent_id']) { | ||
102 | - $classList[$k]['child'][] = $info; | ||
103 | - unset($childList[$index]); | ||
104 | - } | ||
105 | - } | ||
106 | - } | ||
107 | - } | ||
108 | - $this->_result = ['list' => $classList]; | ||
109 | - } | ||
110 | -} |
trunk/Message/Apicp/Controller/NewsClass/OpenController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | - | ||
3 | -namespace Apicp\Controller\NewsClass; | ||
4 | - | ||
5 | -use Com\PackageValidate; | ||
6 | -use Common\Service\ClassService; | ||
7 | - | ||
8 | -class OpenController extends \Apicp\Controller\AbstractController | ||
9 | -{ | ||
10 | - /** | ||
11 | - * class_id int 分类ID | ||
12 | - * is_open bool 开关 1:禁用 2:启用 | ||
13 | - * @return bool | ||
14 | - */ | ||
15 | - public function index() | ||
16 | - { | ||
17 | - // 验证规则 | ||
18 | - $rules = [ | ||
19 | - 'class_id' => 'require|integer', | ||
20 | - 'is_open' => 'require|integer', | ||
21 | - ]; | ||
22 | - | ||
23 | - // 验证数据 | ||
24 | - $validate = new PackageValidate($rules, [ | ||
25 | - 'class_id.require' => L('_ERR_PARAM_CAN_NOT_EMPTY', ['name' => '分类ID']), | ||
26 | - 'is_open.require' => L('_ERR_PARAM_CAN_NOT_EMPTY', ['name' => '开启禁用']) | ||
27 | - ], array_keys($rules)); | ||
28 | - $postData = $validate->postData; | ||
29 | - | ||
30 | - // 修改 | ||
31 | - $classServ = new ClassService(); | ||
32 | - $classServ->update($postData['class_id'], [ | ||
33 | - 'is_open' => $postData['is_open'] | ||
34 | - ]); | ||
35 | - | ||
36 | - return true; | ||
37 | - } | ||
38 | -} |
trunk/Message/Apicp/Controller/NewsClass/SaveController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | - | ||
3 | -namespace Apicp\Controller\NewsClass; | ||
4 | - | ||
5 | -use Com\PackageValidate; | ||
6 | -use Common\Service\ArticleService; | ||
7 | -use Common\Service\ClassService; | ||
8 | - | ||
9 | -class SaveController extends \Apicp\Controller\AbstractController | ||
10 | -{ | ||
11 | - /** | ||
12 | - * Save | ||
13 | - * @author tangxingguo | ||
14 | - * @desc 保存分类 | ||
15 | - * @param Int parent_id 上级分类ID(二级分类保存时必填) | ||
16 | - * @param Int class_id 分类ID | ||
17 | - * @param String class_name:true 分类标题 | ||
18 | - * @param String description 分类描述 | ||
19 | - * @return array | ||
20 | - */ | ||
21 | - public function Index_post() | ||
22 | - { | ||
23 | - // 验证规则 | ||
24 | - $rules = [ | ||
25 | - 'parent_id' => 'integer', | ||
26 | - 'class_id' => 'integer', | ||
27 | - 'class_name' => 'require|max:20', | ||
28 | - 'description' => 'max:120', | ||
29 | - 'is_open' => 'in:1,2', | ||
30 | - ]; | ||
31 | - | ||
32 | - // 验证数据 | ||
33 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
34 | - $postData = $validate->postData; | ||
35 | - | ||
36 | - // 分类信息初始化 | ||
37 | - $classServ = new ClassService(); | ||
38 | - $classInfo = [ | ||
39 | - 'class_name' => $postData['class_name'], | ||
40 | - 'description' => isset($postData['description']) ? $postData['description'] : '', | ||
41 | - 'is_open' => $postData['is_open'] | ||
42 | - ]; | ||
43 | - | ||
44 | - // 唯一分类名检查 | ||
45 | - if (!$classServ->uniqueName($classInfo['class_name'], $postData['class_id'])) { | ||
46 | - E('_ERR_CLASS_NAME_REPEAT'); | ||
47 | - } | ||
48 | - | ||
49 | - // 二级分类操作 | ||
50 | - if (isset($postData['parent_id'])) { | ||
51 | - if (!isset($postData['parent_id']) || empty($postData['parent_id'])) { | ||
52 | - E('_ERR_CLASS_PARENT_ID_EMPTY'); | ||
53 | - } | ||
54 | - $classInfo['parent_id'] = $postData['parent_id']; | ||
55 | - | ||
56 | - // 分类名改变,修改article内分类名称 | ||
57 | - if (isset($postData['class_id'])) { | ||
58 | - $class = $classServ->get($postData['class_id']); | ||
59 | - if ($class && $class['class_name'] != $postData['class_name']) { | ||
60 | - $articleServ = new ArticleService(); | ||
61 | - $articleServ->update_by_conds( | ||
62 | - [ | ||
63 | - 'class_id' => $postData['class_id']], | ||
64 | - [ | ||
65 | - 'class_name' => $postData['class_name'] | ||
66 | - ] | ||
67 | - ); | ||
68 | - } | ||
69 | - } | ||
70 | - } else { | ||
71 | - // 一级分类 默认开启 | ||
72 | - $classInfo['is_open'] = 2; | ||
73 | - } | ||
74 | - | ||
75 | - if (empty($postData['class_id'])) { | ||
76 | - // 保存 | ||
77 | - $postData['class_id'] = $classServ->insert($classInfo); | ||
78 | - } else { | ||
79 | - // 修改 | ||
80 | - $classServ->update($postData['class_id'], $classInfo); | ||
81 | - } | ||
82 | - } | ||
83 | -} |
trunk/Message/Apicp/Controller/NewsClass/UpdateOrderController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: liyifei2012it | ||
5 | - * Date: 17/4/11 | ||
6 | - * Time: 19:16 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\NewsClass; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Service\ClassService; | ||
12 | - | ||
13 | -class UpdateOrderController extends \Apicp\Controller\AbstractController | ||
14 | -{ | ||
15 | - /** | ||
16 | - * UpdateOrder | ||
17 | - * @author tangxingguo | ||
18 | - * @desc 分类拖动排序 | ||
19 | - * @param int list[].class_id:true 一级分类ID | ||
20 | - * @param int list[].child[].class_id:true 二级分类ID | ||
21 | - * @return array | ||
22 | - */ | ||
23 | - public function Index_post() | ||
24 | - { | ||
25 | - // 验证规则 | ||
26 | - $rules = [ | ||
27 | - 'list' => 'require|array', | ||
28 | - ]; | ||
29 | - | ||
30 | - // 验证数据 | ||
31 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
32 | - $postData = $validate->postData; | ||
33 | - | ||
34 | - // 入库 | ||
35 | - $classServ = new ClassService(); | ||
36 | - $order = 0; | ||
37 | - foreach ($postData['list'] as $k => $v) { | ||
38 | - $classServ->update($v['class_id'], ['`order`' => $order]); | ||
39 | - $order ++; | ||
40 | - if (isset($v['child'])) { | ||
41 | - foreach ($v['child'] as $child) { | ||
42 | - $classServ->update($child['class_id'], ['`order`' => $order]); | ||
43 | - $order ++; | ||
44 | - } | ||
45 | - } | ||
46 | - } | ||
47 | - } | ||
48 | -} |
trunk/Message/Apicp/Controller/Operate/ClassListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 18:36 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\Operate; | ||
9 | - | ||
10 | -use Common\Service\ClassService; | ||
11 | - | ||
12 | -class ClassListController extends \Apicp\Controller\AbstractController | ||
13 | -{ | ||
14 | - /** | ||
15 | - * Banner 分类选择接口 | ||
16 | - * @desc 用于首页 Banner 展示的接口 | ||
17 | - * @return array( | ||
18 | - * array( | ||
19 | - * 'id' => '分类 ID', // 分类 ID | ||
20 | - * 'name' => '分类名称', // 分类名称 | ||
21 | - * 'upId' => '上级分类 ID,为 0 则表示顶级' // 上级分类 ID,为 0 则表示顶级 | ||
22 | - * ), | ||
23 | - * array() | ||
24 | - * ) | ||
25 | - */ | ||
26 | - public function Index_post() | ||
27 | - { | ||
28 | - $classServ = new ClassService(); | ||
29 | - $classList = $classServ->list_all(); | ||
30 | - | ||
31 | - // 格式化数据 | ||
32 | - $res = []; | ||
33 | - if (!empty($classList)) { | ||
34 | - foreach ($classList as $k => $v) { | ||
35 | - $res[] = [ | ||
36 | - 'id' => $v['class_id'], | ||
37 | - 'name' => $v['class_name'], | ||
38 | - 'upId' => $v['parent_id'], | ||
39 | - ]; | ||
40 | - } | ||
41 | - } | ||
42 | - | ||
43 | - $this->_result = $res; | ||
44 | - } | ||
45 | -} |
trunk/Message/Apicp/Controller/Operate/IconApiController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 18:36 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\Operate; | ||
9 | - | ||
10 | -use Common\Service\ClassService; | ||
11 | - | ||
12 | -class IconApiController extends \Apicp\Controller\AbstractController | ||
13 | -{ | ||
14 | - /** | ||
15 | - * 栏目接口 | ||
16 | - * @desc 栏目接口 | ||
17 | - * @return array( | ||
18 | - * array( | ||
19 | - * 'id' => '分类 ID', // 分类 ID | ||
20 | - * 'name' => '分类名称', // 分类名称 | ||
21 | - * 'url' => '分类链接,如果为空,则表明该链接不可直接访问', // 分类链接,如果为空,则表明该链接不可直接访问 | ||
22 | - * 'upId' => '上级分类 ID,为 0 则表示顶级' // 上级分类 ID,为 0 则表示顶级 | ||
23 | - * ), | ||
24 | - * array() | ||
25 | - * ) | ||
26 | - */ | ||
27 | - public function Index_post() | ||
28 | - { | ||
29 | - $classServ = new ClassService(); | ||
30 | - $classList = $classServ->list_all(); | ||
31 | - | ||
32 | - // 格式化数据 | ||
33 | - $res = [ | ||
34 | - [ | ||
35 | - 'id' => 0, | ||
36 | - 'name' => '全部', | ||
37 | - 'url' => 'News/Frontend/Index/NewsList/Index?class_id=0', | ||
38 | - 'upId' => 0, | ||
39 | - ] | ||
40 | - ]; | ||
41 | - if (!empty($classList)) { | ||
42 | - foreach ($classList as $k => $v) { | ||
43 | - $res[] = [ | ||
44 | - 'id' => $v['class_id'], | ||
45 | - 'name' => $v['class_name'], | ||
46 | - // 只有一级分类可以直接跳转 | ||
47 | - 'url' => $v['parent_id'] == 0 ? 'News/Frontend/Index/NewsList/Index?class_id=' . $v['class_id'] : '', | ||
48 | - 'upId' => $v['parent_id'], | ||
49 | - ]; | ||
50 | - } | ||
51 | - } | ||
52 | - | ||
53 | - $this->_result = $res; | ||
54 | - } | ||
55 | -} |
trunk/Message/Apicp/Controller/Operate/NewsListController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 18:36 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\Operate; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\Constant; | ||
12 | -use Common\Service\ArticleService; | ||
13 | - | ||
14 | -class NewsListController extends \Apicp\Controller\AbstractController | ||
15 | -{ | ||
16 | - /** | ||
17 | - * Banner 新闻列表接口 | ||
18 | - * @desc 用于首页 Banner 新闻列表的接口 | ||
19 | - * @param integer categoryId:false 要列表的分类 Id,为空则请求全部 | ||
20 | - * @param integer limit:false:20 每页显示的数据条数 | ||
21 | - * @param integer page:false:1 当前请求的页码 | ||
22 | - * @return array( | ||
23 | - array( | ||
24 | - 'limit' => 20, // 每页显示的数据条数 | ||
25 | - 'page' => 1, // 当前请求的页码 | ||
26 | - 'total' => 20, // 数据总数 | ||
27 | - 'pages' => 1, // 页码总数 | ||
28 | - 'categoryId' => 1, // 当前请求的分类 ID | ||
29 | - 'list' => array( | ||
30 | - 'id' => '新闻 ID', // 新闻ID | ||
31 | - 'subject' => '新闻标题', // 新闻标题 | ||
32 | - 'time' => '发表时间', // 发表时间 | ||
33 | - 'categoryName' => '所属分类名称', // 分类名称 | ||
34 | - 'categoryId' => '所属分类 ID', // 分类ID | ||
35 | - 'author' => '作者名称', // 作者名称 | ||
36 | - ) | ||
37 | - ); | ||
38 | - */ | ||
39 | - public function Index_post() | ||
40 | - { | ||
41 | - // 验证规则 | ||
42 | - $rules = [ | ||
43 | - 'categoryId' => 'integer', | ||
44 | - 'limit' => 'integer', | ||
45 | - 'page' => 'integer', | ||
46 | - ]; | ||
47 | - | ||
48 | - // 验证数据 | ||
49 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
50 | - $postData = $validate->postData; | ||
51 | - | ||
52 | - // 默认值 | ||
53 | - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; | ||
54 | - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; | ||
55 | - | ||
56 | - // 组合条件 | ||
57 | - $conds = ['news_status' => Constant::NEWS_STATUS_SEND]; | ||
58 | - if (isset($postData['categoryId'])) { | ||
59 | - $conds['class_id'] = $postData['categoryId']; | ||
60 | - } | ||
61 | - | ||
62 | - // 分页 | ||
63 | - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); | ||
64 | - | ||
65 | - // 排序 | ||
66 | - $order_option = ['top_time' => 'desc', 'send_time' => 'desc']; | ||
67 | - | ||
68 | - // 列表 | ||
69 | - $articleServ = new ArticleService(); | ||
70 | - $list = $articleServ->list_by_conds($conds, [$start, $perpage], $order_option); | ||
71 | - $resList = []; | ||
72 | - if (!empty($list)) { | ||
73 | - foreach ($list as $v) { | ||
74 | - $resList[] = [ | ||
75 | - 'id' => $v['article_id'], | ||
76 | - 'subject' => $v['title'], | ||
77 | - 'time' => $v['send_time'], | ||
78 | - 'categoryName' => $v['class_name'], | ||
79 | - 'categoryId' => $v['class_id'], | ||
80 | - 'author' => $v['author'], | ||
81 | - ]; | ||
82 | - } | ||
83 | - } | ||
84 | - | ||
85 | - // 数据总数 | ||
86 | - $total = $articleServ->count_by_conds($conds); | ||
87 | - | ||
88 | - $this->_result = [ | ||
89 | - 'limit' => $postData['limit'], | ||
90 | - 'page' => $postData['page'], | ||
91 | - 'total' => intval($total), | ||
92 | - 'pages' => ceil($total/$postData['limit']), | ||
93 | - 'categoryId' => isset($postData['categoryId']) ? $postData['categoryId'] : 0, | ||
94 | - 'list' => $resList, | ||
95 | - ]; | ||
96 | - } | ||
97 | -} |
trunk/Message/Apicp/Controller/Operate/NewsSearchController.class.php deleted
100644 → 0
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: tangxingguo | ||
5 | - * Date: 2017/4/11 | ||
6 | - * Time: 18:36 | ||
7 | - */ | ||
8 | -namespace Apicp\Controller\Operate; | ||
9 | - | ||
10 | -use Com\PackageValidate; | ||
11 | -use Common\Common\Constant; | ||
12 | -use Common\Service\ArticleService; | ||
13 | -use Common\Service\ClassService; | ||
14 | - | ||
15 | -class NewsSearchController extends \Apicp\Controller\AbstractController | ||
16 | -{ | ||
17 | - /** | ||
18 | - * Banner 搜索新闻接口 | ||
19 | - * @desc 用于 Banner 选择器的新闻搜索接口 | ||
20 | - * @param string kw:false 待搜索的关键词,为空则返回全部 | ||
21 | - * @param integer categoryId:false 分类筛选 | ||
22 | - * @param integer limit:false:15 每页显示的数据条数 | ||
23 | - * @param integer page:false:1 当前请求的页码 | ||
24 | - * @return array( | ||
25 | - array( | ||
26 | - 'limit' => 20, // 每页显示的数据条数 | ||
27 | - 'page' => 1, // 当前请求的页码 | ||
28 | - 'total' => 20, // 数据总数 | ||
29 | - 'pages' => 1, // 页码总数 | ||
30 | - 'categoryId' => 1, // 当前请求的分类 ID | ||
31 | - 'list' => array( | ||
32 | - 'id' => '新闻 ID', // 新闻ID | ||
33 | - 'subject' => '新闻标题', // 新闻标题 | ||
34 | - 'time' => '发表时间', // 发表时间 | ||
35 | - 'categoryName' => '所属分类名称', // 分类名称 | ||
36 | - 'categoryId' => '所属分类 ID', // 分类ID | ||
37 | - 'author' => '作者名称', // 作者名称 | ||
38 | - ) | ||
39 | - ); | ||
40 | - */ | ||
41 | - public function Index_post() | ||
42 | - { | ||
43 | - // 验证规则 | ||
44 | - $rules = [ | ||
45 | - 'kw' => 'max:120', | ||
46 | - 'categoryId' => 'integer', | ||
47 | - 'limit' => 'integer', | ||
48 | - 'page' => 'integer', | ||
49 | - ]; | ||
50 | - | ||
51 | - // 验证数据 | ||
52 | - $validate = new PackageValidate($rules, [], array_keys($rules)); | ||
53 | - $postData = $validate->postData; | ||
54 | - | ||
55 | - // 默认值 | ||
56 | - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; | ||
57 | - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; | ||
58 | - | ||
59 | - // 组合条件 | ||
60 | - $conds = ['news_status' => Constant::NEWS_STATUS_SEND]; | ||
61 | - if (isset($postData['categoryId'])) { | ||
62 | - $conds['class_id'] = $postData['categoryId']; | ||
63 | - } | ||
64 | - if (isset($postData['kw'])) { | ||
65 | - $conds['title like ?'] = '%' . $postData['kw'] . '%'; | ||
66 | - } | ||
67 | - | ||
68 | - // 分页 | ||
69 | - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); | ||
70 | - | ||
71 | - // 排序 | ||
72 | - $order_option = ['top_time' => 'desc', 'send_time' => 'desc']; | ||
73 | - | ||
74 | - // 列表 | ||
75 | - $articleServ = new ArticleService(); | ||
76 | - $list = $articleServ->list_by_conds($conds, [$start, $perpage], $order_option); | ||
77 | - $resList = []; | ||
78 | - if (!empty($list)) { | ||
79 | - // 取分类 | ||
80 | - $classServ = new ClassService(); | ||
81 | - $classList = $classServ->list_all(); | ||
82 | - if (!empty($classList)) { | ||
83 | - $classList = array_combine_by_key($classList, 'class_id'); | ||
84 | - } | ||
85 | - | ||
86 | - // 格式化数据 | ||
87 | - foreach ($list as $v) { | ||
88 | - $resList[] = [ | ||
89 | - 'id' => $v['article_id'], | ||
90 | - 'subject' => $v['title'], | ||
91 | - 'time' => $v['send_time'], | ||
92 | - 'categoryName' => $v['class_name'], | ||
93 | - 'categoryId' => $v['class_id'], | ||
94 | - 'author' => $v['author'], | ||
95 | - 'attachId' => $v['cover_id'], | ||
96 | - 'url' => 'News/Frontend/Index/Detail/Index?article_id=' . $v['article_id'], | ||
97 | - 'category' => isset($classList) ? $this->_getCategory($v['class_id'], $classList) : [], | ||
98 | - ]; | ||
99 | - } | ||
100 | - } | ||
101 | - | ||
102 | - // 数据总数 | ||
103 | - $total = $articleServ->count_by_conds($conds); | ||
104 | - | ||
105 | - $this->_result = [ | ||
106 | - 'limit' => $postData['limit'], | ||
107 | - 'page' => $postData['page'], | ||
108 | - 'total' => intval($total), | ||
109 | - 'pages' => ceil($total/$postData['limit']), | ||
110 | - 'categoryId' => isset($postData['categoryId']) ? $postData['categoryId'] : 0, | ||
111 | - 'list' => $resList, | ||
112 | - ]; | ||
113 | - } | ||
114 | - | ||
115 | - /** | ||
116 | - * @desc 根据分类ID取出当前分类以及父级分类信息 | ||
117 | - * @author tangxingguo | ||
118 | - * @param int $classId 分类ID | ||
119 | - * @param array $classList 分类列表 | ||
120 | - * @return array | ||
121 | - */ | ||
122 | - private function _getCategory($classId, $classList) | ||
123 | - { | ||
124 | - $category = []; | ||
125 | - while (isset($classList[$classId]) && $classId != 0) { | ||
126 | - $category[] = [ | ||
127 | - 'id' => $classId, | ||
128 | - 'name' => $classList[$classId]['class_name'], | ||
129 | - 'upId' => $classList[$classId]['parent_id'], | ||
130 | - 'url' => $classList[$classId]['parent_id'] == 0 ? frontUrl('/app/page/news/list/list', ['class_id' => $classId]) : '', | ||
131 | - ]; | ||
132 | - $classId = $classList[$classId]['parent_id']; | ||
133 | - } | ||
134 | - return $category; | ||
135 | - } | ||
136 | -} |
trunk/Message/Common/Model/AttachmentModel.class.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Dell | ||
5 | + * Date: 2018/9/5 | ||
6 | + * Time: 9:47 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace Common\Model; | ||
10 | + | ||
11 | +use Common\Common\Constant; | ||
12 | + | ||
13 | +class AttachmentModel extends AbstractModel | ||
14 | +{ | ||
15 | + /** | ||
16 | + * 构造方法 | ||
17 | + * AttachmentModel constructor. | ||
18 | + */ | ||
19 | + public function __construct() | ||
20 | + { | ||
21 | + parent::__construct(); | ||
22 | + } | ||
23 | +} |
trunk/Message/Common/Model/MessagesModel.class.php
@@ -13,9 +13,13 @@ use Common\Common\Constant; | @@ -13,9 +13,13 @@ use Common\Common\Constant; | ||
13 | class MessagesModel extends AbstractModel | 13 | class MessagesModel extends AbstractModel |
14 | { | 14 | { |
15 | 15 | ||
16 | - // 构造方法 | 16 | + /** |
17 | + * 构造方法 | ||
18 | + * MessagesModel constructor. | ||
19 | + */ | ||
17 | public function __construct() | 20 | public function __construct() |
18 | { | 21 | { |
22 | + $this->prefield = 'm_'; | ||
19 | parent::__construct(); | 23 | parent::__construct(); |
20 | } | 24 | } |
21 | 25 |
trunk/Message/Common/Sql/structure.php
@@ -26,6 +26,7 @@ m_imgs VARCHAR(1000) DEFAULT '' COMMENT '图片路径', | @@ -26,6 +26,7 @@ m_imgs VARCHAR(1000) DEFAULT '' COMMENT '图片路径', | ||
26 | m_ip varchar(20) DEFAULT '' COMMENT '留言IP', | 26 | m_ip varchar(20) DEFAULT '' COMMENT '留言IP', |
27 | m_status TINYINT UNSIGNED DEFAULT 1 COMMENT '1:未审核 2:已审核 3:已删除', | 27 | m_status TINYINT UNSIGNED DEFAULT 1 COMMENT '1:未审核 2:已审核 3:已删除', |
28 | m_uid INT UNSIGNED NOT NULL COMMENT '用户ID', | 28 | m_uid INT UNSIGNED NOT NULL COMMENT '用户ID', |
29 | +m_domain VARCHAR(100) NULL DEFAULT '' COMMENT '企业标识', | ||
29 | ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '留言时间', | 30 | ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '留言时间', |
30 | upd_date TIMESTAMP NULL COMMENT '修改/删除时间', | 31 | upd_date TIMESTAMP NULL COMMENT '修改/删除时间', |
31 | PRIMARY KEY (`m_id`), | 32 | PRIMARY KEY (`m_id`), |
@@ -35,12 +36,12 @@ FOREIGN KEY(`m_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE C | @@ -35,12 +36,12 @@ FOREIGN KEY(`m_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE C | ||
35 | CREATE TABLE IF NOT EXISTS luoyanshou_attachment( | 36 | CREATE TABLE IF NOT EXISTS luoyanshou_attachment( |
36 | a_mid INT UNSIGNED NOT NULL COMMENT '留言ID', | 37 | a_mid INT UNSIGNED NOT NULL COMMENT '留言ID', |
37 | a_path VARCHAR(200) DEFAULT '' COMMENT '附件路径', | 38 | a_path VARCHAR(200) DEFAULT '' COMMENT '附件路径', |
38 | -a_status TINYINT UNSIGNED COMMENT '0:未删除 1:已删除', | 39 | +a_status TINYINT UNSIGNED DEFAULT 0 COMMENT '0:未删除 1:已删除', |
39 | ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '上传时间', | 40 | ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '上传时间', |
40 | upd_date TIMESTAMP NULL COMMENT '修改/删除时间', | 41 | upd_date TIMESTAMP NULL COMMENT '修改/删除时间', |
41 | PRIMARY KEY(`a_mid`,`a_path`), | 42 | PRIMARY KEY(`a_mid`,`a_path`), |
42 | FOREIGN KEY(`a_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE | 43 | FOREIGN KEY(`a_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE |
43 | -)ENGINE=INNODB DEFAULT charset=utf8 | 44 | +)ENGINE=INNODB DEFAULT charset=utf8; |
44 | 45 | ||
45 | CREATE TABLE IF NOT EXISTS luoyanshou_comment( | 46 | CREATE TABLE IF NOT EXISTS luoyanshou_comment( |
46 | c_uid INT UNSIGNED NOT NULL COMMENT '评论用户ID', | 47 | c_uid INT UNSIGNED NOT NULL COMMENT '评论用户ID', |
@@ -50,7 +51,7 @@ ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '评论时间', | @@ -50,7 +51,7 @@ ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '评论时间', | ||
50 | upd_date TIMESTAMP NULL COMMENT '修改时间', | 51 | upd_date TIMESTAMP NULL COMMENT '修改时间', |
51 | FOREIGN KEY(`c_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE CASCADE, | 52 | FOREIGN KEY(`c_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE CASCADE, |
52 | FOREIGN KEY(`c_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE | 53 | FOREIGN KEY(`c_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE |
53 | -)ENGINE=INNODB DEFAULT charset=utf8 | 54 | +)ENGINE=INNODB DEFAULT charset=utf8; |
54 | 55 | ||
55 | 56 | ||
56 | 57 |