EnterpriseTemplateModule.Class.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * 企业模版模块
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/11/29
  7. * Time: 16:57
  8. */
  9. namespace JinDouYun\Controller\System;
  10. use JinDouYun\Controller\BaseController;
  11. use Mall\Framework\Core\ErrorCode;
  12. use Mall\Framework\Core\StatusCode;
  13. use JinDouYun\Model\System\MEnterpriseTemplateModule;
  14. class EnterpriseTemplateModule extends BaseController
  15. {
  16. private $objMEnterpriseTemplateModule;
  17. /**
  18. * EnterpriseTemplateModule constructor.
  19. * @param bool $isCheckAcl
  20. * @param bool $isMustLogin
  21. * @throws \Exception
  22. */
  23. public function __construct($isCheckAcl = true, $isMustLogin = true)
  24. {
  25. parent::__construct($isCheckAcl, $isMustLogin);
  26. $this->objMEnterpriseTemplateModule = new MEnterpriseTemplateModule($this->onlineUserId, $this->onlineEnterpriseId);
  27. }
  28. /**
  29. * 添加,编辑企业模版模块
  30. * @return array
  31. */
  32. public function commonFieldFilter()
  33. {
  34. $params = $this->request->getRawJson();
  35. if (empty($params)) {
  36. $this->sendOutput('参数为空', ErrorCode::$paramError);
  37. }
  38. $data = [
  39. 'templateId' => isset($params['templateId']) ? $params['templateId'] : '',
  40. 'moduleAlias' => isset($params['moduleAlias']) ? $params['moduleAlias'] : '',//模块别名
  41. 'moduleData' => isset($params['moduleData']) ? json_encode($params['moduleData']) : '',
  42. 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : StatusCode::$delete,
  43. ];
  44. foreach ($data as $key => $value) {
  45. if (empty($value) && $value !== 0) {
  46. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  47. }
  48. }
  49. return $data;
  50. }
  51. /**
  52. * 添加企业模版模块数据
  53. */
  54. public function add()
  55. {
  56. $data = $this->commonFieldFilter();
  57. $result = $this->objMEnterpriseTemplateModule->add($data);
  58. if ($result->isSuccess()) {
  59. parent::sendOutput($result->getData());
  60. }
  61. parent::sendOutput($result->getData(), $result->getErrorCode());
  62. }
  63. /**
  64. * 根据模版id+模块id,获取当前企业下改模块的数据
  65. */
  66. public function getModuleInfo()
  67. {
  68. $params = $this->request->getRawJson();
  69. $data = [
  70. 'templateId' => $this->request->param('request_id'),//模版id
  71. 'moduleAlias' => isset($params['moduleAlias']) ? $params['moduleAlias'] : '',//模块id
  72. ];
  73. foreach ($data as $key => $value) {
  74. if (empty($value)) {
  75. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  76. }
  77. }
  78. $result = $this->objMEnterpriseTemplateModule->getModuleInfo($data);
  79. if ($result->isSuccess()) {
  80. parent::sendOutput($result->getData());
  81. }
  82. parent::sendOutput($result->getData(), $result->getErrorCode());
  83. }
  84. /**
  85. * 编辑企业模版模块数据
  86. */
  87. public function edit()
  88. {
  89. $data = $this->commonFieldFilter();
  90. $result = $this->objMEnterpriseTemplateModule->edit($data);
  91. if ($result->isSuccess()) {
  92. parent::sendOutput($result->getData());
  93. }
  94. parent::sendOutput($result->getData(), $result->getErrorCode());
  95. }
  96. }