Help.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\store\controller\content;
  13. use app\store\controller\Controller;
  14. use app\store\model\Help as HelpModel;
  15. /**
  16. * 帮助中心
  17. * Class help
  18. * @package app\store\controller\wxapp
  19. */
  20. class Help extends Controller
  21. {
  22. /**
  23. * 获取列表记录
  24. * @return array
  25. * @throws \think\db\exception\DbException
  26. */
  27. public function list()
  28. {
  29. $model = new HelpModel;
  30. $list = $model->getList();
  31. return $this->renderSuccess(compact('list'));
  32. }
  33. /**
  34. * 添加帮助
  35. * @return array|mixed
  36. */
  37. public function add()
  38. {
  39. // 新增记录
  40. $model = new HelpModel;
  41. if ($model->add($this->postForm())) {
  42. return $this->renderSuccess('添加成功');
  43. }
  44. return $this->renderError($model->getError() ?: '添加失败');
  45. }
  46. /**
  47. * 更新帮助
  48. * @param $helpId
  49. * @return array|mixed
  50. */
  51. public function edit(int $helpId)
  52. {
  53. // 帮助详情
  54. $model = HelpModel::detail($helpId);
  55. // 更新记录
  56. if ($model->edit($this->postForm())) {
  57. return $this->renderSuccess('更新成功');
  58. }
  59. return $this->renderError($model->getError() ?: '更新失败');
  60. }
  61. /**
  62. * 删除帮助
  63. * @param int $helpId
  64. * @return array
  65. */
  66. public function delete(int $helpId)
  67. {
  68. // 帮助详情
  69. $model = HelpModel::detail($helpId);
  70. if (!$model->setDelete()) {
  71. return $this->renderError($model->getError() ?: '删除失败');
  72. }
  73. return $this->renderSuccess('删除成功');
  74. }
  75. }