1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\newhome\controller;
- use think\Controller;
- use app\user\model\UserComment;
- class Comment extends Controller {
-
- private $commentModel;
-
- public function _initialize(){
- parent::_initialize();
-
- $this->commentModel = new UserComment();
- }
-
- public function index(){
- $data = decode($this->request->post());
-
- $user = $data['u'];
- $page = $data['p'];
- $type = $data['t'];
-
- $info = $this->commentModel->getInfo($user, $type, $page);
-
- return json(["l"=>$info]);
- }
-
- public function find(){
- $data = decode($this->request->post());
-
- $user = $data['u'];
- $comment = $data['c'];
- $page = $data['p'];
- $type = $data['t'];
-
- $info = $this->commentModel->getInfoByComment($user, $comment, $type, $page);
-
- return json(["l"=>$info]);
- }
-
- public function comment(){
- $data = decode($this->request->post());
-
- $user = $data['u'];
- $comment = $data['c'];
- $content = $data['i'];
- $type = $data['t'];
-
- $data = ['id'=>getId(), 'user_id'=>$user, 'comment_id'=>$comment, 'content'=>$content, 'type'=>$type];
- $this->commentModel->add($data);
-
- return json(['error'=>0]);
- }
-
- }
|