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
package cn.ksource.web.controller.link;
 
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.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.entity.link.CmsLink;
import cn.ksource.web.facade.link.LinkFacade;
 
@Controller
@RequestMapping("/business/pages/cms/link")
public class LinkController {
 
    @Resource(name="linkFacade")
    private LinkFacade linkFacade;
    
    
    /**
     * 展示链接管理列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/linkList.html")
    public ModelAndView linkList(HttpServletRequest request,HttpServletResponse response){
        ModelAndView view=new ModelAndView("/page/link/linkList");
        String categoryId = request.getParameter("categoryId");
        view.addObject("categoryId", categoryId);
        return view;
    }
    
    /**
     * 展示链接管理列表
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/linkData.html")
    public ModelAndView linkData(HttpServletRequest request,PageInfo pageInfo){
        ModelAndView view=new ModelAndView("/page/link/linkData");
        String categoryId = request.getParameter("categoryId");
        PageInfo info = linkFacade.querylinkData( pageInfo, categoryId);
        view.addObject("links", info);
        return view;
    }
    
    /**
     * 展示链接管理列表总数量
     */
    @RequestMapping("linkCount.html")
    public void linkCount(HttpServletRequest request,HttpServletResponse response) {
        String categoryId = request.getParameter("categoryId");
        int count = linkFacade.querylinkCount(categoryId);
        WebUtil.write(response, String.valueOf(count));
    }
    
    
    @RequestMapping("/addLink.html")
    public ModelAndView addLink(HttpServletRequest request, HttpServletResponse response){
        ModelAndView modelAndView = new ModelAndView("/page/link/addLink");
        String categoryId = request.getParameter("categoryId");
        //通过分类id查询分类信息
        Map link = linkFacade.queryLinkCategoryById(categoryId);
        modelAndView.addObject("link",link);
        modelAndView.addObject("categoryId",categoryId);
        System.out.println("categoryId:"+categoryId);
        return modelAndView;
    }
    
    
    @RequestMapping("addLinkSubmit.html")
    public ModelAndView addLinkSubmit(HttpServletRequest request, HttpServletResponse response,CmsLink link){
        String summary = request.getParameter("summary");
        String content = request.getParameter("content");
        link.setContent(content);
        link.setSummary(summary);
        //通过分类id查询分类信息
        boolean b = linkFacade.save(link,request);
        return WebUtil.sysInfoPage(request, "操作成功!",
                "window.top.hideDialog('0');window.top.query();",
                SysInfo.Success,"");
    
    }
    
    /**
     * 跳转到修改信息界面                                                               
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/updateLink.html")
    public ModelAndView update(HttpServletRequest request, HttpServletResponse response){
        ModelAndView modelAndView = new ModelAndView("/page/link/updateLink");
        String categoryId = request.getParameter("categoryId");
        String linkId = request.getParameter("id");
        //通过分类id查询分类信息
        Map linkCategory = linkFacade.queryLinkCategoryById(categoryId);
        //通过信息id查询信息
        Map link = linkFacade.queryLinkById(linkId);
        
        modelAndView.addObject("linkCategory",linkCategory);
        modelAndView.addObject("link", link);
        return modelAndView;
    }
    
    @RequestMapping("updateLinkSubmit.html")
    public ModelAndView updateLink(HttpServletRequest request, HttpServletResponse response,CmsLink link){
        String summary = request.getParameter("summary");
        String content = request.getParameter("content");
        System.out.println("content"+content);
        link.setContent(content);
        link.setSummary(summary);
        //通过分类id查询分类信息
        boolean b = linkFacade.updateLink(link,request);
        return WebUtil.sysInfoPage(request, "操作成功!",
                "window.top.hideDialog('0');window.top.query();",
                SysInfo.Success,"");
        
    }
    
    /**
     * 删除信息
     */
    @RequestMapping("deleteLink.html")
    public void deleteLink(HttpServletRequest request,HttpServletResponse response) {
        String id = request.getParameter("id");
        String index = request.getParameter("index");
        linkFacade.deleteLink(id,index);
        WebUtil.write(response, "0");
    }
}