123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- /**
- * 企业模版模块
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/11/29
- * Time: 16:57
- */
- namespace JinDouYun\Controller\System;
- use JinDouYun\Controller\BaseController;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Model\System\MEnterpriseTemplateModule;
- class EnterpriseTemplateModule extends BaseController
- {
- private $objMEnterpriseTemplateModule;
- /**
- * EnterpriseTemplateModule constructor.
- * @param bool $isCheckAcl
- * @param bool $isMustLogin
- * @throws \Exception
- */
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMEnterpriseTemplateModule = new MEnterpriseTemplateModule($this->onlineUserId, $this->onlineEnterpriseId);
- }
- /**
- * 添加,编辑企业模版模块
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'templateId' => isset($params['templateId']) ? $params['templateId'] : '',
- 'moduleAlias' => isset($params['moduleAlias']) ? $params['moduleAlias'] : '',//模块别名
- 'moduleData' => isset($params['moduleData']) ? json_encode($params['moduleData']) : '',
- 'enableStatus' => isset($params['enableStatus']) ? $params['enableStatus'] : StatusCode::$delete,
- ];
- foreach ($data as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- return $data;
- }
- /**
- * 添加企业模版模块数据
- */
- public function add()
- {
- $data = $this->commonFieldFilter();
- $result = $this->objMEnterpriseTemplateModule->add($data);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 根据模版id+模块id,获取当前企业下改模块的数据
- */
- public function getModuleInfo()
- {
- $params = $this->request->getRawJson();
- $data = [
- 'templateId' => $this->request->param('request_id'),//模版id
- 'moduleAlias' => isset($params['moduleAlias']) ? $params['moduleAlias'] : '',//模块id
- ];
- foreach ($data as $key => $value) {
- if (empty($value)) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- $result = $this->objMEnterpriseTemplateModule->getModuleInfo($data);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- /**
- * 编辑企业模版模块数据
- */
- public function edit()
- {
- $data = $this->commonFieldFilter();
- $result = $this->objMEnterpriseTemplateModule->edit($data);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- }
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
|