Video.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\marketing\video;
  12. use app\controller\admin\AuthController;
  13. use app\services\activity\video\VideoServices;
  14. use think\facade\App;
  15. /**
  16. * 短视频控制器
  17. * Class Video
  18. * @package app\controller\admin\v1\marketing\video
  19. */
  20. class Video extends AuthController
  21. {
  22. /**
  23. * Video constructor.
  24. * @param App $app
  25. * @param VideoServices $service
  26. */
  27. public function __construct(App $app, VideoServices $service)
  28. {
  29. parent::__construct($app);
  30. $this->services = $service;
  31. }
  32. /**
  33. * 分类列表
  34. * @return mixed
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\DbException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. */
  39. public function index()
  40. {
  41. $where = $this->request->getMore([
  42. ['data', '', '', 'time'],
  43. ['keyword', ''],
  44. ['is_verify', '']
  45. ]);
  46. $where['is_del'] = 0;
  47. return $this->success($this->services->sysPage($where));
  48. }
  49. /**
  50. * 获取视频信息
  51. * @param $id
  52. * @return mixed
  53. */
  54. public function info($id)
  55. {
  56. if (!$id) return $this->fail('缺少参数');
  57. return $this->success($this->services->getInfo((int)$id));
  58. }
  59. /**
  60. * 保存新增分类
  61. * @return mixed
  62. */
  63. public function save($id)
  64. {
  65. $data = $this->request->postMore([
  66. ['image', ''],
  67. ['desc', ''],
  68. ['video_url', ''],
  69. ['product_id', []],
  70. ['is_show', 1],
  71. ['is_recommend', 0],
  72. ['sort', 0]
  73. ]);
  74. $data['type'] = 0;
  75. $data['relation_id'] = 0;
  76. $data['is_verify'] = 1;
  77. if ($id) {
  78. $info = $this->services->get($id);
  79. if (!$info) {
  80. $this->fail('视频不存在');
  81. }
  82. $this->services->update($id, $data);
  83. } else {
  84. $data['add_time'] = time();
  85. $this->services->save($data);
  86. }
  87. return $this->success('添加视频成功!');
  88. }
  89. /**
  90. * 修改状态
  91. * @param string $is_show
  92. * @param string $id
  93. */
  94. public function set_show($id = '', $status = '')
  95. {
  96. if ($status == '' || $id == '') return $this->fail('缺少参数');
  97. $this->services->update($id, ['is_show' => $status]);
  98. return $this->success($status == 1 ? '显示成功' : '隐藏成功');
  99. }
  100. /**
  101. * 审核
  102. * @param $id
  103. * @param $verify
  104. * @return mixed
  105. */
  106. public function verify($id, $verify)
  107. {
  108. if ($verify == '' || $id == '') return $this->fail('缺少参数');
  109. $info = $this->services->get($id);
  110. if (!$info) {
  111. $this->fail('视频不存在');
  112. }
  113. if ($verify == 1) {
  114. $verify = 1;
  115. } else {//拒绝通过
  116. $verify = -1;
  117. }
  118. $this->services->update($id, ['is_verify' => $verify]);
  119. return $this->success('审核成功');
  120. }
  121. /**
  122. * 推荐
  123. * @param $id
  124. * @param $recommend
  125. * @return mixed
  126. */
  127. public function recommend($id, $recommend)
  128. {
  129. if ($recommend == '' || $id == '') return $this->fail('缺少参数');
  130. $info = $this->services->get($id);
  131. if (!$info) {
  132. $this->fail('视频不存在');
  133. }
  134. $this->services->update($id, ['is_recommend' => $recommend]);
  135. return $this->success($recommend == 1 ? '推荐成功' : '取消推荐');
  136. }
  137. /**
  138. * 强制下架
  139. * @param $id
  140. * @param $recommend
  141. * @return mixed
  142. */
  143. public function takeDown($id)
  144. {
  145. if ($id == '') return $this->fail('缺少参数');
  146. $info = $this->services->get($id);
  147. if (!$info) {
  148. $this->fail('视频不存在');
  149. }
  150. $this->services->update($id, ['is_verify' => -2, 'is_show' => 0, 'is_recommend' => 0]);
  151. return $this->success('下架成功');
  152. }
  153. /**
  154. * 删除视频
  155. * @param $id
  156. * @return mixed
  157. */
  158. public function delete($id)
  159. {
  160. if ($id == '') return $this->fail('缺少参数');
  161. $info = $this->services->get($id);
  162. if ($info) {
  163. $this->services->update($id, ['is_del' => 1]);
  164. }
  165. return $this->success('删除成功!');
  166. }
  167. }