Comment.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. class Comment extends Base
  7. {
  8. public function __construct(App $app = null) {
  9. parent::__construct($app);
  10. $this->model = new \app\common\model\Comment();
  11. }
  12. public function add(){
  13. $jsonArray=[
  14. 'score'=>input('score'),
  15. 'content'=>input('content'),
  16. 'userId'=>$this->userId,
  17. 'type'=>input('type'),
  18. 'fromId'=>input('fromId'),
  19. 'orgId'=>$this->orgId
  20. ];
  21. $ret=$this->model->addSave($jsonArray);
  22. if($ret){
  23. HelpHander::success([],'添加成功');
  24. }else{
  25. HelpHander::error($this->model->getError());
  26. }
  27. }
  28. public function detail(){
  29. $id = input('id');
  30. $ret = $this->model->details($id);
  31. if($ret){
  32. HelpHander::success($ret);
  33. }else{
  34. HelpHander::error('暂无信息');
  35. }
  36. }
  37. public function list(){
  38. $page = input('page/d',1);
  39. $size = input('size/d',20);
  40. $ret = $this->model->lists($this->userId,$this->orgId,$page,$size);
  41. HelpHander::success($ret);
  42. }
  43. }