Review.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | framework
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://framework.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/framework
  12. // +----------------------------------------------------------------------
  13. namespace app\wechat\controller\api;
  14. use app\wechat\service\MediaService;
  15. use library\Controller;
  16. use think\Db;
  17. /**
  18. * Class Review
  19. * @package app\wechat\controller\api
  20. */
  21. class Review extends Controller
  22. {
  23. /**
  24. * 图文展示
  25. * @param integer $id 图文ID
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. * @throws \think\exception\DbException
  29. */
  30. public function news($id = 0)
  31. {
  32. $this->news = MediaService::news(empty($id) ? input('id') : $id);
  33. $this->fetch();
  34. }
  35. /**
  36. * 文章展示
  37. * @param integer $id 文章ID
  38. * @throws \think\Exception
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. * @throws \think\exception\DbException
  42. * @throws \think\exception\PDOException
  43. */
  44. public function view($id = 0)
  45. {
  46. $where = ['id' => empty($id) ? input('id') : $id];
  47. Db::name('WechatNewsArticle')->where($where)->update(['read_num' => Db::raw('read_num+1')]);
  48. $this->info = Db::name('WechatNewsArticle')->where($where)->find();
  49. $this->fetch();
  50. }
  51. /**
  52. * 文本展示
  53. */
  54. public function text()
  55. {
  56. $this->content = strip_tags(input('content', ''), '<a><img>');
  57. $this->fetch();
  58. }
  59. /**
  60. * 图片展示
  61. */
  62. public function image()
  63. {
  64. $this->content = strip_tags(input('content', ''), '<a><img>');
  65. $this->fetch();
  66. }
  67. /**
  68. * 视频展示
  69. */
  70. public function video()
  71. {
  72. $this->url = strip_tags(input('url', ''), '<a><img>');
  73. $this->title = strip_tags(input('title', ''), '<a><img>');
  74. $this->fetch();
  75. }
  76. /**
  77. * 语音展示
  78. */
  79. public function voice()
  80. {
  81. $this->url = strip_tags(input('url', ''), '<a><img>');
  82. $this->fetch();
  83. }
  84. /**
  85. * 音乐展示
  86. */
  87. public function music()
  88. {
  89. $this->url = strip_tags(input('url', ''), '<a><img>');
  90. $this->desc = strip_tags(input('desc', ''), '<a><img>');
  91. $this->title = strip_tags(input('title', ''), '<a><img>');
  92. $this->fetch();
  93. }
  94. }