Commit d9ad22de authored by Huang's avatar Huang
Browse files

no commit message

parent c235571d
/**
* Copyright &copy; 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package com.jeespring.modules.cms.web.front;
import java.util.Date;
import java.util.List;
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.PathVariable;
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.bind.annotation.ResponseBody;
import com.google.common.collect.Lists;
import com.jeespring.common.config.Global;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.servlet.ValidateCodeServlet;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.cms.entity.Article;
import com.jeespring.modules.cms.entity.Category;
import com.jeespring.modules.cms.entity.Comment;
import com.jeespring.modules.cms.entity.Link;
import com.jeespring.modules.cms.entity.Site;
import com.jeespring.modules.cms.service.ArticleDataService;
import com.jeespring.modules.cms.service.ArticleService;
import com.jeespring.modules.cms.service.CategoryService;
import com.jeespring.modules.cms.service.CommentService;
import com.jeespring.modules.cms.service.LinkService;
import com.jeespring.modules.cms.service.SiteService;
import com.jeespring.modules.cms.utils.CmsUtils;
/**
* 网站Controller
* @author JeeSpring
* @version 2013-5-29
*/
@Controller
@RequestMapping(value = "${frontPath}")
public class FrontController extends AbstractBaseController{
@Autowired
private ArticleService articleService;
@Autowired
private ArticleDataService articleDataService;
@Autowired
private LinkService linkService;
@Autowired
private CommentService commentService;
@Autowired
private CategoryService categoryService;
@Autowired
private SiteService siteService;
/**
* 网站首页
*/
@RequestMapping
public String index(Model model,HttpServletRequest request, HttpServletResponse response) {
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
model.addAttribute("isIndex", true);
if(request.getParameter("theme")!=null){
site.setTheme(request.getParameter("theme"));
}
return "modules/cms/front/themes/"+site.getTheme()+"/frontIndex";
}
@RequestMapping(value = "index2")
public String index2(Model model,HttpServletRequest request, HttpServletResponse response) {
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
model.addAttribute("isIndex", true);
if(request.getParameter("theme")!=null){
site.setTheme(request.getParameter("theme"));
}
return "modules/cms/front/themes/"+site.getTheme()+"/index";
}
/**
* 网站首页
*/
@RequestMapping(value = "index-{siteId}${urlSuffix}")
public String index(@PathVariable String siteId, Model model) {
if ("1".equals(siteId)){
return "redirect:"+Global.getFrontPath();
}
Site site = CmsUtils.getSite(siteId);
// 子站有独立页面,则显示独立页面
if (StringUtils.isNotBlank(site.getCustomIndexView())){
model.addAttribute("site", site);
model.addAttribute("isIndex", true);
return "modules/cms/front/themes/"+site.getTheme()+"/frontIndex"+site.getCustomIndexView();
}
// 否则显示子站第一个栏目
List<Category> mainNavList = CmsUtils.getMainNavList(siteId);
if (mainNavList.size() > 0){
String firstCategoryId = CmsUtils.getMainNavList(siteId).get(0).getId();
return "redirect:"+Global.getFrontPath()+"/list-"+firstCategoryId+Global.getUrlSuffix();
}else{
model.addAttribute("site", site);
return "modules/cms/front/themes/"+site.getTheme()+"/frontListCategory";
}
}
/**
* 内容列表
*/
@RequestMapping(value = "list-{categoryId}${urlSuffix}")
public String list(@PathVariable String categoryId, @RequestParam(required=false, defaultValue="1") Integer pageNo,
@RequestParam(required=false, defaultValue="15") Integer pageSize, Model model) {
Category category = categoryService.get(categoryId);
if (category==null){
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
return "error/404";
}
Site site = siteService.get(category.getSite().getId());
model.addAttribute("site", site);
// 2:简介类栏目,栏目第一条内容
if("2".equals(category.getShowModes()) && "article".equals(category.getModule())){
// 如果没有子栏目,并父节点为跟节点的,栏目列表为当前栏目。
List<Category> categoryList = Lists.newArrayList();
if ("1".equals(category.getParent().getId())){
categoryList.add(category);
}else{
categoryList = categoryService.findByParentId(category.getParent().getId(), category.getSite().getId());
}
model.addAttribute("category", category);
model.addAttribute("categoryList", categoryList);
// 获取文章内容
Page<Article> page = new Page<Article>(1, 1, -1);
Article article = new Article(category);
page = articleService.findPage(page, article, false);
if (page.getList().size()>0){
article = page.getList().get(0);
article.setArticleData(articleDataService.get(article.getId()));
articleService.updateHitsAddOne(article.getId());
}
model.addAttribute("article", article);
CmsUtils.addViewConfigAttribute(model, category);
CmsUtils.addViewConfigAttribute(model, article.getViewConfig());
return "modules/cms/front/themes/"+site.getTheme()+"/"+getTpl(article);
}else{
List<Category> categoryList = categoryService.findByParentId(category.getId(), category.getSite().getId());
// 展现方式为1 、无子栏目或公共模型,显示栏目内容列表
if("1".equals(category.getShowModes())||categoryList.size()==0){
// 有子栏目并展现方式为1,则获取第一个子栏目;无子栏目,则获取同级分类列表。
if(categoryList.size()>0){
category = categoryList.get(0);
}else{
// 如果没有子栏目,并父节点为跟节点的,栏目列表为当前栏目。
if ("1".equals(category.getParent().getId())){
categoryList.add(category);
}else{
categoryList = categoryService.findByParentId(category.getParent().getId(), category.getSite().getId());
}
}
model.addAttribute("category", category);
model.addAttribute("categoryList", categoryList);
// 获取内容列表
if ("article".equals(category.getModule())){
Page<Article> page = new Page<Article>(pageNo, pageSize);
//System.out.println(page.getPageNo());
page = articleService.findPage(page, new Article(category), false);
model.addAttribute("page", page);
// 如果第一个子栏目为简介类栏目,则获取该栏目第一篇文章
if ("2".equals(category.getShowModes())){
Article article = new Article(category);
if (page.getList().size()>0){
article = page.getList().get(0);
article.setArticleData(articleDataService.get(article.getId()));
articleService.updateHitsAddOne(article.getId());
}
model.addAttribute("article", article);
CmsUtils.addViewConfigAttribute(model, category);
CmsUtils.addViewConfigAttribute(model, article.getViewConfig());
return "modules/cms/front/themes/"+site.getTheme()+"/"+getTpl(article);
}
}else if ("link".equals(category.getModule())){
Page<Link> page = new Page<Link>(1, -1);
page = linkService.findPage(page, new Link(category), false);
model.addAttribute("page", page);
}
String view = "/frontList";
if (StringUtils.isNotBlank(category.getCustomListView())){
view = "/"+category.getCustomListView();
}
CmsUtils.addViewConfigAttribute(model, category);
site =siteService.get(category.getSite().getId());
//System.out.println("else 栏目第一条内容 _2 :"+category.getSite().getTheme()+","+site.getTheme());
return "modules/cms/front/themes/"+siteService.get(category.getSite().getId()).getTheme()+view;
//return "modules/cms/front/themes/"+category.getSite().getTheme()+view;
}
// 有子栏目:显示子栏目列表
else{
model.addAttribute("category", category);
model.addAttribute("categoryList", categoryList);
String view = "/frontListCategory";
if (StringUtils.isNotBlank(category.getCustomListView())){
view = "/"+category.getCustomListView();
}
CmsUtils.addViewConfigAttribute(model, category);
return "modules/cms/front/themes/"+site.getTheme()+view;
}
}
}
/**
* 内容列表(通过url自定义视图)
*/
@RequestMapping(value = "listc-{categoryId}-{customView}${urlSuffix}")
public String listCustom(@PathVariable String categoryId, @PathVariable String customView, @RequestParam(required=false, defaultValue="1") Integer pageNo,
@RequestParam(required=false, defaultValue="15") Integer pageSize, Model model) {
Category category = categoryService.get(categoryId);
if (category==null){
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
return "error/404";
}
Site site = siteService.get(category.getSite().getId());
model.addAttribute("site", site);
List<Category> categoryList = categoryService.findByParentId(category.getId(), category.getSite().getId());
model.addAttribute("category", category);
model.addAttribute("categoryList", categoryList);
CmsUtils.addViewConfigAttribute(model, category);
return "modules/cms/front/themes/"+site.getTheme()+"/frontListCategory"+customView;
}
/**
* 显示内容
*/
@RequestMapping(value = "view-{categoryId}-{contentId}${urlSuffix}")
public String view(@PathVariable String categoryId, @PathVariable String contentId, Model model) {
Category category = categoryService.get(categoryId);
if (category==null){
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
return "error/404";
}
model.addAttribute("site", category.getSite());
if ("article".equals(category.getModule())){
// 如果没有子栏目,并父节点为跟节点的,栏目列表为当前栏目。
List<Category> categoryList = Lists.newArrayList();
if ("1".equals(category.getParent().getId())){
categoryList.add(category);
}else{
categoryList = categoryService.findByParentId(category.getParent().getId(), category.getSite().getId());
}
// 获取文章内容
Article article = articleService.get(contentId);
if (article==null || !Article.DEL_FLAG_NORMAL.equals(article.getDelFlag())){
return "error/404";
}
// 文章阅读次数+1
articleService.updateHitsAddOne(contentId);
// 获取推荐文章列表
List<Object[]> relationList = articleService.findByIds(articleDataService.get(article.getId()).getRelation());
// 将数据传递到视图
model.addAttribute("category", categoryService.get(article.getCategory().getId()));
model.addAttribute("categoryList", categoryList);
article.setArticleData(articleDataService.get(article.getId()));
model.addAttribute("article", article);
model.addAttribute("relationList", relationList);
CmsUtils.addViewConfigAttribute(model, article.getCategory());
CmsUtils.addViewConfigAttribute(model, article.getViewConfig());
Site site = siteService.get(category.getSite().getId());
model.addAttribute("site", site);
// return "modules/cms/front/themes/"+category.getSite().getTheme()+"/"+getTpl(article);
return "modules/cms/front/themes/"+site.getTheme()+"/"+getTpl(article);
}
return "error/404";
}
/**
* 内容评论
*/
@RequestMapping(value = "comment", method=RequestMethod.GET)
public String comment(String theme, Comment comment, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Comment> page = new Page<Comment>(request, response);
Comment c = new Comment();
c.setCategory(comment.getCategory());
c.setContentId(comment.getContentId());
c.setDelFlag(Comment.DEL_FLAG_NORMAL);
page = commentService.findPage(page, c);
model.addAttribute("page", page);
model.addAttribute("comment", comment);
return "modules/cms/front/themes/"+theme+"/frontComment";
}
/**
* 内容评论保存
*/
@ResponseBody
@RequestMapping(value = "comment", method=RequestMethod.POST)
public String commentSave(Comment comment, String validateCode,@RequestParam(required=false) String replyId, HttpServletRequest request) {
if (StringUtils.isNotBlank(validateCode)){
if (ValidateCodeServlet.validate(request, validateCode)){
if (StringUtils.isNotBlank(replyId)){
Comment replyComment = commentService.get(replyId);
if (replyComment != null){
comment.setContent("<div class=\"reply\">"+replyComment.getName()+":<br/>"
+replyComment.getContent()+"</div>"+comment.getContent());
}
}
comment.setIp(request.getRemoteAddr());
comment.setCreateDate(new Date());
comment.setDelFlag(Comment.DEL_FLAG_AUDIT);
commentService.save(comment);
return "{result:1, message:'提交成功。'}";
}else{
return "{result:2, message:'验证码不正确。'}";
}
}else{
return "{result:2, message:'验证码不能为空。'}";
}
}
/**
* 站点地图
*/
@RequestMapping(value = "map-{siteId}${urlSuffix}")
public String map(@PathVariable String siteId, Model model) {
Site site = CmsUtils.getSite(siteId!=null?siteId:Site.defaultSiteId());
model.addAttribute("site", site);
return "modules/cms/front/themes/"+site.getTheme()+"/frontMap";
}
private String getTpl(Article article){
if(StringUtils.isBlank(article.getCustomContentView())){
String view = null;
Category c = article.getCategory();
boolean goon = true;
do{
if(StringUtils.isNotBlank(c.getCustomContentView())){
view = c.getCustomContentView();
goon = false;
}else if(c.getParent() == null || c.getParent().isRoot()){
goon = false;
}else{
c = c.getParent();
}
}while(goon);
return StringUtils.isBlank(view) ? Article.DEFAULT_TEMPLATE : view;
}else{
return article.getCustomContentView();
}
}
}
/**
* Copyright &copy; 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package com.jeespring.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.jeespring.common.config.Global;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.cms.entity.Guestbook;
import com.jeespring.modules.cms.entity.Site;
import com.jeespring.modules.cms.service.GuestbookService;
import com.jeespring.modules.cms.utils.CmsUtils;
/**
* 留言板Controller
* @author JeeSpring
* @version 2013-3-15
*/
@Controller
@RequestMapping(value = "${frontPath}/guestbook")
public class FrontGuestbookController extends AbstractBaseController {
@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";
}
}
/**
* Copyright &copy; 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package com.jeespring.modules.cms.web.front;
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.RequestParam;
import com.jeespring.common.persistence.Page;
import com.jeespring.common.utils.StringUtils;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.cms.entity.Article;
import com.jeespring.modules.cms.entity.Guestbook;
import com.jeespring.modules.cms.entity.Site;
import com.jeespring.modules.cms.service.ArticleService;
import com.jeespring.modules.cms.service.GuestbookService;
import com.jeespring.modules.cms.utils.CmsUtils;
import com.jeespring.modules.sys.utils.UserUtils;
/**
* 网站搜索Controller
* @author JeeSpring
* @version 2013-5-29
*/
@Controller
@RequestMapping(value = "${frontPath}/search")
public class FrontSearchController extends AbstractBaseController{
@Autowired
private ArticleService articleService;
@Autowired
private GuestbookService guestbookService;
/**
* 全站搜索
*/
@RequestMapping(value = "")
public String search(String t, @RequestParam(required=false) String q, @RequestParam(required=false) String qand, @RequestParam(required=false) String qnot,
@RequestParam(required=false) String a, @RequestParam(required=false) String cid, @RequestParam(required=false) String bd,
@RequestParam(required=false) String ed, HttpServletRequest request, HttpServletResponse response, Model model) {
long start = System.currentTimeMillis();
Site site = CmsUtils.getSite(Site.defaultSiteId());
model.addAttribute("site", site);
// 重建索引(需要超级管理员权限)
if ("cmd:reindex".equals(q)){
if (UserUtils.getUser().isAdmin()){
// 文章模型
if (StringUtils.isBlank(t) || "article".equals(t)){
articleService.createIndex();
}
// 留言模型
else if ("guestbook".equals(t)){
guestbookService.createIndex();
}
model.addAttribute("message", "重建索引成功,共耗时 " + (System.currentTimeMillis() - start) + "毫秒。");
}else{
model.addAttribute("message", "你没有执行权限。");
}
}
// 执行检索
else{
String qStr = StringUtils.replace(StringUtils.replace(q, ",", " "), ", ", " ");
// 如果是高级搜索
if ("1".equals(a)){
if (StringUtils.isNotBlank(qand)){
qStr += " +" + StringUtils.replace(StringUtils.replace(StringUtils.replace(qand, ",", " "), ", ", " "), " ", " +");
}
if (StringUtils.isNotBlank(qnot)){
qStr += " -" + StringUtils.replace(StringUtils.replace(StringUtils.replace(qnot, ",", " "), ", ", " "), " ", " -");
}
}
// 文章检索
if (StringUtils.isBlank(t) || "article".equals(t)){
Page<Article> page = articleService.search(new Page<Article>(request, response), qStr, cid, bd, ed);
page.setMessage("匹配结果,共耗时 " + (System.currentTimeMillis() - start) + "毫秒。");
model.addAttribute("page", page);
}
// 留言检索
else if ("guestbook".equals(t)){
Page<Guestbook> page = guestbookService.search(new Page<Guestbook>(request, response), qStr, bd, ed);
page.setMessage("匹配结果,共耗时 " + (System.currentTimeMillis() - start) + "毫秒。");
model.addAttribute("page", page);
}
}
model.addAttribute("t", t);// 搜索类型
model.addAttribute("q", q);// 搜索关键字
model.addAttribute("qand", qand);// 包含以下全部的关键词
model.addAttribute("qnot", qnot);// 不包含以下关键词
model.addAttribute("cid", cid);// 搜索类型
return "modules/cms/front/themes/"+site.getTheme()+"/frontSearch";
}
}
/**
* Copyright &copy; 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a>All rights reserved.
*/
package com.jeespring.modules.cms.web.front;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeespring.common.web.AbstractBaseController;
import com.jeespring.modules.cms.utils.WiexinSignUtil;
/**
* 测试Controller
* @author JeeSpring
* @version 2014-02-28
*/
@Controller
@RequestMapping(value = "${frontPath}/weixin")
public class WeixinController extends AbstractBaseController {
/**
*
* @param signature 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
* @param timestamp 时间戳
* @param nonce 随机数
* @param echostr 随机数
* @return
*/
@RequestMapping(value = "", method = RequestMethod.GET)
@ResponseBody
public String get(String signature, String timestamp, String nonce, String echostr, HttpServletRequest request) {
System.out.println("=============================================== get start");
for (Object o : request.getParameterMap().keySet()){
System.out.println(o + " = " + request.getParameter((String)o));
}
System.out.println("=============================================== get end");
// 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
if (WiexinSignUtil.checkSignature(signature, timestamp, nonce)) {
return echostr;
}
return "";
}
@RequestMapping(value = "", method = RequestMethod.POST)
@ResponseBody
public String post(String signature, String timestamp, String nonce, String echostr, HttpServletRequest request) {
System.out.println("=============================================== post start");
for (Object o : request.getParameterMap().keySet()){
System.out.println(o + " = " + request.getParameter((String)o));
}
System.out.println("=============================================== post end");
StringBuilder result = new StringBuilder();
result.append("<xml>" +
"<ToUserName><![CDATA[toUser]]></ToUserName>" +
"<FromUserName><![CDATA[fromUser]]></FromUserName>" +
"<CreateTime>12345678</CreateTime>" +
"<MsgType><![CDATA[text]]></MsgType>" +
"<Content><![CDATA[你好]]></Content>" +
"</xml>");
return result.toString();
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeespring.modules.cms.dao.ArticleDao">
<sql id="cmsArticleColumns">
a.id AS "id",
a.category_id AS "category.id",
a.title AS "title",
a.link AS "link",
a.color AS "color",
a.image AS "image",
a.keywords AS "keywords",
a.description AS "description",
a.weight AS "weight",
a.weight_date AS "weightDate",
a.hits AS "hits",
a.posid AS "posid",
a.custom_content_view AS "customContentView",
a.view_config AS "viewConfig",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.remarks AS "remarks",
a.del_flag AS "delFlag",
c.name AS "category.name",
u.name AS "user.name"
</sql>
<sql id="cmsArticleJoins">
JOIN cms_category c ON c.id = a.category_id
JOIN sys_office o ON o.id = c.office_id
JOIN sys_user u ON u.id = a.create_by
</sql>
<select id="get" resultType="Article">
SELECT
<include refid="cmsArticleColumns"/>
FROM cms_article a
<include refid="cmsArticleJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Article">
SELECT
<include refid="cmsArticleColumns"/>
FROM cms_article a
<include refid="cmsArticleJoins"/>
<where>
a.del_flag = #{delFlag}
<if test="title != null and title != ''">
AND a.title LIKE
<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{title}, '%')</if>
</if>
<if test="posid != null and posid != ''">
AND a.posid LIKE
<if test="dbName == 'oracle'">'%'||#{posid}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{posid}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{posid}, '%')</if>
</if>
<if test="category.id != null and category.id != ''">
AND (a.category_id = #{category.id}
<if test="category.parentIds != null and category.parentIds != ''">
or c.parent_ids like
<if test="dbName == 'oracle'">'%'||#{category.id}||'%'</if>
<if test="dbName == 'mssql'">'%,'+#{category.id}+',%'</if>
<if test="dbName == 'mysql'">CONCAT('%,', #{category.id}, ',%')</if>
</if>)
</if>
<if test="image != null and image != ''">
AND a.image = #{image}
</if>
<if test="createBy != null and createBy.id != null and createBy.id != ''">
AND a.create_by = #{createBy.id}
</if>
<!-- ${sqlMap.dsf}-->
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.weight DESC, a.update_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Article">
SELECT
<include refid="cmsArticleColumns"/>
FROM cms_article a
<include refid="cmsArticleJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.weight DESC, a.update_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO cms_article(
id,
category_id,
title,
link,
color,
image,
keywords,
description,
weight,
weight_date,
hits,
posid,
custom_content_view,
view_config,
create_by,
create_date,
update_by,
update_date,
remarks,
del_flag
) VALUES (
#{id},
#{category.id},
#{title},
#{link},
#{color},
#{image},
#{keywords},
#{description},
#{weight},
#{weightDate},
#{hits},
#{posid},
#{customContentView},
#{viewConfig},
#{createBy.id},
#{createDate},
#{updateBy.id},
#{updateDate},
#{remarks},
#{delFlag}
)
</insert>
<update id="update">
UPDATE cms_article SET
category_id = #{category.id},
title = #{title},
link = #{link},
color = #{color},
image = #{image},
keywords = #{keywords},
description = #{description},
weight = #{weight},
weight_date = #{weightDate},
hits = #{hits},
posid = #{posid},
custom_content_view = #{customContentView},
view_config = #{viewConfig},
create_date = #{createDate},
update_by = #{updateBy.id},
update_date = #{updateDate},
remarks = #{remarks},
del_flag = #{delFlag}
WHERE id = #{id}
</update>
<update id="delete">
UPDATE cms_article SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<select id="findByIdIn" resultType="Article">
SELECT
<include refid="cmsArticleColumns"/>
from cms_article a where
<where>
id in (${id});
</where>
</select>
<update id="updateExpiredWeight">
update cms_article SET
weight = 0
WHERE weight &gt; 0 AND weight_date &lt;
<if test="dbName == 'oracle'">sysdate</if>
<if test="dbName == 'mssql'">FLOOR(CONVERT(FLOAT,GETDATE()))</if>
<if test="dbName == 'mysql'">CURDATE()</if>
</update>
<update id="updateHitsAddOne">
update cms_article set
hits = hits+1
WHERE id = #{id}
</update>
<select id="findStats" resultType="Category">
select max(c.id) AS "id",
max(c.name) AS "name",
max(cp.id) AS "parent.id",
max(cp.name) AS "parent.name",
count(*) AS "cnt",
sum(a.hits) AS "hits",
max(a.update_date) as "updateDate",
max(o.id) AS "office.id",
max(o.name) AS "office.name"
FROM cms_article a
RIGHT JOIN cms_category c ON c.id = a.category_id
JOIN cms_category cp ON c.parent_id = cp.id
JOIN sys_office o ON o.id = c.office_id
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
AND c.site_id = #{site.id}
<if test="office.id != null and office.id != ''">
AND (c.office_id = #{office.id} OR o.parent_ids like
<if test="dbName == 'oracle'">'%'||#{office.id}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{office.id}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{office.id}, '%')</if>)
</if>
<if test="id != null and id != ''">
AND (c.id = #{id} OR c.parent_ids LIKE
<if test="dbName == 'oracle'">'%'||#{id}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{id}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{id}, '%')</if>)
</if>
group by cp.sort, cp.id, c.sort, c.id
order by cp.sort, cp.id, c.sort, c.id
</where>
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeespring.modules.cms.dao.ArticleDataDao">
<sql id="cmsArticleDataColumns">
a.id AS "id",
a.content AS "content",
a.copyfrom AS "copyfrom",
a.relation AS "relation",
a.allow_comment AS "allow_comment"
</sql>
<sql id="cmsArticleDataJoins">
</sql>
<select id="get" resultType="ArticleData">
SELECT
<include refid="cmsArticleDataColumns"/>
FROM cms_article_data a
<include refid="cmsArticleDataJoins"/>
WHERE a.id = #{id}
</select>
<insert id="insert">
INSERT INTO cms_article_data(
id,
content,
copyfrom,
relation,
allow_comment
) VALUES (
#{id},
#{content},
#{copyfrom},
#{relation},
#{allowComment}
)
</insert>
<update id="update">
UPDATE cms_article_data SET
content = #{content},
copyfrom = #{copyfrom},
relation = #{relation},
allow_comment = #{allowComment}
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeespring.modules.cms.dao.CommentDao">
<sql id="cmsCommentDaoColumns">
a.id AS "id",
a.category_id AS "category.id",
a.content_id AS "contentId",
a.title AS "title",
a.content AS "content",
a.name AS "name",
a.ip AS "ip",
a.create_date AS "createDate",
a.audit_user_id AS "auditUser.id",
a.audit_date AS "auditDate",
a.del_flag AS "delFlag"
</sql>
<sql id="cmsCommentDaoJoins">
</sql>
<select id="get" resultType="Comment">
SELECT
<include refid="cmsCommentDaoColumns"/>
FROM cms_comment a
<include refid="cmsCommentDaoJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Comment">
SELECT
<include refid="cmsCommentDaoColumns"/>
FROM cms_comment a
<include refid="cmsCommentDaoJoins"/>
<where>
a.del_flag = #{delFlag}
<if test="title != null and title != ''">
AND a.title LIKE
<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
<if test="dbName == 'mysql'">CONCAT('%', #{title}, '%')</if>
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.create_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Comment">
SELECT
<include refid="cmsCommentDaoColumns"/>
FROM cms_comment a
<include refid="cmsCommentDaoJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.create_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO cms_comment(
id,
category_id,
content_id,
title,
content,
name,
ip,
create_date,
audit_user_id,
audit_date,
del_flag
) VALUES (
#{id},
#{category.id},
#{contentId},
#{title},
#{content},
#{name},
#{ip},
#{createDate},
#{auditUser.id},
#{auditDate},
#{delFlag}
)
</insert>
<update id="update">
UPDATE cms_comment SET
category_id = #{category.id},
content_id = #{contentId},
title = #{title},
content = #{content},
name = #{name},
ip = #{ip},
create_date = #{createDate},
audit_user_id = #{auditUser.id},
audit_date = #{auditDate},
del_flag = #{delFlag}
WHERE id = #{id}
</update>
<update id="delete">
UPDATE cms_comment SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jeespring.modules.cms.dao.GuestbookDao">
<sql id="cmsGuestbookColumns">
a.id AS "id",
a.type AS "type",
a.content AS "content",
a.name AS "name",
a.email AS "email",
a.phone AS "phone",
a.workunit AS "workunit",
a.ip AS "ip",
a.create_date AS "createDate",
a.re_user_id AS "reUser.id",
a.re_date AS "reDate",
a.re_content AS "reContent",
a.del_flag AS "delFlag",
u.name AS "reUser.name"
</sql>
<sql id="cmsGuestbookJoins">
LEFT JOIN sys_user u ON u.id = a.re_user_id
</sql>
<select id="get" resultType="Guestbook">
SELECT
<include refid="cmsGuestbookColumns"/>
FROM cms_guestbook a
<include refid="cmsGuestbookJoins"/>
WHERE a.id = #{id}
</select>
<select id="findList" resultType="Guestbook">
SELECT
<include refid="cmsGuestbookColumns"/>
FROM cms_guestbook a
<include refid="cmsGuestbookJoins"/>
<where>
a.del_flag = #{delFlag}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.create_date DESC
</otherwise>
</choose>
</select>
<select id="findAllList" resultType="Guestbook">
SELECT
<include refid="cmsGuestbookColumns"/>
FROM cms_guestbook a
<include refid="cmsGuestbookJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.create_date DESC
</otherwise>
</choose>
</select>
<insert id="insert">
INSERT INTO cms_guestbook(
id,
type,
content,
name,
email,
phone,
workunit,
ip,
create_date,
re_user_id,
re_date,
re_content,
del_flag
) VALUES (
#{id},
#{type},
#{content},
#{name},
#{email},
#{phone},
#{workunit},
#{ip},
#{createDate},
#{reUser.id},
#{reDate},
#{reContent},
#{delFlag}
)
</insert>
<update id="update">
UPDATE cms_guestbook SET
type = #{type},
content = #{content},
name = #{name},
email = #{email},
phone = #{phone},
workunit = #{workunit},
ip = #{ip},
create_date = #{createDate},
re_user_id = #{reUser.id},
re_date = #{reDate},
re_content = #{reContent},
del_flag = #{delFlag}
WHERE id = #{id}
</update>
<update id="delete">
UPDATE cms_guestbook SET
del_flag = #{DEL_FLAG_DELETE}
WHERE id = #{id}
</update>
<select id="findByIdIn" resultType="Guestbook">
SELECT
<include refid="cmsGuestbookColumns"/>
from cms_guestbook a where
<where>
id in ();
</where>
</select>
</mapper>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>内容管理</title>
<meta name="decorator" content="default"/>
<%@ include file="/WEB-INF/views/include/headMeta.jsp" %>
<%@ include file="/WEB-INF/views/include/headCss.jsp" %>
<%@ include file="/WEB-INF/views/include/headJs.jsp" %>
</head>
<body>
<div id="content" class="row-fluid row">
<div class="col-sm-2">
<iframe id="cmsMenuFrame" name="cmsMenuFrame" src="${ctx}/cms/tree" style="overflow:visible;"
scrolling="yes" frameborder="no" width="100%"></iframe>
</div>
<!--div id="openClose" class="close">&nbsp;</div-->
<div class="col-sm-10">
<iframe id="cmsMainFrame" name="cmsMainFrame" src="${ctx}/cms/article/?category.id=2" style="overflow:visible;"
scrolling="yes" frameborder="no" width="100%"></iframe>
</div>
</div>
<script type="text/javascript">
var leftWidth = "160"; // 左侧窗口大小
function wSize(){
var strs=getWindowSize().toString().split(",");
$("#cmsMenuFrame, #cmsMainFrame, #openClose").height(strs[0]-5);
$("#right").width($("body").width()-$("#left").width()-$("#openClose").width()-20);
}
// 鼠标移动到边界自动弹出左侧菜单
$("#openClose").mouseover(function(){
if($(this).hasClass("open")){
$(this).click();
}
});
</script>
<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>
</body>
</html>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment