Gift.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\supplier\controller\live;
  3. use app\supplier\controller\Controller;
  4. use app\supplier\model\live\Gift as GiftModel;
  5. /**
  6. * 礼物控制器
  7. */
  8. class Gift extends Controller
  9. {
  10. /**
  11. * 列表
  12. */
  13. public function index()
  14. {
  15. $model = new GiftModel();
  16. $list = $model->getList($this->postData());
  17. return $this->renderSuccess('', compact('list'));
  18. }
  19. /**
  20. * 添加
  21. */
  22. public function add()
  23. {
  24. $model = new GiftModel();
  25. // 新增记录
  26. if ($model->add($this->postData())) {
  27. return $this->renderSuccess('添加成功');
  28. }
  29. return $this->renderError('添加失败');
  30. }
  31. /**
  32. * 更新
  33. */
  34. public function edit($gift_id)
  35. {
  36. $detail = GiftModel::detail($gift_id);
  37. if($this->request->isGet()){
  38. return $this->renderSuccess('', compact('detail'));
  39. }
  40. if ($detail->edit($this->postData())) {
  41. return $this->renderSuccess('更新成功');
  42. }
  43. return $this->renderError('更新失败');
  44. }
  45. /**
  46. * 删除
  47. */
  48. public function delete($gift_id)
  49. {
  50. // 详情
  51. $model = new GiftModel;
  52. // 更新记录
  53. if ($model->setDelete(['gift_id' => $gift_id])) {
  54. return $this->renderSuccess('删除成功');
  55. }
  56. return $this->renderError('删除失败');
  57. }
  58. }