dhz
2022-06-22 4d198cd78684d17c849b0bd7d323894009ca17f5
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package cn.ksource.web.controller.column;
 
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.beans.CMS_CATEGORY;
import cn.ksource.core.page.PageInfo;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.StringUtil;
import cn.ksource.core.web.SysInfo;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.entity.colunm.CmsCategory;
import cn.ksource.web.facade.colunm.ColunmFacade;
 
@Controller
@RequestMapping("/business/pages/cms/column/")
@SuppressWarnings("unchecked")
public class ColumnController {
    
    @Resource(name="colunmFacade")
    private ColunmFacade colunmFacade;
    
    
    /**
     * 栏目分类
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("classifyTreeList.html")
    public ModelAndView datamanager(HttpServletRequest request,HttpServletResponse response){
        ModelAndView view=new ModelAndView("/page/colunm/classifyTreeList");
        return view;
    }
    
    /**
     * 栏目分类树
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("classifyTree.html")
    public ModelAndView categoryTree( HttpServletRequest request,HttpServletResponse response) {
        ModelAndView view=new ModelAndView("/page/colunm/classifyTree");
        List<Map> cates = colunmFacade.queryColumnTree(request);
        view.addObject("cates", cates);
        
        String firstCate = request.getParameter("firstCate");
        String secondCate = request.getParameter("secondCate");
        
        view.addObject("firstCate", firstCate);
        view.addObject("secondCate", secondCate);
        return view;
    }
    
    /**
     * 展示档案分类列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/classifyList.html")
    public ModelAndView classifyList(HttpServletRequest request,HttpServletResponse response){
        ModelAndView view=new ModelAndView("/page/colunm/classifyList");
        String pId = request.getParameter("pId");
        view.addObject("pId", pId);
        return view;
    }
    
    /**
     * 展示档案分类列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/classifyData.html")
    public ModelAndView classifyData(HttpServletRequest request,PageInfo pageInfo){
        ModelAndView view=new ModelAndView("/page/colunm/classifyData");
        String pId = request.getParameter("pId");
        PageInfo info = colunmFacade.queryClassifyData(pageInfo,pId);
        view.addObject("info", info);
        return view;
    }
    
    /**
     * 展示档案分类列表总数量
     */
    @RequestMapping("classifyCount.html")
    public void classifyCount(HttpServletRequest request,HttpServletResponse response) {
        String pId = request.getParameter("pId");
        int count = colunmFacade.queryClassifyCount(pId);
        WebUtil.write(response, String.valueOf(count));
    }
    
    
    @RequestMapping("addClassify.html")
    public ModelAndView addClassify(HttpServletRequest request, HttpServletResponse response){
        ModelAndView modelAndView = new ModelAndView("/page/colunm/addClassify");
        String pId = request.getParameter("pId");
        modelAndView.addObject("pId",pId);
        return modelAndView;
    }
 
    @RequestMapping(value="saveClassify.html")
    public ModelAndView saveClassify(HttpServletRequest request,HttpServletResponse response,CmsCategory cmsCategory) {
        //通过id查询级别
        System.out.println("ssssssssssss");
        String pId = request.getParameter("up_id");
        String level = "";
        String firstCate = "";
        String secondCate = "";
        if(StringUtil.isBlank(pId)||Constants.TOP_ID.equals(pId)) {
            level = "1";
        } else {
            level = ConvertUtil.obj2StrBlank(ConvertUtil.obj2Int(colunmFacade.queryLevelById(pId))+1);
            cmsCategory.setUpId(pId);
            CMS_CATEGORY cate = new CMS_CATEGORY(pId).getInstanceById();
            if("2".equals(level)) {
                firstCate = ConvertUtil.obj2StrBlank(cate.getUp_id());
                secondCate = cate.getId();
            } else {
                firstCate = cate.getId();
            }
        }
        cmsCategory.setLevel(level);
        colunmFacade.saveColumnClassify(cmsCategory,request);
        String execJs = "window.top.document.getElementById('myiframe').contentWindow.query('"+pId+"');window.top.queryTree('"+firstCate+"','"+secondCate+"');window.top.hideDialog('0');";
        return WebUtil.sysInfoPage(request, "操作成功!",
                execJs,
                SysInfo.Success,"");
    }
    
    /**
     * 删除栏目分类
     * @param id
     * @param request
     * @return
     */
    @RequestMapping("/delClassify.html")
     public void del(HttpServletRequest request,HttpServletResponse response) {
       String id = request.getParameter("id");
       Map result = colunmFacade.deleteClassify(id);       
       WebUtil.write(response, JsonUtil.map2Json(result));
   }
    
    /**
     * 跳转到修改页面
     */
    @RequestMapping("updateClassify.html")
    public ModelAndView update(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/page/colunm/updateClassify");
        String id = request.getParameter("id");
        Map colunmMap = colunmFacade.queryColunmById(id);
        System.out.println("classifyImage:"+colunmMap.get("CLASSIFYIMAGE"));
        modelAndView.addObject("cate", colunmMap);
        String pId = request.getParameter("pId");
        modelAndView.addObject("pId",pId);
        return modelAndView;
    }
    
    
    
    /**
     * 更新栏目管理分类
     */
    @RequestMapping( "updateColunm.html")
    public ModelAndView updateColunm(HttpServletRequest request,HttpServletResponse response,CmsCategory cmsCategory) {
        String pId = request.getParameter("up_id");
        String level = "";
        String firstCate = "";
        String secondCate = "";
        if(StringUtil.isBlank(pId)||Constants.TOP_ID.equals(pId)) {
            level = "1";
        } else {
            
            CMS_CATEGORY cate = new CMS_CATEGORY(pId).getInstanceById();
            if("2".equals(level)) {
                firstCate = ConvertUtil.obj2StrBlank(cate.getUp_id());
                secondCate = cate.getId();
            } else {
                firstCate = cate.getId();
            }
            level = ConvertUtil.obj2StrBlank(ConvertUtil.obj2Int(colunmFacade.queryLevelById(pId))+1);
            cmsCategory.setUpId(pId);
        }
        colunmFacade.updateColunm(cmsCategory,request);
        String execJs = "window.top.document.getElementById('myiframe').contentWindow.query('"+pId+"');window.top.queryTree('"+firstCate+"','"+secondCate+"');window.top.hideDialog('0');";
        return WebUtil.sysInfoPage(request, "操作成功!",
                execJs,
                SysInfo.Success,"");
    }
    
 
}