Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
hellokaton committed Dec 14, 2015
1 parent 7145b7b commit 4744111
Show file tree
Hide file tree
Showing 39 changed files with 1,727 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# film

使用blade框架开发的电影站点。
99 changes: 99 additions & 0 deletions doc/film.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
SQLyog Ultimate v11.11 (64 bit)
MySQL - 5.5.40 : Database - film
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`film` /*!40100 DEFAULT CHARACTER SET utf8 */;

/*Table structure for table `t_menu` */

DROP TABLE IF EXISTS `t_menu`;

CREATE TABLE `t_menu` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL COMMENT '菜单名',
`slug` varchar(100) NOT NULL COMMENT '菜单缩略名',
`display_order` tinyint(4) NOT NULL COMMENT '菜单排序',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

/*Data for the table `t_menu` */

insert into `t_menu`(`id`,`name`,`slug`,`display_order`) values (1,'首页','/',0),(2,'高清电影','/gaoqingdianying',1),(3,'1080P','/1080P',2),(4,'720P','/720P',3),(5,'电视剧','/tv',4);

/*Table structure for table `t_option` */

DROP TABLE IF EXISTS `t_option`;

CREATE TABLE `t_option` (
`opt_key` varchar(255) NOT NULL,
`opt_value` text NOT NULL,
PRIMARY KEY (`opt_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

/*Data for the table `t_option` */

/*Table structure for table `t_post` */

DROP TABLE IF EXISTS `t_post`;

CREATE TABLE `t_post` (
`pid` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL COMMENT '标题',
`slug` varchar(255) DEFAULT NULL COMMENT '缩略名',
`cover` varchar(255) NOT NULL COMMENT '封面',
`category_id` int(11) DEFAULT NULL COMMENT '所属分类',
`content` text NOT NULL COMMENT '内容',
`views` int(10) NOT NULL DEFAULT '0' COMMENT '浏览量',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已经删除',
`dateline` int(11) NOT NULL COMMENT '发布日期',
PRIMARY KEY (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

/*Data for the table `t_post` */

/*Table structure for table `t_tag` */

DROP TABLE IF EXISTS `t_tag`;

CREATE TABLE `t_tag` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL COMMENT '标签',
`count` int(10) NOT NULL DEFAULT '0' COMMENT '标签下的文章个数',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

/*Data for the table `t_tag` */

insert into `t_tag`(`id`,`name`,`count`) values (1,'2015',0),(2,'悬疑',0),(3,'惊悚',0),(4,'喜剧',0),(5,'爱情',0),(6,'华语',0),(7,'欧美',0),(8,'搞笑',0),(9,'科幻',0),(10,'动画',0);

/*Table structure for table `t_user` */

DROP TABLE IF EXISTS `t_user`;

CREATE TABLE `t_user` (
`uid` int(10) NOT NULL AUTO_INCREMENT,
`login_name` varchar(100) NOT NULL COMMENT '登录名',
`pass_word` varchar(255) NOT NULL COMMENT '密码',
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
`is_admin` tinyint(1) NOT NULL COMMENT '是否是管理员',
`is_del` tinyint(1) NOT NULL COMMENT '是否删除',
`dateline` int(11) NOT NULL COMMENT '注册时间',
PRIMARY KEY (`uid`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

/*Data for the table `t_user` */

insert into `t_user`(`uid`,`login_name`,`pass_word`,`avatar`,`is_admin`,`is_del`,`dateline`) values (1,'admin','BQlRvE7PKAX4b1waywkqD8Vom3yjeYGn',NULL,1,0,0);

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
Expand Down
79 changes: 79 additions & 0 deletions pom.xml
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>
62 changes: 62 additions & 0 deletions src/main/java/me/biezhi/film/App.java
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();
}
}

}
12 changes: 12 additions & 0 deletions src/main/java/me/biezhi/film/Const.java
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;


}
56 changes: 56 additions & 0 deletions src/main/java/me/biezhi/film/Validator.java
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 src/main/java/me/biezhi/film/controller/BaseController.java
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;
}

}
Loading

0 comments on commit 4744111

Please sign in to comment.