yujian
2019-02-26 a4d96fb3100e6aaf65e54d260921ceb1c00e54ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.yeshi.fanli.controller.client;
 
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.HomeNavbar;
import com.yeshi.fanli.entity.bus.homemodule.SuperHomeNavbar;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.service.inter.config.SystemService;
import com.yeshi.fanli.service.inter.homemodule.SuperHomeNavbarService;
import org.yeshi.utils.JsonUtil;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("api/v1/navbar")
public class HomeNavbarController<E> {
 
    @Resource
    private SystemService systemService;
    
    @Resource
    private SuperHomeNavbarService superHomeNavbarService;
 
 
 
    /**
     * 获取导航栏内容
     * 
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "gethomenavbar", method = RequestMethod.POST)
    public void gethomenavbar(AcceptData acceptData, PrintWriter out) {
        
        System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        
        List<SuperHomeNavbar> listSuper = superHomeNavbarService.listBySystemCache(system.getId());
        if (listSuper == null || listSuper.size() == 0) {
            out.print(JsonUtil.loadFalseResult("暂无数据"));
            return;
        }
        
        List<HomeNavbar> listNavbar = new ArrayList<HomeNavbar>();
        
        for (SuperHomeNavbar superHomeNavbar : listSuper) {
            HomeNavbar homeNavbar = superHomeNavbar.getHomeNavbar();
            if (homeNavbar == null) {
                continue;
            }
            
            homeNavbar.setCreatetime(null);
            homeNavbar.setUpdatetime(null);
            
            listNavbar.add(homeNavbar);
        }
        
        JSONObject data = new JSONObject();
        data.put("count", listNavbar.size());
        data.put("listNavbar", listNavbar);
        
        out.print(JsonUtil.loadTrueResult(data));
    }
    
}