SystemAgreement.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\adminapi\controller\v1\setting;
  3. use app\adminapi\controller\AuthController;
  4. use app\services\other\AgreementServices;
  5. use think\facade\App;
  6. class SystemAgreement extends AuthController
  7. {
  8. /**
  9. * 构造方法
  10. * SystemCity constructor.
  11. * @param App $app
  12. * @param AgreementServices $services
  13. */
  14. public function __construct(App $app, AgreementServices $services)
  15. {
  16. parent::__construct($app);
  17. $this->services = $services;
  18. }
  19. /**
  20. * 获取协议内容
  21. * @param $type
  22. * @return mixed
  23. * @throws \think\db\exception\DataNotFoundException
  24. * @throws \think\db\exception\DbException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. */
  27. public function getAgreement($type)
  28. {
  29. if (!$type) return app('json')->fail(400184);
  30. $info = $this->services->getAgreementBytype($type);
  31. return app('json')->success($info);
  32. }
  33. /**
  34. * 保存协议内容
  35. * @return mixed
  36. */
  37. public function saveAgreement()
  38. {
  39. $data = $this->request->postMore([
  40. ['id', 0],
  41. ['type', 0],
  42. ['title', ''],
  43. ['content', ''],
  44. ]);
  45. $data['status'] = 1;
  46. $this->services->saveAgreement($data, $data['id']);
  47. return app('json')->success(100000);
  48. }
  49. }