ApiIndexController.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. package com.huijy.web.controller.api;
  2. import com.huijy.common.annotation.UnLogin;
  3. import com.huijy.common.core.domain.AjaxResult;
  4. import com.huijy.common.core.domain.entity.SysDictData;
  5. import com.huijy.common.core.page.TableDataInfo;
  6. import com.huijy.common.utils.StringUtils;
  7. import com.huijy.management.domain.*;
  8. import com.huijy.management.service.*;
  9. import com.huijy.system.service.ISysDictDataService;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiImplicitParam;
  12. import io.swagger.annotations.ApiImplicitParams;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.web.bind.annotation.*;
  16. import springfox.documentation.annotations.ApiIgnore;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  20. @Api(value = "小程序",tags = "小程序接口")
  21. @RestController
  22. @RequestMapping("/api/index")
  23. public class ApiIndexController extends ApiAbstractController {
  24. @Autowired
  25. private IMemberService memberService;
  26. @Autowired
  27. private IMemberLocationService memberLocationService;
  28. @Autowired
  29. private IAboutUsService aboutUsService;
  30. @Autowired
  31. private IContentService contentService;
  32. @Autowired
  33. private IShopService shopService;
  34. @Autowired
  35. private IShopSalesRecordService shopSalesRecordService;
  36. @Autowired
  37. private ISysDictDataService sysDictDataService;
  38. @Autowired
  39. private IMarkerService markerService;
  40. @Autowired
  41. private IEarlyWarningService earlyWarningService;
  42. @Autowired
  43. private IMemberHelpService memberHelpService;
  44. @PostMapping("/pushLatLng")
  45. @ApiOperation("上传会员坐标")
  46. @ApiImplicitParams({
  47. @ApiImplicitParam(name = "lat", value = "坐标的lat", paramType = "body"),
  48. @ApiImplicitParam(name = "lng", value = "坐标的lng", paramType = "body")
  49. })
  50. public AjaxResult pushLatLng(@ApiIgnore Member member, @RequestBody Map params) {
  51. String lat = (String) params.get("lat");
  52. String lng = (String) params.get("lng");
  53. member.setLastLat(lat);
  54. member.setLastLng(lng);
  55. memberService.updateMember(member);
  56. MemberLocation location = new MemberLocation();
  57. location.setLat(lat);
  58. location.setLng(lng);
  59. location.setMemberId(member.getMemberId());
  60. memberLocationService.insertMemberLocation(location);
  61. return AjaxResult.success();
  62. }
  63. //上传会员拨打记录
  64. @PostMapping("/pushHelp")
  65. @ApiOperation("上传会员拨打记录")
  66. @ApiImplicitParams({
  67. @ApiImplicitParam(name = "lat", value = "坐标的lat",dataType = "String", paramType = "body"),
  68. @ApiImplicitParam(name = "lng", value = "坐标的lng",dataType = "String",paramType = "body"),
  69. @ApiImplicitParam(name = "phone", value = "求助电话",dataType = "String", paramType = "body")
  70. })
  71. public AjaxResult pushHelp(@ApiIgnore Member member, @RequestBody MemberHelp help) {
  72. help.setMemberId(member.getMemberId());
  73. memberHelpService.insertMemberHelp(help);
  74. return AjaxResult.success();
  75. }
  76. //关于我们信息,包括小程序的展示素材
  77. @GetMapping("/getAboutUs")
  78. @ApiOperation("获取关于我们的信息")
  79. @UnLogin
  80. public AjaxResult getAboutUs(@ApiIgnore Member member) {
  81. AboutUs aboutUs = aboutUsService.selectAboutUsByAboutUsId(1L);
  82. Map<String, Object> resultObj = new HashMap<String, Object>();
  83. resultObj.put("aboutUs", aboutUs);
  84. return AjaxResult.success(resultObj);
  85. }
  86. //分页获取主要内容信息
  87. @GetMapping("/getPageContent")
  88. @ApiOperation("分页获取主要内容信息")
  89. @UnLogin
  90. @ApiImplicitParams({
  91. @ApiImplicitParam(name = "type", value = "类型:1、党政服务;2、景区介绍;3、旅游攻略;4、热门活动",required = true,defaultValue = "1",dataType = "Integer",
  92. allowableValues = "1,2,3,4",paramType = "query"),
  93. @ApiImplicitParam(name = "pageNum", required = true,defaultValue = "1",value = "页码", paramType = "query"),
  94. @ApiImplicitParam(name = "pageSize", required = true,defaultValue = "20", value = "显示记录数", paramType = "query")
  95. })
  96. public TableDataInfo getPageContent(@ApiIgnore Member member, Integer type) {
  97. // AboutUs aboutUs = aboutUsService.selectAboutUsByAboutUsId(1L);
  98. Content content = new Content();
  99. content.setServiceInfo(type+"");
  100. content.setReleaseFlag("1");
  101. startPage();
  102. List<Content> list = contentService.selectContentList(content);
  103. return getDataTable(list);
  104. }
  105. //分页获取主要内容信息
  106. @GetMapping("/getContentInfo/{contentId}")
  107. @ApiOperation("获取主要内容详细信息")
  108. @UnLogin
  109. public AjaxResult getContentInfo(@ApiIgnore Member member, @PathVariable Integer contentId) {
  110. // AboutUs aboutUs = aboutUsService.selectAboutUsByAboutUsId(1L);
  111. Content info = contentService.selectContentByContentId(contentId.longValue());
  112. Map<String, Object> resultObj = new HashMap<String, Object>();
  113. resultObj.put("info", info);
  114. return AjaxResult.success(resultObj);
  115. }
  116. //门店开通申请
  117. @PostMapping("/shopApply")
  118. @ApiOperation("商铺开通申请")
  119. @ApiImplicitParams({
  120. @ApiImplicitParam(name = "name", value = "商铺名称",required = true,paramType = "body"),
  121. @ApiImplicitParam(name = "addres", value = "地址", paramType = "body"),
  122. @ApiImplicitParam(name = "bossName", value = "老板名称",required = true, paramType = "body"),
  123. @ApiImplicitParam(name = "bossPhone", value = "老板电话",required = true, paramType = "body"),
  124. @ApiImplicitParam(name = "businessHours", value = "营业时间", paramType = "body"),
  125. @ApiImplicitParam(name = "briefContent", value = "简介", paramType = "body"),
  126. @ApiImplicitParam(name = "lat", value = "坐标的lat", paramType = "body"),
  127. @ApiImplicitParam(name = "lng", value = "坐标的lng", paramType = "body"),
  128. @ApiImplicitParam(name = "shopType", value = "商铺类型 1、商铺 2、酒店",defaultValue = "1",paramType = "body"),
  129. })
  130. public AjaxResult storeApply(@ApiIgnore Member member, @RequestBody Shop shop) {
  131. if (shop == null){
  132. AjaxResult.error("提交数据为空");
  133. }
  134. shop.setMemberId(member.getMemberId());
  135. shop.setAuditFlag("0");
  136. shop.setEnableFlag("0");
  137. shopService.insertShop(shop);
  138. return AjaxResult.success();
  139. }
  140. //门店开通申请
  141. @GetMapping("/getShopList")
  142. @ApiOperation("获取商铺列表")
  143. public AjaxResult getShopList(@ApiIgnore Member member) {
  144. List list = shopService.getListByMemberId(member.getMemberId());
  145. Map<String, Object> resultObj = new HashMap<String, Object>();
  146. resultObj.put("list", list);
  147. return AjaxResult.success(resultObj);
  148. }
  149. @GetMapping("/getShopInfo/{shopId}")
  150. @ApiOperation("获取商铺列表")
  151. public AjaxResult getShopInfo(@ApiIgnore Member member, @PathVariable Long shopId) {
  152. if (shopId == null){
  153. AjaxResult.error("提交数据为空");
  154. }
  155. Shop shop = shopService.selectShopByShopId(shopId);
  156. Map<String, Object> resultObj = new HashMap<String, Object>();
  157. resultObj.put("shopInfo", shop);
  158. return AjaxResult.success(resultObj);
  159. }
  160. //更新门店坐标
  161. @PostMapping("/updateLatLng")
  162. @ApiOperation("更新门店坐标")
  163. @ApiImplicitParams({
  164. @ApiImplicitParam(name = "shopId", value = "商铺id",required = true,paramType = "body"),
  165. @ApiImplicitParam(name = "lat", value = "坐标的lat", paramType = "body"),
  166. @ApiImplicitParam(name = "lng", value = "坐标的lng", paramType = "body")
  167. })
  168. public AjaxResult storeApply(@ApiIgnore Member member, @RequestBody Map params) {
  169. String lat = (String) params.get("lat");
  170. String lng = (String) params.get("lng");
  171. Integer shopId = (Integer) params.get("shopId");
  172. if (shopId==null || shopId<=0){
  173. return AjaxResult.error("店铺id不能为空");
  174. }
  175. Shop shop = shopService.selectShopByShopId(shopId.longValue());
  176. if (shop == null){
  177. return AjaxResult.error("获取店铺信息出错");
  178. }
  179. shop.setLat(lat);
  180. shop.setLng(lng);
  181. shopService.updateShop(shop);
  182. return AjaxResult.success();
  183. }
  184. //门店数据上报
  185. @PostMapping("/pushRecord")
  186. @ApiOperation("门店数据上报")
  187. public AjaxResult storeApply(@ApiIgnore Member member, @RequestBody ShopSalesRecord shopSalesRecord) {
  188. if (shopSalesRecord==null){
  189. AjaxResult.error("上传数据为空");
  190. }
  191. shopSalesRecordService.insertShopSalesRecord(shopSalesRecord);
  192. return AjaxResult.success();
  193. }
  194. //返回标记物类型
  195. @PostMapping("/getMarkerType")
  196. @ApiOperation("获取标记物类型")
  197. public AjaxResult getMarkerDictData(){
  198. SysDictData dictData = new SysDictData();
  199. dictData.setDictType("marker_type");
  200. dictData.setStatus("0");
  201. List<SysDictData> list = sysDictDataService.selectDictDataList(dictData);
  202. Map<String, Object> resultObj = new HashMap<String, Object>();
  203. resultObj.put("list", list);
  204. return AjaxResult.success(resultObj);
  205. }
  206. //
  207. @GetMapping("/getPageMarker")
  208. @ApiOperation("根据标记物类型分页获取标记物信息")
  209. @ApiImplicitParams({
  210. @ApiImplicitParam(name = "markerType", value = "标记物类型:0为所有类型",required = true,defaultValue = "0",dataType = "String",paramType = "query"),
  211. @ApiImplicitParam(name = "pageNum", required = true,defaultValue = "1",value = "页码", paramType = "query"),
  212. @ApiImplicitParam(name = "pageSize", required = true,defaultValue = "20", value = "显示记录数", paramType = "query")
  213. })
  214. public TableDataInfo getPageMarker(String markerType) {
  215. Marker marker = new Marker();
  216. if (StringUtils.isNotEmpty(markerType) && !markerType.equalsIgnoreCase("0")){
  217. marker.setMarkerType(markerType);
  218. }
  219. startPage();
  220. List<Marker> list = markerService.selectMarkerList(marker);
  221. return getDataTable(list);
  222. }
  223. @PostMapping("/getEarlyWarnType")
  224. @ApiOperation("获取预警类型")
  225. public AjaxResult getEarlyWarnType(){
  226. SysDictData dictData = new SysDictData();
  227. dictData.setDictType("early_warning_type");
  228. dictData.setStatus("0");
  229. List<SysDictData> list = sysDictDataService.selectDictDataList(dictData);
  230. Map<String, Object> resultObj = new HashMap<String, Object>();
  231. resultObj.put("list", list);
  232. return AjaxResult.success(resultObj);
  233. }
  234. @GetMapping("/getPageEarlyWarn")
  235. @ApiOperation("根据预警类型分页获取预警信息")
  236. @ApiImplicitParams({
  237. @ApiImplicitParam(name = "earlyWarnType", value = "预警类型:0为所有类型",required = true,defaultValue = "0",dataType = "String",paramType = "query"),
  238. @ApiImplicitParam(name = "pageNum", required = true,defaultValue = "1",value = "页码", paramType = "query"),
  239. @ApiImplicitParam(name = "pageSize", required = true,defaultValue = "20", value = "显示记录数", paramType = "query")
  240. })
  241. public TableDataInfo getPageEarlyWarn(String earlyWarnType) {
  242. EarlyWarning earlyWarning = new EarlyWarning();
  243. if (StringUtils.isNotEmpty(earlyWarnType) && !earlyWarnType.equalsIgnoreCase("0")){
  244. earlyWarning.setEarlyWarningType(earlyWarnType);
  245. }
  246. startPage();
  247. List<EarlyWarning> list = earlyWarningService.selectEarlyWarningList(earlyWarning);
  248. return getDataTable(list);
  249. }
  250. }