Building.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\BuildingModel;
  5. use app\common\model\BusinessModel;
  6. use think\Db;
  7. /**
  8. * 智慧党建
  9. */
  10. class Building extends Api
  11. {
  12. protected $noNeedLogin = ['lists', 'banner', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
  13. protected $noNeedRight = ['*'];
  14. /**
  15. * 智慧党建轮播图
  16. */
  17. public function banner()
  18. {
  19. $data = Db::name('building_banner')
  20. ->where('switch',1)
  21. ->order('sort desc')
  22. ->select();
  23. if ($data) {
  24. foreach ($data as &$v) {
  25. $v['image'] = config('site.httpurl') . $v['image'];
  26. }
  27. return $this->success('', $data);
  28. } else {
  29. return $this->success('暂无数据');
  30. }
  31. }
  32. /**
  33. * 党建资讯列表
  34. * @param string $page 页数
  35. * @param string $limit 条数
  36. */
  37. public function lists()
  38. {
  39. $page = $this->request->get('page');
  40. $limit = $this->request->get('limit');
  41. if (!$page) {
  42. $pages = '0,10';
  43. } else {
  44. $page = $page - 1;
  45. if ($page < 0) $page = 0;
  46. $pages = $page . ',' . $limit;
  47. }
  48. $buildingModel = new BuildingModel();
  49. $data = $buildingModel->where('switch', 1)
  50. ->order('sort desc')
  51. ->limit($pages)
  52. ->select();
  53. return $this->success('', $data);
  54. }
  55. /**
  56. * 党建资讯详情
  57. * @param string $id id
  58. *
  59. */
  60. public function listInfo()
  61. {
  62. $id = $this->request->get('id');
  63. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  64. $buildingModel = new BuildingModel();
  65. $data = $buildingModel->where('switch', 1)
  66. ->where('id', $id)
  67. ->order('sort desc')
  68. ->find();
  69. return $this->success('', $data);
  70. }
  71. /**
  72. * 党组织介绍
  73. */
  74. public function buildInfo()
  75. {
  76. $data = Db::name('building_info')
  77. ->where('id',1)
  78. ->find();
  79. if ($data) {
  80. $data['content'] = str_replace('src="','src="'.config('site.httpurl'),$data['content']);
  81. return $this->success('', $data);
  82. } else {
  83. return $this->success('暂无数据');
  84. }
  85. }
  86. /**
  87. * 党建常见问题
  88. * @param string $page 页数
  89. * @param string $limit 条数
  90. */
  91. public function qustion()
  92. {
  93. $page = $this->request->get('page');
  94. $limit = $this->request->get('limit');
  95. if (!$page) {
  96. $pages = '0,10';
  97. } else {
  98. $page = $page - 1;
  99. if ($page < 0) $page = 0;
  100. $pages = $page . ',' . $limit;
  101. }
  102. $data = Db::name('building_qustion')->where('switch', 1)
  103. ->order('sort desc')
  104. ->limit($pages)
  105. ->select();
  106. if ($data) {
  107. foreach ($data as &$v) {
  108. $v['content'] = str_replace('src="','src="'.config('site.httpurl'),$v['content']);
  109. }
  110. return $this->success('', $data);
  111. } else {
  112. return $this->success('暂无数据');
  113. }
  114. }
  115. /**
  116. * 常见问题详情
  117. * @param string $id id
  118. *
  119. */
  120. public function qustionInfo()
  121. {
  122. $id = $this->request->get('id');
  123. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  124. $data = Db::name('building_qustion')->where('switch', 1)
  125. ->where('id', $id)
  126. ->order('sort desc')
  127. ->find();
  128. if ($data) {
  129. $data['content'] = str_replace('src="','src="'.config('site.httpurl'),$data['content']);
  130. return $this->success('', $data);
  131. } else {
  132. return $this->success('暂无数据');
  133. }
  134. }
  135. }