Express.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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\setting;
  13. use app\store\controller\Controller;
  14. use app\store\model\Express as ExpressModel;
  15. /**
  16. * 物流公司
  17. * Class Express
  18. * @package app\store\controller\setting
  19. */
  20. class Express extends Controller
  21. {
  22. /**
  23. * 物流公司列表
  24. * @return array
  25. * @throws \think\db\exception\DbException
  26. */
  27. public function list()
  28. {
  29. $model = new ExpressModel;
  30. $list = $model->getList($this->request->param());
  31. return $this->renderSuccess(compact('list'));
  32. }
  33. /**
  34. * 获取全部记录
  35. * @return array
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function all()
  41. {
  42. $model = new ExpressModel;
  43. $list = $model->getAll($this->request->param());
  44. return $this->renderSuccess(compact('list'));
  45. }
  46. /**
  47. * 删除物流公司
  48. * @param int $expressId
  49. * @return array
  50. * @throws \Exception
  51. */
  52. public function delete(int $expressId)
  53. {
  54. $model = ExpressModel::detail($expressId);
  55. if (!$model->remove()) {
  56. return $this->renderError($model->getError() ?: '删除失败');
  57. }
  58. return $this->renderSuccess('删除成功');
  59. }
  60. /**
  61. * 添加物流公司
  62. * @return array|mixed
  63. */
  64. public function add()
  65. {
  66. // 新增记录
  67. $model = new ExpressModel;
  68. if ($model->add($this->postForm())) {
  69. return $this->renderSuccess('添加成功');
  70. }
  71. return $this->renderError($model->getError() ?: '添加失败');
  72. }
  73. /**
  74. * 编辑物流公司
  75. * @param $expressId
  76. * @return array|mixed
  77. */
  78. public function edit(int $expressId)
  79. {
  80. // 模板详情
  81. $model = ExpressModel::detail($expressId);
  82. // 更新记录
  83. if ($model->edit($this->postForm())) {
  84. return $this->renderSuccess('更新成功');
  85. }
  86. return $this->renderError($model->getError() ?: '更新失败');
  87. }
  88. }