Commit 7bfe0d47282c178aa2841f9cf0409acb8610bdf6

Authored by zhang
1 parent 95a834ad

[留言板]后台评论添加

trunk/Message/Apicp/Controller/AbstractController.class.php 0 → 100644
  1 +<?php
  2 +namespace Apicp\Controller;
  3 +
  4 +use \Common\Controller\Apicp\AbstractController as BaseAbstractController;
  5 +
  6 +abstract class AbstractController extends BaseAbstractController
  7 +{
  8 +
  9 +}
... ...
trunk/Message/Apicp/Controller/Message/MessageController.class.php 0 → 100644
  1 +<?php
  2 +namespace Apicp\Controller\Message;
  3 +
  4 +use Apicp\Controller\AbstractController;
  5 +use Common\Model\MessageModel;
  6 +
  7 +class MessageController extends AbstractController
  8 +{
  9 + protected $_require_login = false;
  10 + private $m_message; // MessageModel 模型对象
  11 +
  12 + public function __construct()
  13 + {
  14 + parent::__construct();
  15 +
  16 + $this->m_message = new MessageModel;
  17 + }
  18 + /**
  19 + * 留言删除
  20 + * @author <362431947@qq.com>
  21 + * @date 2018-10-10
  22 + */
  23 + public function del_post()
  24 + {
  25 + $input = I('post.');
  26 +
  27 + $message_id = intval($input['message_id']);
  28 + if(! $message_id){
  29 + E('_ERROR_MESSAGE_ID_EMPTY');
  30 + }
  31 +
  32 + $uid = intval($input['uid']);
  33 + if(! $uid){
  34 + E('_ERROR_USER_ID_EMPTY');
  35 + }
  36 +
  37 + $result = $this->m_message->del($message_id);
  38 +
  39 + $this->_result = boolval($result);
  40 + }
  41 +
  42 + /**
  43 + * 搜索 搜索(按姓名、性别、手机号、邮箱以及留言标题进行或查询)、列表、留言详情查看
  44 + * @author <362431947@qq.com>
  45 + * @date 2018-10-10
  46 + * @return [type]
  47 + */
  48 + public function search_post()
  49 + {
  50 + $input = I('post.');
  51 +
  52 + $conds = $this->getConds($input);
  53 + if(false === $conds){
  54 + E('_ERROR_SEARCH_CONDS_EMPTY');
  55 + return false;
  56 + }
  57 +
  58 + $list = $this->m_message->search($conds);
  59 + $this->_result = $list;
  60 +
  61 + return true;
  62 + }
  63 +
  64 + /**
  65 + * 获取搜索条件
  66 + * @author <362431947@qq.com>
  67 + * @date 2018-10-10
  68 + * @param array $search 搜索条件
  69 + * @return [type]
  70 + */
  71 + private function getConds($search = [])
  72 + {
  73 + if(! $search){
  74 + return false;
  75 + }
  76 + $conds = [];
  77 + $fields = ['name','sex','mobile','email','title'];
  78 +
  79 + foreach ($fields as $field) {
  80 + if($val = trim($search[$field])){
  81 + $conds[$field] = $val;
  82 + }
  83 + }
  84 + return $conds;
  85 + }
  86 +}
... ...
trunk/Message/Apicp/Lang/zh-cn.php 0 → 100644
  1 +<?php
  2 +return [
  3 + '_ERR_POST_EMPTY' => '2018001:提交数据为空',
  4 + '_ERROR_PERSON_EMPTY' => '2018002:姓名为空',
  5 + '_ERROR_PERSON_NAME_LENGTH' => '2018003:姓名不能大于15个字符',
  6 + '_ERROR_LOGIN_EMPTY' => '2018004:登录信息错误',
  7 +
  8 + '_ERROR_TITLE_EMPTY' => '2018005:标题为空',
  9 + '_ERROR_MESSAGE_TITLE_LENGTH'=> '2018006:标题长度不能大于80个字符',
  10 + '_ERROR_MESSAGE_EMPTY' => '2018007:内容为空',
  11 + '_ERROR_MESSAGE_LENGTH' => '2018008:内容长度不能大于500个字符',
  12 + '_ERROR_USER_ID_EMPTY' => '2091009:用户id为空',
  13 + '_ERR_ID_EMPTY' => '2091003:id为空',
  14 +];
... ...
trunk/Message/Common/Model/CommentModel.class.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace Common\Model;
  4 +
  5 +class CommentModel extends AbstractModel
  6 +{
  7 + public function __construct()
  8 + {
  9 + parent::__construct();
  10 + }
  11 +
  12 + public function addOne($data)
  13 + {
  14 + return $this->_m->insert($data);
  15 + }
  16 +
  17 + /**
  18 + * 保存评论信息
  19 + * @author <362431947@qq.com>
  20 + * @date 2018-10-10
  21 + */
  22 + public function add($data = [])
  23 + {
  24 + $data['domain'] = md5($_SERVER['HTTP_HOST']);
  25 + $data['created'] = $this->microtime();
  26 + print_r($data);
  27 +
  28 + return $this->_m->insert($data);
  29 +
  30 + // $comment_id = $this->_m->insert($data);
  31 +
  32 +// $msg_comment = [
  33 +// 'message_id' => intval($data['message_id']),
  34 +// 'comment_id' => $comment_id,
  35 +// 'domain' => md5($_SERVER['HTTP_HOST']),
  36 +// 'created' => $this->microtime(),
  37 +// ];
  38 +
  39 +// $m_msg_comment = new MsgCommentModel();
  40 +//
  41 +// $id = $m_msg_comment->add($msg_comment);
  42 +//
  43 +// if($comment_id && $id){
  44 +// $this->_m->commit();
  45 +// $result = true;
  46 +// }
  47 +// else{
  48 +// $this->_m->rollback();
  49 +// $result = false;
  50 +// }
  51 +
  52 +// return $result;
  53 + }
  54 +
  55 + public function getCommentByMsgId($message_id = 0)
  56 + {
  57 + $params = [];
  58 + $wheres = [];
  59 +
  60 + $conds = ['message_id' =>$message_id];
  61 +
  62 + if (!$this->_parse_where($wheres, $params, $conds)) {
  63 + return false;
  64 + }
  65 +
  66 + $m_person = new PersonModel();
  67 + $table_person = $m_person->get_tname();
  68 +
  69 + $sql = "SELECT `comment`,b.name commenter
  70 + FROM __TABLE a
  71 + LEFT JOIN {$table_person} b ON a.uid = b.person_id
  72 + WHERE `message` = ? ";
  73 + return $this->_m->fetch_array($sql,$params);
  74 + }
  75 +
  76 + public function del($message_id = 0)
  77 + {
  78 + return $this->_m->delete($message_id);
  79 + }
  80 +}
... ...