Skip to content

Commit

Permalink
jfinal cms v4.1.5 release~!~
Browse files Browse the repository at this point in the history
  • Loading branch information
FLY的狐狸 committed Jan 26, 2017
1 parent 94705ea commit 52df620
Show file tree
Hide file tree
Showing 33 changed files with 1,100 additions and 78 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Change Log 更新说明
------------------------------
## 2017-01-01 jfinal cms4.1.5
> 1. 后台加入新的主题flat。
## 2016-12-31
> 1. 优化站点配置后台以及拦截逻辑。
> 2. 将站点设置加入到参数管理中。
> 3. 默认为单站点,可以方便的通过站点管理切换。
## 2016-12-17 jfinal cms4.1.4
> 1. 加入系统参数配置模块。
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jfinal cms
------------------------

> 1. jfinal cms,采用了简洁强大的JFinal作为web框架,模板引擎用的是beetl,数据库用mysql,前端bootstrap框架。
> 2. 后台模块包含:栏目管理,栏目公告,栏目滚动图片,文章管理,回复管理,意见反馈,我的相册,相册管理,图片管理,专辑管理视频管理缓存更新,友情链接,访问统计,联系人管理,模板管理,组织机构管理,用户管理,角色管理,菜单管理,数据字典管理。
> 2. 后台模块包含:栏目管理,栏目公告,栏目滚动图片,文章管理,回复管理,意见反馈,我的相册,相册管理,图片管理,专辑管理视频管理缓存更新,友情链接,访问统计,联系人管理,模板管理,组织机构管理,用户管理,角色管理,菜单管理,参数配置,数据字典管理。
> 3. 后端模板支持:bootstrap默认样式、bootstrap黑色样式和flat-ui样式
> 4. 前端模板支持:默认内容发布、官网模板、图片模板和视频模板
> 5. jfinal cms交流群:568909653。 文档见doc/jfinal cms文档.docx
Expand All @@ -19,9 +19,9 @@ jfinal cms
> 4. 数据库配置文件:/jfinal_cms/src/main/resources/conf/db.properties
> 5. 如需要oauth2的,设置src/conf/oauth.properties
> 6. 运行:mvn tomcat:run
> 7. 默认站点通过配置src/conf/sites.properties文件中SITE.DEFAULT.ID即可实现
> 8. 多站点各个模板的切换已通过系统中“站点管理”模块进行操作。站点管理是通过域名解析实现各个模板的对应
> 9. 如果只使用单站点,可以将sites.properties文件中SITE.MULTI.FLAG = true改为false。然后通过config.properties的ATTR.PATH_PC=/template/mtg配置模板
> 7. 系统默认采用单站点模式,各个站点可以在“其他管理”下“站点管理”菜单方便的切换
> 8. 如果使用多站点,可以在“系统管理”下“多站点标示”菜单中,将“多站点标示”项目修改为true
> 9. 多站点需要设置各个站点对应的域名,通过域名解析到不同的站点模板

其他说明
Expand Down
Binary file modified doc/jfinal cms文档.docx
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.jflyfox</groupId>
<artifactId>jfinal_cms</artifactId>
<packaging>war</packaging>
<version>4.1.4</version>
<version>4.1.5</version>

