cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package cn.ksource.web.controller.message;
 
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.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.core.page.PageInfo;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.web.SysInfo;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.entity.message.CmsNews;
import cn.ksource.web.facade.colunm.ColunmFacade;
import cn.ksource.web.facade.message.MessageFacade;
import cn.ksource.web.service.file.FileService;
@Controller
@RequestMapping("/business/pages/cms/message/")
public class MessageController {
 
    @Resource(name="messageFacade")
    private MessageFacade messageFacade;
    
    @Resource(name="colunmFacade")
    private ColunmFacade colunmFacade;
    
    @Resource(name="fileService")
    private FileService fileService;
    
    
    /**
     * 展示栏目管理列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/messageList.html")
    public ModelAndView messageList(HttpServletRequest request,HttpServletResponse response){
        ModelAndView view=new ModelAndView("/page/message/messageList");
        //String categoryId = request.getParameter("categoryId");
        String categoryId = "11";
         boolean isShowAddButton = messageFacade.isShowAddButton(categoryId);
        view.addObject("categoryId", categoryId);
        view.addObject("isShowAddButton", isShowAddButton);
        return view;
    }
    
    /**
     * 展示栏目管理列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/messageData.html")
    public ModelAndView messageData(HttpServletRequest request,PageInfo pageInfo){
        ModelAndView view=new ModelAndView("/page/message/messageData");
        String categoryId = request.getParameter("categoryId");
        PageInfo info = messageFacade.querymessageData(pageInfo,categoryId);
        view.addObject("messages", info);
        return view;
    }
    
    /**
     * 展示栏目管理列表总数量
     */
    @RequestMapping("messageCount.html")
    public void messageCount(HttpServletRequest request,HttpServletResponse response) {
        String categoryId = request.getParameter("categoryId");
        int count = messageFacade.querymessageCount(categoryId);
        WebUtil.write(response, String.valueOf(count));
    }
    
    
    @RequestMapping("/addMessage.html")
    public ModelAndView addMessage(HttpServletRequest request, HttpServletResponse response){
        ModelAndView modelAndView = new ModelAndView("/page/message/addMessage");
        String categoryId = request.getParameter("categoryId");
        //通过分类id查询分类信息
        Map colunm = colunmFacade.queryColunmById(categoryId);
        modelAndView.addObject("colunm",colunm);
        modelAndView.addObject("categoryId",categoryId);
        return modelAndView;
    }
    
    
    @RequestMapping("addMessageSubmit.html")
    public ModelAndView addMessageSubmit(HttpServletRequest request, HttpServletResponse response,CmsNews cmsNews){
        String summary = request.getParameter("summary");
        String content = request.getParameter("content");
        cmsNews.setContent(content);
        cmsNews.setSummary(summary);
        //通过分类id查询分类信息
        boolean b = messageFacade.save(cmsNews,request);
        return WebUtil.sysInfoPage(request, "操作成功!",
                "window.top.hideDialog('0');window.top.query();",
                SysInfo.Success,"");
    
    }
    
