CommentsController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * CommentsController.php UTF-8
  4. *
  5. *
  6. * @date : 2018/6/11 18:42
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\wapapp\controller\v8;
  13. use api\common\controller\V2ApiBaseController;
  14. use huo\controller\comment\Comment;
  15. use think\Lang;
  16. class CommentsController extends V2ApiBaseController {
  17. public function _initialize() {
  18. parent::_initialize();
  19. $langSet = $this->request->langset();
  20. Lang::load([APP_PATH.'wapapp'.DS.'lang'.DS.$langSet.DS.'comments'.EXT,]);
  21. }
  22. /**
  23. * 评论列表
  24. * http://doc.1tsdk.com/95?page_id=2389
  25. *【域名】/v8/comments/list
  26. */
  27. public function index() {
  28. $_param = $this->request->param();
  29. $result = $this->validate($_param, 'Comment.list');
  30. if ($result !== true) {
  31. $this->error($result);
  32. }
  33. $_page = $this->request->param('page/d', 1);
  34. $_offset = $this->request->param('offset/d', 10);
  35. $_comment_class = new Comment();
  36. // $_rs = $_comment_class->getList($_param, $_page.','.$_offset);
  37. $this->returnData($_rs);
  38. }
  39. /**
  40. * 添加评论
  41. * http://doc.1tsdk.com/95?page_id=2390
  42. *【域名】/v8/comments/add
  43. */
  44. public function save() {
  45. $this->checkLogin();
  46. $_mem_id = $this->getMemId();
  47. $_param = $this->request->param();
  48. $result = $this->validate($_param, 'Comment.list');
  49. if ($result !== true) {
  50. $this->error($result);
  51. }
  52. $_comment_class = new Comment();
  53. $_rs = $_comment_class->addComment($_param, $_mem_id);
  54. $this->returnData($_rs);
  55. }
  56. }