LiveAnchor.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\marketing\live;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\activity\live\LiveAnchorServices;
  14. use think\facade\App;
  15. /**
  16. * 直播间主播
  17. * Class LiveAnchor
  18. * @package app\controller\admin\store
  19. */
  20. class LiveAnchor extends AuthController
  21. {
  22. /**
  23. * LiveAnchor constructor.
  24. * @param App $app
  25. * @param LiveAnchorServices $services
  26. */
  27. public function __construct(App $app, LiveAnchorServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 列表
  34. * @return mixed
  35. */
  36. public function list()
  37. {
  38. $where = $this->request->postMore([
  39. ['kerword', ''],
  40. ]);
  41. return app('json')->success($this->services->getList($where));
  42. }
  43. /**
  44. * 添加修改表单
  45. * @return mixed
  46. */
  47. public function add()
  48. {
  49. list($id) = $this->request->getMore([
  50. ['id', 0],
  51. ], true);
  52. return app('json')->success($this->services->add((int)$id));
  53. }
  54. /**
  55. * 保存标签表单数据
  56. * @return mixed
  57. */
  58. public function save()
  59. {
  60. $data = $this->request->postMore([
  61. ['id', 0],
  62. ['name', ''],
  63. ['wechat', ''],
  64. ['phone', ''],
  65. ['cover_img', '']
  66. ]);
  67. $this->validate($data, \app\adminapi\validate\marketing\LiveAnchorValidate::class, 'save');
  68. $res = $this->services->save((int)$data['id'], $data);
  69. if ($res === true) {
  70. return app('json')->success(100000, ['auth' => false]);
  71. }else{
  72. return app('json')->fail(100006);
  73. }
  74. }
  75. /**
  76. * 删除
  77. * @return mixed
  78. * @throws \Exception
  79. */
  80. public function delete()
  81. {
  82. list($id) = $this->request->getMore([
  83. ['id', 0],
  84. ], true);
  85. if (!$id) return app('json')->fail(100100);
  86. $this->services->delAnchor((int)$id);
  87. return app('json')->success(100002);
  88. }
  89. /**
  90. * 设置会员等级显示|隐藏
  91. * @param string $id
  92. * @param string $is_show
  93. * @return mixed
  94. */
  95. public function setShow($id = '', $is_show = '')
  96. {
  97. if ($is_show == '' || $id == '') return app('json')->fail(100100);
  98. $this->services->setShow((int)$id, (int)$is_show);
  99. return app('json')->success(100014);
  100. }
  101. /**
  102. * 同步主播
  103. * @return mixed
  104. */
  105. public function syncAnchor()
  106. {
  107. $this->services->syncAnchor();
  108. return app('json')->success(100038);
  109. }
  110. }