Video.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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\store\marketing\video;
  12. use app\controller\store\AuthController;
  13. use app\services\activity\video\VideoServices;
  14. use think\facade\App;
  15. /**
  16. * 短视频控制器
  17. * Class Video
  18. * @package app\admin\controlle\store\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['type'] = 1;
  47. $where['relation_id'] = $this->storeId;
  48. $where['is_del'] = 0;
  49. return $this->success($this->services->sysPage($where));
  50. }
  51. /**
  52. * 获取视频信息
  53. * @param $id
  54. * @return mixed
  55. */
  56. public function info($id)
  57. {
  58. if (!$id) return $this->fail('缺少参数');
  59. return $this->success($this->services->getInfo((int)$id));
  60. }
  61. /**
  62. * 保存新增分类
  63. * @return mixed
  64. */
  65. public function save($id)
  66. {
  67. $data = $this->request->postMore([
  68. ['image', ''],
  69. ['desc', ''],
  70. ['video_url', ''],
  71. ['product_id', []],
  72. ['is_show', 1],
  73. ['is_recommend', 0],
  74. ['sort', 0]
  75. ]);
  76. $data['type'] = 1;
  77. $data['relation_id'] = $this->storeId;
  78. if ($id) {
  79. $info = $this->services->get($id);
  80. if (!$info) {
  81. $this->fail('视频不存在');
  82. }
  83. $data['is_verify'] = 0;
  84. $this->services->update($id, $data);
  85. } else {
  86. $data['add_time'] = time();
  87. $this->services->save($data);
  88. }
  89. return $this->success('添加视频成功!');
  90. }
  91. /**
  92. * 修改状态
  93. * @param string $status
  94. * @param string $id
  95. */
  96. public function set_show($id = '', $status = '')
  97. {
  98. if ($status == '' || $id == '') return $this->fail('缺少参数');
  99. $this->services->update($id, ['is_show' => $status]);
  100. return $this->success($status == 1 ? '显示成功' : '隐藏成功');
  101. }
  102. /**
  103. * 删除视频
  104. * @param $id
  105. * @return mixed
  106. */
  107. public function delete($id)
  108. {
  109. if ($id == '') return $this->fail('缺少参数');
  110. $info = $this->services->get($id);
  111. if ($info) {
  112. $this->services->update($id, ['is_del' => 1]);
  113. }
  114. return $this->success('删除成功!');
  115. }
  116. }