yujian
2019-06-24 bd331a582851cffcce54316e677e23760de4f384
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
78
79
80
81
package com.yeshi.fanli.controller.client.v2;
 
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.core.task.TaskExecutor;
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.clazz.GoodsClass;
import com.yeshi.fanli.service.inter.clazz.GoodsSubClassLabelService;
import com.yeshi.fanli.service.inter.goods.GoodsClassService;
import com.yeshi.fanli.vo.goods.GoodsSubClassLabelVO;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("api/v2/class")
public class GoodsClassControllerV2 {
 
 
    @Resource
    private GoodsClassService goodsClassService;
 
    @Resource
    private GoodsSubClassLabelService goodsSubClassLabelService;
 
 
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
 
    /**
     * 一级分类
     * @param acceptData
     * @param out
     */
    @RequestMapping(value = "listClass", method = RequestMethod.POST)
    public void listClass(AcceptData acceptData, PrintWriter out) {
        List<GoodsClass> list =goodsClassService.getEffectiveClassCache();
        if (list == null ) {
            list = new ArrayList<GoodsClass>();
        }
 
        JSONObject data = new JSONObject();
        data.put("list", JsonUtil.getApiCommonGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
 
    /**
     * 二级分类、标签
     * 
     * @param acceptData
     * @param gcid
     * @param out
     */
    @RequestMapping(value = "listSubMap", method = RequestMethod.POST)
    public void listSubMap(AcceptData acceptData, Long cid, PrintWriter out) {
        if(cid == null) {
            out.print(JsonUtil.loadFalseResult("参数不能为空"));
            return;
        }
        
        List<GoodsSubClassLabelVO> list = goodsSubClassLabelService.listSubMapCache(cid);
        if (list == null) {
            list = new ArrayList<GoodsSubClassLabelVO>();
        }
        
        JSONObject data = new JSONObject();
        data.put("list", JsonUtil.getApiCommonGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
 
 
    
}