Commit 04f7987679fcaf15e7fbbca92cfdc848ce546aa3

Authored by luoyanshou
1 parent aa7f1abc

test

Showing 66 changed files with 4718 additions and 0 deletions

Too many changes to show.

To preserve performance only 66 of 91 files are displayed.

trunk/Message/Api/Controller/AbstractController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei
  5 + * Date: 16/9/13
  6 + * Time: 下午14:10
  7 + */
  8 +namespace Api\Controller;
  9 +
  10 +use Common\Controller\Api;
  11 +
  12 +abstract class AbstractController extends Api\AbstractController
  13 +{
  14 +}
... ...
trunk/Message/Api/Controller/Message/MessInputController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Dell
  5 + * Date: 2018/9/3
  6 + * Time: 17:57
  7 + */
  8 +
  9 +namespace Api\Controller\Message;
  10 +
  11 +class MessInputController extends \Api\Controller\AbstractController
  12 +{
  13 +
  14 + public function Index_post()
  15 + {
  16 + $this->_result = [
  17 + 'mess' => '请求错误',
  18 + ];
  19 + }
  20 +
  21 +}
... ...
trunk/Message/Api/Lang/index.html 0 → 100644
No preview for this file type
trunk/Message/Api/Lang/zh-cn.php 0 → 100644
  1 +<?php
  2 +
  3 +return array(
  4 + '_ERR_TEST' => '2011001:错误码示例',
  5 + '_ERR_USER_INFO_FAIL' => '2011002:用户信息获取失败',
  6 + '_ERR_ARTICLE_ALREADY_LIKE' => '2011003:已经点赞了',
  7 + '_ERR_ARTICLE_NOT_FOUND' => '2011004:头条不存在',
  8 + '_ERR_ATTACH_ID_EMPTY' => '2011005:附件ID不可为空',
  9 + '_ERR_ATTACH_NOT_FOUND' => '2011006:附件不存在',
  10 + '_ERR_ATTACH_IS_DOWNLOAD_FALSE' => '2011007:附件不支持下载',
  11 + '_ERR_ARTICLE_CAN_NOT_READ' => '2011008:无阅读权限',
  12 + '_ERR_ARTICLE_ALREADY_FAVORITE' => '2011009:已经收藏了',
  13 + '_ERR_FAVORITE_STATUS_EMPTY' => '2011010:查询收藏结果失败',
  14 + '_ERR_FAVORITE_OPERATE_FAIL' => '2011011:收藏操作失败',
  15 + '_ERR_ATTACH_FILE_SIZE_OVERRUN' => '2011012:文件大小超过微信限制,不可下载',
  16 +);
... ...
trunk/Message/Api/index.html 0 → 100644
No preview for this file type
trunk/Message/Apicp/Controller/AbstractController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei
  5 + * Date: 16/9/13
  6 + * Time: 下午14:10
  7 + */
  8 +namespace Apicp\Controller;
  9 +
  10 +use Common\Controller\Apicp;
  11 +
  12 +abstract class AbstractController extends Apicp\AbstractController
  13 +{
  14 +}
... ...
trunk/Message/Apicp/Controller/News/CommentController.class.php 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 +}
0 70 \ No newline at end of file
... ...
trunk/Message/Apicp/Controller/News/RemindController.class.php 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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 0 → 100644
  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/Apicp/Controller/index.html 0 → 100644
No preview for this file type
trunk/Message/Apicp/Lang/index.html 0 → 100644
No preview for this file type
trunk/Message/Apicp/Lang/zh-cn.php 0 → 100644
  1 +<?php
  2 +
  3 +return array(
  4 + '_ERR_TEST' => '2014001:错误码示例',
  5 + '_ERR_CLASS_DATA_NOT_FOUND' => '2014002:分类数据不存在',
  6 + '_ERR_CLASS_CONTAIN_CHILD' => '2014003:分类内存在二级分类,无法删除',
  7 + '_ERR_CLASS_NAME_REPEAT' => '2014004:分类名重复',
  8 + '_ERR_CLASS_PARENT_ID_EMPTY' => '2014005:一级分类ID不能为空',
  9 + '_ERR_CLASS_IS_OPEN_EMPTY' => '2014006:是否启用不能为空',
  10 + '_ERR_CLASS_RIGHT_EMPTY' => '2014007:权限数据不能为空',
  11 + '_ERR_ARTICLE_NOT_FOUND' => '2014008:头条不存在',
  12 + '_ERR_ARTICLE_ID_EMPTY' => '2014009:头条ID不能为空',
  13 + '_ERR_CLASS_CONTAIN_ARTICLE' => '2014010:分类内存在头条内容,不能被删除',
  14 + '_ERR_ARTICLE_FILE_ATTACH_MORE' => '2014011:{$at_type}最多上传5个',
  15 + '_ERR_ARTICLE_STATUS_FAIL' => '2014012:预发布与草稿不能发送未读提醒',
  16 + '_ERR_ARTICLE_ATTACH_PARAM' => '2014013:视频附件参数不正确',
  17 + '_ERR_ARTICLE_RIGHT_PARAM' => '2014014:阅读权限参数不正确',
  18 + '_ERR_ARTICLE_DATA_ID_NOT_FOUND' => '2014015:数据标识不能为空',
  19 + '_ERR_ARTICLE_STRATEGY_ID_EMPTY' => '2014016:积分策略ID不可为空',
  20 + '_ERR_ARTICLE_STRATEGY_PARAM_FORMAT' => '2014017:积分策略数据格式错误',
  21 + '_ERR_ARTICLE_STRATEGY_PARAM_LOSE' => '2014018:积分策略数据缺少参数',
  22 + '_ERR_ARTICLE_SAVE_FAILED' => '2014019:头条保存失败,请稍后再试',
  23 + '_ERR_VIDEO_ID_IS_EMPTY' => '2014020:视频ID不能为空',
  24 + '_ERR_PARAM_CAN_NOT_EMPTY' => '2014021:{$name}不能为空',
  25 + '_ERR_CREDIT_STRATEGY_ID_EMPTY' => '2014022:学分策略ID不可为空',
  26 + '_ERR_CREDIT_STRATEGY_PARAM_FORMAT' => '2014023:学分策略数据格式错误',
  27 + '_ERR_CREDIT_STRATEGY_PARAM_LOSE' => '2014024:学分策略数据缺少参数',
  28 + '_ERR_CREDIT_CRON_TIME_ERR' => '2014025:定时发布时间有误',
  29 +);
