Permalink
Browse files

meger

  • Loading branch information...
1 parent 72bf65f commit 818438df1e15529c7c11de0fcaf86a4be8da604a @sanluan committed Jan 9, 2017
@@ -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);
@@ -34,7 +34,7 @@
/**
* @param templateFilePath
* @param destFilePath
- * @param config
+ * @param configuration
* @param model
* @throws IOException
* @throws TemplateException
@@ -86,6 +86,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 +104,7 @@ public static void makeFileByFile(String templateFilePath, String destFilePath,
/**
* @param template
- * @param configurationuration
+ * @param configuration
* @return
* @throws TemplateException
* @throws IOException
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>publiccms</groupId>
<artifactId>cms</artifactId>
- <version>V2017.01.01</version>
+ <version>V2016.0828</version>
<packaging>war</packaging>
<name>PublicCMS</name>
<url>http://www.publiccms.com/</url>
@@ -22,35 +22,25 @@
@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)) {
- entity = service.getEntity(id);
-
- }else if(notEmpty(categoryId)){
- entity = service.getLastEntity(categoryId);
-
+ CmsContent entity = service.getEntity(id);
+ if (notEmpty(entity) && site.getId() == entity.getSiteId()) {
+ handler.put("object", entity).render();
+ }
} 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,7 +5,6 @@
// 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;
@@ -27,12 +26,7 @@ public void execute(RenderHandler handler) throws IOException, Exception {
if (notEmpty(code) && notEmpty(subcode)) {
SysConfig entity = service.getEntity(site.getId(), code, subcode);
if (notEmpty(entity)) {
- Map<String, String> extendMap = getExtendMap(entity.getData());
- if(extendMap.size()>0){
- handler.put("object", extendMap).render();
- }else{
- handler.put("data", entity.getData()).render();
- }
+ handler.put("object", getExtendMap(entity.getData())).render();
}
}
}
@@ -9,15 +9,8 @@
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;
@@ -41,6 +34,7 @@
/**
* @param templateFilePath
* @param destFilePath
+ * @param configuration
* @param model
* @throws IOException
* @throws TemplateException
@@ -81,8 +75,6 @@ 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) {
@@ -112,6 +104,7 @@ public static void makeFileByFile(String templateFilePath, String destFilePath,
/**
* @param template
+ * @param configuration
* @return
* @throws TemplateException
* @throws IOException
@@ -1,4 +1,4 @@
-site.filePath=/media/gaojie/Java/workspace-jee/PublicCMS/data/publiccms
+site.filePath=/data/publiccms/
site.masterSiteIds=1
site.defaultSiteId=1
ftp.enable=true

0 comments on commit 818438d

Please sign in to comment.