forked from hellokaton/wechat-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7145b7b
commit 4744111
Showing
39 changed files
with
1,727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# film | ||
|
||
使用blade框架开发的电影站点。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>me.biezhi</groupId> | ||
<artifactId>film</artifactId> | ||
<packaging>war</packaging> | ||
<version>0.0.1</version> | ||
<name>film Maven Webapp</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<maven.compiler.source>1.6</maven.compiler.source> | ||
<maven.compiler.target>1.6</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.bladejava</groupId> | ||
<artifactId>blade-core</artifactId> | ||
<version>1.5.0-beta</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.bladejava</groupId> | ||
<artifactId>blade-sql2o</artifactId> | ||
<version>1.3.0-alpha</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.subchen</groupId> | ||
<artifactId>jetbrick-template</artifactId> | ||
<version>2.0.12</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>druid</artifactId> | ||
<version>1.0.15</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.35</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.0.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>film</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
<encoding>UTF8</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>9.2.12.v20150709</version> | ||
<configuration> | ||
<scanIntervalSeconds>3</scanIntervalSeconds> | ||
<webApp> | ||
<contextPath>/</contextPath> | ||
</webApp> | ||
<httpConnector> | ||
<port>9000</port> | ||
</httpConnector> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package me.biezhi.film; | ||
|
||
import java.util.Properties; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import jetbrick.template.JetEngine; | ||
import jetbrick.template.JetGlobalContext; | ||
import jetbrick.template.resolver.GlobalResolver; | ||
import me.biezhi.film.func.Funcs; | ||
import blade.kit.PropertyKit; | ||
import blade.plugin.sql2o.Sql2oPlugin; | ||
|
||
import com.alibaba.druid.pool.DruidDataSourceFactory; | ||
import com.blade.Blade; | ||
import com.blade.Bootstrap; | ||
import com.blade.render.JetbrickRender; | ||
import com.blade.route.RouteHandler; | ||
import com.blade.web.http.Request; | ||
import com.blade.web.http.Response; | ||
|
||
public class App extends Bootstrap { | ||
|
||
@Override | ||
public void init(Blade blade) { | ||
// 加载配置文件 | ||
blade.config("blade.conf"); | ||
blade.routeConf("me.biezhi.film.controller", "route_front.conf"); | ||
blade.routeConf("me.biezhi.film.controller.admin", "route_admin.conf"); | ||
|
||
// 设置模板引擎 | ||
JetbrickRender jetbrickRender = new JetbrickRender(); | ||
JetEngine jetEngine = jetbrickRender.getJetEngine(); | ||
|
||
JetGlobalContext globalContext = jetEngine.getGlobalContext(); | ||
Const.CONTEXT = globalContext; | ||
|
||
GlobalResolver resolver = jetEngine.getGlobalResolver(); | ||
resolver.registerFunctions(Funcs.class); | ||
|
||
blade.viewEngin(jetbrickRender); | ||
|
||
// 拦截器 | ||
blade.before("/admin/.*", new RouteHandler() { | ||
@Override | ||
public void handle(Request request, Response response) { | ||
|
||
} | ||
}); | ||
|
||
// 配置数据库 | ||
try { | ||
Properties props = PropertyKit.getProperty("ds.conf"); | ||
DataSource dataSource = DruidDataSourceFactory.createDataSource(props); | ||
Sql2oPlugin sql2oPlugin = blade.plugin(Sql2oPlugin.class); | ||
sql2oPlugin.config(dataSource).run(); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.biezhi.film; | ||
|
||
import jetbrick.template.JetGlobalContext; | ||
|
||
public class Const { | ||
|
||
public static final String LOGIN_SESSION = "login_user"; | ||
|
||
public static JetGlobalContext CONTEXT = null; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package me.biezhi.film; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import blade.kit.PropertyKit; | ||
|
||
public final class Validator { | ||
|
||
private static Map<String, String> errorMsg = new HashMap<String, String>(); | ||
|
||
static { | ||
errorMsg = PropertyKit.getPropertyMap("validation.lang"); | ||
} | ||
|
||
public static String required(String val){ | ||
return String.format(errorMsg.get("required"), val); | ||
} | ||
|
||
public static String email(String val){ | ||
return String.format(errorMsg.get("email"), val); | ||
} | ||
|
||
public static String date(String val){ | ||
return String.format(errorMsg.get("date"), val); | ||
} | ||
|
||
public static String number(String val){ | ||
return String.format(errorMsg.get("number"), val); | ||
} | ||
|
||
public static String phone(String val){ | ||
return String.format(errorMsg.get("phone"), val); | ||
} | ||
|
||
public static String url(String val){ | ||
return String.format(errorMsg.get("url"), val); | ||
} | ||
|
||
public static String min(Long val){ | ||
return String.format(errorMsg.get("min"), val); | ||
} | ||
|
||
public static String max(Long val){ | ||
return String.format(errorMsg.get("max"), val); | ||
} | ||
|
||
public static String minLen(Long val){ | ||
return String.format(errorMsg.get("minLen"), val); | ||
} | ||
|
||
public static String maxLen(Long val){ | ||
return String.format(errorMsg.get("maxLen"), val); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/me/biezhi/film/controller/BaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package me.biezhi.film.controller; | ||
|
||
import me.biezhi.film.kit.SessionKit; | ||
import me.biezhi.film.model.User; | ||
|
||
import com.blade.render.ModelAndView; | ||
import com.blade.web.http.Request; | ||
|
||
public class BaseController { | ||
|
||
/** | ||
* 默认分页条数 | ||
*/ | ||
protected Integer pageSize = 10; | ||
|
||
/** | ||
* 状态字段 | ||
*/ | ||
protected String STATUS = "status"; | ||
|
||
/** | ||
* 成功 | ||
*/ | ||
protected String SUCCESS = "success"; | ||
|
||
/** | ||
* 服务器异常 | ||
*/ | ||
protected String ERROR = "error"; | ||
|
||
/** | ||
* 已经存在 | ||
*/ | ||
protected String EXIST = "exist"; | ||
|
||
/** | ||
* 失败 | ||
*/ | ||
protected String FAILURE = "failure"; | ||
|
||
protected ModelAndView getFront(String view){ | ||
return new ModelAndView(view); | ||
} | ||
|
||
protected ModelAndView getAdmin(String view){ | ||
view = "admin/" + view; | ||
return new ModelAndView(view); | ||
} | ||
|
||
/** | ||
* @return 返回是否登录 | ||
*/ | ||
public boolean isSignin(Request request){ | ||
return null != SessionKit.getLoginUser(request); | ||
} | ||
|
||
/** | ||
* @return 返回是否登录并且是管理员 | ||
*/ | ||
public boolean isAdmin(Request request){ | ||
User user= SessionKit.getLoginUser(request); | ||
if(null != user && user.getIs_admin()){ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
Oops, something went wrong.