ConfigValue.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\controller\admin\system\config;
  3. use ln\basic\BaseController;
  4. use app\common\repositories\system\config\ConfigClassifyRepository;
  5. use app\common\repositories\system\config\ConfigValueRepository;
  6. use think\App;
  7. /**
  8. * Class ConfigValue
  9. * @package app\controller\admin\system\config
  10. * @author zfy
  11. * @day 2020-03-27
  12. */
  13. class ConfigValue extends BaseController
  14. {
  15. /**
  16. * @var ConfigClassifyRepository
  17. */
  18. private $repository;
  19. /**
  20. * ConfigValue constructor.
  21. * @param App $app
  22. * @param ConfigValueRepository $repository
  23. */
  24. public function __construct(App $app, ConfigValueRepository $repository)
  25. {
  26. parent::__construct($app);
  27. $this->repository = $repository;
  28. }
  29. /**
  30. * @param string $key
  31. * @return mixed
  32. * @author zfy
  33. * @day 2020-04-22
  34. */
  35. public function save($key)
  36. {
  37. $formData = $this->request->post();
  38. if (!count($formData)) return app('json')->fail('保存失败');
  39. /** @var ConfigClassifyRepository $make */
  40. $make = app()->make(ConfigClassifyRepository::class);
  41. if (!($cid = $make->keyById($key))) return app('json')->fail('保存失败');
  42. $this->repository->save($cid, $formData, $this->request->merId());
  43. return app('json')->success('保存成功');
  44. }
  45. }