SystemAgreement.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\setting;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\other\AgreementServices;
  14. use think\facade\App;
  15. class SystemAgreement extends AuthController
  16. {
  17. /**
  18. * 构造方法
  19. * SystemCity constructor.
  20. * @param App $app
  21. * @param AgreementServices $services
  22. */
  23. public function __construct(App $app, AgreementServices $services)
  24. {
  25. parent::__construct($app);
  26. $this->services = $services;
  27. }
  28. /**
  29. * 获取协议内容
  30. * @param $type
  31. * @return mixed
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\DbException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. */
  36. public function getAgreement($type)
  37. {
  38. if (!$type) return app('json')->fail('协议类型不存在');
  39. $info = $this->services->getAgreementBytype($type);
  40. return app('json')->success($info);
  41. }
  42. /**
  43. * 保存协议内容
  44. * @return mixed
  45. */
  46. public function saveAgreement()
  47. {
  48. $data = $this->request->postMore([
  49. ['id', 0],
  50. ['type', 0],
  51. ['title', ''],
  52. ['content', ''],
  53. ]);
  54. $data['status'] = 1;
  55. $this->services->saveAgreement($data, $data['id']);
  56. return app('json')->success('保存成功');
  57. }
  58. }