From 9011d217f8d95f36b37be7e4657d1ced3172ea02 Mon Sep 17 00:00:00 2001 From: shoushou <luoyanshou@vchangyi.com> Date: Wed, 5 Sep 2018 14:31:32 +0800 Subject: [PATCH] 【留言板】手机端获取留言列表实现 --- trunk/Message/Api/Controller/Message/MessInputController.class.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++++--------------------- trunk/Message/Api/Controller/Message/MessListController.class.php | 9 ++++++--- trunk/Message/Apicp/Controller/Message/MessAuditController.class.php | 23 +++++++++++++++++++++++ trunk/Message/Apicp/Controller/Message/MessDelController.class.php | 25 +++++++++++++++++++++++++ trunk/Message/Apicp/Controller/Message/MessDetailController.class.php | 25 +++++++++++++++++++++++++ trunk/Message/Apicp/Controller/Message/MessListController.class.php | 25 +++++++++++++++++++++++++ trunk/Message/Apicp/Controller/News/CommentController.class.php | 48 ------------------------------------------------ trunk/Message/Apicp/Controller/News/CompanyQrcodeController.class.php | 28 ---------------------------- trunk/Message/Apicp/Controller/News/DeleteController.class.php | 105 --------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/ExportLikeListController.class.php | 104 -------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/ExportReadListController.class.php | 182 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/InfoController.class.php | 160 ---------------------------------------------------------------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/LikeListController.class.php | 76 ---------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/ListController.class.php | 127 ------------------------------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/ReadListController.class.php | 250 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/ReleaseController.class.php | 69 --------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/RemindController.class.php | 69 --------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/SaveController.class.php | 478 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/News/TopController.class.php | 50 -------------------------------------------------- trunk/Message/Apicp/Controller/News/UpdateUnreadController.class.php | 61 ------------------------------------------------------------- trunk/Message/Apicp/Controller/News/VideoInfoController.class.php | 45 --------------------------------------------- trunk/Message/Apicp/Controller/NewsClass/DeleteController.class.php | 58 ---------------------------------------------------------- trunk/Message/Apicp/Controller/NewsClass/InfoController.class.php | 99 --------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/NewsClass/ListController.class.php | 110 -------------------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/NewsClass/OpenController.class.php | 38 -------------------------------------- trunk/Message/Apicp/Controller/NewsClass/SaveController.class.php | 83 ----------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/NewsClass/UpdateOrderController.class.php | 48 ------------------------------------------------ trunk/Message/Apicp/Controller/Operate/ClassListController.class.php | 45 --------------------------------------------- trunk/Message/Apicp/Controller/Operate/IconApiController.class.php | 55 ------------------------------------------------------- trunk/Message/Apicp/Controller/Operate/NewsListController.class.php | 97 ------------------------------------------------------------------------------------------------- trunk/Message/Apicp/Controller/Operate/NewsSearchController.class.php | 136 ---------------------------------------------------------------------------------------------------------------------------------------- trunk/Message/Common/Model/AttachmentModel.class.php | 23 +++++++++++++++++++++++ trunk/Message/Common/Model/MessagesModel.class.php | 6 +++++- trunk/Message/Common/Sql/structure.php | 7 ++++--- 34 files changed, 185 insertions(+), 2649 deletions(-) create mode 100644 trunk/Message/Apicp/Controller/Message/MessAuditController.class.php create mode 100644 trunk/Message/Apicp/Controller/Message/MessDelController.class.php create mode 100644 trunk/Message/Apicp/Controller/Message/MessDetailController.class.php create mode 100644 trunk/Message/Apicp/Controller/Message/MessListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/CommentController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/CompanyQrcodeController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/DeleteController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/ExportLikeListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/ExportReadListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/InfoController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/LikeListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/ListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/ReadListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/ReleaseController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/RemindController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/SaveController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/TopController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/UpdateUnreadController.class.php delete mode 100644 trunk/Message/Apicp/Controller/News/VideoInfoController.class.php delete mode 100644 trunk/Message/Apicp/Controller/NewsClass/DeleteController.class.php delete mode 100644 trunk/Message/Apicp/Controller/NewsClass/InfoController.class.php delete mode 100644 trunk/Message/Apicp/Controller/NewsClass/ListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/NewsClass/OpenController.class.php delete mode 100644 trunk/Message/Apicp/Controller/NewsClass/SaveController.class.php delete mode 100644 trunk/Message/Apicp/Controller/NewsClass/UpdateOrderController.class.php delete mode 100644 trunk/Message/Apicp/Controller/Operate/ClassListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/Operate/IconApiController.class.php delete mode 100644 trunk/Message/Apicp/Controller/Operate/NewsListController.class.php delete mode 100644 trunk/Message/Apicp/Controller/Operate/NewsSearchController.class.php create mode 100644 trunk/Message/Common/Model/AttachmentModel.class.php diff --git a/trunk/Message/Api/Controller/Message/MessInputController.class.php b/trunk/Message/Api/Controller/Message/MessInputController.class.php index f016e17..4314f18 100644 --- a/trunk/Message/Api/Controller/Message/MessInputController.class.php +++ b/trunk/Message/Api/Controller/Message/MessInputController.class.php @@ -9,35 +9,63 @@ namespace Api\Controller\Message; use Common\Model\MessagesModel; +use Common\Model\AttachmentModel; class MessInputController extends \Api\Controller\AbstractController { - /** - * 是否需要登录 - * - * @var bool - */ + // 禁止系统自动登录 protected $_require_login = false; - + /** + * 发表留言 + */ public function Index_post() { - session_start(); - - $data = $this->checkFields( I('post.') ); - - if( !$data ){ + $data = $this->checkFields(I('post.')); + if (!$data) { $this->_result = "数据验证失败"; die; } $messagesModel = new MessagesModel(); - $messagesModel->m_uid = $_SESSION['userid']; - $messagesModel->m_title = $data['title']; - $messagesModel->m_content = $data['message']; - $messagesModel->m_ip = $_SERVER['REMOTE_ADDR']; + $data['m_uid'] = $_SESSION['userid']; + $data['m_title'] = $data['title']; + $data['m_content'] = $data['message']; + $data['m_ip'] = $_SERVER['REMOTE_ADDR']; + + /* + * 上传图片 取得图片路径 $path_img + * $data['m_imgs'] = $path_img; + * + */ + if ($_FILES['myImg']) { + // coding... + } + + $mid = $messagesModel->insert($data); + var_dump($mid); + die; + + if (($mid = $messagesModel->insert($data)) != null && $_FILES['myFile']) { + // 留言成功后开始上传附件 + $attachmentModel = new AttachmentModel(); + unset($data); + $data['a_mid'] = $mid; + + /** + * 附件上传实现 取得附件路径 $path_att + * $data['a_path'] = $path_att; + */ + if (($aid = $attachmentModel->insert($data)) != null) { + $this->_result = "留言成功,上传附件成功。"; + }else{ + // 上传附件失败后 进行相应的处理 + $this->_result = "上传附件失败。"; + } + + } //$this->_result = "您已留言成功,请等待审核。"; @@ -54,19 +82,19 @@ class MessInputController extends \Api\Controller\AbstractController $parrent = "/\ |\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\\' | \`|\-|\=|\\\|\|/"; $data = []; - if( empty($postData['title']) || strlen($postData['title'])>80 ){ + if (empty($postData['title']) || strlen($postData['title'])>80) { $this->_result = "标题不能为空且标题长度必须小于80。"; return false; - }else{ - $data['title'] = preg_replace( $parrent, "", $postData['title']); + } else { + $data['title'] = preg_replace($parrent, "", $postData['title']); } - if( empty($postData['message']) || strlen($postData['message'])>500 ){ + if (empty($postData['message']) || strlen($postData['message'])>500) { $this->_result = "留言内容不能为空且长度必须小于500。"; return false; - }else{ - $data['message'] = preg_replace( $parrent, "", $postData['message'] ); + } else { + $data['message'] = preg_replace($parrent, "", $postData['message']); } return $data; diff --git a/trunk/Message/Api/Controller/Message/MessListController.class.php b/trunk/Message/Api/Controller/Message/MessListController.class.php index 49a0e58..6e2d8fc 100644 --- a/trunk/Message/Api/Controller/Message/MessListController.class.php +++ b/trunk/Message/Api/Controller/Message/MessListController.class.php @@ -8,6 +8,7 @@ namespace Api\Controller\Message; +use Common\Model\MessagesModel; class MessListController extends \Api\Controller\AbstractController { @@ -15,11 +16,13 @@ class MessListController extends \Api\Controller\AbstractController protected $_require_login = false; /** - * 构造方法 + * 获取留言列表 */ - public function getList_post() + public function getList_get() { - $this->_result = '留言列表'; + $messagesModel = new MessagesModel(); + + $this->_result = $messagesModel->list_all_without_domain([intval(I('get.page'))*10,10]); } } diff --git a/trunk/Message/Apicp/Controller/Message/MessAuditController.class.php b/trunk/Message/Apicp/Controller/Message/MessAuditController.class.php new file mode 100644 index 0000000..5d336be --- /dev/null +++ b/trunk/Message/Apicp/Controller/Message/MessAuditController.class.php @@ -0,0 +1,23 @@ +<?php +/** + * Created by PhpStorm. + * User: Dell + * Date: 2018/9/5 + * Time: 14:22 + */ + +namespace Apicp\Controller\Message; + +use Common\Model\MessagesModel; + +/** + * 留言审核 + * Class MessAuditController + * @package Apicp\Controller\Message + */ +class MessAuditController extends \Apicp\Controller\AbstractController +{ + public function Audit_post(){ + + } +} diff --git a/trunk/Message/Apicp/Controller/Message/MessDelController.class.php b/trunk/Message/Apicp/Controller/Message/MessDelController.class.php new file mode 100644 index 0000000..1e7c522 --- /dev/null +++ b/trunk/Message/Apicp/Controller/Message/MessDelController.class.php @@ -0,0 +1,25 @@ +<?php +/** + * Created by PhpStorm. + * User: Dell + * Date: 2018/9/5 + * Time: 14:25 + */ + +namespace Apicp\Controller\Message; + +use Common\Model\MessagesModel; +use Common\Model\AttachmentModel; + +/** + * 删除留言 + * Class MessDelController + * @package Apicp\Controller\Message + */ +class MessDelController extends \Apicp\Controller\AbstractController +{ + public function Del_post() + { + + } +} diff --git a/trunk/Message/Apicp/Controller/Message/MessDetailController.class.php b/trunk/Message/Apicp/Controller/Message/MessDetailController.class.php new file mode 100644 index 0000000..3d306d3 --- /dev/null +++ b/trunk/Message/Apicp/Controller/Message/MessDetailController.class.php @@ -0,0 +1,25 @@ +<?php +/** + * Created by PhpStorm. + * User: Dell + * Date: 2018/9/5 + * Time: 14:28 + */ + +namespace Apicp\Controller\Message; + +use Common\Model\MessagesModel; +use Common\Model\AttachmentModel; + +/** + * 获取留言详情 + * Class MessDetailController + * @package Apicp\Controller\Message + */ +class MessDetailController extends \Apicp\Controller\AbstractController +{ + public function getDetail() + { + + } +} diff --git a/trunk/Message/Apicp/Controller/Message/MessListController.class.php b/trunk/Message/Apicp/Controller/Message/MessListController.class.php new file mode 100644 index 0000000..078bfdc --- /dev/null +++ b/trunk/Message/Apicp/Controller/Message/MessListController.class.php @@ -0,0 +1,25 @@ +<?php +/** + * Created by PhpStorm. + * User: Dell + * Date: 2018/9/5 + * Time: 14:15 + */ + +namespace Apicp\Controller\Message; + +use Common\Model\MessagesModel; + +/** + * 获取留言列表 + * Class MessListController + * @package Apicp\Controller\Message + */ +class MessListController extends \Apicp\Controller\AbstractController +{ + public function getList() + { + $messagesModel = new MessagesModel(); + $this->_result = $messagesModel->list_all([intval(I('get.page')*10),10]); + } +} diff --git a/trunk/Message/Apicp/Controller/News/CommentController.class.php b/trunk/Message/Apicp/Controller/News/CommentController.class.php deleted file mode 100644 index cc80a4c..0000000 --- a/trunk/Message/Apicp/Controller/News/CommentController.class.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -namespace Apicp\Controller\News; - -use Common\Common\Comment; -use Common\Service\ArticleService; - -class CommentController extends \Apicp\Controller\AbstractController -{ - - /** - - * DeleteComment - * - * @author tangxingguo - - * @desc 删除新闻 - - * @param int data_id:true 数据标识 - - * @return null - - */ - public function Index_post() - { - $data_id = I('post.data_id', 0, 'trim'); - - // 数据标识不能为空 - if (empty($data_id)) { - E('_ERR_ARTICLE_DATA_ID_NOT_FOUND'); - } - - $articleServ = new ArticleService(); - $article = $articleServ->get_by_conds(['data_id' => $data_id]); - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - // UC获取当前评论总数 - $commentServ = &Comment::instance(); - $commentList = $commentServ->listAll(['cmtObjid' => $data_id]); - - // 修改课程主表数据 - if (isset($commentList['cmttlNums'])) { - $total = $commentList['cmttlNums']; - $articleServ->update_by_conds(['data_id' => $data_id], ['comment_total' => $total]); - } - } -} diff --git a/trunk/Message/Apicp/Controller/News/CompanyQrcodeController.class.php b/trunk/Message/Apicp/Controller/News/CompanyQrcodeController.class.php deleted file mode 100644 index f3c9b39..0000000 --- a/trunk/Message/Apicp/Controller/News/CompanyQrcodeController.class.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * 获取公司二维码 - * User: wangjiayu - * Date: 2017-12-28 - */ -namespace Apicp\Controller\News; - -use Common\Common\CompanyQrcode; - -class CompanyQrcodeController extends \Apicp\Controller\AbstractController -{ - - // 免登录 - protected $_require_login = false; - - public function Index() - { - // 实例化类 - $CompanyQrcode = &CompanyQrcode::instance(); - - // 获取二维码 - $qr_code = $CompanyQrcode->showCompanyQrcode(); - - // 返回二维码 - $this->_result = $qr_code; - } -} diff --git a/trunk/Message/Apicp/Controller/News/DeleteController.class.php b/trunk/Message/Apicp/Controller/News/DeleteController.class.php deleted file mode 100644 index 535b396..0000000 --- a/trunk/Message/Apicp/Controller/News/DeleteController.class.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 18:24 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Common\AttachOperation; -use Common\Common\DataCenter; -use Common\Common\Constant; -use Common\Common\RpcFavoriteHelper; -use Common\Service\ArticleService; -use Common\Service\TaskService; -use Common\Service\AttachService; -use VcySDK\Service; -use VcySDK\Cron; - -class DeleteController extends \Apicp\Controller\AbstractController -{ - /** - * Delete - * @author zhonglei - * @desc 删除新闻 - * @param Array article_ids:true 新闻ID数组 - * @return mixed - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_ids' => 'require|array', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - $article_ids = $postData['article_ids']; - - $artServ = new ArticleService(); - $list = $artServ->list_by_conds(['article_id' => $article_ids]); - - if (empty($list)) { - return true; - } - - // 删除首页推送 - foreach ($article_ids as $article_id) { - $artServ->delNewsRpc($article_id); - } - - // 删除新闻 - $artServ->delete_by_conds(['article_id' => $article_ids]); - - // 删除新闻附件 - $attachServ = new AttachService(); - - // 从UC附件服务器删除 - $attach_serv = new AttachOperation(); - $attach_serv->delete_attach( - APP_DIR, - 'article', - $article_ids - ); - - // 删除业务数据库附件 - $attachServ->delete_by_conds(['article_id' => $article_ids]); - - // 删除应用数据时,RPC同步收藏状态 - $rpcFavorite = &RpcFavoriteHelper::instance(); - $rpcFavorite->updateStatus($postData['article_ids']); - - // 数据中心删除点赞埋点 - $dataCenter = &DataCenter::instance(); - $dataCenter->delLike($article_ids); - // 数据中心删除点赞埋点 - - // 数据中心删除评论埋点 - $dataCenter->delComment($article_ids); - // 数据中心删除评论埋点 - - // 数据中心删除点击量埋点 - $dataCenter->delClick($article_ids); - // 数据中心删除点击量埋点 - - $taskServ = new TaskService(); - $task_list = $taskServ->list_by_conds(['article_id' => $article_ids]); - - if (empty($task_list)) { - return true; - } - - $cron_ids = array_filter(array_column($task_list, 'cron_id')); - $cronSdk = new Cron(Service::instance()); - - // 删除计划任务 - foreach ($cron_ids as $cron_id) { - $cronSdk->delete($cron_id); - } - - return true; - } -} diff --git a/trunk/Message/Apicp/Controller/News/ExportLikeListController.class.php b/trunk/Message/Apicp/Controller/News/ExportLikeListController.class.php deleted file mode 100644 index d4bff3b..0000000 --- a/trunk/Message/Apicp/Controller/News/ExportLikeListController.class.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 18/7/6 - * Time: 10:53 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Com\PythonExcel; -use Common\Common\ExportDownload; -use Common\Common\NewsHelper; -use Common\Common\User; -use Common\Service\LikeService; -use Common\Service\ArticleService; - -class ExportLikeListController extends \Apicp\Controller\AbstractController -{ - /** - * LikeList - * @desc 导出点赞列表 - * @param int article_id:true 新闻ID - * @return mixed - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_id' => 'require|integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 取新闻信息 - $articleServ = new ArticleService(); - $article = $articleServ->get($postData['article_id']); - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - // 点赞列表 - $likeServ = new LikeService(); - $likeList = $likeServ->list_by_conds(['article_id' => $postData['article_id']]); - - if ($likeList) { - // UC人员信息 - $uids = array_column($likeList, 'uid'); - $userServ = &User::instance(); - $userList = $userServ->listAll(['memUids' => $uids]); - $userList = array_combine_by_key($userList, 'memUid'); - - // Excel文件名前缀 - $titleSuffix = '_点赞人员'; - - // Excel列名 - $columns = ['姓名', '组织', '岗位', '角色', '手机号']; - - // Excel行数据 - $rows = []; - if ($userList) { - $newsHelper = &NewsHelper::instance(); - - foreach ($likeList as $k => $v) { - $uid = $v['uid']; - if (isset($userList[$uid])) { - $user = $userList[$uid]; - - $rows[] = [ - $user['memUsername'], - $newsHelper->getDpPath($user), - $user['memJob'], - $user['memRole'], - $user['memMobile'], - ]; - } - } - } - - $title = $article['title'] . $titleSuffix . rgmdate(MILLI_TIME, '_ymdHis'); - $filename = ExportDownload::get_down_dir($this->_login->user['eaId']) . $title . '.xls'; - $result = PythonExcel::instance()->write($filename, $columns, $rows); - - if ($result === true) { - // 写入数据到下载中心 - $conditon = [ - 'title' => $title, - 'ea_id' => $this->_login->user['eaId'], - 'type' => ExportDownload::EXCEL_TYPE, - 'size' => filesize($filename), - 'username' => $this->_login->user['eaRealname'], - 'url' => $filename, - 'app_dir' => APP_DIR - ]; - - ExportDownload::insert_down_load($conditon); - } - } - - return true; - } -} diff --git a/trunk/Message/Apicp/Controller/News/ExportReadListController.class.php b/trunk/Message/Apicp/Controller/News/ExportReadListController.class.php deleted file mode 100644 index 3ba5f1a..0000000 --- a/trunk/Message/Apicp/Controller/News/ExportReadListController.class.php +++ /dev/null @@ -1,182 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 18/7/5 - * Time: 11:22 - */ -namespace Apicp\Controller\News; - -use Com\PythonExcel; -use Common\Common\ExportDownload; -use Common\Common\NewsHelper; -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Common\User; -use Common\Service\ArticleService; -use Common\Service\RightService; -use Common\Service\ReadService; - -class ExportReadListController extends \Apicp\Controller\AbstractController -{ - /** - * ExportReadList - * @desc 导出阅读列表 - * @param Int article_id:true 新闻ID - * @param Int read_type:true:1 阅读类型(1=未读,2=已读) - * @param String username 姓名 - * @param Array dp_ids 部门ID - * @param Array job_ids 职位ID - * @param Array role_ids 角色ID - * @return mixed - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_id' => 'require|integer', - 'read_type' => 'require|integer', - 'username' => 'max:64', - 'dp_ids' => 'array', - 'job_ids' => 'array', - 'role_ids' => 'array', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 取新闻信息 - $articleServ = new ArticleService(); - $article = $articleServ->get($postData['article_id']); - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - // UC筛选uid - $uidCond = $this->formatConds($postData); - - // 获取人员ID - $newsHelper = &NewsHelper::instance(); - list(, $uids_study, $uids_unstudy) = $newsHelper->getReadData($article['article_id'], $uidCond); - - // Excel列名 - $columns = ['姓名', '组织', '岗位', '角色', '手机号']; - - // 实例化对象 - $userServ = &User::instance(); - - $rows = []; - if ($postData['read_type'] == Constant::READ_STATUS_IS_YES) { - $titleSuffix = '_已学人员'; - $columns[] = '阅读时间'; - - // 已读人员列表 - $readConds = [ - 'uid' => $uids_study, - 'article_id' => $postData['article_id'], - ]; - $readServ = new ReadService(); - $readList = $readServ->list_by_conds($readConds); - - // 人员详情列表 - $userList = $userServ->listByUid(array_column($readList, 'uid')); - $userList = array_combine_by_key($userList, 'memUid'); - foreach ($readList as $item) { - $uid = $item['uid']; - $user = $userList[$uid]; - - // Excel行数据 - $rows[] = [ - $user['memUsername'], - $newsHelper->getDpPath($user), - $user['memJob'], - $user['memRole'], - $user['memMobile'], - rgmdate($item['created'], 'Y/m/d H:i'), - ]; - } - - } else { - $titleSuffix = '_未学人员'; - - if ($uids_unstudy) { - $userServ = &User::instance(); - $userList = $userServ->listUsersAll(['memUids' => $uids_unstudy]); - - if ($userList) { - foreach ($userList as $user) { - $rows[] = [ - $user['memUsername'], - $newsHelper->getDpPath($user), - $user['memJob'], - $user['memRole'], - $user['memMobile'], - ]; - } - } - } - } - - $title = $article['title'] . $titleSuffix . rgmdate(MILLI_TIME, '_ymdHis'); - $filename = ExportDownload::get_down_dir($this->_login->user['eaId']) . $title . '.xls'; - $result = PythonExcel::instance()->write($filename, $columns, $rows); - - if ($result === true) { - // 写入数据到下载中心 - $conditon = [ - 'title' => $title, - 'ea_id' => $this->_login->user['eaId'], - 'type' => ExportDownload::EXCEL_TYPE, - 'size' => filesize($filename), - 'username' => $this->_login->user['eaRealname'], - 'url' => $filename, - 'app_dir' => APP_DIR - ]; - - ExportDownload::insert_down_load($conditon); - } - - return true; - } - - /** - * 将搜索条件转化为用户UID - * @author tangxingguo - * @param array $postData 用户提交的数据 - * @return array|bool - */ - private function formatConds($postData) - { - $condUids = []; - - $userServ = &User::instance(); - if (isset($postData['username'])) { - // UC - $userConds = ['memUsername' => $postData['username']]; - $list = $userServ->listAll($userConds); - $condUids = array_column($list, 'memUid'); - } - - // 部门、岗位、角色搜索交集 - $right = array_intersect_key_reserved($postData, ['dp_ids', 'job_ids', 'role_ids'], true); - if (!empty($right)) { - $rightServ = new RightService(); - $rights = $rightServ->formatPostData($right); - $unitUids = $rightServ->getUidsByRight($rights); - if (!empty($condUids)) { - // 筛选已经有值,取交集 - $condUids = array_intersect($condUids, $unitUids); - } else { - $condUids = $unitUids; - } - } - - // 如果有查询 并且 结果为空 - if ((!empty($right) || !empty($postData['username'])) && empty($condUids)) { - return false; - } - - return $condUids; - } -} diff --git a/trunk/Message/Apicp/Controller/News/InfoController.class.php b/trunk/Message/Apicp/Controller/News/InfoController.class.php deleted file mode 100644 index 33fde52..0000000 --- a/trunk/Message/Apicp/Controller/News/InfoController.class.php +++ /dev/null @@ -1,160 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 17:06 - */ -namespace Apicp\Controller\News; - -use Common\Service\ArticleService; -use Common\Service\RightService; -use Common\Service\AttachService; - -class InfoController extends \Apicp\Controller\AbstractController -{ - /** - * Info - * @author liyifei - * @desc 新闻详情 - * @param int article_id:true 新闻公告ID - * @return array 新闻详情 - * array( - 'news_status' => 1, // 新闻状态(1=草稿,2=已发布,3=预发布) - 'convert_status' => 1, // 转码状态(1=转码中,2=转码成功,3=转码失败) - 'article_id' => 123, // 新闻ID - 'title' => '重大新闻', // 新闻标题 - 'cover_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 封面图片ID - 'cover_url' => 'http://qy.vchangyi.org', // 封面图片地址 - 'is_show_cover' => 1, // 是否正文显示封面图片(1=不显示,2=显示) - 'summary' => '零食增加卫龙系列', // 摘要 - 'parent_id' => 1, // 父分类ID - 'parent_name' => '一级分类', // 父分类名称 - 'class_id' => 2, // 分类ID - 'class_name' => '内部公告', // 分类名称 - 'author' => '张三', // 作者 - 'at_video' => array( // 视频附件 - array( - 'at_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 附件ID - 'at_name' => '小视频.mp4', // 附件名 - 'at_time' => '123456543000', // 音、视频类型的播放时长(单位:毫秒) - 'at_size' => 10240.12, // 附件尺寸(单位KB) - 'at_url' => 'http://qy.vchangyi.com', // 附件地址 - 'at_convert_url' => 'http://qy.vchangyi.com', // 视频转码后url - 'at_suffix' => '.xml', // 附件后缀 - 'convert_status' => 1, // 转码状态(1=转码中,2=转码成功,3=转码失败) - ), - ), - 'at_audio' => array( // 音频附件 - array( - 'at_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 附件ID - 'at_name' => '音频.mp3', // 附件名 - 'at_time' => '123456543000', // 音、视频类型的播放时长(单位:毫秒) - 'at_size' => 1024.12, // 附件尺寸(单位KB) - 'at_url' => 'http://qy.vchangyi.com', // 附件地址 - 'at_convert_url' => '', // 转码后url,音频附件为空 - 'at_suffix' => '.txt', // 附件后缀 - 'convert_status' => 2, // 转码状态(1=转码中,2=转码成功,3=转码失败) - ), - ), - 'at_file' => array( // 文件附件 - array( - 'at_id' => 'b3ddbc502e307665f346cbd6e52cc10d', // 附件ID - 'at_name' => '文档.doc', // 附件名 - 'at_size' => 123.12, // 附件大小(单位:字节) - 'at_url' => 'http://qy.vchangyi.com', // 附件地址 - 'at_convert_url' => 'http://qy.vchangyi.com', // 文件转码后url - 'at_suffix' => '.xml', // 附件后缀 - 'convert_status' => 3, // 转码状态(1=转码中,2=转码成功,3=转码失败) - ), - ), - 'right' => array( // 新闻阅读权限 - 'is_all' => 1, // 是否全公司(1=否,2=是) - 'tag_list' => array( - array( - 'tag_id' => '3CDBB2867F0000012C7F8D28432943BB', - 'tag_name' => 'liyifei001' - ), - ), - 'dp_list' => array( - array( - 'dp_id' => 'B65085507F0000017D3965FCB20CA747', - 'dp_name' => '一飞冲天' - ), - ), - 'user_list' => array( - array( - 'uid' => 'B4B3BA5B7F00000173E870DA6ADFEA2A', - 'username' => '缘来素雅', - 'face' => 'http://shp.qpic.cn/bizmp/gdZUibR6BHrmiar6pZ6pLfRyZSVaXJicn2CsvKRdI9gccXRfP2NrDvJ8A/' - ), - ) - 'job_list' => array(// 职位 - array( - 'job_id' => '62C316437F0000017AE8E6ACC7EFAC22',// 职位ID - 'job_name' => '攻城狮',// 职位名称 - ), - ), - 'role_list' => array(// 角色 - array( - 'role_id' => '62C354B97F0000017AE8E6AC4FD6F429',// 角色ID - 'role_name' => '国家元首',// 角色名称 - ), - ), - ), - 'is_download' => 1, // 附件是否支持下载(1=不支持,2=支持) - 'is_secret' => 1, // 是否保密(1=不保密,2=保密) - 'is_share' => 1, // 允许分享(1=不允许,2=允许) - 'is_notice' => 1, // 消息通知(1=不开启,2=开启) - 'is_comment' => 1, // 评论功能(1=不开启,2=开启) - 'is_like' => 1, // 点赞功能(1=不开启,2=开启) - 'is_recommend' => 1, // 首页推荐(1=不开启,2=开启) - 'content' => '语言是民族的重要特征之一', // 新闻内容 - 'strategy_setting' => 3, // 积分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) - 'strategys' => array( // 自定义策略数据(积分策略设置=2时,返回空字符串) - array( - 'action_key' => 'one_learning', // 触发行为key - 'strategy_id' => '123', // 策略ID - ), - ), - 'credit_strategy_setting' => 3, // 学分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) - 'credit_strategys' => array( // 自定义策略数据(学分策略设置=2时,返回空字符串) - array( - 'action_key' => 'one_learning', // 触发行为key - 'strategy_id' => '123', // 策略ID - ), - ), - ) - */ - public function Index_post() - { - $article_id = I('post.article_id', 0, 'intval'); - $articleServ = new ArticleService(); - $article = $articleServ->get($article_id); - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - // 格式化新闻数据 - $formatArticle = $articleServ->formatData($article); - - // 格式化附件数据 - $user = $this->_login->user; - $attachServ = new AttachService(); - $formatAttach = $attachServ->formatData($article['article_id'], $user); - - // 将格式化后的附件数据格式,从对象转为数组 - $formatAttach['at_audio'] = isset($formatAttach['at_audio']) ? array_values($formatAttach['at_audio']) : []; - $formatAttach['at_video'] = isset($formatAttach['at_video']) ? array_values($formatAttach['at_video']) : []; - $formatAttach['at_file'] = isset($formatAttach['at_file']) ? array_values($formatAttach['at_file']) : []; - - // 格式化新闻权限数据 - $rightServ = new RightService(); - $formatRight['right'] = $rightServ->getData(['article_id' => $article_id]); - - // 组合数据 - $data = array_merge($formatArticle, $formatRight, $formatAttach); - - $this->_result = $data; - } -} diff --git a/trunk/Message/Apicp/Controller/News/LikeListController.class.php b/trunk/Message/Apicp/Controller/News/LikeListController.class.php deleted file mode 100644 index 4f2f015..0000000 --- a/trunk/Message/Apicp/Controller/News/LikeListController.class.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 19:10 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Common\User; -use Common\Service\LikeService; - -class LikeListController extends \Apicp\Controller\AbstractController -{ - /** - * LikeList - * @desc 点赞列表 - * @param int article_id:true 新闻ID - * @return array 点赞列表 - * array( - 'list' => array( // 点赞列表 - 'uid' => 'B4B3BAFE7F00000173E870DA83A9751E', // 人员ID - 'username' => '张三', // 人员姓名 - 'face' => 'http://shp.qpic.cn/bizmp/gdZUibR6BHrkuqSjvCzX33qvZpCIOaYZiaFRnciae9WgxiaWXqxkqIOyeg/', // 头像 - 'created' => 1434567890000, // 点赞时间 - ), - ); - */ - - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_id' => 'require|integer', - 'page' => 'integer', - 'limit' => 'integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 点赞列表 - $likeServ = new LikeService(); - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); - $likeList = $likeServ->list_by_conds(['article_id' => $postData['article_id']], [$start, $perpage]); - $total = $likeServ->count_by_conds(['article_id' => $postData['article_id']]); - - if ($likeList) { - // 人员信息 - $uids = array_column($likeList, 'uid'); - $userServ = &User::instance(); - $userList = $userServ->listAll(['memUids' => $uids]); - $userList = array_combine_by_key($userList, 'memUid'); - - // 合并头像 - if ($userList) { - foreach ($likeList as $k => $v) { - if (isset($userList[$v['uid']])) { - $likeList[$k]['username'] = isset($userList[$v['uid']]) ? $userList[$v['uid']]['memUsername'] : ''; - $likeList[$k]['face'] = isset($userList[$v['uid']]) ? $userList[$v['uid']]['memFace'] : ''; - } - } - } - - } - - $this->_result = [ - 'list' => $likeList, - 'total' => $total, - 'page' => $postData['page'], - 'limit' => $postData['limit'] - ]; - } -} diff --git a/trunk/Message/Apicp/Controller/News/ListController.class.php b/trunk/Message/Apicp/Controller/News/ListController.class.php deleted file mode 100644 index b457b36..0000000 --- a/trunk/Message/Apicp/Controller/News/ListController.class.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 15:07 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Service\ArticleService; -use Common\Service\ClassService; - -class ListController extends \Apicp\Controller\AbstractController -{ - /** - * List - * @desc 新闻列表 - * @ahthor liyifei - * @param Int page:1 当前页(默认第一页) - * @param Int limit:20 当前页条数 - * @param string start_time 更新开始时间(毫秒级时间戳) - * @param string end_time 更新结束时间(毫秒级时间戳) - * @param string title 标题关键词 - * @param Int class_id 分类ID - * @param Int news_status 发布状态(1=草稿;2=已发布;3=预发布) - * @return array - * array( - * 'total' => 100, // 总条数 - * 'page' => 1, // 当前页 - * 'limit' => 20, // 当前页条数 - * 'list' => array( // 列表数据 - * 'article_id' => 1, // 新闻ID - * 'title' => '电商冲击,实体店靠什么赢', // 标题 - * 'class_name' => '导购FM', // 栏目 - * 'is_secret' => 1, // 是否保密(1=不保密,2=保密) - * 'read_total' => 1, // 已阅读人数 - * 'allow_read_total' => 30, // 可阅读人数 - * 'news_status' => 1, // 发布状态(1=草稿,2=已发布,3=预发布) - * 'convert_status' => 1, // 转码状态(1=转码中,2=转码成功,3=转码失败) - * 'like_total' => 12, // 点赞人数 - * 'comment_total' => 34, // 评论人数 - * 'send_time' => '1491897290000', // 最后更新时间(毫秒级时间戳) - * 'top_time' => '1491897290000', // 置顶时间(毫秒级时间戳,0为未置顶) - * 'qr_code' => 'awddwdad.awddadad?awdadwad=awdada', // 二维码链接 - * ), - * ) - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'page' => 'integer', - 'limit' => 'integer', - 'start_time' => 'integer', - 'end_time' => 'integer', - 'title' => 'max:64', - 'class_id' => 'integer', - 'news_status' => 'integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 默认值 - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; - - // 组合条件 - $conds = []; - if (isset($postData['start_time'])) { - $conds['send_time > ?'] = $postData['start_time']; - } - if (isset($postData['end_time'])) { - $conds['send_time < ?'] = $postData['end_time']; - } - if (isset($postData['title'])) { - // 查询%化需要转义 - $postData['title'] = str_replace("%", '\%', $postData['title']); - $conds['title like ?'] = '%' . $postData['title'] . '%'; - } - if (isset($postData['class_id'])) { - $classServ = new ClassService(); - $childList = $classServ->list_by_conds(['parent_id' => $postData['class_id']]); - $class_ids = array_column($childList, 'class_id'); - $class_ids[] = $postData['class_id']; - $conds['class_id in (?)'] = $class_ids; - } - if (isset($postData['news_status'])) { - if ($postData['news_status'] == Constant::NEWS_STATUS_READY_SEND) { - $conds['news_status in (?)'] = [Constant::NEWS_STATUS_READY_SEND, Constant::NEWS_STATUS_TIMING_RELEASE]; - } else { - $conds['news_status = ?'] = $postData['news_status']; - } - } - - // 分页 - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); - - // 排序 - $order_option = ['top_time' => 'desc', 'send_time' => 'desc']; - - // 列表 - $articleServ = new ArticleService(); - $list = $articleServ->list_by_conds($conds, [$start, $perpage], $order_option); - if ($list) { - // 可阅读人数 - foreach ($list as $k => $v) { - $list[$k]['allow_read_total'] = $v['read_total'] + $v['unread_total']; - // 加入二维码链接 - $list[$k]['qr_code'] = oaUrl('Frontend/Index/NewsQrcode/index', ['article_id' => $v['article_id']]); - } - } - - // 数据总数 - $total = $articleServ->count_by_conds($conds); - - $this->_result = [ - 'page' => $postData['page'], - 'limit' => $postData['limit'], - 'total' => intval($total), - 'list' => $list, - ]; - } -} diff --git a/trunk/Message/Apicp/Controller/News/ReadListController.class.php b/trunk/Message/Apicp/Controller/News/ReadListController.class.php deleted file mode 100644 index 998a7af..0000000 --- a/trunk/Message/Apicp/Controller/News/ReadListController.class.php +++ /dev/null @@ -1,250 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/13 - * Time: 11:48 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Common\User; -use Common\Service\ArticleService; -use Common\Service\ReadService; -use Common\Service\RightService; - -class ReadListController extends \Apicp\Controller\AbstractController -{ - - /** - * ReadList - * @desc 阅读列表 - * @param Int article_id:true 新闻ID - * @param Int read_type:true 阅读类型(1=未读,2=已读) - * @param Int page 页码 - * @param Int limit 每页数据条数 - * @return array 阅读列表 - * array( - 'article_id' => 123, // 新闻ID - 'read_type' => 1, // 阅读类型(1=未读,2=已读) - 'title' => '', // 新闻标题 - 'send_time' => '', // 更新时间 - 'page' => '', // 页码 - 'limit' => '', // 每页数据条数 - 'read_total' => '', // 已读总数 - 'unread_total' => '', // 未读总数 - 'list' => array( - 'username' => '张三', // 姓名 - 'dp_name' => array('技术部'), // 所属部门 - 'job' => 'PHP', // 职位 - 'mobile' => '15821392414', // 手机号码 - 'created' => '1234566898988', // 阅读时间(毫秒级时间戳) - ), - ); - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_id' => 'require|integer', - 'read_type' => 'require|integer', - 'page' => 'integer', - 'limit' => 'integer', - 'dp_ids' => 'array', - 'job_ids' => 'array', - 'role_ids' => 'array', - 'username' => 'max:64', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 默认值 - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; - // 查询条件 - $uidCond = $this->formatConds($postData); - - // 取新闻信息 - $articleServ = new ArticleService(); - $newsInfo = $articleServ->get($postData['article_id']); - if (empty($newsInfo)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - $list = []; - $total = 0; - $readServ = new ReadService(); - - $read_total = 0; - $unread_total = 0; - if ($uidCond !== false) { - // 已读 - $readConds = ['article_id' => $postData['article_id']]; - $read_total = $readServ->count_by_conds($readConds); - - if (!empty($uidCond)) { - $readConds['uid'] = $uidCond; - } - if ($postData['read_type'] == Constant::READ_STATUS_IS_YES) { - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); - $readList = $readServ->list_by_conds($readConds, [$start, $perpage]); - $userServ = &User::instance(); - $userlist = $userServ->listByUid(array_column($readList, 'uid')); - $userlist = array_combine_by_key($userlist, 'memUid'); - foreach ($readList as &$item) { - $uid = $item['uid']; - $list[] = [ - 'username' => $userlist[$uid]['memUsername'], - 'dp_name' => empty($userlist[$uid]['dpName']) ? - [] : array_column($userlist[$uid]['dpName'], 'dpName'), - 'job' => $userlist[$uid]['memJob'], - 'role' => $userlist[$uid]['memRole'], - 'mobile' => $userlist[$uid]['memMobile'], - 'created' => $item['created'] - ]; - } - - $total = $read_total; - } - - // 未读 - list($uids_all, $uids_read, $uids_unread, $unread_total) = - $this->getReadData($postData['article_id'], $uidCond); - - if ($postData['read_type'] == Constant::READ_STATUS_IS_NO) { - $total = count($uids_unread); - // 取未读人员信息 - if ($uids_unread) { - $userServ = &User::instance(); - $userList = $userServ->listByConds(['memUids' => $uids_unread], $postData['page'], $postData['limit']); - if ($userList) { - foreach ($userList['list'] as $v) { - $list[] = [ - 'uid' => $v['memUid'], - 'username' => $v['memUsername'], - 'dp_name' => empty($v['dpName']) ? [] : array_column($v['dpName'], 'dpName'), - 'job' => $v['memJob'], - 'role' => $v['memRole'], - 'mobile' => $v['memMobile'], - ]; - } - } - - } - } - } - - $this->_result = [ - 'article_id' => $postData['article_id'], - 'read_type' => $postData['read_type'], - 'limit' => $postData['limit'], - 'page' => $postData['page'], - 'title' => $newsInfo['title'], - 'send_time' => $newsInfo['send_time'], - 'read_total' => $read_total, - 'unread_total' => $unread_total, - 'total' => $total, - 'list' => $list, - ]; - } - - /** - * 将搜索条件转化为用户UID - * @author tangxingguo - * @param array $postData 用户提交的数据 - * @return array|bool - */ - private function formatConds($postData) - { - $condUids = []; - - $userServ = &User::instance(); - if (isset($postData['username'])) { - // UC - $userConds = ['memUsername' => $postData['username']]; - $list = $userServ->listAll($userConds); - $condUids = array_column($list, 'memUid'); - } - // 部门、岗位、角色搜索交集 - $right = array_intersect_key_reserved($postData, ['dp_ids', 'job_ids', 'role_ids'], true); - - // 部门/岗位存在 名字存在 - if (!empty($right) && isset($postData['username'])) { - $rightServ = new RightService(); - $rights = $rightServ->formatPostData($right); - $unitUids = $rightServ->getUidsByRight($rights); - if (!empty($condUids)) { - // 筛选已经有值,取交集 - $condUids = array_intersect($condUids, $unitUids); - } else { - //$condUids = $unitUids; - return false; - } - } - - // 部门/岗位存在 名字存在 人名不存在 - if (!empty($right) && !isset($postData['username'])) { - $rightServ = new RightService(); - $rights = $rightServ->formatPostData($right); - $unitUids = $rightServ->getUidsByRight($rights); - $condUids = $unitUids; - } - - // 如果有查询 并且 结果为空 - if ((!empty($right) || !empty($postData['username'])) && empty($condUids)) { - return false; - } - - return $condUids; - } - - /** - * 获取新闻可读、已读、未读人员ID数组 - * @author zhonglei - * @param int $article_id 新闻ID - * @return array [0 => 可读人员ID, 1 => 已读人员ID, 2 => 未读人员ID] - */ - public function getReadData($article_id, $uidCond) - { - $uids_all = []; - $uids_read = []; - $uids_unread = []; - - // 查询条件 - $conds = ['article_id' => $article_id]; - // 获取权限数据 - $rightServ = new RightService(); - $right_list = $rightServ->list_by_conds($conds); - $rights = $rightServ->formatDBData($right_list); - - if (empty($rights)) { - return [$uids_all, $uids_read, $uids_unread]; - } - - // 获取可读数据 - $uids_all = $rightServ->getUidsByRight($rights); - // 获取已读数据 - $readServ = new ReadService(); - if (!empty($uidCond)) { - $conds['uid'] = $uidCond; - } - $study_list = $readServ->list_by_conds($conds); - $uids_read = array_column($study_list, 'uid'); - $uids_unread = array_values( - array_diff( - // 如果外部传了条件 - !empty($uidCond) ? array_intersect($uids_all, $uidCond) : $uids_all, - $uids_read - ) - ); - // 已经学习人数 (跟传入条件无关) - $studyListWithOutConds = $readServ->list_by_conds(['article_id' => $article_id]); - $studyListWithOutConds = array_column($studyListWithOutConds, 'uid'); - - // 未读数据 - return [$uids_all, $uids_read, $uids_unread, count(array_diff($uids_all, $studyListWithOutConds))]; - } -} diff --git a/trunk/Message/Apicp/Controller/News/ReleaseController.class.php b/trunk/Message/Apicp/Controller/News/ReleaseController.class.php deleted file mode 100644 index 567e958..0000000 --- a/trunk/Message/Apicp/Controller/News/ReleaseController.class.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: 大熊 - * Date: 2018/5/17 - * Time: 15:05 - */ - -namespace Apicp\Controller\News; - -use Apicp\Controller\AbstractController; -use Common\Common\Constant; -use Common\Common\NewsHelper; -use Common\Service\ArticleService; -use Common\Service\ClassService; -use Think\Log; - -class ReleaseController extends AbstractController -{ - public function index_post() - { - $param = I('post.'); - - // 获取数据信息 - $service = new ArticleService(); - $data = $service->get($param['article_id']); - - // 不为定时发布时不做处理 - if ($data['news_status'] != Constant::NEWS_STATUS_TIMING_RELEASE) { - $this->_result = ['state' => true]; - return true; - } - - // 判断素材状态,若转码成功则为发布状态,否则为预发布状态 - $updateData = ['news_status' => Constant::NEWS_STATUS_SEND]; - if ($data['convert_status'] == Constant::FILE_STATUS_CONVERT) { - $updateData['news_status'] = Constant::NEWS_STATUS_READY_SEND; - } - - $service->update($param['article_id'], $updateData); - - // 当为发布时 - if ($updateData['news_status'] == Constant::NEWS_STATUS_SEND) { - try { - // 获取顶级分类名称 - $classServ = new ClassService(); - $class = $classServ->getTopClass($data['class_id']); - $data['class_name'] = $class['class_name']; - - // 发送未读提醒 - if ($data['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) { - $newsHelper = &NewsHelper::instance(); - list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($param['article_id']); - $newsHelper->sendUnreadMsg($uids_unread, $data); - } - - // RPC推送到运营中心 - if ($data['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { - $service->addNewsRpc($param['article_id'], []); - } - } catch (\Exception $e) { - Log::record('头条立即发布错误'.$e->getMessage()); - } - } - - $this->_result = ['state' => true]; - return true; - } -} \ No newline at end of file diff --git a/trunk/Message/Apicp/Controller/News/RemindController.class.php b/trunk/Message/Apicp/Controller/News/RemindController.class.php deleted file mode 100644 index cbd8795..0000000 --- a/trunk/Message/Apicp/Controller/News/RemindController.class.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 18:20 - */ - -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Common\NewsHelper; -use Common\Service\ClassService; -use Common\Service\ArticleService; - -class RemindController extends \Apicp\Controller\AbstractController -{ - /** - * Remind - * @author liyifei - * @desc 未读提醒 - * @param Int article_id:true 新闻ID - * @param array uids:false 用户UIDS集合格式(array[1,2,3]) - * @return array - */ - public function Index_post() - { - $uids = I('post.uids'); - // 验证规则 - $rules = [ - 'article_id' => 'require|integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 获取新闻详情 - $articleServ = new ArticleService(); - $article = $articleServ->get($postData['article_id']); - - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - - // 草稿和预发布不允许发送提醒 - if (in_array($article['news_status'], [Constant::NEWS_STATUS_DRAFT, Constant::NEWS_STATUS_READY_SEND])) { - E('_ERR_ARTICLE_STATUS_FAIL'); - } - - // 获取顶级分类名称 - $classServ = new ClassService(); - $class = $classServ->getTopClass($article['class_id']); - $article['class_name'] = $class['class_name']; - - // 获取未读人员列表 - $newsHelper = &NewsHelper::instance(); - list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($postData['article_id']); - - // 提醒人员UID - if (!empty($uids)) { - $uids_unread = array_intersect($uids_unread, $uids); - } - // 发送未读提醒 - $newsHelper->sendUnreadMsg($uids_unread, $article); - } -} diff --git a/trunk/Message/Apicp/Controller/News/SaveController.class.php b/trunk/Message/Apicp/Controller/News/SaveController.class.php deleted file mode 100644 index 905ef04..0000000 --- a/trunk/Message/Apicp/Controller/News/SaveController.class.php +++ /dev/null @@ -1,478 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 18:33 - */ - -namespace Apicp\Controller\News; - -use Common\Common\ArticleHelper; -use Common\Common\Attach; -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Common\NewsHelper; -use Common\Service\AttachService; -use Common\Service\ClassService; -use Common\Service\ReadService; -use Common\Service\RightService; -use Common\Service\ArticleService; -use Common\Service\TaskService; -use phpDocumentor\Reflection\Types\String_; -use VcySDK\Cron; -use VcySDK\Service; - -class SaveController extends \Apicp\Controller\AbstractController -{ - /** - * Save - * @author liyifei - * @desc 新闻保存(创建、修改) - * @param Int article_id 新闻ID - * @param String title:true 标题 - * @param Int class_id:true 分类ID - * @param String author:true 作者 - * @param String content 内容 - * @param String cover_id:true 封面图片ID - * @param String is_show_cover:true:2 是否正文显示封面图片(1=不显示,2=显示) - * @param array file_at_ids 文件附件ID数组 - * @param array audio_at_ids 音频附件ID数组 - * @param array video_at_info 视频附件详情 - * @param String video_at_info[].at_id:true 视频附件ID - * @param String video_at_info[].at_name:true 视频名称 - * @param String video_at_info[].at_size:true 视频大小(单位:字节) - * @param String video_at_info[].at_time:true 视频时长 - * @param array is_download:true:1 附件是否支持下载(1=不支持,2=支持) - * @param String summary:true 摘要(最多输入150字符) - * @param array right:true 阅读范围 - * @param Int right.is_all 是否全公司(1=否;2=是) - * @param array right.uids 人员ID - * @param array right.dp_ids 部门ID - * @param array right.tag_ids 标签ID - * @param array right.job_ids 职位ID - * @param array right.role_ids 角色ID - * @param String link 外部链接 - * @param Int is_jump 是否直接跳转外链(1=不直接跳转,2=直接跳转) - * @param Int is_secret:true:1 是否保密(1=不保密,2=保密) - * @param Int is_share:true:1 允许分享(1=不允许,2=允许) - * @param Int is_notice:true:2 消息通知(1=不开启,2=开启) - * @param Int is_comment:true:2 评论功能(1=不开启,2=开启) - * @param Int is_like:true:2 点赞功能(1=不开启,2=开启) - * @param Int is_recommend:true:2 首页推荐(1=不开启,2=开启) - * @param Int news_status:true:1 新闻状态(1=草稿与保存并预览,2=已发布) - * @param Int strategy_setting:true:2 积分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) - * @param array strategys 自定义策略数据 - * @param String strategys[].action_key 触发行为key - * @param String strategys[].strategy_id 策略ID - * @param Int credit_strategy_setting:true:2 学分策略设置(1=启用默认策略;2=不启用策略;3=自定义策略) - * @param array credit_strategys 自定义策略数据 - * @param String credit_strategys[].action_key 触发行为key - * @param String credit_strategys[].strategy_id 策略ID - * @return array 二维码链接 - * array( - * 'qr_code' => 'asdadsdasdad.asdsadasdsa?asdasdds=adasdadad', - * ) - */ - public function Index_post() - { - // 验证规则 - $rules = [ - // 非必填 - 'article_id' => 'integer', - 'summary' => 'max:120', - 'audio_at_ids' => 'array', - 'file_at_ids' => 'array', - 'video_at_info' => 'array', - 'link' => 'max:500', - 'is_jump' => 'integer|in:1,2', - 'strategys' => 'array', - 'credit_strategys' => 'array', - 'cron_time' => 'max:20', - // 必填 - 'title' => 'require|max:64', - 'class_id' => 'require|integer', - 'author' => 'require|max:20', - 'cover_id' => 'require', - 'right' => 'require|array', - 'is_show_cover' => 'require|integer|in:1,2', - 'is_download' => 'require|integer|in:1,2', - 'is_secret' => 'require|integer|in:1,2', - 'is_share' => 'require|integer|in:1,2', - 'is_notice' => 'require|integer|in:1,2', - 'is_comment' => 'require|integer|in:1,2', - 'comment_anonymous' => 'require|integer|in:1,2', - 'is_like' => 'require|integer|in:1,2', - 'is_recommend' => 'require|integer|in:1,2', - 'news_status' => 'require|integer|in:1,2,4', - 'strategy_setting' => 'require|integer|in:1,2,3', - 'credit_strategy_setting' => 'require|integer|in:1,2,3', - ]; - - // 验证请求数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 完整请求参数 - $postData['content'] = I('post.content', '', 'trim'); - $fixData = $this->_fixData($postData); - - // 格式化权限数据 - $rightServ = new RightService(); - $formatRights = $rightServ->formatPostData($postData['right']); - if (empty($formatRights)) { - - E('_ERR_ARTICLE_RIGHT_PARAM'); - } - - // 校验传参(验证器无法验证的部分) - $this->_checkData($fixData); - - // 组合写入article表的数据 - $sqlData = $this->_fixSqlData($fixData); - - // 保存新闻 - $articleServ = new ArticleService(); - if ($fixData['article_id'] == 0) { - // 创建新闻 - $articleId = $articleServ->insert($sqlData); - if (!$articleId) { - - E('_ERR_ARTICLE_SAVE_FAILED'); - } - - // 二维码的链接 - $qr_code = oaUrl('Frontend/Index/NewsQrcode/index', ['article_id' => $articleId]); - - // RPC推送到运营中心 - if ($sqlData['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { - - $articleServ->addNewsRpc($articleId, $postData['right']); - } - - } else { - // 修改前的新闻数据 - $articleOld = $articleServ->get($fixData['article_id']); - $articleId = $articleOld['article_id']; - - // 如果存在定时发布,删除定时发布 - if ($articleOld['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { - // 实例化定时任务类 - $cron_serv = new Cron(Service::instance()); - $cron_serv->delete($articleOld['release_crid']); - } - - // 二维码的链接 - $qr_code = oaUrl('Frontend/Index/NewsQrcode/index', ['article_id' => $articleId]); - - if (!in_array($fixData['news_status'], [Constant::NEWS_STATUS_DRAFT, Constant::NEWS_STATUS_READY_SEND, Constant::NEWS_STATUS_TIMING_RELEASE])) { - $this->_operationRpc($fixData['article_id'], $sqlData, $postData['right']); - } - // RPC推送到运营中心 - - - // 修改新闻 - $articleServ->update_by_conds(['article_id' => $fixData['article_id']], $sqlData); - } - - // 定时发布, 增加定时任务 - if ($sqlData['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { - $articleServ->cronAdd($articleId, $sqlData['cron_time']); - } - - // 推送未读消息(草稿、预发布除外;新建已发布新闻、草稿新闻修改为已发布新闻时,也推送消息;) - $newsHelper = &NewsHelper::instance(); - if (!in_array($sqlData['news_status'], [ - Constant::NEWS_STATUS_DRAFT, - Constant::NEWS_STATUS_READY_SEND, - Constant::NEWS_STATUS_TIMING_RELEASE - ]) && $sqlData['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) { - // 发布过就不推消息了 - if ($fixData['article_id'] == 0 || (isset($articleOld) && $articleOld['news_status'] == Constant::NEWS_STATUS_DRAFT && $sqlData['news_status'] == Constant::NEWS_STATUS_SEND)) { - // 新闻所在顶级分类信息 - $classServ = new ClassService(); - $class = $classServ->getTopClass($sqlData['class_id']); - $sqlData['class_name'] = $class['class_name']; - - $sqlData['article_id'] = $articleId; - $newsHelper->sendNotice($sqlData, $formatRights); - } - } - - // 创建计划任务(预发布新闻:视频、文件附件) 添加定时任务 - if ($sqlData['news_status'] == Constant::NEWS_STATUS_READY_SEND || $sqlData['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { - - $taskServ = new TaskService(); - $taskServ->createCheckAttachTask($articleId); - } - - // 保存阅读范围 - $rightServ->saveData(['article_id' => $articleId], $postData['right']); - - // 修改新闻未读人数 - list($uids_all, ,) = $newsHelper->getReadData($articleId); - sort($uids_all); - // 兼容多次编辑文章未读人数变化问题 - $readServ = new ReadService(); - $read_list = $readServ->list_by_conds([ - 'article_id' => $articleId, - 'uid' => $uids_all, - ]); - - // 如果存在已读取过的人员 - if (!empty($read_list)) { - // 获取已读取人员的uids - $read_uids = array_column($read_list, 'uid'); - $uids_all = array_diff($uids_all, $read_uids); - } - - $articleServ->update($articleId, ['unread_total' => count($uids_all)]); - - // 保存附件(已发布、预发布的新闻,不可修改附件) - if ($fixData['article_id'] == 0 || (isset($articleOld) && $articleOld['news_status'] == Constant::NEWS_STATUS_DRAFT)) { - - $attachServ = new AttachService(); - $attachServ->saveData($articleId, $fixData); - } - - $this->_result = ['qr_code' => $qr_code]; - } - - /** - * 补全请求数据 - * @param array $postData 请求数据 - * @return array - */ - private function _fixData($postData) - { - // 非必填参数,补全默认值 - $postData['article_id'] = isset($postData['article_id']) ? $postData['article_id'] : 0; - $postData['summary'] = isset($postData['summary']) ? $postData['summary'] : ''; - $postData['audio_at_ids'] = isset($postData['audio_at_ids']) ? $postData['audio_at_ids'] : ''; - $postData['file_at_ids'] = isset($postData['file_at_ids']) ? $postData['file_at_ids'] : []; - $postData['video_at_info'] = isset($postData['video_at_info']) ? $postData['video_at_info'] : []; - $postData['link'] = isset($postData['link']) ? $postData['link'] : ''; - $postData['is_jump'] = isset($postData['is_jump']) ? $postData['is_jump'] : Constant::NEWS_IS_JUMP_FALSE; - - return $postData; - } - - /** - * 校验传参 - * @author liyifei - * @param array $fixData 补全后的请求参数 - * @return mixed - */ - private function _checkData($fixData) - { - // 为定时发布时,定时发布时间不能为空且大于当前时间 - if ($fixData['news_status'] == Constant::NEWS_STATUS_TIMING_RELEASE) { - if (!$fixData['cron_time'] || $fixData['cron_time'] <= MILLI_TIME) { - E('_ERR_CREDIT_CRON_TIME_ERR'); - } - - } - // 文件最多上传5个 - if (isset($fixData['file_at_ids']) && count($fixData['file_at_ids']) > Constant::UPLOAD_FILE_ATTACH_LIMIT) { - - E(L('_ERR_ARTICLE_FILE_ATTACH_MORE', ['at_type' => '文件'])); - } - - // 音频最多上传5个 - if (isset($fixData['audio_at_ids']) && count($fixData['audio_at_ids']) > Constant::UPLOAD_FILE_ATTACH_LIMIT) { - - E(L('_ERR_ARTICLE_FILE_ATTACH_MORE', ['at_type' => '音频'])); - } - - // 视频最多上传5个 - if (isset($fixData['video_at_info']) && count($fixData['video_at_info']) > Constant::UPLOAD_FILE_ATTACH_LIMIT) { - - E(L('_ERR_ARTICLE_FILE_ATTACH_MORE', ['at_type' => '视频'])); - } - - // 视频附件参数不正确 - if (!empty($fixData['video_at_info'])) { - foreach ($fixData['video_at_info'] as $video) { - if (!isset($video['at_id'], $video['at_name'], $video['at_size'], $video['at_time'])) { - - E('_ERR_ARTICLE_ATTACH_PARAM'); - } - } - } - - // 保存自定义积分策略时,策略数据必传 - $allow_key = [ - 'action_key', - 'strategy_id', - ]; - if ($fixData['strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM) { - if (!isset($fixData['strategys']) || empty($fixData['strategys'])) { - E('_ERR_ARTICLE_STRATEGY_ID_EMPTY'); - } - - foreach ($fixData['strategys'] as $strategys) { - if (!is_array($strategys) || empty($strategys)) { - E('_ERR_ARTICLE_STRATEGY_PARAM_FORMAT'); - } - - $strategy_key = array_keys($strategys); - if (array_diff($allow_key, $strategy_key)) { - E('_ERR_ARTICLE_STRATEGY_PARAM_LOSE'); - } - } - } - - // 保存自定义学分策略时,策略数据必传 - if ($fixData['credit_strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM) { - if (!isset($fixData['credit_strategys']) || empty($fixData['credit_strategys'])) { - E('_ERR_CREDIT_STRATEGY_ID_EMPTY'); - } - - foreach ($fixData['credit_strategys'] as $credit_strategys) { - if (!is_array($credit_strategys) || empty($credit_strategys)) { - E('_ERR_CREDIT_STRATEGY_PARAM_FORMAT'); - } - - $strategy_key = array_keys($credit_strategys); - if (array_diff($allow_key, $strategy_key)) { - E('_ERR_CREDIT_STRATEGY_PARAM_LOSE'); - } - } - } - - return true; - } - - /** - * 补全写入article表的数据 - * @author liyifei - * @param array $fixData 补全后的请求参数 - * @return array - */ - private function _fixSqlData($fixData) - { - // 补全data_id - $articleServ = new ArticleService(); - if ($fixData['article_id'] == 0) { - - $fixData['data_id'] = $articleServ->buildDataID(); - } - - // 补全管理员信息 - $fixData['ea_id'] = $this->_login->user['eaId']; - $fixData['ea_name'] = $this->_login->user['eaRealname']; - - // 补全class_name - $classServ = new ClassService(); - $class = $classServ->get($fixData['class_id']); - if (empty($class)) { - E('_ERR_CLASS_DATA_NOT_FOUND'); - } - $fixData['class_name'] = $class['class_name']; - - // 补全summary - if (empty($fixData['summary']) && !empty($fixData['content'])) { - // 去除html格式,自动从内容中抓取54个字符 - $content = htmlspecialchars(strip_tags($fixData['content'])); - $fixData['summary'] = mb_substr($content, 0, Constant::AUTO_SUMMARY_LENGTH, 'UTF-8'); - } - - // 补全cover_url - $attachServ = &Attach::instance(); - $fixData['cover_url'] = $attachServ->getAttachUrl($fixData['cover_id']); - - // 补全send_time - $fixData['send_time'] = MILLI_TIME; - - // 补全news_status、convert_status - $fixData['convert_status'] = Constant::FILE_STATUS_NORMAL; - if ($fixData['news_status'] == Constant::NEWS_STATUS_SEND) { - if ($fixData['article_id'] == 0) { - // 新建新闻,有附件(预发布、转码中)(视频现在必须转码完成后才能提交,因此不会在保存后进行转码) - if (!empty($fixData['file_at_ids'])) { - $fixData['news_status'] = Constant::NEWS_STATUS_READY_SEND; - $fixData['convert_status'] = Constant::FILE_STATUS_CONVERT; - } - - } else { - $article = $articleServ->get($fixData['article_id']); - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - // 原草稿->现已发布,有附件(预发布、转码中)(视频现在必须转码完成后才能提交,因此不会在保存后进行转码) - if ($article['news_status'] == Constant::NEWS_STATUS_DRAFT && (!empty($fixData['file_at_ids']))) { - $fixData['news_status'] = Constant::NEWS_STATUS_READY_SEND; - $fixData['convert_status'] = Constant::FILE_STATUS_CONVERT; - } - // 原已发布->现已发布(不修改附件) - if ($article['news_status'] == Constant::NEWS_STATUS_SEND) { - $fixData['news_status'] = Constant::NEWS_STATUS_SEND; - $fixData['convert_status'] = Constant::FILE_STATUS_NORMAL; - } - } - } - - // 序列化存储积分策略数据 - if ($fixData['strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM && !empty($fixData['strategys'])) { - $strategys = []; - foreach ($fixData['strategys'] as $v) { - $action_key = $v['action_key']; - $strategys[$action_key] = $v['strategy_id']; - } - $fixData['strategys'] = serialize($strategys); - } else { - $fixData['strategys'] = ''; - } - - // 序列化存储学分策略数据 - if ($fixData['credit_strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM && !empty($fixData['credit_strategys'])) { - $strategys = []; - foreach ($fixData['credit_strategys'] as $v) { - $action_key = $v['action_key']; - $strategys[$action_key] = $v['strategy_id']; - } - $fixData['credit_strategys'] = serialize($strategys); - } else { - $fixData['credit_strategys'] = ''; - } - - // 去掉postData请求参数中,不在article主表中的字段 - $removeKeys = [ - 'article_id', - 'audio_at_ids', - 'file_at_ids', - 'video_at_info', - 'right', - ]; - foreach ($fixData as $k => $v) { - if (in_array($k, $removeKeys)) { - unset($fixData[$k]); - } - } - - return $fixData; - } - - /** - * @desc 更新数据时,数据库与提交数据对比,判断推送接口 - * @author tangxingguo - * @param int $article_id 新闻ID - * @param array $newInfo 更新的新闻数据 - * @param array $postRight 用户提交的权限数据 - */ - private function _operationRpc($article_id, $newInfo, $postRight) - { - $articleServ = new ArticleService(); - $articleDBInfo = $articleServ->get($article_id); - 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)) { - // 有推送过取消推送 或 计划任务,删除接口 - $articleServ->delNewsRpc($article_id); - } elseif ($articleDBInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_FALSE && $newInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { - // 第一次推送,添加接口 - $articleServ->addNewsRpc($article_id, $postRight); - } elseif ($articleDBInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE && $newInfo['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) { - // 有推送过,更新接口 - $articleServ->updateNewsRpc($article_id, $newInfo, $postRight); - } - } -} diff --git a/trunk/Message/Apicp/Controller/News/TopController.class.php b/trunk/Message/Apicp/Controller/News/TopController.class.php deleted file mode 100644 index df5d4c5..0000000 --- a/trunk/Message/Apicp/Controller/News/TopController.class.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 18:16 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Service\ArticleService; - -class TopController extends \Apicp\Controller\AbstractController -{ - /** - - * Top - * - * @author zhonglei - - * @desc 新闻置顶/取消置顶 - - * @param Int article_id:true 新闻ID - - * @return mixed - - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_id' => 'require|integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - $article_id = $postData['article_id']; - - $artServ = new ArticleService(); - $article = $artServ->get($article_id); - - if (empty($article)) { - E('_ERR_ARTICLE_NOT_FOUND'); - } - - $top_time = $article['top_time'] > 0 ? 0 : MILLI_TIME; - $artServ->update($article_id, ['top_time' => $top_time]); - } -} diff --git a/trunk/Message/Apicp/Controller/News/UpdateUnreadController.class.php b/trunk/Message/Apicp/Controller/News/UpdateUnreadController.class.php deleted file mode 100644 index ef5ecc0..0000000 --- a/trunk/Message/Apicp/Controller/News/UpdateUnreadController.class.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 19:12 - */ -namespace Apicp\Controller\News; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Common\NewsHelper; -use Common\Service\ArticleService; - -class UpdateUnreadController extends \Apicp\Controller\AbstractController -{ - /** - * UpdateUnread - * @author zhonglei - * @desc 更新未读总数 - * @param Array article_ids:true 新闻ID数组 - * @return mixed - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'article_ids' => 'require|array', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - $article_ids = $postData['article_ids']; - - $artServ = new ArticleService(); - $list = $artServ->list_by_conds([ - 'article_id' => $article_ids, - 'update_time < ?' => MILLI_TIME - Constant::NEWS_UNREAD_TIME, - ]); - - if (empty($list)) { - return true; - } - - $newsHelper = &NewsHelper::instance(); - - foreach ($list as $article) { - list(, $uids_read, $uids_unread) = $newsHelper->getReadData($article['article_id']); - $unread_total = count($uids_unread); - $read_total = count($uids_read); - if ($article['unread_total'] != $unread_total || $article['read_total'] != $read_total) { - $artServ->update($article['article_id'], [ - 'unread_total' => $unread_total, - 'read_total' => $read_total, - 'update_time' => MILLI_TIME, - ]); - } - } - } -} diff --git a/trunk/Message/Apicp/Controller/News/VideoInfoController.class.php b/trunk/Message/Apicp/Controller/News/VideoInfoController.class.php deleted file mode 100644 index d8b0a14..0000000 --- a/trunk/Message/Apicp/Controller/News/VideoInfoController.class.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/9/20 - * Time: 15:05 - */ -namespace Apicp\Controller\News; - -use VcySDK\Service; -use VcySDK\FileConvert; - -class VideoInfoController extends \Apicp\Controller\AbstractController -{ - /** - * VideoInfo - * @author liyifei - * @desc 视频详情 - * @param String at_id 视频附件ID - * @return array - array( - 'coverUrl' => 'http://1251064102.vod2.myqcloud.com/3f09017dvodtransgzp1251064102/a1c2a89f9031868223244026455/snapshot/1505805642_4281657565.100_0.jpg', // 封面地址(5秒内会生成) - 'sd' =>'http://1251064102.vod2.myqcloud.com/3f09017dvodtransgzp1251064102/a1c2a89f9031868223244026455/v.f20.mp4', // 标清 (如果值为空,说明腾讯云后台还在转码中) - 'default' =>'http://1251064102.vod2.myqcloud.com/8ae15ed5vodgzp1251064102/a1c2a89f9031868223244026455/f0.avi', // 原始视频 (实时,上传视频成功之后就会有) - 'url' =>'http://1251064102.vod2.myqcloud.com/3f09017dvodtransgzp1251064102/a1c2a89f9031868223244026455/v.f20.mp4', // 播放地址 (如果值为空,说明腾讯云后台还在转码中, 下次迭代会删除此参数,建议使用sd代替) - 'fileId' =>'9031868223244026455', // 视频fileId - ) - */ - public function Index() - { - $atId = I('post.at_id', '', 'trim'); - if (empty($atId)) { - E('_ERR_VIDEO_ID_IS_EMPTY'); - } - - $convertServ = new FileConvert(Service::instance()); - $videoInfo = $convertServ->getVodPlayUrl($atId); - - $videoInfo['sd'] = $videoInfo['sd'] ?? ''; - $videoInfo['hd'] = $videoInfo['hd'] ?? ''; - $videoInfo['coverUrl'] = $videoInfo['coverUrl'] ?? ''; - - $this->_result = $videoInfo; - } -} diff --git a/trunk/Message/Apicp/Controller/NewsClass/DeleteController.class.php b/trunk/Message/Apicp/Controller/NewsClass/DeleteController.class.php deleted file mode 100644 index 9a9932e..0000000 --- a/trunk/Message/Apicp/Controller/NewsClass/DeleteController.class.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 18:36 - */ -namespace Apicp\Controller\NewsClass; - -use Com\PackageValidate; -use Common\Service\ArticleService; -use Common\Service\ClassService; - -class DeleteController extends \Apicp\Controller\AbstractController -{ - /** - * Delete - * @author tangxingguo - * @desc 删除分类 - * @param int class_id:true 分类ID - * @return null - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'class_id' => 'require|integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - $classServ = new ClassService(); - $classInfo = $classServ->get($postData['class_id']); - if (empty($classInfo)) { - E('_ERR_CLASS_DATA_NOT_FOUND'); - } - - // 一级分类检查有无子分类 - if ($classInfo['parent_id'] == 0) { - $child = $classServ->get_by_conds(['parent_id' => $classInfo['class_id']]); - if ($child) { - E('_ERR_CLASS_CONTAIN_CHILD'); - } - } - - // 检查分类下有无新闻 - $articleServ = new ArticleService(); - $articleCount = $articleServ->count_by_conds(['class_id' => $postData['class_id']]); - if ($articleCount > 0) { - E('_ERR_CLASS_CONTAIN_ARTICLE'); - } - - // 删除分类 - $classServ->delete($postData['class_id']); - } -} diff --git a/trunk/Message/Apicp/Controller/NewsClass/InfoController.class.php b/trunk/Message/Apicp/Controller/NewsClass/InfoController.class.php deleted file mode 100644 index ea404fd..0000000 --- a/trunk/Message/Apicp/Controller/NewsClass/InfoController.class.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/13 - * Time: 17:02 - */ -namespace Apicp\Controller\NewsClass; - -use Com\PackageValidate; -use Common\Service\ClassService; -use Common\Service\RightService; - -class InfoController extends \Apicp\Controller\AbstractController -{ - /** - * Info - * @author tangxingguo - * @desc 分类详情 - * @param int class_id:true 分类ID - * @return array 分类信息 - array ( - 'class_id' => 2 // 当前分类ID - 'parent_id' => 1 // 这是父级分类ID(仅二级分类存在) - 'parent_name' => 分类1 // 这是父级分类名称(仅二级分类存在) - 'class_name' => 分类标题 // 这是分类标题 - 'description' => 分类描述 // 这是分类描述 - 'is_open' => 1 // 启用分类(1=禁用,2=启用)(仅二级分类存在) - 'right' => array( // 权限详情 - 'is_all' => 1, // 是否全公司(1=否,2=是) - 'tag_list' => array( // 标签信息(仅二级分类存在) - 'tag_id' => '0E19B0B47F0000012652058BA42EEEDE', // 标签ID - 'tag_name' => '吃货', // 标签名称 - ), - 'dp_list' => array( // 部门信息(仅二级分类存在) - 'dp_id' => '0E19B0B47F0000012652058BA42EEEDE', // 部门ID - 'dp_name' => '技术部', // 部门名称 - ), - 'user_list' => array( // 人员信息(仅二级分类存在) - 'uid' => '0E19B0B47F0000012652058BA42EEEDE', // 人员ID - 'username' => '张三', // 人员姓名 - 'face' => 'http://qy.vchangyi.com', // 人员姓名 - ), - 'job_list' => array( // 职位(仅二级分类存在) - array( - 'job_id' => '62C316437F0000017AE8E6ACC7EFAC22', // 职位ID - 'job_name' => '攻城狮', // 职位名称 - ), - ), - 'role_list' => array( // 角色(仅二级分类存在) - array( - 'role_id' => '62C354B97F0000017AE8E6AC4FD6F429', // 角色ID - 'role_name' => '国家元首', // 角色名称 - ), - ), - ), - ); - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'class_id' => 'require|integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - $classServ = new ClassService(); - $classInfo = $classServ->get($postData['class_id']); - if (empty($classInfo)) { - E('_ERR_CLASS_DATA_NOT_FOUND'); - } - $info = [ - 'class_id' => $classInfo['class_id'], - 'class_name' => $classInfo['class_name'], - 'description' => $classInfo['description'], - 'right' => [], - ]; - - // 二级分类 - $level = $classServ->classLevel($postData['class_id']); - if ($level == 2) { - $pInfo = $classServ->get($classInfo['parent_id']); - if ($pInfo) { - $info['parent_name'] = $pInfo['class_name']; - $info['is_open'] = $classInfo['is_open']; - } - - // 取权限 - $rightServ = new RightService(); - $right = $rightServ->getData(['class_id' => $postData['class_id']]); - $info['right'] = $right; - } - - $this->_result = $info; - } -} diff --git a/trunk/Message/Apicp/Controller/NewsClass/ListController.class.php b/trunk/Message/Apicp/Controller/NewsClass/ListController.class.php deleted file mode 100644 index 6218ddc..0000000 --- a/trunk/Message/Apicp/Controller/NewsClass/ListController.class.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 16:31 - */ -namespace Apicp\Controller\NewsClass; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Service\ClassService; - -class ListController extends \Apicp\Controller\AbstractController -{ - /** - - * List - - * @desc 分类列表 - - * @param int is_open 获取的分类启禁用类型(1=禁用,2=启用) - - * @return array - - * array( - - * 'list' => array( - - * array( - - * 'class_id' => 1, // 分类ID - - * 'class_name' => '分类1', // 分类名称 - - * 'is_open' => 1, // 启用分类(1=禁用,2=启用) - - * 'order' => 1, // 排序 - - * 'child' => array( // 子分类 - - * array( - - * 'class_id' => 2, // 分类ID - - * 'class_name' => '分类2', // 分类名称 - - * 'is_open' => 1, // 启用分类(1=禁用,2=启用) - - * 'order' => 1, // 排序 - - * ) - - * ) - - * ) - - * ) - - * ) - - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'is_open' => 'integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - $classServ = new ClassService(); - - // 排序规则 - $order_option = ['`order`' => 'asc']; - - // 取一级分类 - $classList = $classServ->list_by_conds(['parent_id' => 0], [], $order_option); - if (empty($classList)) { - return $this->_result = ['list' => []]; - } - - // 取二级分类 - if (isset($postData['is_open']) && in_array($postData['is_open'], [Constant::CLASS_IS_OPEN_FALSE, Constant::CLASS_IS_OPEN_TRUE])) { - $conds = [ - 'parent_id > ?' => 0, - 'is_open' => $postData['is_open'], - ]; - $childList = $classServ->list_by_conds($conds, [], $order_option); - } else { - $childList = $classServ->list_by_conds(['parent_id > ?' => 0], [], $order_option); - } - - - // 组合数据 - foreach ($classList as $k => $v) { - if ($childList) { - foreach ($childList as $index => $info) { - if ($v['class_id'] == $info['parent_id']) { - $classList[$k]['child'][] = $info; - unset($childList[$index]); - } - } - } - } - $this->_result = ['list' => $classList]; - } -} diff --git a/trunk/Message/Apicp/Controller/NewsClass/OpenController.class.php b/trunk/Message/Apicp/Controller/NewsClass/OpenController.class.php deleted file mode 100644 index b7baa1d..0000000 --- a/trunk/Message/Apicp/Controller/NewsClass/OpenController.class.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Apicp\Controller\NewsClass; - -use Com\PackageValidate; -use Common\Service\ClassService; - -class OpenController extends \Apicp\Controller\AbstractController -{ - /** - * class_id int 分类ID - * is_open bool 开关 1:禁用 2:启用 - * @return bool - */ - public function index() - { - // 验证规则 - $rules = [ - 'class_id' => 'require|integer', - 'is_open' => 'require|integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [ - 'class_id.require' => L('_ERR_PARAM_CAN_NOT_EMPTY', ['name' => '分类ID']), - 'is_open.require' => L('_ERR_PARAM_CAN_NOT_EMPTY', ['name' => '开启禁用']) - ], array_keys($rules)); - $postData = $validate->postData; - - // 修改 - $classServ = new ClassService(); - $classServ->update($postData['class_id'], [ - 'is_open' => $postData['is_open'] - ]); - - return true; - } -} diff --git a/trunk/Message/Apicp/Controller/NewsClass/SaveController.class.php b/trunk/Message/Apicp/Controller/NewsClass/SaveController.class.php deleted file mode 100644 index bfacc51..0000000 --- a/trunk/Message/Apicp/Controller/NewsClass/SaveController.class.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -namespace Apicp\Controller\NewsClass; - -use Com\PackageValidate; -use Common\Service\ArticleService; -use Common\Service\ClassService; - -class SaveController extends \Apicp\Controller\AbstractController -{ - /** - * Save - * @author tangxingguo - * @desc 保存分类 - * @param Int parent_id 上级分类ID(二级分类保存时必填) - * @param Int class_id 分类ID - * @param String class_name:true 分类标题 - * @param String description 分类描述 - * @return array - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'parent_id' => 'integer', - 'class_id' => 'integer', - 'class_name' => 'require|max:20', - 'description' => 'max:120', - 'is_open' => 'in:1,2', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 分类信息初始化 - $classServ = new ClassService(); - $classInfo = [ - 'class_name' => $postData['class_name'], - 'description' => isset($postData['description']) ? $postData['description'] : '', - 'is_open' => $postData['is_open'] - ]; - - // 唯一分类名检查 - if (!$classServ->uniqueName($classInfo['class_name'], $postData['class_id'])) { - E('_ERR_CLASS_NAME_REPEAT'); - } - - // 二级分类操作 - if (isset($postData['parent_id'])) { - if (!isset($postData['parent_id']) || empty($postData['parent_id'])) { - E('_ERR_CLASS_PARENT_ID_EMPTY'); - } - $classInfo['parent_id'] = $postData['parent_id']; - - // 分类名改变,修改article内分类名称 - if (isset($postData['class_id'])) { - $class = $classServ->get($postData['class_id']); - if ($class && $class['class_name'] != $postData['class_name']) { - $articleServ = new ArticleService(); - $articleServ->update_by_conds( - [ - 'class_id' => $postData['class_id']], - [ - 'class_name' => $postData['class_name'] - ] - ); - } - } - } else { - // 一级分类 默认开启 - $classInfo['is_open'] = 2; - } - - if (empty($postData['class_id'])) { - // 保存 - $postData['class_id'] = $classServ->insert($classInfo); - } else { - // 修改 - $classServ->update($postData['class_id'], $classInfo); - } - } -} diff --git a/trunk/Message/Apicp/Controller/NewsClass/UpdateOrderController.class.php b/trunk/Message/Apicp/Controller/NewsClass/UpdateOrderController.class.php deleted file mode 100644 index 29929eb..0000000 --- a/trunk/Message/Apicp/Controller/NewsClass/UpdateOrderController.class.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: liyifei2012it - * Date: 17/4/11 - * Time: 19:16 - */ -namespace Apicp\Controller\NewsClass; - -use Com\PackageValidate; -use Common\Service\ClassService; - -class UpdateOrderController extends \Apicp\Controller\AbstractController -{ - /** - * UpdateOrder - * @author tangxingguo - * @desc 分类拖动排序 - * @param int list[].class_id:true 一级分类ID - * @param int list[].child[].class_id:true 二级分类ID - * @return array - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'list' => 'require|array', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 入库 - $classServ = new ClassService(); - $order = 0; - foreach ($postData['list'] as $k => $v) { - $classServ->update($v['class_id'], ['`order`' => $order]); - $order ++; - if (isset($v['child'])) { - foreach ($v['child'] as $child) { - $classServ->update($child['class_id'], ['`order`' => $order]); - $order ++; - } - } - } - } -} diff --git a/trunk/Message/Apicp/Controller/Operate/ClassListController.class.php b/trunk/Message/Apicp/Controller/Operate/ClassListController.class.php deleted file mode 100644 index 632cbe8..0000000 --- a/trunk/Message/Apicp/Controller/Operate/ClassListController.class.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 18:36 - */ -namespace Apicp\Controller\Operate; - -use Common\Service\ClassService; - -class ClassListController extends \Apicp\Controller\AbstractController -{ - /** - * Banner 分类选择接口 - * @desc 用于首页 Banner 展示的接口 - * @return array( - * array( - * 'id' => '分类 ID', // 分类 ID - * 'name' => '分类名称', // 分类名称 - * 'upId' => '上级分类 ID,为 0 则表示顶级' // 上级分类 ID,为 0 则表示顶级 - * ), - * array() - * ) - */ - public function Index_post() - { - $classServ = new ClassService(); - $classList = $classServ->list_all(); - - // 格式化数据 - $res = []; - if (!empty($classList)) { - foreach ($classList as $k => $v) { - $res[] = [ - 'id' => $v['class_id'], - 'name' => $v['class_name'], - 'upId' => $v['parent_id'], - ]; - } - } - - $this->_result = $res; - } -} diff --git a/trunk/Message/Apicp/Controller/Operate/IconApiController.class.php b/trunk/Message/Apicp/Controller/Operate/IconApiController.class.php deleted file mode 100644 index 4ce4620..0000000 --- a/trunk/Message/Apicp/Controller/Operate/IconApiController.class.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 18:36 - */ -namespace Apicp\Controller\Operate; - -use Common\Service\ClassService; - -class IconApiController extends \Apicp\Controller\AbstractController -{ - /** - * 栏目接口 - * @desc 栏目接口 - * @return array( - * array( - * 'id' => '分类 ID', // 分类 ID - * 'name' => '分类名称', // 分类名称 - * 'url' => '分类链接,如果为空,则表明该链接不可直接访问', // 分类链接,如果为空,则表明该链接不可直接访问 - * 'upId' => '上级分类 ID,为 0 则表示顶级' // 上级分类 ID,为 0 则表示顶级 - * ), - * array() - * ) - */ - public function Index_post() - { - $classServ = new ClassService(); - $classList = $classServ->list_all(); - - // 格式化数据 - $res = [ - [ - 'id' => 0, - 'name' => '全部', - 'url' => 'News/Frontend/Index/NewsList/Index?class_id=0', - 'upId' => 0, - ] - ]; - if (!empty($classList)) { - foreach ($classList as $k => $v) { - $res[] = [ - 'id' => $v['class_id'], - 'name' => $v['class_name'], - // 只有一级分类可以直接跳转 - 'url' => $v['parent_id'] == 0 ? 'News/Frontend/Index/NewsList/Index?class_id=' . $v['class_id'] : '', - 'upId' => $v['parent_id'], - ]; - } - } - - $this->_result = $res; - } -} diff --git a/trunk/Message/Apicp/Controller/Operate/NewsListController.class.php b/trunk/Message/Apicp/Controller/Operate/NewsListController.class.php deleted file mode 100644 index a8fc354..0000000 --- a/trunk/Message/Apicp/Controller/Operate/NewsListController.class.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 18:36 - */ -namespace Apicp\Controller\Operate; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Service\ArticleService; - -class NewsListController extends \Apicp\Controller\AbstractController -{ - /** - * Banner 新闻列表接口 - * @desc 用于首页 Banner 新闻列表的接口 - * @param integer categoryId:false 要列表的分类 Id,为空则请求全部 - * @param integer limit:false:20 每页显示的数据条数 - * @param integer page:false:1 当前请求的页码 - * @return array( - array( - 'limit' => 20, // 每页显示的数据条数 - 'page' => 1, // 当前请求的页码 - 'total' => 20, // 数据总数 - 'pages' => 1, // 页码总数 - 'categoryId' => 1, // 当前请求的分类 ID - 'list' => array( - 'id' => '新闻 ID', // 新闻ID - 'subject' => '新闻标题', // 新闻标题 - 'time' => '发表时间', // 发表时间 - 'categoryName' => '所属分类名称', // 分类名称 - 'categoryId' => '所属分类 ID', // 分类ID - 'author' => '作者名称', // 作者名称 - ) - ); - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'categoryId' => 'integer', - 'limit' => 'integer', - 'page' => 'integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 默认值 - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; - - // 组合条件 - $conds = ['news_status' => Constant::NEWS_STATUS_SEND]; - if (isset($postData['categoryId'])) { - $conds['class_id'] = $postData['categoryId']; - } - - // 分页 - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); - - // 排序 - $order_option = ['top_time' => 'desc', 'send_time' => 'desc']; - - // 列表 - $articleServ = new ArticleService(); - $list = $articleServ->list_by_conds($conds, [$start, $perpage], $order_option); - $resList = []; - if (!empty($list)) { - foreach ($list as $v) { - $resList[] = [ - 'id' => $v['article_id'], - 'subject' => $v['title'], - 'time' => $v['send_time'], - 'categoryName' => $v['class_name'], - 'categoryId' => $v['class_id'], - 'author' => $v['author'], - ]; - } - } - - // 数据总数 - $total = $articleServ->count_by_conds($conds); - - $this->_result = [ - 'limit' => $postData['limit'], - 'page' => $postData['page'], - 'total' => intval($total), - 'pages' => ceil($total/$postData['limit']), - 'categoryId' => isset($postData['categoryId']) ? $postData['categoryId'] : 0, - 'list' => $resList, - ]; - } -} diff --git a/trunk/Message/Apicp/Controller/Operate/NewsSearchController.class.php b/trunk/Message/Apicp/Controller/Operate/NewsSearchController.class.php deleted file mode 100644 index 7d62caa..0000000 --- a/trunk/Message/Apicp/Controller/Operate/NewsSearchController.class.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: tangxingguo - * Date: 2017/4/11 - * Time: 18:36 - */ -namespace Apicp\Controller\Operate; - -use Com\PackageValidate; -use Common\Common\Constant; -use Common\Service\ArticleService; -use Common\Service\ClassService; - -class NewsSearchController extends \Apicp\Controller\AbstractController -{ - /** - * Banner 搜索新闻接口 - * @desc 用于 Banner 选择器的新闻搜索接口 - * @param string kw:false 待搜索的关键词,为空则返回全部 - * @param integer categoryId:false 分类筛选 - * @param integer limit:false:15 每页显示的数据条数 - * @param integer page:false:1 当前请求的页码 - * @return array( - array( - 'limit' => 20, // 每页显示的数据条数 - 'page' => 1, // 当前请求的页码 - 'total' => 20, // 数据总数 - 'pages' => 1, // 页码总数 - 'categoryId' => 1, // 当前请求的分类 ID - 'list' => array( - 'id' => '新闻 ID', // 新闻ID - 'subject' => '新闻标题', // 新闻标题 - 'time' => '发表时间', // 发表时间 - 'categoryName' => '所属分类名称', // 分类名称 - 'categoryId' => '所属分类 ID', // 分类ID - 'author' => '作者名称', // 作者名称 - ) - ); - */ - public function Index_post() - { - // 验证规则 - $rules = [ - 'kw' => 'max:120', - 'categoryId' => 'integer', - 'limit' => 'integer', - 'page' => 'integer', - ]; - - // 验证数据 - $validate = new PackageValidate($rules, [], array_keys($rules)); - $postData = $validate->postData; - - // 默认值 - $postData['page'] = isset($postData['page']) ? $postData['page'] : Constant::PAGING_DEFAULT_PAGE; - $postData['limit'] = isset($postData['limit']) ? $postData['limit'] : Constant::PAGING_DEFAULT_LIMIT; - - // 组合条件 - $conds = ['news_status' => Constant::NEWS_STATUS_SEND]; - if (isset($postData['categoryId'])) { - $conds['class_id'] = $postData['categoryId']; - } - if (isset($postData['kw'])) { - $conds['title like ?'] = '%' . $postData['kw'] . '%'; - } - - // 分页 - list($start, $perpage) = page_limit($postData['page'], $postData['limit']); - - // 排序 - $order_option = ['top_time' => 'desc', 'send_time' => 'desc']; - - // 列表 - $articleServ = new ArticleService(); - $list = $articleServ->list_by_conds($conds, [$start, $perpage], $order_option); - $resList = []; - if (!empty($list)) { - // 取分类 - $classServ = new ClassService(); - $classList = $classServ->list_all(); - if (!empty($classList)) { - $classList = array_combine_by_key($classList, 'class_id'); - } - - // 格式化数据 - foreach ($list as $v) { - $resList[] = [ - 'id' => $v['article_id'], - 'subject' => $v['title'], - 'time' => $v['send_time'], - 'categoryName' => $v['class_name'], - 'categoryId' => $v['class_id'], - 'author' => $v['author'], - 'attachId' => $v['cover_id'], - 'url' => 'News/Frontend/Index/Detail/Index?article_id=' . $v['article_id'], - 'category' => isset($classList) ? $this->_getCategory($v['class_id'], $classList) : [], - ]; - } - } - - // 数据总数 - $total = $articleServ->count_by_conds($conds); - - $this->_result = [ - 'limit' => $postData['limit'], - 'page' => $postData['page'], - 'total' => intval($total), - 'pages' => ceil($total/$postData['limit']), - 'categoryId' => isset($postData['categoryId']) ? $postData['categoryId'] : 0, - 'list' => $resList, - ]; - } - - /** - * @desc 根据分类ID取出当前分类以及父级分类信息 - * @author tangxingguo - * @param int $classId 分类ID - * @param array $classList 分类列表 - * @return array - */ - private function _getCategory($classId, $classList) - { - $category = []; - while (isset($classList[$classId]) && $classId != 0) { - $category[] = [ - 'id' => $classId, - 'name' => $classList[$classId]['class_name'], - 'upId' => $classList[$classId]['parent_id'], - 'url' => $classList[$classId]['parent_id'] == 0 ? frontUrl('/app/page/news/list/list', ['class_id' => $classId]) : '', - ]; - $classId = $classList[$classId]['parent_id']; - } - return $category; - } -} diff --git a/trunk/Message/Common/Model/AttachmentModel.class.php b/trunk/Message/Common/Model/AttachmentModel.class.php new file mode 100644 index 0000000..db1bd0c --- /dev/null +++ b/trunk/Message/Common/Model/AttachmentModel.class.php @@ -0,0 +1,23 @@ +<?php +/** + * Created by PhpStorm. + * User: Dell + * Date: 2018/9/5 + * Time: 9:47 + */ + +namespace Common\Model; + +use Common\Common\Constant; + +class AttachmentModel extends AbstractModel +{ + /** + * 构造方法 + * AttachmentModel constructor. + */ + public function __construct() + { + parent::__construct(); + } +} diff --git a/trunk/Message/Common/Model/MessagesModel.class.php b/trunk/Message/Common/Model/MessagesModel.class.php index 39dd9cd..275f31d 100644 --- a/trunk/Message/Common/Model/MessagesModel.class.php +++ b/trunk/Message/Common/Model/MessagesModel.class.php @@ -13,9 +13,13 @@ use Common\Common\Constant; class MessagesModel extends AbstractModel { - // 构造方法 + /** + * 构造方法 + * MessagesModel constructor. + */ public function __construct() { + $this->prefield = 'm_'; parent::__construct(); } diff --git a/trunk/Message/Common/Sql/structure.php b/trunk/Message/Common/Sql/structure.php index 86bc779..515e575 100644 --- a/trunk/Message/Common/Sql/structure.php +++ b/trunk/Message/Common/Sql/structure.php @@ -26,6 +26,7 @@ m_imgs VARCHAR(1000) DEFAULT '' COMMENT '图片路径', m_ip varchar(20) DEFAULT '' COMMENT '留言IP', m_status TINYINT UNSIGNED DEFAULT 1 COMMENT '1:未审核 2:已审核 3:已删除', m_uid INT UNSIGNED NOT NULL COMMENT '用户ID', +m_domain VARCHAR(100) NULL DEFAULT '' COMMENT '企业标识', ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '留言时间', upd_date TIMESTAMP NULL COMMENT '修改/删除时间', PRIMARY KEY (`m_id`), @@ -35,12 +36,12 @@ FOREIGN KEY(`m_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE C CREATE TABLE IF NOT EXISTS luoyanshou_attachment( a_mid INT UNSIGNED NOT NULL COMMENT '留言ID', a_path VARCHAR(200) DEFAULT '' COMMENT '附件路径', -a_status TINYINT UNSIGNED COMMENT '0:未删除 1:已删除', +a_status TINYINT UNSIGNED DEFAULT 0 COMMENT '0:未删除 1:已删除', ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '上传时间', upd_date TIMESTAMP NULL COMMENT '修改/删除时间', PRIMARY KEY(`a_mid`,`a_path`), FOREIGN KEY(`a_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE -)ENGINE=INNODB DEFAULT charset=utf8 +)ENGINE=INNODB DEFAULT charset=utf8; CREATE TABLE IF NOT EXISTS luoyanshou_comment( c_uid INT UNSIGNED NOT NULL COMMENT '评论用户ID', @@ -50,7 +51,7 @@ ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '评论时间', upd_date TIMESTAMP NULL COMMENT '修改时间', FOREIGN KEY(`c_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY(`c_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE -)ENGINE=INNODB DEFAULT charset=utf8 +)ENGINE=INNODB DEFAULT charset=utf8; -- libgit2 0.22.2