Building.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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->error('暂无数据');
  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. if ($data) {
  54. return $this->success('', $data);
  55. } else {
  56. return $this->error('暂无数据');
  57. }
  58. }
  59. /**
  60. * 党建资讯详情
  61. * @param string $id id
  62. *
  63. */
  64. public function listInfo()
  65. {
  66. $id = $this->request->get('id');
  67. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  68. $buildingModel = new BuildingModel();
  69. $data = $buildingModel->where('switch', 1)
  70. ->where('id', $id)
  71. ->order('sort desc')
  72. ->find();
  73. if ($data) {
  74. return $this->success('', $data);
  75. } else {
  76. return $this->error('暂无数据');
  77. }
  78. }
  79. /**
  80. * 党组织介绍
  81. */
  82. public function buildInfo()
  83. {
  84. $data = Db::name('building_info')
  85. ->where('id',1)
  86. ->find();
  87. if ($data) {
  88. $data['content'] = str_replace('src="','src="'.config('site.httpurl'),$data['content']);
  89. return $this->success('', $data);
  90. } else {
  91. return $this->error('暂无数据');
  92. }
  93. }
  94. /**
  95. * 党建常见问题
  96. * @param string $page 页数
  97. * @param string $limit 条数
  98. */
  99. public function qustion()
  100. {
  101. $page = $this->request->get('page');
  102. $limit = $this->request->get('limit');
  103. if (!$page) {
  104. $pages = '0,10';
  105. } else {
  106. $page = $page - 1;
  107. if ($page < 0) $page = 0;
  108. $pages = $page . ',' . $limit;
  109. }
  110. $data = Db::name('building_qustion')->where('switch', 1)
  111. ->order('sort desc')
  112. ->limit($pages)
  113. ->select();
  114. if ($data) {
  115. foreach ($data as &$v) {
  116. $v['content'] = str_replace('src="','src="'.config('site.httpurl'),$v['content']);
  117. }
  118. return $this->success('', $data);
  119. } else {
  120. return $this->error('暂无数据');
  121. }
  122. }
  123. /**
  124. * 常见问题详情
  125. * @param string $id id
  126. *
  127. */
  128. public function qustionInfo()
  129. {
  130. $id = $this->request->get('id');
  131. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  132. $data = Db::name('building_qustion')->where('switch', 1)
  133. ->where('id', $id)
  134. ->order('sort desc')
  135. ->find();
  136. if ($data) {
  137. $data['content'] = str_replace('src="','src="'.config('site.httpurl'),$data['content']);
  138. return $this->success('', $data);
  139. } else {
  140. return $this->error('暂无数据');
  141. }
  142. }
  143. }