添加新标签

This commit is contained in:
sgjj 2020-06-24 11:24:40 +08:00
parent 2cc387c271
commit 22db6187be
9 changed files with 73 additions and 140 deletions

View File

@ -34,6 +34,8 @@ import net.mingsoft.cms.entity.CategoryEntity;
import net.mingsoft.cms.util.CmsParserUtil;
import net.mingsoft.mdiy.util.ParserUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
@ -64,6 +66,11 @@ import java.util.List;
@Scope("request")
public class GeneraterAction extends BaseAction {
/*
* log4j日志记录
*/
protected final Logger LOG = LoggerFactory.getLogger(this.getClass());
/**
* 文章管理业务层
*/
@ -163,6 +170,7 @@ public class GeneraterAction extends BaseAction {
for (CategoryEntity column : columns) {
// 判断模板文件是否存在
if (!FileUtil.exist(ParserUtil.buildTempletPath(column.getCategoryUrl()))) {
LOG.error("模板不存在:{}",column.getCategoryUrl());
continue;
}
articleIdList = contentBiz.queryIdsByCategoryIdForParser(column.getId(), null, null);

View File

@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@ -284,7 +285,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
*/
@RequestMapping(value = "search")
@ResponseBody
public void search(HttpServletRequest request, HttpServletResponse response) {
public void search(HttpServletRequest request, HttpServletResponse response) throws IOException {
Map<String, Object> map = new HashMap<>();
// 读取请求字段
@ -358,19 +359,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
//设置分页类
PageBean page = new PageBean();
//读取模板的分页数量
int size = BasicUtil.getInt(ParserUtil.SIZE,10);
try {
size = TagParser.getPageSize(ParserUtil.read(SEARCH+ParserUtil.HTM_SUFFIX,false ));
} catch (TemplateNotFoundException e1) {
e1.printStackTrace();
} catch (MalformedTemplateNameException e1) {
e1.printStackTrace();
} catch (ParseException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
Map<String, Object> searchMap = field;
searchMap.forEach((k,v)->{
//sql注入过滤
@ -381,24 +369,31 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
//查询数量
int count= contentBiz.getSearchCount(contentModel,fieldValueList,searchMap,BasicUtil.getAppId(),categoryIds);
int total = PageUtil.totalPage(count, size);
map.put(ParserUtil.URL, BasicUtil.getUrl());
map.put(SEARCH, searchMap);
map.put(ParserUtil.APP_ID, BasicUtil.getAppId());
map.put(ParserUtil.PAGE, page);
map.put(ParserUtil.HTML, ParserUtil.HTML);
//动态解析
map.put(ParserUtil.IS_DO,false);
//设置动态请求的模块路径
map.put(ParserUtil.MODEL_NAME, "mcms");
searchMap.put(ParserUtil.PAGE_NO, 0);
ParserUtil.read(SEARCH+ParserUtil.HTM_SUFFIX,map, page);
int total = PageUtil.totalPage(count, page.getSize());
int pageNo = BasicUtil.getInt(ParserUtil.PAGE_NO, 1);
if(pageNo >= total && total!=0) {
pageNo = total;
}
//获取总数
page.setTotal(total);
//设置页面显示数量
page.setSize(size);
//设置列表当前页
page.setPageNo(pageNo);
String str = ParserUtil.PAGE_NO+","+ParserUtil.SIZE;
//设置分页的统一链接
String url = BasicUtil.getUrl()+request.getServletPath() +"?" + BasicUtil.assemblyRequestUrlParams(str.split(","));
String pageNoStr = "&"+ParserUtil.SIZE+"="+size+"&"+ParserUtil.PAGE_NO+"=";
String pageNoStr = "&"+ParserUtil.SIZE+"="+page.getSize()+"&"+ParserUtil.PAGE_NO+"=";
//下一页
String nextUrl = url + pageNoStr+((pageNo+1 > total)?total:pageNo+1);
//首页
@ -412,14 +407,8 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
page.setNextUrl(nextUrl);
page.setPreUrl(preUrl);
page.setLastUrl(lastUrl);
map.put(ParserUtil.URL, BasicUtil.getUrl());
searchMap.put(ParserUtil.PAGE_NO, pageNo);
map.put(SEARCH, searchMap);
map.put(ParserUtil.PAGE, page);
//动态解析
map.put(ParserUtil.IS_DO,false);
//设置动态请求的模块路径
map.put(ParserUtil.MODEL_NAME, "mcms");
//解析后的内容
String content = "";

View File

@ -1,15 +1,12 @@
package net.mingsoft.cms.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.PageUtil;
import freemarker.cache.FileTemplateLoader;
import freemarker.core.ParseException;
import freemarker.template.MalformedTemplateNameException;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateNotFoundException;
import net.mingsoft.base.constant.Const;
import net.mingsoft.basic.util.BasicUtil;
@ -20,17 +17,12 @@ import net.mingsoft.mdiy.bean.PageBean;
import net.mingsoft.mdiy.biz.IModelBiz;
import net.mingsoft.mdiy.biz.impl.ModelBizImpl;
import net.mingsoft.mdiy.entity.ModelEntity;
import net.mingsoft.mdiy.parser.TagParser;
import net.mingsoft.mdiy.util.ParserUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.util.WebAppRootListener;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -61,14 +53,6 @@ public class CmsParserUtil extends ParserUtil {
map.put(COLUMN, column);
String content = CmsParserUtil.generate(templatePath, map, false);
FileUtil.writeString(content, ParserUtil.buildHtmlPath(targetPath), Const.UTF8);
// 生成移动页面
if (ParserUtil.hasMobileFile(templatePath)) {
// 手机端m
map.put(ParserUtil.MOBILE, BasicUtil.getApp().getAppMobileStyle());
content = CmsParserUtil.generate(templatePath, map, true);
FileUtil.writeString(content, ParserUtil.buildMobileHtmlPath(targetPath), Const.UTF8);
}
}
/**
@ -95,13 +79,12 @@ public class CmsParserUtil extends ParserUtil {
// 文章的栏目模型编号
String columnContentModelId = column.getMdiyModelId();
//ParserUtil.read(File.separator + column.getCategoryListUrl(), false, acrList);
PageBean page = new PageBean();
page.setSize(10);
//获取分页数量
//获取列表页显示的文章数量
int pageSize = 10;
//获取总数
int totalPageSize = PageUtil.totalPage(articleIdTotal, pageSize);
String columnListPath;
String mobilePath;
@ -112,12 +95,10 @@ public class CmsParserUtil extends ParserUtil {
contentModel = (ModelEntity) SpringUtil.getBean(ModelBizImpl.class).getEntity(Integer.parseInt(columnContentModelId));
}
int pageNo = 1;
PageBean page = new PageBean();
page.setSize(pageSize);
//全局参数设置
Map<String, Object> parserParams = new HashMap<String, Object>();
parserParams.put(COLUMN, column);
page.setTotal(totalPageSize);
parserParams.put(IS_DO, false);
parserParams.put(HTML, HTML);
parserParams.put(APP_ID, BasicUtil.getAppId());
@ -129,24 +110,18 @@ public class CmsParserUtil extends ParserUtil {
if(ParserUtil.IS_SINGLE) {
parserParams.put(ParserUtil.URL, BasicUtil.getUrl());
}
int totalPageSize = PageUtil.totalPage(articleIdTotal, page.getSize());
page.setTotal(totalPageSize);
parserParams.put(ParserUtil.PAGE, page);
ParserUtil.read(File.separator + column.getCategoryListUrl(),parserParams, page);
//文章列表页没有写文章列表标签总数为0
if (totalPageSize <= 0) {
// 数据库中第一页是从开始0*size
// 首页路径index.html
mobilePath = ParserUtil.buildMobileHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX);
columnListPath = ParserUtil.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX);
// 设置分页的起始位置
page.setPageNo(pageNo);
parserParams.put(ParserUtil.PAGE, page);
String read = ParserUtil.read(File.separator + column.getCategoryListUrl(), false, parserParams);
String read = ParserUtil.read(File.separator + column.getCategoryListUrl(), parserParams);
FileUtil.writeString(read, columnListPath, Const.UTF8);
// 判断是手机端生成还是pc端,防止重复生成
if (ParserUtil.hasMobileFile(column.getCategoryListUrl())) {
parserParams.put(ParserUtil.MOBILE, BasicUtil.getApp().getAppMobileStyle());
String read1 = ParserUtil.read(File.separator + column.getCategoryListUrl(), true, parserParams);
FileUtil.writeString(read1, mobilePath, Const.UTF8);
}
} else {
// 遍历分页
@ -154,29 +129,17 @@ public class CmsParserUtil extends ParserUtil {
if (i == 0) {
// 数据库中第一页是从开始0*size
// 首页路径index.html
mobilePath = ParserUtil
.buildMobileHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX);
columnListPath = ParserUtil
.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.INDEX);
} else {
// 其他路径list-2.html
mobilePath = ParserUtil.buildMobileHtmlPath(
column.getCategoryPath() + File.separator + ParserUtil.PAGE_LIST + pageNo);
columnListPath = ParserUtil
.buildHtmlPath(column.getCategoryPath() + File.separator + ParserUtil.PAGE_LIST + pageNo);
}
// 设置分页的起始位置
page.setPageNo(pageNo);
parserParams.put(ParserUtil.PAGE, page);
String read = ParserUtil.read(File.separator + column.getCategoryListUrl(), false, parserParams);
String read = ParserUtil.read(File.separator + column.getCategoryListUrl(), parserParams);
FileUtil.writeString(read, columnListPath, Const.UTF8);
// 判断是手机端生成还是pc端,防止重复生成
if (ParserUtil.hasMobileFile(column.getCategoryListUrl())) {
parserParams.put(ParserUtil.MOBILE, BasicUtil.getApp().getAppMobileStyle());
String read1 = ParserUtil.read(File.separator + column.getCategoryListUrl(), true, parserParams);
// 将tag.getContent()写入路径
FileUtil.writeString(read1, mobilePath, Const.UTF8);
}
pageNo++;
}
}
@ -290,33 +253,6 @@ public class CmsParserUtil extends ParserUtil {
e.printStackTrace();
}
});
// 手机端
if (ParserUtil.hasMobileFile(columnUrl)) {
//如果是封面就生成index.html
if(Integer.parseInt(articleIdList.get(artId).getCategoryType()) == COLUMN_TYPE_COVER) {
writePath = ParserUtil.buildMobileHtmlPath(articleColumnPath + File.separator + ParserUtil.INDEX);
}else {
writePath = ParserUtil.buildMobileHtmlPath(articleColumnPath + File.separator + articleId);
}
// 判断文件是否存在若不存在弹出返回信息
if (!FileUtil.exist(ParserUtil.buildTempletPath(MOBILE + File.separator + columnUrl))) {
artId++;
continue;
}
String finalWritePath1 = writePath;
pool.execute(() -> {
SpringUtil.setRequest(request);
parserParams.put(MOBILE, BasicUtil.getApp().getAppMobileStyle());
String content = null;
try {
content = CmsParserUtil.generate(columnUrl, parserParams, true);
FileUtil.writeString(content, finalWritePath1, Const.UTF8);
} catch (IOException e) {
e.printStackTrace();
}
});
}
artId++;
}
}

View File

@ -6,7 +6,7 @@
<body>
<#include "head.htm"/>
<div class="ms-banner" style="background:url({ms:global.host/}/{ms:global.style/}/images/about_us.jpg) no-repeat center;">
<div class="ms-banner" style="background:url(${global.host}/${global.style}/images/about_us.jpg) no-repeat center;">
<p class="banner_tit_about animated fadeInLeft">关于我们</p>
<p class="banner_tit_about_des animated fadeInRight">About us</p>
</div>
@ -15,13 +15,13 @@
<#include "menu-left.htm"/>
<div class="ms-content-right">
<div class="ms-content-right-position">
<a href="{ms:global.host/}">首页</a>
<a href="${global.host}">首页</a>
<span>></span>
<a href="{ms:field.typelink/}">${field.typetitle}</a>
<a href="${field.typelink}">${field.typetitle}</a>
</div>
<div class="ms-content-right-main">
<div class="ms-content-right-main-title">{ms:field.title/}</div>
<div class="ms-content-right-main-content">{ms:field.content/}</div>
<div class="ms-content-right-main-title">${field.title}</div>
<div class="ms-content-right-main-content">${field.content}</div>
</div>
</div>
</div>

View File

@ -6,7 +6,7 @@
<body>
<#include "head.htm"/>
<div class="ms-banner" style="background:url({ms:global.host/}/{ms:global.style/}/images/00.png) no-repeat center;">
<div class="ms-banner" style="background:url(${global.host}/${global.style}/images/00.png) no-repeat center;">
<p class="banner_tit_other animated fadeInLeft">&nbsp;&nbsp;&nbsp;</p>
<p class="banner_tit_other_des animated fadeInRight">Case list</p>
</div>

View File

@ -1,7 +1,7 @@
<div class="ms-head">
<div class="head-menu">
<div class="head-men-left head-menu-flex-center">
<a href="{ms:global.host/}/html/1/index.html">
<a href="${global.host}/html/1/index.html">
<img src="http://cdn.mingsoft.net/images/logo.png" />
</a>
<ul class="head-menu-list">
@ -54,7 +54,7 @@
</div>
<div class="head-men-right head-menu-flex-center">
<div class="head-menu-flex-center head-menu-right-search">
<form id="searchDataForm" action="{ms:global.host/}/mcms/search.do" method="post">
<form id="searchDataForm" action="${global.host}/mcms/search.do" method="post">
<input type="text" class='ms-search-input' name="content_title" placeholder="请输入关键字">
<!-- <i class="iconfont ms-search-click">&#xe85e;</i> -->
<input type="submit" value="" class="ms-search-click">
@ -63,12 +63,12 @@
<div class="head-menu-right-content" id="ms-login-vue">
<span v-show="!isLogin" style="display: none;">
<span>
<a href='{ms:global.host/}/mdiyPage/login.do'>登录</a>
</span>|<span><a href='{ms:global.host/}/mdiyPage/register.do'>注册</a></span>
<a href='${global.host}/mdiyPage/login.do'>登录</a>
</span>|<span><a href='${global.host}/mdiyPage/register.do'>注册</a></span>
</span>
<div class="topbar-info J_userInfo loginSuccess hide-default" v-show="isLogin" style="display: none;">
<a class="user-name" href="{ms:global.host/}/people/center.do">
<img :src="'{ms:global.host/}/'+peopleInfo.puIcon" class="loginImg user_icon" onerror="this.src='http://cdn.mingsoft.net/global/images/msheader.png'">
<a class="user-name" href="${global.host}/people/center.do">
<img :src="'${global.host}/'+peopleInfo.puIcon" class="loginImg user_icon" onerror="this.src='http://cdn.mingsoft.net/global/images/msheader.png'">
<b class="userName ms-userName" v-text="peopleInfo.puNickname"></b>
</a>
<a href="javascript:;" class="quitLogin" @click="quitLogin">退出</a>
@ -91,13 +91,13 @@
var target = this;
$.ajax({
type: "POST",
url: "{ms:global.host/}/checkLoginStatus.do",
url: "${global.host}/checkLoginStatus.do",
success: function(msg) {
target.isLogin = msg.result; //判断用户是否登录如登录则target.isLogin===true
if(msg.result) {
$.ajax({
type: "GET",
url: "{ms:global.host/}/people/user/info.do",
url: "${global.host}/people/user/info.do",
success: function(msg) {
target.peopleInfo = msg; //target.peopleInfo为当前登录用户的基本信息
}
@ -112,11 +112,11 @@
var target = this;
$.ajax({
type: "GET",
url: "{ms:global.host/}/people/quit.do",
url: "${global.host}/people/quit.do",
success: function(msg) {
if(msg.result) {
$("body").append("<form id='msHeadForm' action=''></form>");
$("#msHeadForm").attr("action", "{ms:global.host/}").submit();
$("#msHeadForm").attr("action", "${global.host}").submit();
}
}
})

View File

@ -5,7 +5,7 @@
</head>
<body>
<#include "head.htm"/>
<div class="ms-banner" style="background:url({ms:global.host/}/{ms:global.style/}/images/our_company.jpeg) no-repeat center;">
<div class="ms-banner" style="background:url(${global.host}/${global.style}/images/our_company.jpeg) no-repeat center;">
<p class="banner_tit_other animated fadeInLeft">公司动态</p>
<p class="banner_tit_other_des animated fadeInRight">Our company</p>
</div>
@ -13,9 +13,9 @@
<div class="ms-content-new-list">
<#include "menu-left.htm"/>
<div class="ms-content-right-position">
<a href="{ms:global.host/}">首页</a>
<a href="${global.host}">首页</a>
<span>></span>
<a href="{ms:field.typelink/}">{column.typetitle}</a>
<a href="{field.typelink}">{column.typetitle}</a>
</div>
<div class="ms-content-main-list">
@ -35,10 +35,10 @@
</div>
</div>
<div class="ms-content-main-page">
<a class="ms-content-main-page-first" href="{ms:global.url/}{ms:page.index/}">首页</a>
<a class="ms-content-main-page-upper" href="{ms:global.url/}{ms:page.pre/}">上一页</a>
<a class="ms-content-main-page-next" href="{ms:global.url/}{ms:page.next/}">下一页</a>
<a class="ms-content-main-page-last" href="{ms:global.url/}{ms:page.last/}">末页</a>
<a class="ms-content-main-page-first" href="${global.url}${page.index}">首页</a>
<a class="ms-content-main-page-upper" href="${global.url}${page.pre}">上一页</a>
<a class="ms-content-main-page-next" href="${global.url}${page.next}">下一页</a>
<a class="ms-content-main-page-last" href="${global.url}${page.last}">末页</a>
</div>
</div>
<#include "footer.htm"/>

View File

@ -27,7 +27,7 @@
<div class="ms-content-right-main-title-div">${field.title}</div>
<div class="ms-content-right-main-icon">
<div class="ms-content-icon-left">
<div class="ms-content-right-main-icon-source">来源:${field.source}
<div class="ms-content-right-main-icon-source">来源:${field.source!''}
<span class="ms-content-right-vertical">|</span>
</div>
<div class="ms-content-right-main-icon-time">时间:${field.date?string("yyyy-MM-dd")}</div>

View File

@ -6,31 +6,31 @@
<body>
<#include "head.htm"/>
<div class="ms-banner">
<img src="{ms:global.host/}/{ms:global.style/}/images/search.jpg">
<img src="${global.host}/${global.style}/images/search.jpg">
</div>
<div class="ms-content" id="body">
<div class="ms-content-main-list" id="ms-content-search">
<div class="ms-content-main-div">
<div class="ms-content-main-div-prompt">您搜索的关键字
<span>{ms:search.content_title/}</span>
<span>${search.content_title}</span>
<!-- 共7个结果 -->
</div>
<ul class="ms-content-main-ul">
{ms:arclist size=10 ispaging=true}
<@arclist size=10 ispaging=true>
<li>
<a href="{ms:global.url/}/[field.link/]">
[field.title/]
<span class="ms-content-main-li-time">[field.date?string("yyyy-MM-dd")/]</span>
<a href="${global.url}/${item.link}">
${item.title}
<span class="ms-content-main-li-time">${item.date?string("yyyy-MM-dd")}</span>
</a>
</li>
{/ms:arclist}
</@arclist>
</ul>
</div>
<div class="ms-content-main-page">
<a class="ms-content-main-page-first" href="{ms:page.index/}">首页</a>
<a class="ms-content-main-page-upper" href="{ms:page.pre/}">上一页</a>
<a class="ms-content-main-page-next" href="{ms:page.next/}">下一页</a>
<a class="ms-content-main-page-last" href="{ms:page.last/}">末页</a>
<a class="ms-content-main-page-first" href="${page.index}">首页</a>
<a class="ms-content-main-page-upper" href="${page.pre}">上一页</a>
<a class="ms-content-main-page-next" href="${page.next}">下一页</a>
<a class="ms-content-main-page-last" href="${page.last}">末页</a>
</div>
</div>
</div>
@ -47,19 +47,19 @@ new Vue({
methods: {
//上下页
search:function(flag){
var pageNo = {ms:search.pageNo/};
var total = {ms:page.total/};
var pageNo = ${search.pageNo};
var total = ${page.total};
if(flag){
pageNo = pageNo==total ? total : pageNo +1;//下一页
}else{
pageNo = pageNo -1==0 ? 1 : pageNo-1;//上一页
}
window.location.href="{ms:global.host/}/cms/1/search.do?basic_title={ms:search.basic_title/}&pageNo="+pageNo;
window.location.href="${global.host}/cms/1/search.do?content_title=${search.content_title}&pageNo="+pageNo;
window.event.returnValue=false;
},
//首页和尾页
indexAndLast:function(pageNo){
window.location.href="{ms:global.host/}/cms/1/search.do?basic_title={ms:search.basic_title/}&pageNo="+pageNo;
window.location.href="${global.host}/cms/1/search.do?content_title=${search.content_title}&pageNo="+pageNo;
window.event.returnValue=false;
},
},