ConfigValue.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\system\config;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\system\config\ConfigClassifyRepository;
  14. use app\common\repositories\system\config\ConfigValueRepository;
  15. use think\App;
  16. /**
  17. * Class ConfigValue
  18. * @package app\controller\admin\system\config
  19. * @author xaboy
  20. * @day 2020-03-27
  21. */
  22. class ConfigValue extends BaseController
  23. {
  24. /**
  25. * @var ConfigClassifyRepository
  26. */
  27. private $repository;
  28. /**
  29. * ConfigValue constructor.
  30. * @param App $app
  31. * @param ConfigValueRepository $repository
  32. */
  33. public function __construct(App $app, ConfigValueRepository $repository)
  34. {
  35. parent::__construct($app);
  36. $this->repository = $repository;
  37. }
  38. /**
  39. * @param string $key
  40. * @return mixed
  41. * @author xaboy
  42. * @day 2020-04-22
  43. */
  44. public function save($key)
  45. {
  46. $formData = $this->request->post();
  47. if (!count($formData)) return app('json')->fail('保存失败');
  48. /** @var ConfigClassifyRepository $make */
  49. $make = app()->make(ConfigClassifyRepository::class);
  50. if (!($cid = $make->keyById($key))) return app('json')->fail('保存失败');
  51. $this->repository->save($cid, $formData, $this->request->merId());
  52. return app('json')->success('保存成功');
  53. }
  54. }