.
This commit is contained in:
45
src/main/java/com/lxyer/config/DbMap.java
Normal file
45
src/main/java/com/lxyer/config/DbMap.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.lxyer.config;
|
||||
|
||||
import com.jfinal.kit.PathKit;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.lxyer.model.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Generated by JFinal, do not modify this file.
|
||||
* <pre>
|
||||
* Example:
|
||||
* public void configPlugin(Plugins me) {
|
||||
* ActiveRecordPlugin arp = new ActiveRecordPlugin(...);
|
||||
* DbMap.mapping(arp);
|
||||
* me.add(arp);
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public class DbMap {
|
||||
|
||||
public static void mapping(ActiveRecordPlugin arp) {
|
||||
arp.addMapping("act_log", "logid", ActLog.class);
|
||||
arp.addMapping("comment", "commentId", Comment.class);
|
||||
arp.addMapping("content", "contentId", Content.class);
|
||||
arp.addMapping("content_item", "itemId", ContentItem.class);
|
||||
// Composite Primary Key order: tid,cate,attr
|
||||
arp.addMapping("dyna_attr", "tid,cate,attr", DynaAttr.class);
|
||||
arp.addMapping("user", "userId", User.class);
|
||||
}
|
||||
|
||||
public static void addSqlTemplate(ActiveRecordPlugin arp) {
|
||||
String baseSqlTemplatePath = PathKit.getWebRootPath() + "/WEB-INF/classes/sql/";
|
||||
arp.setBaseSqlTemplatePath(baseSqlTemplatePath);
|
||||
|
||||
File sqlFiles = new File(baseSqlTemplatePath);
|
||||
File[] files = sqlFiles.listFiles();
|
||||
for (File f : files){
|
||||
if (f.isFile() || f.getName().endsWith(".sql")){
|
||||
arp.addSqlTemplate(f.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
src/main/java/com/lxyer/config/E.java
Normal file
37
src/main/java/com/lxyer/config/E.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.lxyer.config;
|
||||
|
||||
/**
|
||||
* Created by Lxyer at 2017/9/10 15:35.
|
||||
*/
|
||||
public class E {
|
||||
|
||||
public enum DynamicAttr {
|
||||
//table,id_k,gk, cate
|
||||
NEWS("dyna_attr", "contentId", "tid", 1),
|
||||
PRODUCTION("dyna_attr", "contentId", "tid", 2),
|
||||
USER("dyna_attr", "userId", "tid", 3)
|
||||
;
|
||||
private String table;
|
||||
private String id_k;
|
||||
private String gk;
|
||||
private int cate;
|
||||
DynamicAttr(String table, String id_k, String gk, int cate) {
|
||||
this.table = table;
|
||||
this.id_k = id_k;
|
||||
this.gk = gk;
|
||||
this.cate = cate;
|
||||
}
|
||||
public String table(){
|
||||
return this.table;
|
||||
}
|
||||
public String id_k(){
|
||||
return this.id_k;
|
||||
}
|
||||
public String gk(){
|
||||
return this.gk;
|
||||
}
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
}
|
||||
}
|
35
src/main/java/com/lxyer/config/F.java
Normal file
35
src/main/java/com/lxyer/config/F.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.lxyer.config;
|
||||
|
||||
/**
|
||||
* Created by JUECHENG at 2018/1/7 14:35.
|
||||
*/
|
||||
public class F {
|
||||
public enum DynamicAttr {
|
||||
//table,id_k,gk, cate
|
||||
NEWS("dyna_attr", "contentId", "tid", 1),
|
||||
USER("dyna_attr", "userId", "tid", 2)
|
||||
;
|
||||
private String table;
|
||||
private String id_k;
|
||||
private String gk;
|
||||
private int cate;
|
||||
DynamicAttr(String table, String id_k, String gk, int cate) {
|
||||
this.table = table;
|
||||
this.id_k = id_k;
|
||||
this.gk = gk;
|
||||
this.cate = cate;
|
||||
}
|
||||
public String table(){
|
||||
return this.table;
|
||||
}
|
||||
public String id_k(){
|
||||
return this.id_k;
|
||||
}
|
||||
public String gk(){
|
||||
return this.gk;
|
||||
}
|
||||
public int getCate() {
|
||||
return cate;
|
||||
}
|
||||
}
|
||||
}
|
66
src/main/java/com/lxyer/config/FlyConfig.java
Normal file
66
src/main/java/com/lxyer/config/FlyConfig.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package com.lxyer.config;
|
||||
|
||||
import com.jfinal.config.*;
|
||||
import com.jfinal.kit.PathKit;
|
||||
import com.jfinal.kit.PropKit;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.ehcache.EhCachePlugin;
|
||||
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||
import com.jfinal.plugin.redis.RedisPlugin;
|
||||
import com.jfinal.template.Engine;
|
||||
import com.lxyer.config.handler.UrlHandler;
|
||||
import com.lxyer.config.interceptor.LoginInterceptor;
|
||||
import com.lxyer.config.route.AdminRoute;
|
||||
import com.lxyer.config.route.SiteRoute;
|
||||
|
||||
/**
|
||||
* Created by Lxyer at 2018/01/07
|
||||
*/
|
||||
public class FlyConfig extends JFinalConfig {
|
||||
|
||||
@Override
|
||||
public void configConstant(Constants me) {
|
||||
me.setDevMode(true);
|
||||
PropKit.use("config.properties");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configRoute(Routes me) {
|
||||
me.add(new AdminRoute());
|
||||
me.add(new SiteRoute());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configEngine(Engine me) {
|
||||
Engine.setMainEngine(me);
|
||||
me.setBaseTemplatePath(PathKit.getWebRootPath());
|
||||
|
||||
me.addSharedFunction("/WEB-INF/_t/layout.html");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configPlugin(Plugins me) {
|
||||
loadPropertyFile("config.properties");
|
||||
|
||||
HikariCpPlugin hikariPlguin = new HikariCpPlugin(getProperty("jdbcUrl"), getProperty("user"), getProperty("password"), "com.mysql.cj.jdbc.Driver");
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(hikariPlguin);
|
||||
me.add(hikariPlguin);
|
||||
me.add(arp);
|
||||
|
||||
DbMap.mapping(arp);
|
||||
DbMap.addSqlTemplate(arp);
|
||||
|
||||
me.add(new RedisPlugin(getProperty("redis.cache_name"), getProperty("redis.host"), getPropertyToInt("redis.port"), getPropertyToInt("redis.timeout")));
|
||||
me.add(new EhCachePlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configInterceptor(Interceptors me) {
|
||||
me.add(new LoginInterceptor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configHandler(Handlers me) {
|
||||
me.add(new UrlHandler());
|
||||
}
|
||||
}
|
17
src/main/java/com/lxyer/config/handler/UrlHandler.java
Normal file
17
src/main/java/com/lxyer/config/handler/UrlHandler.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.lxyer.config.handler;
|
||||
|
||||
import com.jfinal.handler.Handler;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Created by JUECHENG at 2018/1/7 11:20.
|
||||
*/
|
||||
public class UrlHandler extends Handler {
|
||||
@Override
|
||||
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
|
||||
|
||||
next.handle(target, request, response, isHandled);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.lxyer.config.interceptor;
|
||||
|
||||
import com.jfinal.aop.Interceptor;
|
||||
import com.jfinal.aop.Invocation;
|
||||
|
||||
/**
|
||||
* Created by JUECHENG at 2018/1/7 11:22.
|
||||
*/
|
||||
public class LoginInterceptor implements Interceptor {
|
||||
@Override
|
||||
public void intercept(Invocation inv) {
|
||||
inv.invoke();
|
||||
}
|
||||
}
|
13
src/main/java/com/lxyer/config/route/AdminRoute.java
Normal file
13
src/main/java/com/lxyer/config/route/AdminRoute.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.lxyer.config.route;
|
||||
|
||||
import com.jfinal.config.Routes;
|
||||
|
||||
/**
|
||||
* Created by JUECHENG at 2018/1/7 11:19.
|
||||
*/
|
||||
public class AdminRoute extends Routes {
|
||||
@Override
|
||||
public void config() {
|
||||
|
||||
}
|
||||
}
|
16
src/main/java/com/lxyer/config/route/SiteRoute.java
Normal file
16
src/main/java/com/lxyer/config/route/SiteRoute.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.lxyer.config.route;
|
||||
|
||||
import com.jfinal.config.Routes;
|
||||
import com.lxyer.controller.HomeController;
|
||||
|
||||
/**
|
||||
* Created by JUECHENG at 2018/1/7 11:16.
|
||||
*/
|
||||
public class SiteRoute extends Routes {
|
||||
@Override
|
||||
public void config() {
|
||||
setBaseViewPath("/WEB-INF/fly");
|
||||
|
||||
add("/", HomeController.class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user