6a13e0e2d41ac340cb086796a28510c3c6ef97e4.svn-base
2.74 KB
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
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.cms.web.front;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.cms.entity.Guestbook;
import com.thinkgem.jeesite.modules.cms.entity.Site;
import com.thinkgem.jeesite.modules.cms.service.GuestbookService;
import com.thinkgem.jeesite.modules.cms.utils.CmsUtils;
/**
* 留言板Controller
* @author ThinkGem
* @version 2013-3-15
*/
@Controller
@RequestMapping(value = "${frontPath}/guestbook")
public class FrontGuestbookController extends BaseController{
@Autowired
private GuestbookService guestbookService;
/**
* 留言板
*/
@RequestMapping(value = "", method=RequestMethod.GET)
public String guestbook(@RequestParam(required=false, defaultValue="1") Integer pageNo,
@RequestParam(required=false, defaultValue="30") Integer pageSize, Model model) {
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
Page<Guestbook> page = new Page<Guestbook>(pageNo, pageSize);
Guestbook guestbook = new Guestbook();
guestbook.setDelFlag(Guestbook.DEL_FLAG_NORMAL);
page = guestbookService.findPage(page, guestbook);
model.addAttribute("page", page);
return "modules/cms/front/themes/"+site.getTheme()+"/frontGuestbook";
}
/**
* 留言板-保存留言信息
*/
@RequestMapping(value = "", method=RequestMethod.POST)
public String guestbookSave(Guestbook guestbook, String validateCode, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
// if (StringUtils.isNotBlank(validateCode)){
// if (ValidateCodeServlet.validate(request, validateCode)){
guestbook.setIp(request.getRemoteAddr());
guestbook.setCreateDate(new Date());
guestbook.setDelFlag(Guestbook.DEL_FLAG_AUDIT);
guestbookService.save(guestbook);
addMessage(redirectAttributes, "提交成功,谢谢!");
// }else{
// addMessage(redirectAttributes, "验证码不正确。");
// }
// }else{
// addMessage(redirectAttributes, "验证码不能为空。");
// }
return "redirect:"+Global.getFrontPath()+"/guestbook";
}
}