You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Config.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\controller\store\system;
  3. use app\controller\store\AuthController;
  4. use app\services\store\StoreConfigServices;
  5. use app\services\system\config\SystemConfigServices;
  6. use app\services\system\config\SystemConfigTabServices;
  7. use think\facade\App;
  8. use app\Request;
  9. /**
  10. * Class Config
  11. * @package app\controller\store\system
  12. */
  13. class Config extends AuthController
  14. {
  15. /**
  16. * Config constructor.
  17. * @param App $app
  18. * @param SystemConfigServices $services
  19. */
  20. public function __construct(App $app, SystemConfigServices $services)
  21. {
  22. parent::__construct($app);
  23. $this->services = $services;
  24. }
  25. /**
  26. * @param $type
  27. * @param StoreConfigServices $services
  28. * @return mixed
  29. */
  30. public function getConfig($type, StoreConfigServices $services)
  31. {
  32. if (!isset(StoreConfigServices::CONFIG_TYPE[$type])) {
  33. return $this->fail('类型不正确');
  34. }
  35. return $this->success($services->getConfigAll($this->storeId, StoreConfigServices::CONFIG_TYPE[$type]));
  36. }
  37. /**
  38. * 保存数据
  39. * @param $type
  40. * @param StoreConfigServices $services
  41. * @return mixed
  42. */
  43. public function save($type, StoreConfigServices $services)
  44. {
  45. if (!isset(StoreConfigServices::CONFIG_TYPE[$type])) {
  46. return $this->fail('类型不正确');
  47. }
  48. $data = $this->request->postMore(StoreConfigServices::CONFIG_TYPE[$type]);
  49. $services->saveConfig($data, $this->storeId);
  50. return $this->success('修改成功');
  51. }
  52. /**
  53. * 基础配置
  54. * @param Request $request
  55. * @param SystemConfigServices $services
  56. * @param SystemConfigTabServices $tabServices
  57. * @return
  58. * @throws \FormBuilder\Exception\FormBuilderException
  59. * @throws \think\db\exception\DataNotFoundException
  60. * @throws \think\db\exception\DbException
  61. * @throws \think\db\exception\ModelNotFoundException
  62. */
  63. public function edit_basics(Request $request, SystemConfigServices $services, SystemConfigTabServices $tabServices)
  64. {
  65. $name = $this->request->param('name', '');
  66. if (!$name) {
  67. return $this->fail('参数错误');
  68. }
  69. $tabId = $tabServices->value(['eng_title' => $name], 'id');
  70. $url = $request->baseUrl();
  71. $store_id = $this->storeId;
  72. return $this->success($services->getConfigForm($url, $tabId, $store_id));
  73. }
  74. }