Cache.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\controller\admin\system;
  3. use app\common\repositories\system\CacheRepository;
  4. use ln\basic\BaseController;
  5. use ln\services\YunxinSmsService;
  6. use think\App;
  7. class Cache extends BaseController
  8. {
  9. /**
  10. * @var CacheRepository
  11. */
  12. protected $repository;
  13. /**
  14. * CacheRepository constructor.
  15. * @param App $app
  16. */
  17. public function __construct(App $app, CacheRepository $repository)
  18. {
  19. parent::__construct($app);
  20. $this->repository = $repository;
  21. }
  22. /**
  23. * @Author:Qinii
  24. * @Date: 2020/9/15
  25. * @return mixed
  26. */
  27. public function getAgree($key)
  28. {
  29. $allow = [
  30. 'sys_integral_rule',
  31. 'sys_intention_agree',
  32. 'sys_product_presell_agree',
  33. 'sys_user_agree',
  34. 'wechat_menus',
  35. 'sys_receipt_agree',
  36. 'sys_extension_agree',
  37. 'sys_merchant_type',
  38. 'sys_brokerage',
  39. ];
  40. if (!in_array($key, $allow)) return app('json')->fail('数据不存在');
  41. $make = app()->make(CacheRepository::class);
  42. $data[$key] = $make->getResult($key);
  43. return app('json')->success($data);
  44. }
  45. /**
  46. * @Author:Qinii
  47. * @Date: 2020/9/15
  48. * @return mixed
  49. */
  50. public function saveAgree($key)
  51. {
  52. /**
  53. * sys_integral_rule 分销
  54. * sys_intention_agree 积分
  55. * sys_product_presell_agree 预售
  56. * sys_user_agree 用户
  57. * wechat_menus
  58. * sys_extension_agree
  59. *
  60. */
  61. $allow = [
  62. 'sys_integral_rule',
  63. 'sys_intention_agree',
  64. 'sys_product_presell_agree',
  65. 'sys_user_agree',
  66. 'wechat_menus',
  67. 'sys_receipt_agree',
  68. 'sys_extension_agree',
  69. 'sys_merchant_type',
  70. 'sys_brokerage',
  71. ];
  72. if (!in_array($key, $allow)) return app('json')->fail('KEY不存在');
  73. $value = $this->request->param('agree');
  74. app()->make(CacheRepository::class)->save($key, $value);
  75. return app('json')->success('保存成功');
  76. }
  77. }