... ...
trunk/Message/Common/Cli/Index.php 0 → 100644
  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | ThinkPHP [ WE CAN DO IT JUST THINK ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author: liu21st <liu21st@gmail.com>
  10 +// +----------------------------------------------------------------------
  11 +
  12 +// 应用入口文件
  13 +
  14 +// 检测PHP环境
  15 +if (version_compare(PHP_VERSION, '5.4.0', '<')) {
  16 + die('require PHP > 5.4.0 !');
  17 +}
  18 +
  19 +// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false
  20 +define('APP_DEBUG', true);
  21 +
  22 +// 绑定 Action 方法名称
  23 +// define('BIND_ACTION', 'execute');
  24 +// 绑定模块到当前文件
  25 +define('BIND_MODULE', 'Cli');
  26 +
  27 +$depr = '/';
  28 +$path = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
  29 +if (! empty($path)) {
  30 + $params = explode($depr, trim($path, $depr));
  31 +}
  32 +
  33 +// !empty($params) ? $_GET['m'] = array_shift($params) : "";
  34 +! empty($params) ? $_GET['c'] = array_shift($params) : "";
  35 +! empty($params) ? $_GET['a'] = array_shift($params) : "";
  36 +
  37 +// 解析剩余参数, 并采用 GET 方式获取
  38 +$params_ct = count($params);
  39 +for ($i = 1; $i + 1 < $params_ct; $i += 2) {
  40 + $_GET[$params[$i]] = $params[$i + 1];
  41 +}
  42 +
  43 +set_time_limit(0);
  44 +// 框架目录
  45 +define('THINK_PATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/thinkphp/ThinkPHP/');
  46 +// 定义应用目录
  47 +define('APP_PATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/thinkphp/Apps/');
  48 +
  49 +// 引入ThinkPHP入口文件
  50 +require THINK_PATH . 'ThinkPHP.php';
  51 +
  52 +// 亲^_^ 后面不需要任何代码了 就是如此简单
... ...
trunk/Message/Common/Common/Constant.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhonglei
  5 + * Date: 2017/3/20
  6 + * Time: 14:14
  7 + */
  8 +
  9 +namespace Common\Common;
  10 +
  11 +class Constant
  12 +{
  13 + /**
  14 + * 允许下载文件上限:20M
  15 + */
  16 + const DOWNLOAD_FILE_MAX_SIZE = 20 * 1024 * 1024;
  17 +
  18 + /**
  19 + * 分页:默认页数
  20 + */
  21 + const PAGING_DEFAULT_PAGE = 1;
  22 +
  23 + /**
  24 + * 分页:默认当前页数据总数
  25 + */
  26 + const PAGING_DEFAULT_LIMIT = 20;
  27 +
  28 + /**
  29 + * 新闻未读总数刷新时间(2分钟)
  30 + */
  31 + const NEWS_UNREAD_TIME = 60 * 1000 * 2;
  32 +
  33 + /**
  34 + * 自动截取摘要长度:54字符
  35 + */
  36 + const AUTO_SUMMARY_LENGTH = 54;
  37 +
  38 + /**
  39 + * 文件附件上传上限:5个
  40 + */
  41 + const UPLOAD_FILE_ATTACH_LIMIT = 5;
  42 +
  43 + /**
  44 + * 启用分类:禁用
  45 + */
  46 + const CLASS_IS_OPEN_FALSE = 1;
  47 +
  48 + /**
  49 + * 启用分类:启用
  50 + */
  51 + const CLASS_IS_OPEN_TRUE = 2;
  52 +
  53 + /**
  54 + * 适用范围类型:分类
  55 + */
  56 + const RIGHT_CLASS_TYPE_CLASS = 1;
  57 +
  58 + /**
  59 + * 适用范围类型:新闻
  60 + */
  61 + const RIGHT_CLASS_TYPE_NEWS = 2;
  62 +
  63 + /**
  64 + * 适用范围是否全公司:否
  65 + */
  66 + const RIGHT_IS_ALL_FALSE = 1;
  67 +
  68 + /**
  69 + * 适用范围是否全公司:是
  70 + */
  71 + const RIGHT_IS_ALL_TRUE = 2;
  72 +
  73 + /**
  74 + * 权限类型:全公司
  75 + */
  76 + const RIGHT_TYPE_ALL = 1;
  77 +
  78 + /**
  79 + * 权限类型:部门
  80 + */
  81 + const RIGHT_TYPE_DEPARTMENT = 2;
  82 +
  83 + /**
  84 + * 权限类型:标签
  85 + */
  86 + const RIGHT_TYPE_TAG = 3;
  87 +
  88 + /**
  89 + * 权限类型:人员
  90 + */
  91 + const RIGHT_TYPE_USER = 4;
  92 +
  93 + /**
  94 + * 权限类型:职位
  95 + */
  96 + const RIGHT_TYPE_JOB = 5;
  97 +
  98 + /**
  99 + * 权限类型:角色
  100 + */
  101 + const RIGHT_TYPE_ROLE = 6;
  102 +
  103 + /**
  104 + * 是否正文显示封面图片:不显示
  105 + */
  106 + const NEWS_IS_SHOW_COVER_FALSE = 1;
  107 +
  108 + /**
  109 + * 是否正文显示封面图片:显示
  110 + */
  111 + const NEWS_IS_SHOW_COVER_TRUE = 2;
  112 +
  113 + /**
  114 + * 附件是否支持下载:不支持
  115 + */
  116 + const NEWS_IS_DOWNLOAD_FALSE = 1;
  117 +
  118 + /**
  119 + * 附件是否支持下载:支持
  120 + */
  121 + const NEWS_IS_DOWNLOAD_TRUE = 2;
  122 +
  123 + /**
  124 + * 是否保密:不保密
  125 + */
  126 + const NEWS_IS_SECRET_FALSE = 1;
  127 +
  128 + /**
  129 + * 是否保密:保密
  130 + */
  131 + const NEWS_IS_SECRET_TRUE = 2;
  132 +
  133 + /**
  134 + * 是否允许分享:不允许
  135 + */
  136 + const NEWS_IS_SHARE_FALSE = 1;
  137 +
  138 + /**
  139 + * 是否允许分享:允许
  140 + */
  141 + const NEWS_IS_SHARE_TRUE = 2;
  142 +
  143 + /**
  144 + * 消息通知:不开启
  145 + */
  146 + const NEWS_IS_NOTICE_FALSE = 1;
  147 +
  148 + /**
  149 + * 消息通知:开启
  150 + */
  151 + const NEWS_IS_NOTICE_TRUE = 2;
  152 +
  153 + /**
  154 + * 评论功能:不开启
  155 + */
  156 + const NEWS_IS_COMMENT_FALSE = 1;
  157 +
  158 + /**
  159 + * 评论功能:开启
  160 + */
  161 + const NEWS_IS_COMMENT_TRUE = 2;
  162 +
  163 + /**
  164 + * 点赞功能:不开启
  165 + */
  166 + const NEWS_IS_LIKE_FALSE = 1;
  167 +
  168 + /**
  169 + * 点赞功能:开启
  170 + */
  171 + const NEWS_IS_LIKE_TRUE = 2;
  172 +
  173 + /**
  174 + * 首页推荐:不开启
  175 + */
  176 + const NEWS_IS_RECOMMEND_FALSE = 1;
  177 +
  178 + /**
  179 + * 首页推荐:开启
  180 + */
  181 + const NEWS_IS_RECOMMEND_TRUE = 2;
  182 +
  183 + /**
  184 + * 新闻状态:草稿
  185 + */
  186 + const NEWS_STATUS_DRAFT = 1;
  187 +
  188 + /**
  189 + * 新闻状态:已发布
  190 + */
  191 + const NEWS_STATUS_SEND = 2;
  192 +
  193 + /**
  194 + * 新闻状态:预发布
  195 + */
  196 + const NEWS_STATUS_READY_SEND = 3;
  197 +
  198 + /**
  199 + * 新闻状态:定时发布
  200 + */
  201 + const NEWS_STATUS_TIMING_RELEASE = 4;
  202 +
  203 + /**
  204 + * 新闻转码状态:转码中
  205 + */
  206 + const FILE_STATUS_CONVERT = 1;
  207 +
  208 + /**
  209 + * 新闻转码状态:转码成功
  210 + */
  211 + const FILE_STATUS_NORMAL = 2;
  212 +
  213 + /**
  214 + * 新闻转码状态:转码失败
  215 + */
  216 + const FILE_STATUS_FAIL = 3;
  217 +
  218 + /**
  219 + * 附件类型:视频
  220 + */
  221 + const ATTACH_TYPE_VIDEO = 1;
  222 +
  223 + /**
  224 + * 附件类型:音频
  225 + */
  226 + const ATTACH_TYPE_AUDIO = 2;
  227 +
  228 + /**
  229 + * 附件类型:其他
  230 + */
  231 + const ATTACH_TYPE_FILE = 3;
  232 +
  233 + /**
  234 + * 阅读状态:已读
  235 + */
  236 + const READ_STATUS_IS_YES = 2;
  237 +
  238 + /**
  239 + * 阅读状态:未读
  240 + */
  241 + const READ_STATUS_IS_NO = 1;
  242 +
  243 + /**
  244 + * 点赞:对于新闻的点赞
  245 + */
  246 + const LIKE_TYPE_ARTICLE = 1;
  247 +
  248 + /**
  249 + * 点赞:对于评论的点赞
  250 + */
  251 + const LIKE_TYPE_COMMENT = 2;
  252 +
  253 + /**
  254 + * 评论操作类型:发表评论
  255 + */
  256 + const COMMENT_TYPE_ADD = 1;
  257 +
  258 + /**
  259 + * 评论操作类型:删除评论
  260 + */
  261 + const COMMENT_TYPE_DELETE = 2;
  262 +
  263 + /**
  264 + * 收藏操作类型:收藏
  265 + */
  266 + const FAVORITE_TYPE_ADD = 2;
  267 +
  268 + /**
  269 + * 收藏操作类型:取消收藏
  270 + */
  271 + const FAVORITE_TYPE_DELETE = 1;
  272 +
  273 + /**
  274 + * 是否外部人员:不是
  275 + */
  276 + const RIGHT_IS_OUTSIDE_NO = 1;
  277 +
  278 + /**
  279 + * 是否外部人员:是
  280 + */
  281 + const RIGHT_IS_OUTSIDE_YES = 2;
  282 +
  283 + /**
  284 + * 是否直接跳转外链:不直接跳转
  285 + */
  286 + const NEWS_IS_JUMP_FALSE = 1;
  287 +
  288 + /**
  289 + * 是否直接跳转外链:直接跳转
  290 + */
  291 + const NEWS_IS_JUMP_TRUE = 2;
  292 +
  293 + /**
  294 + * 是否是分享入口:不是
  295 + */
  296 + const RIGHT_INPUT_IS_SHARE_FALSE = 1;
  297 +
  298 + /**
  299 + * 是否是分享入口:是
  300 + */
  301 + const RIGHT_INPUT_IS_SHARE_TRUE = 2;
  302 +
  303 + /**
  304 + * 积分策略设置:启用默认策略
  305 + */
  306 + const NEWS_STRATEGY_DEFAULT = 1;
  307 +
  308 + /**
  309 + * 积分策略设置:不启用策略
  310 + */
  311 + const NEWS_STRATEGY_DISABLE = 2;
  312 +
  313 + /**
  314 + * 积分策略设置:自定义策略
  315 + */
  316 + const NEWS_STRATEGY_CUSTOM = 3;
  317 +
  318 + /**
  319 + * 学分策略设置:启用默认策略
  320 + */
  321 + const NEWS_CREDIT_STRATEGY_DEFAULT = 1;
  322 +
  323 + /**
  324 + * 学分策略设置:不启用策略
  325 + */
  326 + const NEWS_CREDIT_STRATEGY_DISABLE = 2;
  327 +
  328 + /**
  329 + * 学分策略设置:自定义策略
  330 + */
  331 + const NEWS_CREDIT_STRATEGY_CUSTOM = 3;
  332 +
  333 + /**
  334 + * 积分策略:业务应用Key
  335 + */
  336 + const INT_APP_KEY = 'news_center';
  337 +
  338 + /**
  339 + * 积分策略行为Key:阅读
  340 + */
  341 + const INT_ACT_READ = 'read';
  342 +
  343 + /**
  344 + * 积分策略行为Key:评论
  345 + */
  346 + const INT_ACT_COMMENT = 'comment';
  347 +
  348 + /**
  349 + * 积分策略行为Key:分享
  350 + */
  351 + const INT_ACT_SHARED = 'shared';
  352 +
  353 + /**
  354 + * 积分策略行为Key:点赞
  355 + */
  356 + const INT_ACT_LIKE = 'like';
  357 +
  358 + /**
  359 + * 积分策略行为Key:收藏
  360 + */
  361 + const INT_ACT_COLLECT = 'collect';
  362 +
  363 + /**
  364 + * 积分触发规则Key:完成阅读
  365 + */
  366 + const INT_TRIGGER_COMPLETE = 'complete';
  367 +
  368 + /**
  369 + * 积分触发规则Key:完成阅读新闻篇数
  370 + */
  371 + const INT_TRIGGER_COMPLETE_NUM = 'complete_num';
  372 +
  373 + /**
  374 + * 积分触发规则Key:评论次数
  375 + */
  376 + const INT_TRIGGER_COMMENT = 'number';
  377 +
  378 + /**
  379 + * 积分触发规则Key:评论新闻篇数
  380 + */
  381 + const INT_TRIGGER_COMMENT_NUM = 'business_num';
  382 +
  383 + /**
  384 + * 积分触发规则Key:分享次数
  385 + */
  386 + const INT_TRIGGER_SHARED = 'shared_num';
  387 +
  388 + /**
  389 + * 积分触发规则Key:点赞次数
  390 + */
  391 + const INT_TRIGGER_LIKE = 'number';
  392 +
  393 + /**
  394 + * 积分触发规则Key:收藏次数
  395 + */
  396 + const INT_TRIGGER_COLLECT = 'collect_num';
  397 +
  398 + /**
  399 + * 任务中心action_key:阅读完成
  400 + */
  401 + const TASK_ACTION_KEY_NEWS_READ = 'news_read';
  402 +
  403 +}
... ...
trunk/Message/Common/Common/NewsHelper.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei2012it
  5 + * Date: 17/6/6
  6 + * Time: 15:47
  7 + */
  8 +namespace Common\Common;
  9 +
  10 +use Common\Service\ReadService;
  11 +use Common\Service\RightService;
  12 +
  13 +class NewsHelper
  14 +{
  15 + /**
  16 + * 实例化
  17 + * @author zhonglei
  18 + * @return NewsHelper
  19 + */
  20 + public static function &instance()
  21 + {
  22 + static $instance;
  23 +
  24 + if (is_null($instance)) {
  25 + $instance = new self();
  26 + }
  27 +
  28 + return $instance;
  29 + }
  30 +
  31 + /**
  32 + * 发送新课程消息通知
  33 + * @author zhonglei
  34 + * @param array $article 课程数据
  35 + * @param array $rights 权限数据
  36 + * @return bool
  37 + */
  38 + public function sendNotice($article, $rights)
  39 + {
  40 + if (!is_array($article) || empty($article) || !is_array($rights) || empty($rights)) {
  41 + return false;
  42 + }
  43 +
  44 + $msgServ = &Msg::instance();
  45 + $msg_data = [
  46 + [
  47 + 'title' => "【{$article['class_name']}】{$article['title']}",
  48 + 'description' => $article['summary'],
  49 + 'url' => oaUrl('Frontend/Index/Detail/Index', ['article_id' => $article['article_id']]),
  50 + 'picUrl' => $article['cover_url'],
  51 + ]
  52 + ];
  53 +
  54 + // 全公司
  55 + if (isset($rights[Constant::RIGHT_TYPE_ALL]) && $rights[Constant::RIGHT_TYPE_ALL] == Constant::RIGHT_IS_ALL_TRUE) {
  56 + $msgServ->sendNews('@all', null, null, $msg_data);
  57 +
  58 + // 其它
  59 + } else {
  60 + $rightServ = new RightService();
  61 + $uids = $rightServ->getUidsByRight($rights);
  62 + $uid_groups = array_chunk($uids, Msg::USER_MAX_COUNT);
  63 +
  64 + // 分批发送
  65 + foreach ($uid_groups as $uid_group) {
  66 + $msgServ->sendNews($uid_group, null, null, $msg_data);
  67 + }
  68 + }
  69 +
  70 + return true;
  71 + }
  72 +
  73 + /**
  74 + * 发送未读提醒消息
  75 + * @author liyifei
  76 + * @param array $uids 需要发送人员的UID一维数组
  77 + * @param array $article 新闻信息
  78 + * + string class_name 一级分类名称
  79 + * + string title 新闻标题
  80 + * + string cover_url 新闻封面地址
  81 + * + string article_id 新闻ID
  82 + * + string summary 新闻摘要
  83 + * @return bool
  84 + */
  85 + public function sendUnreadMsg($uids, $article)
  86 + {
  87 + if (empty($uids) || !isset($article['title'], $article['cover_url'], $article['article_id'], $article['summary'])) {
  88 + return false;
  89 + }
  90 +
  91 + $msgServ = &Msg::instance();
  92 + $msg_data = [
  93 + [
  94 + 'title' => "【{$article['class_name']}】{$article['title']}",
  95 + 'description' => $article['summary'],
  96 + 'url' => oaUrl('Frontend/Index/Detail/Index', ['article_id' => $article['article_id']]),
  97 + 'picUrl' => $article['cover_url'],
  98 + ]
  99 + ];
  100 +
  101 + // 分批发送
  102 + $uid_groups = array_chunk($uids, Msg::USER_MAX_COUNT);
  103 + foreach ($uid_groups as $uid_group) {
  104 + $msgServ->sendNews($uid_group, null, null, $msg_data);
  105 + }
  106 +
  107 + return true;
  108 + }
  109 +
  110 + /**
  111 + * 获取新闻可读、已读、未读人员ID数组
  112 + * @author zhonglei
  113 + * @param int $article_id 新闻ID
  114 + * @return array [0 => 可读人员ID, 1 => 已读人员ID, 2 => 未读人员ID]
  115 + */
  116 + public function getReadData($article_id, $uidCond = [])
  117 + {
  118 + $uids_all = [];
  119 + $uids_read = [];
  120 + $uids_unread = [];
  121 +
  122 + // 查询条件
  123 + $conds = ['article_id' => $article_id];
  124 +
  125 + // 获取权限数据
  126 + $rightServ = new RightService();
  127 + $right_list = $rightServ->list_by_conds($conds);
  128 + $rights = $rightServ->formatDBData($right_list);
  129 +
  130 + if (empty($rights)) {
  131 + return [$uids_all, $uids_read, $uids_unread];
  132 + }
  133 +
  134 + // 获取可读数据
  135 + $uids_all = $rightServ->getUidsByRight($rights);
  136 + if (!empty($uidCond)) {
  137 + $uids_all = array_intersect($uidCond, $uids_all);
  138 + }
  139 +
  140 + // 获取已读数据
  141 + $readServ = new ReadService();
  142 + if (!empty($uidCond)) {
  143 + $conds['uid'] = $uidCond;
  144 + }
  145 + $study_list = $readServ->list_by_conds($conds);
  146 + $uids_read = array_column($study_list, 'uid');
  147 +
  148 + // 未读数据
  149 + $uids_unread = array_values(array_diff($uids_all, $uids_read));
  150 + return [$uids_all, $uids_read, $uids_unread];
  151 + }
  152 +
  153 + /**
  154 + * @desc 格式化推送运营中心权限数据
  155 + * @author tangxingguo
  156 + * @param array $postRight 用户提交的权限数据
  157 + * @return array
  158 + */
  159 + public function formatRightForRPC($postRight)
  160 + {
  161 + $data = [];
  162 +
  163 + foreach ($postRight as $k => $v) {
  164 + // 全公司
  165 + if ($k == 'is_all' && $v == Constant::RIGHT_IS_ALL_TRUE) {
  166 + $data = [];
  167 + break;
  168 + }
  169 +
  170 + // 过滤空数组
  171 + if (!is_array($v) || empty($v)) {
  172 + continue;
  173 + }
  174 +
  175 + switch ($k) {
  176 + // 部门
  177 + case 'dp_ids':
  178 + $data['departments'] = $v;
  179 + break;
  180 + // 标签
  181 + case 'tag_ids':
  182 + $data['tags'] = $v;
  183 + break;
  184 + // 人员
  185 + case 'uids':
  186 + $data['users'] = $v;
  187 + break;
  188 + // 职位
  189 + case 'job_ids':
  190 + $data['jobs'] = $v;
  191 + break;
  192 + // 角色
  193 + case 'role_ids':
  194 + $data['roles'] = $v;
  195 + break;
  196 + }
  197 + }
  198 +
  199 + return $data;
  200 + }
  201 +
  202 + /**
  203 + * 构造积分、学分触发参数
  204 + * @author zhonglei
  205 + * @param array $article 新闻数据
  206 + * @param string $action_key 动作Key
  207 + * @param array $trigger_types 触发规则
  208 + * @return array
  209 + */
  210 + public function buildTrigger($article, $action_key, $trigger_types)
  211 + {
  212 + if (!\is_array($article) || !\is_array($trigger_types)) {
  213 + return [];
  214 + }
  215 +
  216 + if (!\is_array($article['strategys'])) {
  217 + $article['strategys'] = empty($article['strategys']) ? [] : unserialize($article['strategys']);
  218 + }
  219 +
  220 + if (!\is_array($article['credit_strategys'])) {
  221 + $article['credit_strategys'] = empty($article['credit_strategys']) ? [] : unserialize($article['credit_strategys']);
  222 + }
  223 +
  224 + $triggers = [];
  225 +
  226 + // 开启积分策略
  227 + if ($article['strategy_setting'] != Constant::NEWS_STRATEGY_DISABLE) {
  228 + $strategy_id = '';
  229 +
  230 + // 自定义积分策略
  231 + if ($article['strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM && isset($article['strategys'][$action_key])) {
  232 + $strategy_id = $article['strategys'][$action_key];
  233 + }
  234 +
  235 + $triggers[] = [
  236 + 'miType' => IntegralStrategy::TRIGGER_TYPE_INTEGRAL,
  237 + 'businessStrategyId' => $strategy_id,
  238 + ];
  239 + }
  240 +
  241 + // 开启学分策略
  242 + if ($article['credit_strategy_setting'] != Constant::NEWS_STRATEGY_DISABLE) {
  243 + $strategy_id = '';
  244 +
  245 + // 自定义学分策略
  246 + if ($article['credit_strategy_setting'] == Constant::NEWS_STRATEGY_CUSTOM && isset($article['credit_strategys'][$action_key])) {
  247 + $strategy_id = $article['credit_strategys'][$action_key];
  248 + }
  249 +
  250 + $triggers[] = [
  251 + 'miType' => IntegralStrategy::TRIGGER_TYPE_CREDIT,
  252 + 'businessStrategyId' => $strategy_id,
  253 + ];
  254 + }
  255 +
  256 + foreach ($triggers as $k => $trigger) {
  257 + $triggers[$k]['triggerTypes'] = $trigger_types;
  258 + }
  259 +
  260 + return $triggers;
  261 + }
  262 +
  263 + /**
  264 + * 格式化部门路径
  265 + * @author liyifei
  266 + * @param array $user
  267 + * @return string
  268 + */
  269 + public function getDpPath($user)
  270 + {
  271 + // 部门列表
  272 + $deptServ = &Department::instance();
  273 + $deptList = $deptServ->listDepartmentFromSdk();
  274 +
  275 + $dpPath = '';
  276 + $dpIds = array_column($user['dpName'], 'dpId');
  277 + foreach ($dpIds as $dpId) {
  278 + $columnSuffix = end($dpIds) == $dpId ? '' : ";\n";
  279 + $dpPath .= $deptList[$dpId]['departmentPath'] . $columnSuffix;
  280 + }
  281 +
  282 + return $dpPath;
  283 + }
  284 +}
... ...
trunk/Message/Common/Common/RpcFavoriteHelper.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei2012it
  5 + * Date: 17/6/7
  6 + * Time: 15:21
  7 + */
  8 +namespace Common\Common;
  9 +
  10 +class RpcFavoriteHelper
  11 +{
  12 + /**
  13 + * 是否收藏:未收藏(所有常量值,必须和RPC规定一致)
  14 + */
  15 + const COLLECTION_NO = 0;
  16 +
  17 + /**
  18 + * 是否收藏:已收藏
  19 + */
  20 + const COLLECTION_YES = 1;
  21 +
  22 + /*
  23 + * 封面类型:无
  24 + */
  25 + const COVER_TYPE_NONE = 0;
  26 +
  27 + /*
  28 + * 封面类型:图片
  29 + */
  30 + const COVER_TYPE_IMAGE = 1;
  31 +
  32 + /*
  33 + * 封面类型:音频
  34 + */
  35 + const COVER_TYPE_RADIO = 2;
  36 +
  37 + /*
  38 + * 封面类型:视频
  39 + */
  40 + const COVER_TYPE_VIDEO = 3;
  41 +
  42 + /*
  43 + * 是否为文件夹:否
  44 + */
  45 + const IS_DIR_FALSE = 0;
  46 +
  47 + /*
  48 + * 是否为文件夹:1
  49 + */
  50 + const IS_DIR_TRUE = 1;
  51 +
  52 + /*
  53 + * RPC查询收藏状态的url
  54 + */
  55 + const COLLECTION_STATUS ='/Public/Rpc/Collection/CollectionStatus';
  56 +
  57 + /*
  58 + * 删除应用数据,同步标记收藏状态的url
  59 + */
  60 + const COLLECTION_UPDATE = '/Public/Rpc/Collection/CollectionUpdate';
  61 +
  62 + /*
  63 + * RPC新增收藏的url
  64 + */
  65 + const COLLECTION_NEW = '/Public/Rpc/Collection/CollectionNew';
  66 +
  67 + /*
  68 + * RPC取消收藏的url
  69 + */
  70 + const COLLECTION_DELETE = '/Public/Rpc/Collection/CollectionDelete';
  71 +
  72 + /**
  73 + * 实例化
  74 + * @author zhonglei
  75 + * @return RpcFavoriteHelper
  76 + */
  77 + public static function &instance()
  78 + {
  79 + static $instance;
  80 +
  81 + if (is_null($instance)) {
  82 + $instance = new self();
  83 + }
  84 +
  85 + return $instance;
  86 + }
  87 +
  88 + /**
  89 + * 查询收藏状态
  90 + * @author liyifei
  91 + * @param array $data 被收藏数据
  92 + * + string app 被收藏数据所在应用模块目录标识名
  93 + * + string uid 当前用户的uid
  94 + * + int dataId 被收藏数据的原始数据 Id
  95 + * @return array
  96 + * array(
  97 + * 'collection' => 1, // 收藏状态(0:未收藏,1:已收藏)
  98 + * )
  99 + */
  100 + public function getStatus($data)
  101 + {
  102 + if (empty($data) || !is_array($data)) {
  103 + return [];
  104 + }
  105 +
  106 + // 必传参数
  107 + $data['app'] = APP_DIR;
  108 + if (!isset($data['uid'], $data['dataId'])) {
  109 + return [];
  110 + }
  111 +
  112 + $url = rpcUrl(self::COLLECTION_STATUS);
  113 + $resJson = \Com\Rpc::phprpc($url)->invoke('index', $data);
  114 + if (!$resJson) {
  115 + return [];
  116 + }
  117 +
  118 + return json_decode($resJson, true);
  119 + }
  120 +
  121 + /**
  122 + * 新增收藏
  123 + * @author liyifei
  124 + * @param array $data 被收藏数据信息
  125 + * + string app 被收藏数据所在应用模块目录标识名
  126 + * + string uid 当前用户的uid
  127 + * + int dataId 被收藏数据的原始数据 Id
  128 + * + string title 收藏标题(同事圈内容,资料库文件(夹)名等)
  129 + * + int cover_type 封面类型(0:无封面,1:图片,2:音频,3:视频)
  130 + * + string cover_id 封面附件ID
  131 + * + string cover_url 封面附件URL
  132 + * + int url 详情跳转地址(请传php相对地址,方便后续维护[/Course/Frontend/Index/Detail?article_id=1&data_id=2])
  133 + * + string file_type 文件类型(JPG,TXT,PDF等)(资料库必传)
  134 + * + int file_size 文件大小(单位:字节)(资料库必传)
  135 + * + int is_dir 是否为文件夹(0:否,1:是)(资料库必传)
  136 + * @return bool
  137 + */
  138 + public function addFavorite($data)
  139 + {
  140 + if (empty($data) || !is_array($data)) {
  141 + return false;
  142 + }
  143 +
  144 + // 必传参数
  145 + $data['app'] = APP_DIR;
  146 + if (!isset($data['uid'], $data['dataId'], $data['title'], $data['url'])) {
  147 + return false;
  148 + }
  149 +
  150 + // 资料库必传参数
  151 + if (APP_DIR == 'Doc') {
  152 + if (!isset($data['file_type'], $data['file_size'], $data['is_dir'])) {
  153 + return false;
  154 + }
  155 + }
  156 +
  157 + $url = rpcUrl(self::COLLECTION_NEW);
  158 +
  159 + return \Com\Rpc::phprpc($url)->invoke('index', $data);
  160 + }
  161 +
  162 + /**
  163 + * 取消收藏
  164 + * @author liyifei
  165 + * @param array $data 收藏信息
  166 + * + string app 被收藏数据所在应用模块目录标识名
  167 + * + string uid 当前用户的uid
  168 + * + int dataId 被收藏数据的原始数据 Id
  169 + * @return bool
  170 + */
  171 + public function cancelFavorite($data)
  172 + {
  173 + // 必传参数
  174 + $data['app'] = APP_DIR;
  175 + if (!isset($data['uid'], $data['dataId'])) {
  176 + return false;
  177 + }
  178 +
  179 + $url = rpcUrl(self::COLLECTION_DELETE);
  180 +
  181 + return \Com\Rpc::phprpc($url)->invoke('index', $data);
  182 + }
  183 +
  184 + /**
  185 + * 删除应用数据时,RPC同步收藏状态
  186 + * @author liyifei
  187 + * @param array $dataIds 被收藏数据的原始数据 Id。如果是多个使用逗号分割(如:'1,25,65')
  188 + * @return bool
  189 + */
  190 + public function updateStatus($dataIds)
  191 + {
  192 + if (empty($dataIds) || !is_array($dataIds)) {
  193 + return false;
  194 + }
  195 +
  196 + $url = rpcUrl(self::COLLECTION_UPDATE);
  197 +
  198 + $param = [
  199 + 'app' => APP_DIR,
  200 + 'dataId' => implode(',', $dataIds),
  201 + ];
  202 +
  203 + return \Com\Rpc::phprpc($url)->invoke('index', $param);
  204 + }
  205 +}
... ...
trunk/Message/Common/Conf.bak/config.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * config.php
  4 + * 公共配置
  5 + * $Author$
  6 + */
  7 +
  8 +return array(
  9 +
  10 + // '配置项'=>'配置值'
  11 +
  12 + // 默认模块
  13 + 'DEFAULT_MODULE' => 'Home',
  14 +
  15 + // 默认控制器
  16 + 'DEFAULT_CONTROLLER' => 'Frontend/Index',
  17 +
  18 + // 附件服务器
  19 + 'FILE_SERVER_URL' => 'http://file/',
  20 +
  21 + // 头像服务器
  22 + 'FACE_SERVER_URL' => 'http://face/',
  23 +
  24 + // 开启多语言
  25 + 'LANG_SWITCH_ON' => true,
  26 +
  27 + // 自动侦测语言 开启多语言功能后有效
  28 + 'LANG_AUTO_DETECT' => true,
  29 +
  30 + // 允许切换的语言列表 用逗号分隔
  31 + 'LANG_LIST' => 'zh-cn',
  32 +
  33 + // 默认语言切换变量
  34 + 'VAR_LANGUAGE' => 'lang',
  35 +
  36 + // 数据库表前缀
  37 + 'DB_PREFIX' => 'oa_news_',
  38 +
  39 + // 数据库连接参数
  40 + 'DB_PARAMS' => array(),
  41 +
  42 + // 数据库调试模式 开启后可以记录SQL日志
  43 + 'DB_DEBUG' => true,
  44 +
  45 + // 启用字段缓存
  46 + 'DB_FIELDS_CACHE' => true,
  47 +
  48 + // 数据库编码默认采用utf8
  49 + 'DB_CHARSET' => 'utf8',
  50 +
  51 + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  52 + 'DB_DEPLOY_TYPE' => 0,
  53 +
  54 + // 数据库读写是否分离 主从式有效
  55 + 'DB_RW_SEPARATE' => false,
  56 +
  57 + // 读写分离后 主服务器数量
  58 + 'DB_MASTER_NUM' => 1,
  59 +
  60 + // 指定从服务器序号
  61 + 'DB_SLAVE_NO' => '',
  62 +
  63 + // 前端路径
  64 + 'FRONTEND_PATH' => 'h5',
  65 +
  66 + // SDK 配置 第三方标识
  67 + 'SDK_THIRD_IDENTIFIER' => 'qy',
  68 +);
... ...
trunk/Message/Common/Conf.bak/debug.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * debug.php
  4 + * DEBUG 配置
  5 + * $Author$
  6 + */
  7 +return array(
  8 + // 是否允许自动创建应用文件和目录(开发)
  9 + 'CREATE_MODEL_ON' => false
  10 +);
... ...
trunk/Message/Common/Conf.bak/tags.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * tags 配置
  4 + */
  5 +return array(
  6 + // 在应用执行前检查语言文件(注意键值的大小写)
  7 + 'app_begin' => array(
  8 + 'Behavior\CheckLangBehavior'
  9 + )
  10 +);
... ...
trunk/Message/Common/Conf/config.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * config.php
  4 + * 公共配置
  5 + * $Author$
  6 + */
  7 +
  8 +return array(
  9 +
  10 + // '配置项'=>'配置值'
  11 +
  12 + // 默认模块
  13 + 'DEFAULT_MODULE' => 'Home',
  14 +
  15 + // 默认控制器
  16 + 'DEFAULT_CONTROLLER' => 'Frontend/Index',
  17 +
  18 + // 附件服务器
  19 + 'FILE_SERVER_URL' => 'http://file/',
  20 +
  21 + // 头像服务器
  22 + 'FACE_SERVER_URL' => 'http://face/',
  23 +
  24 + // 开启多语言
  25 + 'LANG_SWITCH_ON' => true,
  26 +
  27 + // 自动侦测语言 开启多语言功能后有效
  28 + 'LANG_AUTO_DETECT' => true,
  29 +
  30 + // 允许切换的语言列表 用逗号分隔
  31 + 'LANG_LIST' => 'zh-cn',
  32 +
  33 + // 默认语言切换变量
  34 + 'VAR_LANGUAGE' => 'lang',
  35 +
  36 + // 数据库表前缀
  37 + 'DB_PREFIX' => 'luoyanshou_',
  38 +
  39 + // 数据库连接参数
  40 + 'DB_PARAMS' => array(),
  41 +
  42 + // 数据库调试模式 开启后可以记录SQL日志
  43 + 'DB_DEBUG' => true,
  44 +
  45 + // 启用字段缓存
  46 + 'DB_FIELDS_CACHE' => true,
  47 +
  48 + // 数据库编码默认采用utf8
  49 + 'DB_CHARSET' => 'utf8',
  50 +
  51 + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
  52 + 'DB_DEPLOY_TYPE' => 0,
  53 +
  54 + // 数据库读写是否分离 主从式有效
  55 + 'DB_RW_SEPARATE' => false,
  56 +
  57 + // 读写分离后 主服务器数量
  58 + 'DB_MASTER_NUM' => 1,
  59 +
  60 + // 指定从服务器序号
  61 + 'DB_SLAVE_NO' => '',
  62 +
  63 + // 前端路径
  64 + 'FRONTEND_PATH' => 'h5',
  65 +
  66 + // SDK 配置 第三方标识
  67 + 'SDK_THIRD_IDENTIFIER' => 'qy',
  68 +);
... ...
trunk/Message/Common/Conf/debug.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * debug.php
  4 + * DEBUG 配置
  5 + * $Author$
  6 + */
  7 +return array(
  8 + // 是否允许自动创建应用文件和目录(开发)
  9 + 'CREATE_MODEL_ON' => false
  10 +);
... ...
trunk/Message/Common/Conf/tags.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * tags 配置
  4 + */
  5 +return array(
  6 + // 在应用执行前检查语言文件(注意键值的大小写)
  7 + 'app_begin' => array(
  8 + 'Behavior\CheckLangBehavior'
  9 + )
  10 +);
... ...
trunk/Message/Common/Lang/zh-cn.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * zh-cn.php
  4 + * 公共的语言文件
  5 + * $Author$
  6 + * $Id$
  7 + */
  8 +
  9 +return array(
  10 + 'COPYRIGHT' => 'copyright@2014畅移',
  11 + '_ERR_TEST' => '2019001:错误码示例',
  12 +);
... ...
trunk/Message/Common/Model/AbstractModel.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * AbstractModel.class.php
  4 + * Model 层基类
  5 + * @author: zhuxun37
  6 + * @version: $Id$
  7 + * @copyright: vchangyi.com
  8 + */
  9 +namespace Common\Model;
  10 +
  11 +abstract class AbstractModel extends \Com\Model
  12 +{
  13 + /**
  14 + * 维护表名,主要用处是连表查询的时候避免表名的硬编码。
  15 + */
  16 + protected $_tb_article = '';
  17 +
  18 + protected $_tb_attach = '';
  19 +
  20 + protected $_tb_class = '';
  21 +
  22 + protected $_tb_like = '';
  23 +
  24 + protected $_tb_read = '';
  25 +
  26 + protected $_tb_right = '';
  27 +
  28 + protected $_tb_favorite = '';
  29 +
  30 +
  31 + // 构造方法
  32 + public function __construct()
  33 + {
  34 + parent::__construct();
  35 + $this->_tb_arctic = cfg('DB_PREFIX') . 'article';
  36 + $this->_tb_attach = cfg('DB_PREFIX') . 'attach';
  37 + $this->_tb_class = cfg('DB_PREFIX') . 'class';
  38 + $this->_tb_like = cfg('DB_PREFIX') . 'like';
  39 + $this->_tb_read = cfg('DB_PREFIX') . 'read';
  40 + $this->_tb_right = cfg('DB_PREFIX') . 'right';
  41 + $this->_tb_favorite = cfg('DB_PREFIX') . 'favorite';
  42 + }
  43 +}
... ...
trunk/Message/Common/Model/RightModel.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: tangxingguo
  5 + * Date: 2017/4/12
  6 + * Time: 10:33
  7 + */
  8 +namespace Common\Model;
  9 +
  10 +use Common\Common\Constant;
  11 +
  12 +class RightModel extends AbstractModel
  13 +{
  14 +
  15 + // 构造方法
  16 + public function __construct()
  17 + {
  18 + parent::__construct();
  19 + }
  20 +
  21 + /**
  22 + * 根据权限数据构建查询条件
  23 + * @author zhonglei
  24 + * @param array $rights 权限数据
  25 + * @return array
  26 + */
  27 + public function buildConds($rights)
  28 + {
  29 + $conds = [];
  30 +
  31 + if (!is_array($rights) || empty($rights)) {
  32 + return $conds;
  33 + }
  34 +
  35 + foreach ($rights as $k => $v) {
  36 + switch ($k) {
  37 + // 全公司
  38 + case Constant::RIGHT_TYPE_ALL:
  39 + $conds[] = "`obj_type` = {$k}";
  40 + break;
  41 +
  42 + // 部门、标签、人员、职位、角色
  43 + default:
  44 + $obj_id = implode("','", $v);
  45 + $conds[] = "(`obj_type` = {$k} and `obj_id` in ('{$obj_id}'))";
  46 + }
  47 + }
  48 +
  49 + return $conds;
  50 + }
  51 +
  52 + /**
  53 + * 根据新闻ID和权限数据计算数量
  54 + * @author zhonglei
  55 + * @param int $article_id 新闻ID
  56 + * @param array $rights 权限数据
  57 + * @return int
  58 + */
  59 + public function countByRight($article_id, $rights)
  60 + {
  61 + $count = 0;
  62 +
  63 + if (!is_array($rights) || empty($rights)) {
  64 + return $count;
  65 + }
  66 +
  67 + $conds = $this->buildConds($rights);
  68 + $where = '`article_id` = ? and (' . implode(' OR ', $conds) . ') and `domain` = ? and status < ?';
  69 + $sql = "SELECT COUNT(*) FROM __TABLE__ WHERE {$where}";
  70 +
  71 + $params = [
  72 + $article_id,
  73 + QY_DOMAIN,
  74 + $this->get_st_delete(),
  75 + ];
  76 +
  77 + $count = $this->_m->result($sql, $params);
  78 + return intval($count);
  79 + }
  80 +
  81 + /**
  82 + * 根据需要的数据类型和权限数据获取数据
  83 + * @author liyifei
  84 + * @param array $rights 权限数据
  85 + * @return array
  86 + */
  87 + public function listByRight($rights)
  88 + {
  89 + if (!is_array($rights) || empty($rights)) {
  90 + return [];
  91 + }
  92 +
  93 + $conds = $this->buildConds($rights);
  94 +
  95 + $where = '`article_id` > ? and (' . implode(' OR ', $conds) . ') and `domain` = ? and status < ?';
  96 + $sql = "SELECT `article_id` FROM __TABLE__ WHERE {$where}";
  97 +
  98 + $params = [
  99 + 0,
  100 + QY_DOMAIN,
  101 + $this->get_st_delete(),
  102 + ];
  103 +
  104 + return $this->_m->fetch_array($sql, $params);
  105 + }
  106 +}
... ...
trunk/Message/Common/Model/SettingModel.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: tangxingguo
  5 + * Date: 2017/2/8
  6 + * Time: 15:40
  7 + */
  8 +
  9 +namespace Common\Model;
  10 +
  11 +class SettingModel extends AbstractModel
  12 +{
  13 +
  14 + // 构造方法
  15 + public function __construct()
  16 + {
  17 + parent::__construct();
  18 + }
  19 +}
... ...
trunk/Message/Common/Model/SyscacheModel.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: tangxingguo
  5 + * Date: 2017/2/8
  6 + * Time: 15:41
  7 + */
  8 +
  9 +namespace Common\Model;
  10 +
  11 +class SyscacheModel extends AbstractModel
  12 +{
  13 +
  14 + // 构造方法
  15 + public function __construct()
  16 + {
  17 + parent::__construct();
  18 + }
  19 +}
... ...
trunk/Message/Common/Model/index.html 0 → 100644
No preview for this file type
trunk/Message/Common/Service/AbstractService.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * AbstractService.class.php
  4 + * Service 层基类
  5 + * @author: tangxingguo
  6 + * @version: $Id$
  7 + * @copyright: vchangyi.com
  8 + */
  9 +namespace Common\Service;
  10 +
  11 +use VcySDK\Service;
  12 +use Common\Model\RightModel;
  13 +
  14 +abstract class AbstractService extends \Com\Service
  15 +{
  16 +
  17 + // 构造方法
  18 + public function __construct()
  19 + {
  20 + $this->_right = new RightModel();
  21 +
  22 + parent::__construct();
  23 + }
  24 +}
... ...
trunk/Message/Common/Service/SettingService.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: tangxingguo
  5 + * Date: 2017/2/8
  6 + * Time: 15:43
  7 + */
  8 +namespace Common\Service;
  9 +
  10 +use Common\Model\SettingModel;
  11 +
  12 +class SettingService extends AbstractService
  13 +{
  14 + // 构造方法
  15 + public function __construct()
  16 + {
  17 + parent::__construct();
  18 + $this->_d = new SettingModel();
  19 + }
  20 +}
... ...
trunk/Message/Common/Service/SyscacheService.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: tangxingguo
  5 + * Date: 2017/2/8
  6 + * Time: 15:44
  7 + */
  8 +
  9 +namespace Common\Service;
  10 +
  11 +use Common\Model\SyscacheModel;
  12 +
  13 +class SyscacheService extends AbstractService
  14 +{
  15 +
  16 + // 构造方法
  17 + public function __construct()
  18 + {
  19 + parent::__construct();
  20 + $this->_d = new SyscacheModel();
  21 + }
  22 +}
... ...
trunk/Message/Common/Service/index.html 0 → 100644
No preview for this file type
trunk/Message/Common/Sql/data.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * 应用安装时的初始数据文件
  4 + * data.php
  5 + * $Author$
  6 + */
  7 +namespace Common\Sql;
  8 +
  9 +class DefaultData
  10 +{
  11 +
  12 + /**
  13 + * 安装数据
  14 + * @author liyifei
  15 + */
  16 + public static function installData()
  17 + {
  18 + return [
  19 +
  20 + ];
  21 + }
  22 +}
... ...
trunk/Message/Common/Sql/structure.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * 应用的数据表结构文件
  4 + * structure.php
  5 + * $Author$
  6 + */
  7 +return "
  8 +CREATE TABLE IF NOT EXISTS luoyanshou(
  9 +u_id INT UNSIGNED NOT NULL auto_increment COMMENT '用户ID',
  10 +u_name VARCHAR(15) NOT NULL DEFAULT '姓名'COMMENT '用户名',
  11 +u_sex TINYINT UNSIGNED DEFAULT 0 COMMENT '用户性别',
  12 +u_mail VARCHAR(50) NULL COMMENT '邮箱',
  13 +u_tel VARCHAR(11) NULL COMMENT '电话',
  14 +`status` TINYINT DEFAULT 0 COMMENT '用户状态 0:有效 1:无效',
  15 +ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '插入时间',
  16 +upd_date TIMESTAMP NULL COMMENT '修改时间',
  17 +PRIMARY KEY(`u_id`)
  18 +)ENGINE=INNODB DEFAULT charset=utf8;
  19 +
  20 +CREATE TABLE IF NOT EXISTS luoyanshou_messages(
  21 +m_id INT UNSIGNED NOT NULL auto_increment COMMENT '留言ID',
  22 +m_title varchar(80) DEFAULT '' COMMENT '标题',
  23 +m_content VARCHAR(500) DEFAULT '' COMMENT '留言',
  24 +m_imgs VARCHAR(1000) DEFAULT '' COMMENT '图片路径',
  25 +m_ip varchar(20) DEFAULT '' COMMENT '留言IP',
  26 +m_status TINYINT UNSIGNED DEFAULT 1 COMMENT '1:未审核 2:已审核 3:已删除',
  27 +m_uid INT UNSIGNED NOT NULL COMMENT '用户ID',
  28 +ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '留言时间',
  29 +upd_date TIMESTAMP NULL COMMENT '修改/删除时间',
  30 +PRIMARY KEY (`m_id`),
  31 +FOREIGN KEY(`m_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE CASCADE
  32 +)ENGINE=INNODB DEFAULT charset=utf8;
  33 +
  34 +CREATE TABLE IF NOT EXISTS luoyanshou_attachment(
  35 +a_mid INT UNSIGNED NOT NULL COMMENT '留言ID',
  36 +a_path VARCHAR(200) DEFAULT '' COMMENT '附件路径',
  37 +a_status TINYINT UNSIGNED COMMENT '0:未删除 1:已删除',
  38 +ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '上传时间',
  39 +upd_date TIMESTAMP NULL COMMENT '修改/删除时间',
  40 +PRIMARY KEY(`a_mid`,`a_path`),
  41 +FOREIGN KEY(`a_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE
  42 +)ENGINE=INNODB DEFAULT charset=utf8
  43 +
  44 +CREATE TABLE IF NOT EXISTS luoyanshou_comment(
  45 +c_uid INT UNSIGNED NOT NULL COMMENT '评论用户ID',
  46 +c_mid INT UNSIGNED NOT NULL COMMENT '被评论留言ID',
  47 +c_comment VARCHAR(140) DEFAULT '' COMMENT '评论内容',
  48 +ins_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP() COMMENT '评论时间',
  49 +upd_date TIMESTAMP NULL COMMENT '修改时间',
  50 +FOREIGN KEY(`c_uid`) REFERENCES luoyanshou(`u_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  51 +FOREIGN KEY(`c_mid`) REFERENCES luoyanshou_messages(`m_id`) ON DELETE CASCADE ON UPDATE CASCADE
  52 +)ENGINE=INNODB DEFAULT charset=utf8
  53 +
  54 +
  55 +
  56 +
  57 +";
... ...
trunk/Message/Common/View/Frontend/Default.tpl 0 → 100644
  1 +<include file="Common@Frontend/Header" />
  2 +
  3 +<h1 class="failure">{$title}</h1>
  4 +
  5 +<p>
  6 +<strong>Module</strong>: {:MODULE_NAME}<br />
  7 +<strong>Controller</strong>: {:CONTROLLER_NAME}
  8 +</p>
  9 +
  10 +<include file="Common@Frontend/Footer" />
0 11 \ No newline at end of file
... ...
trunk/Message/Common/View/Frontend/Error.tpl 0 → 100644
  1 +<include file="Common@Frontend/Header" />
  2 +
  3 +<head>
  4 + <style type="text/css">
  5 + body {
  6 + background-color: #f0eff5;
  7 + }
  8 +
  9 + .error-page {
  10 + margin-top: 2.35rem;
  11 + text-align: center;
  12 + }
  13 +
  14 + .error-page img {
  15 + width: 3.11rem;
  16 + height: 2.53rem;
  17 + }
  18 +
  19 + .error-page span {
  20 + display: block;
  21 + font-size: 0.24rem;
  22 + color: #555555;
  23 + }
  24 + .display-no {
  25 + display: none;
  26 + }
  27 + </style>
  28 + <script>
  29 + var doc = document.documentElement;
  30 + var deviceWidth = doc.clientWidth > 640 ? 640 : doc.clientWidth;
  31 + doc.style.fontSize = deviceWidth / 6.4 + 'px';
  32 + </script>
  33 +</head>
  34 +<body>
  35 +<div class="error-page">
  36 + <img src="/static/img/frontendError.png">
  37 + <span>网络正忙,请稍后再试</span>
  38 + <div class="display-no">
  39 + errorCode:{$error_code};
  40 + errorMsg:{$error_msg}
  41 + </div>
  42 +</div>
  43 +</body>
  44 +
  45 +
  46 +<include file="Common@Frontend/Footer" />
0 47 \ No newline at end of file
... ...
trunk/Message/Common/View/Frontend/Footer.tpl 0 → 100644
  1 +</body>
  2 +</html>
0 3 \ No newline at end of file
... ...
trunk/Message/Common/View/Frontend/Header.tpl 0 → 100644
  1 +<!DOCTYPE html>
  2 +<html lang="zh-CN">
  3 +<head>
  4 +<meta charset="UTF-8" />
  5 +<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  6 +<meta name="format-detection" content="telephone=no" />
  7 +<title>{$title}</title>
  8 +</head>
  9 +<body>
... ...
trunk/Message/Common/View/Frontend/Redirect.tpl 0 → 100644
  1 +<include file="Common@Frontend/Header" />
  2 +
  3 +<script type="text/javascript">
  4 + <php>if (!empty($redirectUrl)) {</php>
  5 + <php>if (stripos($os, 'android') !== false || '' != $top) {</php>
  6 + window.top.location.href = '{$redirectUrl}';
  7 + <php>} else {</php>
  8 + window.location.href = '{$redirectUrl}';
  9 + <php>}</php>
  10 + <php>}</php>
  11 + <php>if (!empty($javascript)) {</php>
  12 + {$javascript}
  13 + <php>}</php>
  14 +</script>
  15 +
  16 +<include file="Common@Frontend/Footer" />
0 17 \ No newline at end of file
... ...
trunk/Message/Frontend/Controller/Callback/AbstractController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * 应用回调控制层
  5 + * User: zhoutao
  6 + * Date: 16/7/14
  7 + * Time: 下午2:56
  8 + */
  9 +
  10 +namespace Frontend\Controller\Callback;
  11 +
  12 +use VcySDK\Service;
  13 +
  14 +abstract class AbstractController extends \Common\Controller\Frontend\AbstractController
  15 +{
  16 +
  17 + // 回调数据
  18 + protected $callBackData = [];
  19 +
  20 + public function before_action($action = '')
  21 + {
  22 +
  23 + // 不必登陆
  24 + $this->_require_login = false;
  25 + // 接收消息
  26 + $service = &Service::instance();
  27 + $this->callBackData = $service->streamJsonData();
  28 +
  29 + return parent::before_action($action);
  30 + }
  31 +
  32 + public function after_action($action = '')
  33 + {
  34 + parent::after_action($action);
  35 + exit('SUCCESS');
  36 + }
  37 +
  38 + /**
  39 + * 获取 identifier
  40 + * @return bool
  41 + */
  42 + protected function _identifier()
  43 + {
  44 + return true;
  45 + }
  46 +}
... ...
trunk/Message/Frontend/Controller/Callback/CheckAttachController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei2012it
  5 + * Date: 17/4/13
  6 + * Time: 11:38
  7 + */
  8 +namespace Frontend\Controller\Callback;
  9 +
  10 +use Think\Log;
  11 +use VcySDK\Service;
  12 +use VcySDK\Cron;
  13 +use VcySDK\FileConvert;
  14 +use Common\Common\Constant;
  15 +use Common\Common\NewsHelper;
  16 +use Common\Service\ArticleService;
  17 +use Common\Service\AttachService;
  18 +use Common\Service\TaskService;
  19 +use Common\Service\ClassService;
  20 +
  21 +class CheckAttachController extends AbstractController
  22 +{
  23 + /**
  24 + * 附件转换计划任务
  25 + * @author zhonglei
  26 + */
  27 + public function Index()
  28 + {
  29 + Log::record(sprintf('---%s %s CheckAttach START---', QY_DOMAIN, APP_IDENTIFIER), Log::INFO);
  30 +
  31 + $article_id = I('get.article_id', 0, 'intval');
  32 + $cron_id = I('get.cron_id', '', 'trim');
  33 + if (empty($article_id)) {
  34 + $this->_exit();
  35 + }
  36 +
  37 + $taskServ = new TaskService();
  38 + $task = $taskServ->get_by_conds(['article_id' => $article_id]);
  39 + // 本地未找到任务,删除UC的任务后退出
  40 + if (empty($task)) {
  41 + if (!empty($cron_id)) {
  42 + $this->_delTask($article_id, $cron_id);
  43 + }
  44 + Log::record("not found task, article_id: {$article_id}", Log::INFO);
  45 + $this->_exit();
  46 + }
  47 +
  48 + $cron_id = $task['cron_id'];
  49 + $articleServ = new ArticleService();
  50 + $article = $articleServ->get($article_id);
  51 +
  52 + // 未找到新闻,删除计划任务
  53 + if (empty($article)) {
  54 + Log::record("not found article, article_id: {$article_id}", Log::INFO);
  55 + $this->_delTask($article_id, $cron_id);
  56 + }
  57 +
  58 + // 获取附件
  59 + $attachServ = new AttachService();
  60 + $list = $attachServ->list_by_conds(['article_id' => $article_id]);
  61 + $attachs = $attachServ->formatDBData($list);
  62 +
  63 + // 未找到附件,删除计划任务
  64 + if (empty($attachs)) {
  65 + Log::record("not found attach, article_id: {$article_id}", Log::INFO);
  66 + $this->_delTask($article_id, $cron_id);
  67 + }
  68 +
  69 + $convertServ = new FileConvert(Service::instance());
  70 +
  71 + $at_convert_status = [];
  72 + foreach ($attachs as $k => $data) {
  73 + // 仅处理文件 (视频现在必须转码完成后才能提交,因此不会在保存后进行转码)
  74 + if (!in_array($k, [Constant::ATTACH_TYPE_FILE])) {
  75 + continue;
  76 + }
  77 +
  78 + foreach ($data as $attach) {
  79 + // 已完成
  80 + if (!empty($attach['at_convert_url'])) {
  81 + continue;
  82 + }
  83 +
  84 + $at_convert_url = '';
  85 + // 默认转码中
  86 + $at_convert_status[$attach['at_id']] = Constant::FILE_STATUS_CONVERT;
  87 +
  88 + switch ($k) {
  89 + // 视频 (视频现在必须转码完成后才能提交,因此不会在保存后进行转码;但此段代码暂时保留)
  90 + case Constant::ATTACH_TYPE_VIDEO:
  91 + $result = $convertServ->getVodPlayUrl($attach['at_id']);
  92 + if (is_array($result) && (isset($result['url']) || isset($result['hd']))) {
  93 + $at_convert_url = str_replace('http://', '//', (!empty($result['hd']) ? $result['hd'] : $result['url']));
  94 + $at_convert_url = str_replace('https://', '//', $at_convert_url);
  95 +
  96 + // 视频封面地址
  97 + $at_cover_url = str_replace('http://', '//', $result['coverUrl']);
  98 + $at_cover_url = str_replace('https://', '//', $at_cover_url);
  99 +
  100 + // 转码成功
  101 + $at_convert_status[$attach['at_id']] = Constant::FILE_STATUS_NORMAL;
  102 + }
  103 + break;
  104 +
  105 + // 文件
  106 + case Constant::ATTACH_TYPE_FILE:
  107 + $result = $convertServ->get($attach['at_id']);
  108 + if (is_array($result) && isset($result['caConvertStatus'])) {
  109 + // 转码成功
  110 + if ($result['caConvertStatus'] == FileConvert::CONVERT_STATUS_SUCCESS) {
  111 + $at_convert_url = $result['caAttachment'];
  112 + $at_convert_status[$attach['at_id']] = Constant::FILE_STATUS_NORMAL;
  113 + }
  114 +
  115 + // 转码失败(状态不是:待处理、转码中、成功,即为失败)
  116 + $normalStatus = [
  117 + FileConvert::CONVERT_STATUS_WATTING,
  118 + FileConvert::CONVERT_STATUS_ING,
  119 + FileConvert::CONVERT_STATUS_SUCCESS,
  120 + ];
  121 + if (!in_array($result['caConvertStatus'], $normalStatus)) {
  122 + $at_convert_status[$attach['at_id']] = Constant::FILE_STATUS_FAIL;
  123 + }
  124 + }
  125 + break;
  126 + }
  127 +
  128 + // 更新文件转码地址
  129 + if (!empty($at_convert_url)) {
  130 + $attachServ->update(
  131 + $attach['attach_id'],
  132 + [
  133 + 'at_convert_url' => $at_convert_url,
  134 + 'at_cover_url' => isset($at_cover_url) ? $at_cover_url : ''
  135 + ]
  136 + );
  137 + Log::record("convert success, attach_id: {$attach['attach_id']}, at_convert_url: {$at_convert_url}", Log::INFO);
  138 + }
  139 + }
  140 + }
  141 +
  142 + // 所有需转码文件的转码状态
  143 + $convert_status = array_unique(array_values($at_convert_status));
  144 +
  145 + // 新闻转码失败(将新闻发布状态改为"草稿",文件转码状态改为"转码失败")
  146 + if (in_array(Constant::FILE_STATUS_FAIL, $convert_status)) {
  147 + $articleServ->update($article_id, ['news_status' => Constant::NEWS_STATUS_DRAFT, 'convert_status' => Constant::FILE_STATUS_FAIL]);
  148 + Log::record("update article news_status, article_id: {$article_id}", Log::INFO);
  149 + // 结束任务
  150 + $this->_delTask($article_id, $cron_id);
  151 + }
  152 +
  153 + // 新闻转码成功
  154 + if (count($convert_status) == 1 && in_array(Constant::FILE_STATUS_NORMAL, $convert_status)) {
  155 + if ($article['news_status'] == Constant::NEWS_STATUS_READY_SEND) {
  156 + // 修改文件发布状态、转码状态
  157 +
  158 + // 修改转码状态为已转码,当发布状态不为定时发布时修改为已发布,否则不做修改
  159 + $updateData = ['convert_status' => Constant::FILE_STATUS_NORMAL];
  160 + if ($article['news_status'] != Constant::NEWS_STATUS_TIMING_RELEASE) {
  161 + $updateData['news_status'] = Constant::NEWS_STATUS_SEND;
  162 + }
  163 + $articleServ->update($article_id, $updateData);
  164 + Log::record("update article news_status, article_id: {$article_id}", Log::INFO);
  165 +
  166 + // 当为发布时
  167 + if (isset($updateData['news_status'])) {
  168 + // 获取顶级分类名称
  169 + $classServ = new ClassService();
  170 + $class = $classServ->getTopClass($article['class_id']);
  171 + $article['class_name'] = $class['class_name'];
  172 +
  173 + // 发送未读提醒
  174 + if ($article['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) {
  175 + $newsHelper = &NewsHelper::instance();
  176 + list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($article_id);
  177 + $newsHelper->sendUnreadMsg($uids_unread, $article);
  178 + }
  179 +
  180 + // RPC推送到运营中心
  181 + if ($article['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) {
  182 + $articleServ->addNewsRpc($article_id, []);
  183 + }
  184 + }
  185 + }
  186 +
  187 + // 结束任务
  188 + $this->_delTask($article_id, $cron_id);
  189 + }
  190 +
  191 + $this->_exit();
  192 + }
  193 +
  194 + /**
  195 + * 退出
  196 + * @author zhonglei
  197 + * @return void
  198 + */
  199 + private function _exit()
  200 + {
  201 + // 日志结束
  202 + Log::record(sprintf('---%s %s CheckAttach END---', QY_DOMAIN, APP_IDENTIFIER), Log::INFO);
  203 + exit('SUCCESS');
  204 + }
  205 +
  206 + /**
  207 + * 删除计划任务并退出
  208 + * @author zhonglei
  209 + * @param int $article_id 新闻ID
  210 + * @param string $cron_id 计划任务ID
  211 + * @return void
  212 + */
  213 + private function _delTask($article_id, $cron_id)
  214 + {
  215 + $taskServ = new TaskService();
  216 + $taskServ->delete_by_conds([
  217 + 'article_id' => $article_id,
  218 + 'cron_id' => $cron_id,
  219 + ]);
  220 +
  221 + $cronSdk = new Cron(Service::instance());
  222 + $cronSdk->delete($cron_id);
  223 +
  224 + Log::record("delete task: {$cron_id}", Log::INFO);
  225 + $this->_exit();
  226 + }
  227 +}
... ...
trunk/Message/Frontend/Controller/Callback/CheckRightController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei2012it
  5 + * Date: 17/6/26
  6 + * Time: 16:14
  7 + */
  8 +namespace Frontend\Controller\Callback;
  9 +
  10 +use Think\Log;
  11 +use Common\Common\Constant;
  12 +use Common\Common\ResAuth;
  13 +use Common\Service\ArticleService;
  14 +use Common\Service\ClassService;
  15 +use Common\Service\RightService;
  16 +
  17 +class CheckRightController extends AbstractController
  18 +{
  19 + public function Index()
  20 + {
  21 + Log::record(sprintf('---%s %s CheckRight Start ---', QY_DOMAIN, APP_DIR), Log::INFO);
  22 +
  23 + // 鉴权失败:缺少必传参数(用户信息、权限载体ID)
  24 + $auth = I('post.auth');
  25 + $id = I('post._id', 0, 'intval');
  26 +
  27 + if (empty($auth)) {
  28 + Log::record(sprintf('---%s %s CheckRight FAIL : uc param missing---', QY_DOMAIN, APP_DIR), Log::INFO);
  29 + Log::record('post: ' . var_export($_POST, true), Log::INFO);
  30 + exit('FAIL');
  31 + }
  32 +
  33 + // 用户信息(管理员 or 普通用户)
  34 + $resAuth = &ResAuth::instance();
  35 + $data = $resAuth->parseSecret($auth);
  36 + if (empty($data)) {
  37 + Log::record(sprintf('---%s %s CheckRight Fail : parseSecret empty---', QY_DOMAIN, APP_DIR), Log::INFO);
  38 + exit('FAIL');
  39 + }
  40 +
  41 + switch ($data['user_type']) {
  42 + // 管理员
  43 + case ResAuth::USER_TYPE_ADMIN:
  44 + Log::record(sprintf('---%s %s CheckRight OK : admin logined---', QY_DOMAIN, APP_DIR), Log::INFO);
  45 + exit('OK');
  46 +
  47 + // 手机端登录用户
  48 + case ResAuth::USER_TYPE_MOBILE:
  49 + // 鉴权失败:文章不存在
  50 + $articleServ = new ArticleService();
  51 + $article = $articleServ->get($id);
  52 + if (empty($article)) {
  53 + Log::record(sprintf('---%s %s CheckRight FAIL : article not found or news status error---', QY_DOMAIN, APP_DIR), Log::INFO);
  54 + exit('FAIL');
  55 + }
  56 +
  57 + // 鉴权失败:课程分类不存在或未开启
  58 + $classServ = new ClassService();
  59 + $class = $classServ->get($article['class_id']);
  60 + if (empty($class) || $class['is_open'] != Constant::CLASS_IS_OPEN_TRUE) {
  61 + Log::record(sprintf('---%s %s CheckRight FAIL : class not found or already closed---', QY_DOMAIN, APP_DIR), Log::INFO);
  62 + exit('FAIL');
  63 + }
  64 +
  65 + // 鉴权失败:手机端登录人员无查看权限
  66 + $rightServ = new RightService();
  67 + $checkRes = $rightServ->checkUserRight($data['user'], $id);
  68 +
  69 + // 超过1S记录日志
  70 + if (time() * 1000 - MILLI_TIME >= 1000) {
  71 + Log::record('attach timeout', Log::ERR);
  72 + }
  73 +
  74 + if (!$checkRes) {
  75 + Log::record(sprintf('---%s %s CheckRight FAIL : have not right---', QY_DOMAIN, APP_DIR), Log::INFO);
  76 + exit('FAIL');
  77 + }
  78 + break;
  79 + }
  80 +
  81 + // 鉴权通过
  82 + Log::record(sprintf('---%s %s CheckRight END---', QY_DOMAIN, APP_DIR), Log::INFO);
  83 + exit('OK');
  84 + }
  85 +}
... ...
trunk/Message/Frontend/Controller/Callback/InstallController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: liyifei2012it
  5 + * Date: 17/6/13
  6 + * Time: 18:13
  7 + */
  8 +
  9 +namespace Frontend\Controller\Callback;
  10 +
  11 +class InstallController extends AbstractController
  12 +{
  13 + /**
  14 + * 应用默认数据安装接口
  15 + * @author liyifei
  16 + */
  17 + public function Index()
  18 + {
  19 + exit('SUCCESS');
  20 + }
  21 +}
... ...
trunk/Message/Frontend/Controller/Callback/ReleaseController.class.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * 定时发布回调
  4 + * Created by PhpStorm.
  5 + * User: 大熊
  6 + * Date: 2018/5/16
  7 + * Time: 19:21
  8 + */
  9 +
  10 +namespace Frontend\Controller\Callback;
  11 +
  12 +
  13 +use Common\Common\Constant;
  14 +use Common\Common\NewsHelper;
  15 +use Common\Service\ArticleService;
  16 +use Common\Service\ClassService;
  17 +use Think\Log;
  18 +
  19 +class ReleaseController extends AbstractController
  20 +{
  21 + public function index()
  22 + {
  23 + $param = $this->callBackData;
  24 + if (empty($param)) {
  25 + $param = I('post.');
  26 + }
  27 +
  28 + if (empty($param)) {
  29 + return true;
  30 + }
  31 +
  32 + // 获取数据信息
  33 + $service = new ArticleService();
  34 + $data = $service->get($param['article_id']);
  35 +
  36 + // 不为定时发布时不做处理
  37 + if ($data['news_status'] != Constant::NEWS_STATUS_TIMING_RELEASE) {
  38 + return true;
  39 + }
  40 +
  41 + // 判断素材状态,若转码成功则为发布状态,否则为预发布状态
  42 + $updateData = ['news_status' => Constant::NEWS_STATUS_SEND];
  43 + if ($data['convert_status'] == Constant::FILE_STATUS_CONVERT) {
  44 + $updateData['news_status'] = Constant::NEWS_STATUS_READY_SEND;
  45 + }
  46 +
  47 + $service->update($param['article_id'], $updateData);
  48 +
  49 + // 当为发布时
  50 + if ($updateData['news_status'] == Constant::NEWS_STATUS_SEND) {
  51 + // 获取顶级分类名称
  52 + $classServ = new ClassService();
  53 + $class = $classServ->getTopClass($data['class_id']);
  54 + $data['class_name'] = $class['class_name'];
  55 +
  56 + // 发送未读提醒
  57 + if ($data['is_notice'] == Constant::NEWS_IS_NOTICE_TRUE) {
  58 + $newsHelper = &NewsHelper::instance();
  59 + list($uids_all, $uids_read, $uids_unread) = $newsHelper->getReadData($param['article_id']);
  60 + $newsHelper->sendUnreadMsg($uids_unread, $data);
  61 + }
  62 +
  63 + // RPC推送到运营中心
  64 + if ($data['is_recommend'] == Constant::NEWS_IS_RECOMMEND_TRUE) {
  65 + $service->addNewsRpc($param['article_id'], []);
  66 + }
  67 + }
  68 +
  69 + return true;
  70 + }
  71 +}
0 72 \ No newline at end of file
... ...