TemplateModule.Class.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * 模版模块
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/11/29
  7. * Time: 16:22
  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\MTemplateModule;
  14. class TemplateModule extends BaseController
  15. {
  16. private $objMTemplateModule;
  17. /**
  18. * TemplateModule constructor.
  19. * @param bool $isCheckAcl
  20. * @param bool $isMustLogin
  21. */
  22. public function __construct($isCheckAcl = true, $isMustLogin = true)
  23. {
  24. parent::__construct($isCheckAcl, $isMustLogin);
  25. $this->objMTemplateModule = new MTemplateModule($this->onlineUserId, $this->onlineEnterpriseId);
  26. }
  27. /**
  28. * 添加,编辑系统模版模块
  29. * @return array
  30. */
  31. public function commonFieldFilter()
  32. {
  33. $params = $this->request->getRawJson();
  34. if (empty($params)) {
  35. $this->sendOutput('参数为空', ErrorCode::$paramError);
  36. }
  37. $data = [
  38. 'templateId' => isset($params['templateId']) ? $params['templateId'] : '',
  39. 'title' => isset($params['title']) ? $params['title'] : '',
  40. ];
  41. foreach ($data as $key => $value) {
  42. if (empty($value) && $value !== 0) {
  43. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  44. }
  45. }
  46. $data['enableStatus'] = isset($params['enableStatus']) ? $params['enableStatus'] : StatusCode::$delete;
  47. return $data;
  48. }
  49. /**
  50. * 获取系统模板下模块
  51. */
  52. public function getAll()
  53. {
  54. $templateId = $this->request->param('request_id');
  55. if (empty($templateId)){
  56. $this->sendOutput('缺少模板id', ErrorCode::$paramError);
  57. }
  58. $selectParams = [
  59. 'templateId' => $templateId,
  60. 'enableStatus' => StatusCode::$standard,
  61. ];
  62. $dbResult = $this->objMTemplateModule->getAll($selectParams);
  63. if ($dbResult->isSuccess()) {
  64. $returnData = $dbResult->getData();
  65. parent::sendOutput($returnData['data'], 0);
  66. }
  67. parent::sendOutput($dbResult->getData(), ErrorCode::$dberror);
  68. }
  69. }