CommentController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * CommentController.php UTF-8
  4. * 评论
  5. *
  6. * @date : 2018/8/23 16:43
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HuoMp 1.0
  11. */
  12. namespace box\api\controller;
  13. use box\common\controller\V2ApiBaseController;
  14. use huo\controller\comment\Comment;
  15. class CommentController extends V2ApiBaseController {
  16. /**
  17. * 游戏评论列表
  18. * http://doc.huosdk.com/159?page_id=4497
  19. * 【域名】/game/comment/list
  20. */
  21. public function getList() {
  22. $_param = $this->request->param();
  23. $result = $this->validate($_param, 'Comment.list');
  24. if ($result !== true) {
  25. $this->error($result);
  26. }
  27. $_page = $this->request->param('page/d', 1);
  28. $_offset = $this->request->param('offset/d', 10);
  29. $_comment_class = new Comment();
  30. $_data['type_name'] = 'game';
  31. $_data['object_id'] = $_param['game_id'];
  32. $_rdata = $_comment_class->getList($_data, $_page.','.$_offset);
  33. $this->returnData($_rdata);
  34. }
  35. /**
  36. * 我的游戏评论列表
  37. * http://doc.huosdk.com/159?page_id=4499
  38. * 【域名】/game/comment/mylist
  39. */
  40. public function myList() {
  41. $this->checkLogin();
  42. $_page = $this->request->param('page/d', 1);
  43. $_offset = $this->request->param('offset/d', 10);
  44. $_mem_id = $this->getMemId();
  45. $_comment_class = new Comment();
  46. $_rdata = $_comment_class->getMyGameCommentList($_mem_id, $_page.','.$_offset);
  47. $this->returnData($_rdata);
  48. }
  49. /**
  50. * 添加评论
  51. * http://doc.huosdk.com/159?page_id=4503
  52. * 【域名】/game/comment/add
  53. */
  54. public function add() {
  55. $this->checkLogin();
  56. $_param = $this->request->param();
  57. $result = $this->validate($_param, 'Comment.add');
  58. if ($result !== true) {
  59. $this->error($result);
  60. }
  61. $_data['object_id'] = $_param['game_id'];
  62. $_data['content'] = $_param['content'];
  63. $_data['table_name'] = 'game';
  64. $_mem_id = $this->getMemId();
  65. $_comment_class = new Comment();
  66. $_rdata = $_comment_class->addComment($_data, $_mem_id);
  67. $this->returnData($_rdata);
  68. }
  69. }