ApiPushMessage.Class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * 推送消息
  4. * Created by PhpStorm.
  5. * User: phperstar
  6. * Date: 2021/05/08
  7. * Time: 12:15
  8. */
  9. namespace JinDouYun\Controller\System;
  10. use JinDouYun\Controller\BaseController;
  11. use JinDouYun\Model\System\MPage;
  12. use Mall\Framework\Core\ErrorCode;
  13. use JinDouYun\Model\System\MSystemPushMessage;
  14. use Mall\Framework\Core\StatusCode;
  15. class ApiPushMessage extends BaseController
  16. {
  17. private $objMSystemPushMessage;
  18. /**
  19. * ApiTemplate constructor.
  20. * @param bool $isCheckAcl
  21. * @param bool $isMustLogin
  22. * @param bool $checkToken
  23. * @param bool $getAreaCode
  24. */
  25. public function __construct($isCheckAcl = false, $isMustLogin = false, $checkToken = true,$getAreaCode=true)
  26. {
  27. parent::__construct($isCheckAcl, $isMustLogin, $checkToken,$getAreaCode);
  28. $authorization = $this->request->getServerParam('HTTP_AUTHORIZATION');
  29. if (!empty($authorization)) {
  30. self::getUserIdByAuthorization();
  31. }
  32. $this->objMSystemPushMessage = new MSystemPushMessage($this->onlineUserId, $this->onlineEnterpriseId);
  33. }
  34. /**
  35. * 获取对应推送模板的推送信息
  36. */
  37. public function getSettingDataByMessageIds()
  38. {
  39. $params = $this->request->getRawJson();
  40. if (empty($params)) {
  41. $this->sendOutput('参数为空', ErrorCode::$paramError);
  42. }
  43. $selectParams = [
  44. 'id' => getArrayItem($params, 'id', []),
  45. ];
  46. foreach ($selectParams as $key => $value) {
  47. if (empty($value)) {
  48. $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
  49. }
  50. }
  51. $result = $this->objMSystemPushMessage->getSettingDataByMessageIds($selectParams);
  52. if($result->isSuccess()){
  53. $this->sendOutput($result->getData());
  54. }else{
  55. $this->sendOutput($result->getData(), $result->getErrorCode());
  56. }
  57. }
  58. }