<properties>
<!-- 文件拷贝时的编码 -->
Expand Down
24 changes: 16 additions & 8 deletions sql/jfinal_cms_v4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ CREATE TABLE `sys_user` (
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO `sys_user` VALUES ('1', 'admin', '1RHFCLt64uOOViCTzgSaww==', '系统管理员', '1', '1', '1', null, null, 'zcool321@sina.com', '123', null, null, '时间是最好的老师,但遗憾的是——最后他把所有的学生都弄死了', 'default', '5', '1', '2016-06-06 06:06:06', '1');
INSERT INTO `sys_user` VALUES ('1', 'admin', '1RHFCLt64uOOViCTzgSaww==', '系统管理员', '1', '1', '1', null, null, 'zcool321@sina.com', '123', null, null, '时间是最好的老师,但遗憾的是——最后他把所有的学生都弄死了', 'flat', '5', '1', '2016-06-06 06:06:06', '1');

-- ----------------------------
-- Table structure for `sys_user_role`
Expand Down Expand Up @@ -920,12 +920,15 @@ CREATE TABLE `tb_site` (
`site_title` varchar(256) DEFAULT NULL COMMENT '标题',
`site_folder_id` int(11) DEFAULT NULL COMMENT '默认标题ID',
`site_article_id` int(11) DEFAULT NULL COMMENT '默认文章ID',
`thumbnail` varchar(256) DEFAULT NULL COMMENT '缩略图',
`db_url` varchar(200) DEFAULT NULL COMMENT '数据库',
`db_user` varchar(64) DEFAULT NULL COMMENT '数据库用户',
`db_pwd` varchar(64) DEFAULT NULL COMMENT '数据库密码',
`db_driver` varchar(64) DEFAULT NULL COMMENT '数据库驱动',
`sort` int(11) DEFAULT '10' COMMENT '序号',
`status` int(11) DEFAULT '1' COMMENT '状态//radio/2,禁用,1,启用',
`status` int(2) DEFAULT '1' COMMENT '状态//radio/2,禁用,1,启用',
`site_defalut` int(2) DEFAULT '2' COMMENT '默认站点:1,是,2,否',
`remark` varchar(1000) DEFAULT NULL COMMENT '备注',
`update_time` varchar(64) DEFAULT NULL COMMENT '更新时间',
`update_id` int(11) DEFAULT '0' COMMENT '更新人',
`create_time` varchar(64) DEFAULT NULL COMMENT '创建时间',
Expand All @@ -936,12 +939,12 @@ CREATE TABLE `tb_site` (
-- ----------------------------
-- Records of tb_site
-- ----------------------------
INSERT INTO `tb_site` VALUES ('1', '视频管理', 'video', 'video', 'video.demo.com', 'video.demo.com', null, 'FLY的狐狸', null, null, null, null, null, null, '12', '1', '2016-04-04 19:57:22', '1', '2016-04-04 19:57:22', '1');
INSERT INTO `tb_site` VALUES ('2', '门头沟', 'mtg', 'mtg', 'mtg.demo.com', 'mtg.demo.com', null, '门头沟信息网', '1', '1', null, null, null, null, '8', '1', '2016-04-07 01:10:22', '1', '2016-04-07 01:10:22', '1');
INSERT INTO `tb_site` VALUES ('3', '网站', 'website', 'website', 'website.demo.com', 'website.demo.com', null, 'FLY的狐狸', '230', '2301', 'jdbc:mysql://127.0.0.1:3306/jfinal_cms_website?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull', 'root', '123456', 'com.mysql.jdbc.Driver', '10', '1', '2016-03-21 23:58:54', '1', '2016-03-21 23:58:54', '1');
INSERT INTO `tb_site` VALUES ('4', '照片管理', 'photo', 'photo', 'photo.demo.com', 'photo.demo.com', null, 'FLY的狐狸', null, null, 'jdbc:mysql://127.0.0.1:3306/jfinal_cms_photo?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull', 'root', '123456', 'com.mysql.jdbc.Driver', '11', '1', '2016-03-22 22:25:21', '1', '2016-03-22 22:25:21', '1');
INSERT INTO `tb_site` VALUES ('5', '博客', 'blog', 'blog', 'blog.demo.com', 'blog.demo.com', null, 'FLY的狐狸', '241', '3001', 'jdbc:mysql://127.0.0.1:3306/jflyfox_mtg?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull', 'root', '123456', 'com.mysql.jdbc.Driver', '15', '1', '2016-03-23 22:07:47', '1', '2016-03-23 22:07:47', '1');
INSERT INTO `tb_site` VALUES ('8', '项目', 'project', 'project', 'project.demo.com', 'project.demo.com', null, 'FLY的狐狸', '253', null, null, null, null, null, '20', '1', '2016-06-17 16:47:44', '1', '2016-06-17 16:47:44', '1');
INSERT INTO `tb_site` VALUES ('1', '视频管理', 'video', 'video', 'video.demo.com', 'video.demo.com', null, 'FLY的狐狸', null, null, 'jflyfox\\website\\site_thumbnail\\20170101_002223_487110.png', null, null, null, null, '12', '1', '2', null, '2016-04-04 19:57:22', '1', '2016-04-04 19:57:22', '1');
INSERT INTO `tb_site` VALUES ('2', '门头沟', 'mtg', 'mtg', 'mtg.demo.com', 'mtg.demo.com', null, '门头沟信息网', '1', '1', 'jflyfox\\website\\site_thumbnail\\20170101_002130_323416.png', null, null, null, null, '8', '1', '2', null, '2016-04-07 01:10:22', '1', '2016-04-07 01:10:22', '1');
INSERT INTO `tb_site` VALUES ('3', '网站', 'website', 'website', 'website.demo.com', 'website.demo.com', null, 'FLY的狐狸', '230', '2301', 'jflyfox\\website\\site_thumbnail\\20170101_002147_613266.gif', 'jdbc:mysql://127.0.0.1:3306/jfinal_cms_website?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull', 'root', '123456', 'com.mysql.jdbc.Driver', '10', '1', '2', null, '2016-03-21 23:58:54', '1', '2016-03-21 23:58:54', '1');
INSERT INTO `tb_site` VALUES ('4', '照片管理', 'photo', 'photo', 'photo.demo.com', 'photo.demo.com', null, 'FLY的狐狸', null, null, 'jflyfox\\website\\site_thumbnail\\20170101_002209_956776.png', 'jdbc:mysql://127.0.0.1:3306/jfinal_cms_photo?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull', 'root', '123456', 'com.mysql.jdbc.Driver', '11', '1', '2', null, '2016-03-22 22:25:21', '1', '2016-03-22 22:25:21', '1');
INSERT INTO `tb_site` VALUES ('5', '博客', 'blog', 'blog', 'blog.demo.com', 'blog.demo.com', null, 'FLY的狐狸', '241', '3001', 'jflyfox\\website\\site_thumbnail\\20170101_002344_503232.png', 'jdbc:mysql://127.0.0.1:3306/jflyfox_mtg?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull', 'root', '123456', 'com.mysql.jdbc.Driver', '15', '1', '1', null, '2016-03-23 22:07:47', '1', '2016-03-23 22:07:47', '1');
INSERT INTO `tb_site` VALUES ('8', '项目', 'project', 'project', 'project.demo.com', 'project.demo.com', null, 'FLY的狐狸', '253', null, 'jflyfox\\website\\site_thumbnail\\20170101_002358_867823.png', null, null, null, null, '20', '1', '2', null, '2016-06-17 16:47:44', '1', '2016-06-17 16:47:44', '1');

-- ----------------------------
-- Table structure for `tb_tags`
Expand Down Expand Up @@ -1442,3 +1445,8 @@ INSERT INTO `sys_config` VALUES ('5', 'API是否开启', 'API.FLAG', 'true', nul
INSERT INTO `sys_config` VALUES ('6', 'ip黑名单,逗号分隔', 'API.IP.BLACK', '127.0.0.122,localhost22', null, '2', '111', '2016-12-17 23:16:29', '1', '2016-12-17 23:16:29', '1');
INSERT INTO `sys_config` VALUES ('7', '支持的版本,逗号分隔', 'API.VERSIONS', '1.0.0,1.0.1', null, '2', '112', '2016-12-17 23:17:00', '1', '2016-12-17 23:17:00', '1');
INSERT INTO `sys_config` VALUES ('8', '登陆验证是否开启', 'API.LOGIN.VALID', 'false', null, '2', '114', '2016-12-17 23:17:23', '1', '2016-12-17 23:17:23', '1');
INSERT INTO `sys_config` VALUES ('9', '站点参数', 'siteParam', '0', null, '0', '12', '2016-12-31 16:27:12', '1', '2016-12-31 16:27:12', '1');
INSERT INTO `sys_config` VALUES ('10', '多站点标示', 'SITE.MULTI.FLAG', 'false', null, '9', '211', '2016-12-31 16:28:02', '1', '2016-12-31 16:28:02', '1');
INSERT INTO `sys_config` VALUES ('11', '站点根目录', 'SITE.TEMPLATE.PATH', '/template/', null, '9', '212', '2016-12-31 16:28:43', '1', '2016-12-31 16:28:43', '1');
INSERT INTO `sys_config` VALUES ('12', 'Session站点列表', 'SITE.SESSION.SITES', 'sites', null, '9', '213', '2016-12-31 16:30:17', '1', '2016-12-31 16:30:17', '1');
INSERT INTO `sys_config` VALUES ('13', 'Session站点', 'SITE.SESSION.SITE', 'site', null, '9', '214', '2016-12-31 16:30:38', '1', '2016-12-31 16:30:38', '1');
13 changes: 13 additions & 0 deletions sql/update/20161231_站点字段完善.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ALTER TABLE `tb_site`
ADD COLUMN `thumbnail` varchar(256) NULL COMMENT '缩略图' AFTER `site_article_id`,
ADD COLUMN `remark` varchar(1000) NULL COMMENT '备注' AFTER `status`,
MODIFY COLUMN `status` int(2) NULL DEFAULT '1' COMMENT '状态//radio/2,禁用,1,启用' AFTER `sort`,
ADD COLUMN `site_defalut` int(2) NULL DEFAULT '2' COMMENT '默认站点:1,是,2,否' AFTER `status`;

INSERT INTO `sys_config` VALUES ('9', '站点参数', 'siteParam', '0', null, '0', '12', '2016-12-31 16:27:12', '1', '2016-12-31 16:27:12', '1');
INSERT INTO `sys_config` VALUES ('10', '多站点标示', 'SITE.MULTI.FLAG', 'false', null, '9', '211', '2016-12-31 16:28:02', '1', '2016-12-31 16:28:02', '1');
INSERT INTO `sys_config` VALUES ('11', '站点根目录', 'SITE.TEMPLATE.PATH', '/template/', null, '9', '212', '2016-12-31 16:28:43', '1', '2016-12-31 16:28:43', '1');
INSERT INTO `sys_config` VALUES ('12', 'Session站点列表', 'SITE.SESSION.SITES', 'sites', null, '9', '213', '2016-12-31 16:30:17', '1', '2016-12-31 16:30:17', '1');
INSERT INTO `sys_config` VALUES ('13', 'Session站点', 'SITE.SESSION.SITE', 'site', null, '9', '214', '2016-12-31 16:30:38', '1', '2016-12-31 16:30:38', '1');

update tb_site set site_defalut = 1 where id = 5;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.Map;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import com.jflyfox.component.util.JFlyFoxUtils;
import com.jflyfox.jfinal.base.BaseController;
Expand All @@ -36,6 +37,8 @@
import com.jflyfox.system.user.UserSvc;
import com.jflyfox.util.NumberUtils;
import com.jflyfox.util.StrUtils;
import com.jflyfox.util.cache.Cache;
import com.jflyfox.util.cache.CacheManager;
import com.jflyfox.util.encrypt.DESUtils;

/**
Expand Down Expand Up @@ -70,7 +73,7 @@ protected String getAutoPath(String view) {

// path = (isMoblie() ? Attr.PATH_MOBILE : Attr.PATH_PC) + path;
TbSite site = new SiteService().getSite(getSessionSite().getSiteId());
path = SiteConstant.TEMPLATE_PATH + (isMoblie() ? site.getTemplateMobile() : site.getTemplate()) + path;
path = SiteConstant.getTemplatePath() + (isMoblie() ? site.getTemplateMobile() : site.getTemplate()) + path;

if (view.startsWith("/")) {
path = "/" + path;
Expand Down Expand Up @@ -138,6 +141,7 @@ public SessionUser setSessionUser(SessionUser user) {
setSessionAttr("menu", map);
// 不能访问的菜单
setSessionAttr("nomenu", new UserSvc().getNoAuthMap(map));

}
return user;
}
Expand Down Expand Up @@ -181,19 +185,20 @@ protected void saveLog(SysUser user, String operType) {
// ///////////////////栏目处理////////////
// 获取用户设置的SITE对象,设置默认
public SessionSite getSessionSite() {
SessionSite sessionSite = getSessionAttr(SiteConstant.SESSION_SITE);
SessionSite sessionSite = getSessionAttr(SiteConstant.getSessionSite());
// 获取用户设置的SITE对象,设置默认
if (sessionSite == null) {
sessionSite = new SessionSite();
sessionSite.setBackSiteId(SiteConstant.DEFAULT_SITE_ID);
sessionSite.setSiteId(SiteConstant.DEFAULT_SITE_ID);
setSessionAttr(SiteConstant.SESSION_SITE, sessionSite);
int defaultSiteId = new SiteService().getDefaultId();
sessionSite.setBackSiteId(defaultSiteId);
sessionSite.setSiteId(defaultSiteId);
setSessionAttr(SiteConstant.getSessionSite(), sessionSite);
}
return sessionSite;
}

public SessionSite setSessionSite(SessionSite sessionSite) {
setSessionAttr(SiteConstant.SESSION_SITE, sessionSite);
setSessionAttr(SiteConstant.getSessionSite(), sessionSite);
return sessionSite;
}

Expand All @@ -204,7 +209,7 @@ public String selectFolder(Integer selected) {
public String selectFolder(Integer selected, Integer selfId) {
return new FolderService().selectFolder(selected, selfId, getSessionSite().getBackSiteId());
}

/**
* 公共文章查询sql
*
Expand All @@ -219,4 +224,23 @@ public String getPublicWhere() {
;
}

Cache cache = CacheManager.get("JFLYFOX_SESSION");

public Controller setSessionAttrCache(String key, Object value) {
String id = getSession().getId();
cache.add(key + "_" + id, value);
return this;
}

public <T> T getSessionAttrCache(String key) {
String id = getSession().getId();
return cache.get(key + "_" + id);
}

public Controller removeSessionAttrCache(String key) {
String id = getSession().getId();
cache.remove(key + "_" + id);
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void intercept(Invocation ai) {

Controller controller = ai.getController();

SessionSite sessionSite = controller.getSessionAttr(SiteConstant.SESSION_SITE);
SessionSite sessionSite = controller.getSessionAttr(SiteConstant.getSessionSite());
if (sessionSite == null) {
// 设置公共属性
controller.setAttr(JFlyFoxUtils.WEBSITE_TITLE, TITLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import com.jfinal.aop.Interceptor;
Expand All @@ -29,34 +27,32 @@ public class SiteInterceptor implements Interceptor {

public void intercept(Invocation ai) {
Controller controller = ai.getController();


SessionSite sessionSite = controller.getSessionAttr(SiteConstant.getSessionSite());
TbSite defaultSite = new SiteService().getDefaultSite();
// 如果修改了默认站点,重新设置site session
if (sessionSite != null && defaultSite.getId() != sessionSite.getSiteDefalutId()) {
sessionSite = null;
}

// 单站点设置
if (!SiteConstant.isMultiSite()) {
SessionSite sessionSite = controller.getSessionAttr(SiteConstant.SESSION_SITE);
if (sessionSite == null) {
sessionSite = new SessionSite();
sessionSite.setBackSiteId(SiteConstant.DEFAULT_SITE_ID);
sessionSite.setSiteId(SiteConstant.DEFAULT_SITE_ID);
TbSite tmpSite = new SiteService().getSite(SiteConstant.DEFAULT_SITE_ID);
sessionSite.setBackModel(tmpSite);
sessionSite.setModel(tmpSite);
controller.setSessionAttr(SiteConstant.SESSION_SITE, sessionSite);
sessionSite.setSiteDefalutId(defaultSite.getId());
sessionSite.setBackSiteId(defaultSite.getId());
sessionSite.setSiteId(defaultSite.getId());
sessionSite.setBackModel(defaultSite);
sessionSite.setModel(defaultSite);
controller.setSessionAttr(SiteConstant.getSessionSite(), sessionSite);
}
ai.invoke();
return;
}

// 每次访问获取session,没有可以从cookie取~
SysUser user = null;
if (controller instanceof BaseController) {
user = (SysUser) ((BaseController) controller).getSessionUser();
} else {
user = controller.getSessionAttr(Attr.SESSION_NAME);
}


// 返回list
List<TbSite> sites = new SiteService().getSiteList(user);
controller.setAttr(SiteConstant.SESSION_SITES, sites);
List<TbSite> sites = new SiteService().getSiteList();
controller.setAttr(SiteConstant.getSessionSites(), sites);

// 请求路径
String tmpPath = ai.getActionKey();
Expand All @@ -68,12 +64,19 @@ public void intercept(Invocation ai) {
}
boolean isBack = JFlyFoxUtils.isBack(tmpPath);

SessionSite sessionSite = controller.getSessionAttr(SiteConstant.SESSION_SITE);
if (sessionSite == null) {
sessionSite = new SessionSite();
}

if (isBack) { // 后台
// 每次访问获取session,没有可以从cookie取~
SysUser user = null;
if (controller instanceof BaseController) {
user = (SysUser) ((BaseController) controller).getSessionUser();
} else {
user = controller.getSessionAttr(Attr.SESSION_NAME);
}

// 权限应该是用户拦截器处理
if (user == null) {
log.error("session user is null!");
Expand All @@ -84,7 +87,7 @@ public void intercept(Invocation ai) {
// 获取用户设置的SITE对象,设置默认
if (sessionSite.getBackSiteId() <= 0) {
int backSiteId = user.getInt("back_site_id");
backSiteId = backSiteId > 0 ? backSiteId : SiteConstant.DEFAULT_SITE_ID;
backSiteId = backSiteId > 0 ? backSiteId : defaultSite.getId();

sessionSite.setBackSiteId(backSiteId);

Expand All @@ -94,12 +97,12 @@ public void intercept(Invocation ai) {
sessionSite.setBackModel(tmpSite);
}

controller.setSessionAttr(SiteConstant.SESSION_SITE, sessionSite);
sessionSite.setSiteDefalutId(defaultSite.getId());
controller.setSessionAttr(SiteConstant.getSessionSite(), sessionSite);
}
} else {
HttpServletRequest request = controller.getRequest();
// 通过site匹配站点
String siteServer = request.getServerName();
String siteServer = controller.getRequest().getServerName();
int siteId = 0;
// if (StrUtils.isEmpty(sessionSite.getLastSite()) ||
// !site.equals(sessionSite.getLastSite())) {
Expand All @@ -115,18 +118,14 @@ public void intercept(Invocation ai) {
}
}

// 没有就用默认的
if (siteId == 0) {
siteId = SiteConstant.DEFAULT_SITE_ID;
// 设置站点对象
TbSite tmpSite = getSite(sites, siteId);
if (tmpSite != null) {
sessionSite.setSiteId(tmpSite.getId());
sessionSite.setModel(tmpSite);
}
// 没有就用默认的,设置站点对象
if (siteId == 0 && defaultSite != null) {
sessionSite.setSiteId(defaultSite.getId());
sessionSite.setModel(defaultSite);
}

controller.setSessionAttr(SiteConstant.SESSION_SITE, sessionSite);
sessionSite.setSiteDefalutId(defaultSite.getId());
controller.setSessionAttr(SiteConstant.getSessionSite(), sessionSite);
// }
}

Expand Down
Loading

0 comments on commit 52df620

Please sign in to comment.