心理咨询网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DoController.php 857B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @copyright (C)2016-2099 Hnaoyun Inc.
  4. * @author XingMeng
  5. * @email hnxsh@foxmail.com
  6. * @date 2018年3月8日
  7. *
  8. */
  9. namespace app\api\controller;
  10. use core\basic\Controller;
  11. use app\api\model\DoModel;
  12. class DoController extends Controller
  13. {
  14. private $model;
  15. public function __construct()
  16. {
  17. $this->model = new DoModel();
  18. }
  19. // 点赞
  20. public function likes()
  21. {
  22. if (! ! $id = request('id', 'int')) {
  23. $this->model->addLikes($id);
  24. json(1, '点赞成功');
  25. } else {
  26. json(0, '点赞失败');
  27. }
  28. }
  29. // 反对
  30. public function oppose()
  31. {
  32. if (! ! $id = request('id', 'int')) {
  33. $this->model->addOppose($id);
  34. json(1, '反对成功');
  35. } else {
  36. json(0, '反对失败');
  37. }
  38. }
  39. }