Permalink
Browse files

Merge pull request !1 from gaojie/master

  • Loading branch information...
2 parents 2c9bce2 + f2fe773 commit 72bf65fee4aff051a33e3e7025f866e20627bdce kerneler committed Jan 9, 2017
@@ -3,11 +3,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>publiccms</groupId>
<artifactId>cms</artifactId>
- <version>V2016.0828</version>
+ <version>V2017.01.01</version>
<packaging>war</packaging>
<name>PublicCMS</name>
<url>http://www.publiccms.com/</url>
<description>PublicCMS</description>
+
+
<properties>
<springVersion>4.3.2.RELEASE</springVersion>
<hibernateVersion>5.1.1.Final</hibernateVersion>
@@ -16,7 +18,41 @@
<httpclientVersion>4.5.2</httpclientVersion>
<jacksonVersion>2.8.1</jacksonVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <db_host>172.17.0.2</db_host>
+ <db_username>root</db_username>
+ <db_password>mysql1234</db_password>
+ <ftl_update_delay>5</ftl_update_delay>
+ <log_level>info</log_level>
+
</properties>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <properties>
+ <db_host>172.18.0.2</db_host>
+ <db_username>root</db_username>
+ <db_password>mysqlqidianxinchuang</db_password>
+ <ftl_update_delay>60</ftl_update_delay>
+ <log_level>info</log_level>
+ </properties>
+ </profile>
+
+ <profile>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <id>local</id>
+ <properties>
+ <db_host>172.17.0.2</db_host>
+ <db_username>root</db_username>
+ <db_password>mysql123</db_password>
+ <ftl_update_delay>5</ftl_update_delay>
+ </properties>
+ </profile>
+ </profiles>
+
<dependencies>
<dependency>
<groupId>org.freemarker</groupId>
@@ -183,7 +219,24 @@
</dependency>
</dependencies>
<build>
+
<defaultGoal>compile</defaultGoal>
+ <resources>
+
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
+
+ <resource>
+ <directory>lib</directory>
+ <targetPath>lib</targetPath>
+ </resource>
+ </resources>
+
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -195,7 +248,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.3</version>
+ <version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
@@ -9,6 +9,8 @@
import com.sanluan.common.handler.PageHandler;
import com.sanluan.common.handler.QueryHandler;
+import java.util.List;
+
@Repository
public class CmsCategoryDao extends BaseDao<CmsCategory> {
public PageHandler getPage(Integer siteId, Integer parentId, Integer typeId, Boolean allowContribute, Boolean hidden,
@@ -38,6 +40,24 @@ public PageHandler getPage(Integer siteId, Integer parentId, Integer typeId, Boo
return getPage(queryHandler, pageIndex, pageSize);
}
+ public CmsCategory getCategory(Integer siteId, String code) {
+ QueryHandler queryHandler = getQueryHandler("from CmsCategory bean");
+ if (notEmpty(siteId)) {
+ queryHandler.condition("bean.siteId = :siteId").setParameter("siteId", siteId);
+ }
+ if (notEmpty(code)) {
+ queryHandler.condition("bean.code = :code").setParameter("code", code);
+ }
+ queryHandler.order("bean.sort asc,bean.id asc");
+ PageHandler page = getPage(queryHandler, 1, 1);
+ List<CmsCategory> list = (List<CmsCategory>) page.getList();
+ if(list.size()>0){
+ return list.get(0);
+ }
+ return null;
+
+ }
+
@Override
protected CmsCategory init(CmsCategory entity) {
if (empty(entity.getChildIds())) {
@@ -130,4 +130,8 @@ public void updateContents(Serializable id, int num) {
@Autowired
private CmsCategoryDao dao;
+
+ public CmsCategory getCategoryByCode(int siteId, String code) {
+ return dao.getCategory(siteId, code);
+ }
}
@@ -165,6 +165,18 @@ public int deleteByCategoryIds(int siteId, Integer[] categoryIds) {
return categoryIds;
}
+ public CmsContent getLastEntity(Integer categoryId) {
+ CmsCategory category = categoryDao.getEntity(categoryId);
+ if(category != null){
+ PageHandler pageHandler = dao.getPage(category.getSiteId(), null, category.getId(), null, false, null, null, null, null, null, null, null, null, null, null, null, null, null, 1, 1);
+ List<CmsContent> list = (List<CmsContent>) pageHandler.getList();
+ if(list.size()>0){
+ return list.get(0);
+ }
+ }
+ return null;
+ }
+
@Autowired
private CmsContentDao dao;
@Autowired
@@ -38,7 +38,7 @@ public String save(SysUser entity, String repassword, Integer[] roleIds, HttpSer
entity.setName(trim(entity.getName()));
entity.setNickName(trim(entity.getNickName()));
entity.setPassword(trim(repassword));
- repassword = trim(entity.getNickName());
+ repassword = trim(entity.getPassword());
if (verifyNotEmpty("username", entity.getName(), model) || verifyNotEmpty("nickname", entity.getNickName(), model)
|| verifyNotUserName("username", entity.getName(), model)
|| verifyNotNickName("nickname", entity.getNickName(), model)) {
@@ -22,13 +22,21 @@
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Integer id = handler.getInteger("id");
+ String code = handler.getString("code");
+
SysSite site = getSite(handler);
if (notEmpty(id)) {
CmsCategory entity = service.getEntity(id);
if (notEmpty(entity) && site.getId() == entity.getSiteId()) {
handler.put("object", entity).render();
}
- } else {
+ }else if(notEmpty(code)){
+ CmsCategory entity = service.getCategoryByCode(site.getId(), code);
+ if (notEmpty(entity) && site.getId() == entity.getSiteId()) {
+ handler.put("object", entity).render();
+ }
+
+ }else{
Integer[] ids = handler.getIntegerArray("ids");
if (notEmpty(ids)) {
List<CmsCategory> entityList = service.getEntitys(ids);
@@ -22,25 +22,35 @@
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
Long id = handler.getLong("id");
+ Integer categoryId = handler.getInteger("categoryId");
+
+ CmsContent entity = null;
+
SysSite site = getSite(handler);
if (notEmpty(id)) {
- CmsContent entity = service.getEntity(id);
- if (notEmpty(entity) && site.getId() == entity.getSiteId()) {
- handler.put("object", entity).render();
- }
+ entity = service.getEntity(id);
+
+ }else if(notEmpty(categoryId)){
+ entity = service.getLastEntity(categoryId);
+
} else {
Long[] ids = handler.getLongArray("ids");
if (notEmpty(ids)) {
List<CmsContent> entityList = service.getEntitys(ids);
Map<String, CmsContent> map = new LinkedHashMap<String, CmsContent>();
- for (CmsContent entity : entityList) {
- if (site.getId() == entity.getSiteId()) {
- map.put(String.valueOf(entity.getId()), entity);
+ for (CmsContent _entity : entityList) {
+ if (site.getId() == _entity.getSiteId()) {
+ map.put(String.valueOf(_entity.getId()), _entity);
}
}
handler.put("map", map).render();
}
}
+
+
+ if (notEmpty(entity) && site.getId() == entity.getSiteId()) {
+ handler.put("object", entity).render();
+ }
}
@Autowired
@@ -5,6 +5,7 @@
// Generated 2016-7-16 11:54:15 by com.sanluan.common.source.SourceMaker
import java.io.IOException;
+import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -26,7 +27,12 @@ public void execute(RenderHandler handler) throws IOException, Exception {
if (notEmpty(code) && notEmpty(subcode)) {
SysConfig entity = service.getEntity(site.getId(), code, subcode);
if (notEmpty(entity)) {
- handler.put("object", getExtendMap(entity.getData())).render();
+ Map<String, String> extendMap = getExtendMap(entity.getData());
+ if(extendMap.size()>0){
+ handler.put("object", extendMap).render();
+ }else{
+ handler.put("data", entity.getData()).render();
+ }
}
}
}
@@ -9,8 +9,15 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.PosixFilePermission;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.springframework.ui.ModelMap;
@@ -34,7 +41,6 @@
/**
* @param templateFilePath
* @param destFilePath
- * @param config
* @param model
* @throws IOException
* @throws TemplateException
@@ -75,6 +81,8 @@ public static void makeFileByFile(String templateFilePath, String destFilePath,
throws MalformedTemplateNameException, ParseException, IOException, TemplateException {
Template t = configuration.getTemplate(templateFilePath);
File destFile = new File(destFilePath);
+
+
if (override || append || !destFile.exists()) {
File parent = destFile.getParentFile();
if (null != parent) {
@@ -86,6 +94,7 @@ public static void makeFileByFile(String templateFilePath, String destFilePath,
Writer out = new BufferedWriter(new OutputStreamWriter(outputStream, DEFAULT_CHARSET));
t.process(model, out);
out.close();
+ destFile.setReadable(true, false);
} finally {
try {
if (notEmpty(outputStream)) {
@@ -103,7 +112,6 @@ public static void makeFileByFile(String templateFilePath, String destFilePath,
/**
* @param template
- * @param configurationuration
* @return
* @throws TemplateException
* @throws IOException
@@ -1,7 +1,7 @@
jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc\:mysql\://127.0.0.1/public_cms?useUnicode\=true&characterEncoding\=UTF-8&zeroDateTimeBehavior\=round
-jdbc.username=publiccms
-jdbc.password=publiccms_password
+jdbc.url=jdbc\:mysql\://${db_host}/pcms?useUnicode\=true&characterEncoding\=UTF-8&zeroDateTimeBehavior\=round
+jdbc.username=${db_username}
+jdbc.password=${db_password}
cpool.checkoutTimeout=20000
cpool.autoCommitOnClose=true
cpool.minPoolSize=5
@@ -1,5 +1,5 @@
freemarkerSettings.new_builtin_class_resolver=allows_nothing
-freemarkerSettings.template_update_delay=1800
+freemarkerSettings.template_update_delay=5
freemarkerSettings.defaultEncoding=UTF-8
freemarkerSettings.url_escaping_charset=UTF-8
freemarkerSettings.locale=zh_CN
@@ -1,4 +1,4 @@
-site.filePath=/data/publiccms/
+site.filePath=/media/gaojie/Java/workspace-jee/PublicCMS/data/publiccms
site.masterSiteIds=1
site.defaultSiteId=1
ftp.enable=true
@@ -13,6 +13,6 @@ org.apache.commons.logging.simplelog.dateTimeFormat=MM-dd HH:mm:ss:SSS zzz
#Default logging detail level for all instances of SimpleLog. Must be one of: trace debug info warn error fatal If not specified, defaults to info.
#org.apache.commons.logging.simplelog.defaultlog=info
-org.apache.commons.logging.simplelog.defaultlog=info
+org.apache.commons.logging.simplelog.defaultlog=${log_level}
## Configure logging levels
#org.apache.commons.logging.simplelog.log.org.springframework.jdbc=trace

0 comments on commit 72bf65f

Please sign in to comment.