Comment.php 911 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\home\controller;
  3. use think\Controller;
  4. use app\user\model\UserComment;
  5. use think\Config;
  6. class Comment extends Controller {
  7. private $commentModel;
  8. public function _initialize(){
  9. parent::_initialize();
  10. $this->commentModel = new UserComment();
  11. }
  12. public function index(){
  13. $data = decode($this->request->post());
  14. $user = $data['u'];
  15. $page = $data['p'];
  16. $type = $data['t'];
  17. $info = $this->commentModel->getInfo($user, $type, $page);
  18. return json(["l"=>$info]);
  19. }
  20. public function comment(){
  21. $data = decode($this->request->post());
  22. $user = $data['u'];
  23. $comment = $data['c'];
  24. $content = $data['i'];
  25. $type = $data['t'];
  26. $data = ['id'=>getId(), 'user_id'=>$user, 'comment_id'=>$comment, 'content'=>$content, 'type'=>$type];
  27. $this->commentModel->add($data);
  28. return json(['error'=>0]);
  29. }
  30. }