BasicSetup.Class.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * 基本设置
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/12/5
  7. * Time: 15:26
  8. */
  9. namespace JinDouYun\Controller\System;
  10. use JinDouYun\Controller\BaseController;
  11. use Mall\Framework\Core\ErrorCode;
  12. use JinDouYun\Model\System\MBasicSetup;
  13. class BasicSetup extends BaseController
  14. {
  15. private $objMBasicSetup;
  16. public function __construct($isCheckAcl = true, $isMustLogin = true)
  17. {
  18. parent::__construct($isCheckAcl, $isMustLogin);
  19. $this->objMBasicSetup = new MBasicSetup($this->onlineEnterpriseId);
  20. }
  21. /**
  22. * 添加,编辑数据
  23. * @return array
  24. */
  25. public function commonFieldFilter()
  26. {
  27. $params = $this->request->getRawJson();
  28. if (empty($params)) {
  29. $this->sendOutput('参数为空', ErrorCode::$paramError);
  30. }
  31. $data = [
  32. 'enterpriseId' => $this->onlineEnterpriseId,
  33. 'basicData' => isset($params['basicData']) ? json_encode($params['basicData']) : '',
  34. ];
  35. foreach ($data as $key => $value) {
  36. if (empty($value) && $value !== 0) {
  37. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  38. }
  39. }
  40. return $data;
  41. }
  42. /**
  43. * 编辑基本设置
  44. */
  45. public function setting()
  46. {
  47. $data = $this->commonFieldFilter();
  48. $result = $this->objMBasicSetup->setting($data);
  49. if ($result->isSuccess()) {
  50. parent::sendOutput($result->getData());
  51. } else {
  52. parent::sendOutput($result->getData(), $result->getErrorCode());
  53. }
  54. }
  55. /**
  56. * 获取基本设置
  57. */
  58. public function getBasicSetup()
  59. {
  60. $result = $this->objMBasicSetup->getBasicSetup();
  61. if ($result->isSuccess()) {
  62. parent::sendOutput($result->getData());
  63. } else {
  64. parent::sendOutput($result->getData(), $result->getErrorCode());
  65. }
  66. }
  67. }