    /**
     * 跳转到修改信息界面                                                               
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/updateMessage.html")
    public ModelAndView updateMessage(HttpServletRequest request, HttpServletResponse response){
        ModelAndView modelAndView = new ModelAndView("/page/message/updateMessage");
        String categoryId = request.getParameter("categoryId");
        String messageId = request.getParameter("id");
        //通过分类id查询分类信息
        Map colunm = colunmFacade.queryColunmById(categoryId);
        //通过信息id查询信息
        Map message = messageFacade.queryMessageById(messageId);
        //查询图片信息
        List images = fileService.getFileListByType(messageId, "1");
        //查询附件信息
        List files = fileService.getFileList(messageId);
        message.put("images", images);
        message.put("files", files);
        modelAndView.addObject("colunm",colunm);
        modelAndView.addObject("msg", message);
        return modelAndView;
    }
    
    @RequestMapping("updateMessageSubmit.html")
    public ModelAndView updateMessageSubmit(HttpServletRequest request, HttpServletResponse response,CmsNews cmsNews){
        String summary = request.getParameter("summary");
        String content = request.getParameter("content");
        cmsNews.setContent(content);
        cmsNews.setSummary(summary);
        System.out.println("show_num"+cmsNews.getShow_num());
        //通过分类id查询分类信息
        boolean b = messageFacade.updateMessage(cmsNews,request);
//        return WebUtil.sysInfoPage(request, "操作成功!",
//                "window.top.hideDialog('0');window.top.query();",
//                SysInfo.Success,"");
        if(b) {
            return  WebUtil.sysInfoPage(request,"操作成功!",
                    "window.top.hideDialog('0');window.top.query();",
                    SysInfo.Success,"");
        } else {
            return  WebUtil.sysInfoPage(request,"操作失败,上传文件大小最大为100M",
                    "window.top.query();",
                    SysInfo.Error,"");
        }
        
    }
    
    /**
     * 删除信息
     */
    @RequestMapping("deleteMessage.html")
    public void deleteMessage(HttpServletRequest request,HttpServletResponse response) {
        String id = request.getParameter("id");
        messageFacade.deleteMessage(id);
        WebUtil.write(response, "0");
    };
    
    
    @RequestMapping("classify.html")
    public ModelAndView classify() {
        ModelAndView modelAndView = new ModelAndView("/page/message/left");
        List<Map> menuList = messageFacade.queryMeunListById();
        modelAndView.addObject("menuList", menuList);
        return modelAndView;
    }
    
    
    @RequestMapping("index.html")
    public ModelAndView messagelist(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/page/message/index");
        String categoryId = request.getParameter("categoryId");
        //判断是否需要展示添加按钮
        //如果此分类是列表展示,则显示添加按钮,如果此分类是单信息,则查询该分类下有无数据,如果有一条数据,则不显示添加按钮,如果无数据,则显示添加按钮
        boolean isShowAddButton = messageFacade.isShowAddButton(categoryId);
        
        //查询该分类详细信息
        Map map = colunmFacade.queryColunmById(categoryId);
        modelAndView.addObject("shenpi",map.get("SHENPI"));
        modelAndView.addObject("isShowAddButton",isShowAddButton);
        modelAndView.addObject("categoryId",categoryId);
        return modelAndView;
    }
    
    
    
    /**
     * 获取表格数据(json形式)
     */
    @RequestMapping("listJson.html")
    public void listJson(HttpServletRequest request,HttpServletResponse response) {
        int page = ConvertUtil.obj2Int(request.getParameter("page"));
        int pageSize = ConvertUtil.obj2Int(request.getParameter("rows"));
        String categoryId = request.getParameter("categoryId");
        Map resultMap = messageFacade.queryMessageListJson(categoryId,page,pageSize);
        WebUtil.write(response, JsonUtil.map2Json(resultMap));
    }
    
    
    @RequestMapping("/add.html")
    public ModelAndView add(HttpServletRequest request, HttpServletResponse response){
        ModelAndView modelAndView = new ModelAndView("/page/message/add");
        String categoryId = request.getParameter("categoryId");
        //通过分类id查询分类信息
        Map colunm = colunmFacade.queryColunmById(categoryId);
        
        modelAndView.addObject("colunm",colunm);
        return modelAndView;
    }
    
    
 
    @RequestMapping("save.html")
    public ModelAndView save(HttpServletRequest request, HttpServletResponse response,CmsNews cmsNews){
        String main_people = request.getParameter("main_people");
        String main_people_name = request.getParameter("main_people_TEXT");
        String shoot_name = request.getParameter("shoot_id_TEXT");
        cmsNews.setMainPeopleId(main_people);
        cmsNews.setMainPeopleName(main_people_name);
        cmsNews.setShoot_name(shoot_name);
        //通过分类id查询分类信息
        boolean b = messageFacade.save(cmsNews,request);
        if(b) {
            return  WebUtil.goSysInfoPage(request,"操作成功!",
                    "window.top.setReload();;window.top.closeDialog(0);",
                    SysInfo.Success);
        } else {
            return  WebUtil.goSysInfoPage(request,"操作失败,上传文件大小最大为100M",
                    "window.top.getDomID().contentWindow.reloadDataGrid('dg',{});",
                    SysInfo.Error);
        }
    }
    
}