yujian
2019-09-03 2ddf5b8a1290123e2d1c05bcc851ec35cd217afc
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
package com.yeshi.fanli.controller.client.v1;
 
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 org.yeshi.utils.JsonUtil;
 
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.HomeNavbar;
import com.yeshi.fanli.entity.bus.homemodule.HomeNavbar.NavbarTypeEnum;
import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("api/v1/navbar")
public class HomeNavbarController<E> {
 
    @Resource
    private HomeNavbarService homeNavbarService;
 
 
    /**
     * 获取导航栏内容
     * 
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "gethomenavbar", method = RequestMethod.POST)
    public void gethomenavbar(AcceptData acceptData, PrintWriter out) {
        
        List<HomeNavbar> list = new ArrayList<HomeNavbar>();
        
        List<HomeNavbar> listNavbar = homeNavbarService.listQueryDefaultNavbar(0);
        if (listNavbar != null) {
            list.addAll(listNavbar);
        }
        
        for (int i = 0; i < list.size(); i ++) {
            NavbarTypeEnum type = list.get(i).getType();
            if (type == NavbarTypeEnum.commonTemplate) {
                list.remove(i);
                i--;
            }
        }
        
        JSONObject data = new JSONObject();
        data.put("count", list.size());
        data.put("listNavbar", JsonUtil.getApiCommonGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
}