傅行帆 6 anos atrás
pai
commit
fc21bc6a19

+ 70
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/AssembleController.java Ver arquivo

@@ -0,0 +1,70 @@
1
+package com.community.huiju.controller;
2
+
3
+import com.community.commom.constant.Constant;
4
+import com.community.commom.mode.ResponseBean;
5
+import com.community.commom.session.UserElement;
6
+import com.community.huiju.model.TaSysMenu;
7
+import com.community.huiju.model.ToBanner;
8
+import com.community.huiju.service.BannerServiceI;
9
+import com.community.huiju.service.MenuServiceI;
10
+import com.community.huiju.service.MessageServiceI;
11
+import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiImplicitParam;
13
+import io.swagger.annotations.ApiImplicitParams;
14
+import io.swagger.annotations.ApiOperation;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.cloud.context.config.annotation.RefreshScope;
17
+import org.springframework.web.bind.annotation.PathVariable;
18
+import org.springframework.web.bind.annotation.RequestMapping;
19
+import org.springframework.web.bind.annotation.RequestMethod;
20
+import org.springframework.web.bind.annotation.RestController;
21
+
22
+import javax.servlet.http.HttpSession;
23
+import java.util.HashMap;
24
+import java.util.List;
25
+import java.util.Map;
26
+
27
+/**
28
+ * @author FXF
29
+ * @date 2018-11-05
30
+ */
31
+@RestController
32
+@RefreshScope
33
+@RequestMapping("/")
34
+@Api(value = "首页聚合API", description = "首页聚合API")
35
+public class AssembleController {
36
+	
37
+	@Autowired
38
+	private MenuServiceI menuService;
39
+	
40
+	@Autowired
41
+	private BannerServiceI bannerService;
42
+	
43
+	@Autowired
44
+	private MessageServiceI messageService;
45
+	
46
+	@ApiOperation(value = "首页数据获取接口", notes = "首页数据获取接口")
47
+	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
48
+			@ApiImplicitParam(paramType = "header",dataType = "String",name = "X-Auth-Token",value = "Token") })
49
+	@RequestMapping(value = "/index/{communityId}",method = RequestMethod.GET)
50
+	public ResponseBean getIndexData(@PathVariable("communityId") Integer communityId, HttpSession session){
51
+		UserElement userElement = (UserElement) session.getAttribute(Constant.APP_USER_SESSION);
52
+		Integer userId = userElement.getId();
53
+		ResponseBean responseBean = new ResponseBean();
54
+		Map<String,Object> indexMap = new HashMap<>();
55
+		//获取菜单数据
56
+		List<TaSysMenu> menuList = menuService.getMenuList(communityId);
57
+		//获取首页banner数据
58
+		List<ToBanner> toBannerList = bannerService.viewAllBannerImg();
59
+		//获取消息总数接口
60
+		Map<String,Object> totalMap = messageService.getMessageTotal(communityId, userId);
61
+		
62
+		//组装数据
63
+		indexMap.put("menuList",menuList);
64
+		indexMap.put("bannerList",toBannerList);
65
+		indexMap.put("messageTotal",totalMap.get("messageTotal"));
66
+		indexMap.put("toDoTotal",totalMap.get("toDoTotal"));
67
+		responseBean.addSuccess(indexMap);
68
+		return responseBean;
69
+	}
70
+}