ApiAnnouncement.Class.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * 小程序系统公告
  4. * Created by PhpStorm.
  5. * User: 小威
  6. * Date: 2020/04/16
  7. * Time: 17:23
  8. */
  9. namespace JinDouYun\Controller\System;
  10. use Mall\Framework\Core\ErrorCode;
  11. use Mall\Framework\Core\StatusCode;
  12. use JinDouYun\Controller\BaseController;
  13. use JinDouYun\Model\System\MAnnouncement;
  14. class ApiAnnouncement extends BaseController
  15. {
  16. private $objMAnnouncement;
  17. public function __construct($isCheckAcl = false, $isMustLogin = false)
  18. {
  19. parent::__construct($isCheckAcl, $isMustLogin);
  20. $this->objMAnnouncement = new MAnnouncement($this->onlineEnterpriseId);
  21. }
  22. /**
  23. * 公告列表
  24. */
  25. public function getAllAnnouncement()
  26. {
  27. $params = $this->request->getRawJson();
  28. if( empty($params) ){
  29. $this->sendOutput('参数为空', ErrorCode::$paramError );
  30. }
  31. $pageParams = pageToOffset($params['page']?:1, $params['pageSize']?:10);
  32. $selectParams['limit'] = $pageParams['limit'];
  33. $selectParams['offset'] = $pageParams['offset'];
  34. if(isset($params['upStatus']) && !empty($params['upStatus'])){
  35. $selectParams['upStatus'] = $params['upStatus'];
  36. }
  37. $selectParams['type'] = StatusCode::$standard;
  38. $result = $this->objMAnnouncement->getAllAnnouncement($selectParams);
  39. if(!$result->isSuccess()){
  40. parent::sendOutput($result->getData(), $result->getErrorCode());
  41. }
  42. $returnData = $result->getData();
  43. $pageData = [
  44. 'pageIndex' => $params['page'],
  45. 'pageSize' => $params['pageSize'],
  46. 'pageTotal' => $returnData['total'],
  47. ];
  48. parent::sendOutput($returnData['data'], 0, $pageData);
  49. }
  50. /**
  51. * 公告详情
  52. */
  53. public function getAnnouncementInfo()
  54. {
  55. $id = $this->request->param('request_id');
  56. if(empty($id)){
  57. $this->sendOutput('参数为空', ErrorCode::$paramError );
  58. }
  59. $where['id'] = $id;
  60. $where['type'] = StatusCode::$standard;
  61. $result = $this->objMAnnouncement->getAnnouncementInfo($where);
  62. if($result->isSuccess()){
  63. parent::sendOutput($result->getData());
  64. }else{
  65. parent::sendOutput($result->getData(), $result->getErrorCode());
  66. }
  67. }
  68. /**
  69. * 弹窗公告详情
  70. */
  71. public function getupStatusAnnouncementInfo()
  72. {
  73. $where['type'] = StatusCode::$standard;
  74. $where['upStatus'] = StatusCode::$standard;
  75. $result = $this->objMAnnouncement->getAnnouncementInfo($where);
  76. if($result->isSuccess()){
  77. parent::sendOutput($result->getData());
  78. }else{
  79. parent::sendOutput($result->getData(), $result->getErrorCode());
  80. }
  81. }
  82. }