hainan
commit
6502c36e23
|
|
@ -0,0 +1,73 @@
|
|||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### Maven template
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
### Java template
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
*.iml
|
||||
.idea
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>cn.cloudowr</groupId>
|
||||
<artifactId>ywxj.shangbao</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>9.4.0.v20161208</version>
|
||||
<configuration>
|
||||
<stopKey>stop</stopKey>
|
||||
<stopPort>5206</stopPort>
|
||||
<webApp>
|
||||
<contextPath>/</contextPath>
|
||||
</webApp>
|
||||
<scanIntervalSeconds>5</scanIntervalSeconds>
|
||||
<httpConnector>
|
||||
<port>4206</port>
|
||||
<idleTimeout>60000</idleTimeout>
|
||||
</httpConnector>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.jfinal</groupId>
|
||||
<artifactId>jfinal</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jfinal</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>8.1.8</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>mysql</groupId>-->
|
||||
<!--<artifactId>mysql-connector-java</artifactId>-->
|
||||
<!--<version>5.1.20</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.24</version>
|
||||
</dependency>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>com.alibaba</groupId>-->
|
||||
<!--<artifactId>druid</artifactId>-->
|
||||
<!--<version>1.0.16</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudowr</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.3.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package cn.cloudowr.ywxj.shangbao;
|
||||
|
||||
import cn.cloudowr.sdk.JQueryParameterFilter;
|
||||
import cn.cloudowr.sdk.jfinal.ErrorInterceptor;
|
||||
import com.jfinal.config.*;
|
||||
import com.jfinal.template.Engine;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.MongoCredential;
|
||||
import com.mongodb.ServerAddress;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by lyf66 on 2017/2/18.
|
||||
*/
|
||||
public class Config extends JFinalConfig{
|
||||
private static MongoDatabase mongoDatabase;
|
||||
|
||||
public static MongoDatabase getMongoDatabase() {
|
||||
return mongoDatabase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configConstant(Constants me) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configRoute(Routes me) {
|
||||
me.add("/", Controller.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configEngine(Engine me) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configPlugin(Plugins me) {
|
||||
// String db_type = PropKit.get(ConstConfig.db_type_key);
|
||||
// DruidPlugin druidPlugin = new DruidPlugin(
|
||||
// PropKit.get(ConstConfig.db_connection_jdbcUrl),
|
||||
// PropKit.get(ConstConfig.db_connection_userName),
|
||||
// PropKit.get(ConstConfig.db_connection_passWord),
|
||||
// PropKit.get(ConstConfig.db_connection_driverClass));
|
||||
//
|
||||
// druidPlugin.set(
|
||||
// PropKit.getInt(ConstConfig.db_initialSize),
|
||||
// PropKit.getInt(ConstConfig.db_minIdle),
|
||||
// PropKit.getInt(ConstConfig.db_maxActive));
|
||||
//
|
||||
// druidPlugin.addFilter(new StatFilter());
|
||||
// WallFilter wall = new WallFilter();
|
||||
// wall.setDbType(db_type);
|
||||
// WallConfig config = new WallConfig();
|
||||
// config.setFunctionCheck(false); // 支持数据库函数
|
||||
// wall.setConfig(config);
|
||||
// druidPlugin.addFilter(wall);
|
||||
//
|
||||
// ActiveRecordPlugin arp = new ActiveRecordPlugin(ConstConfig.db_dataSource_main, druidPlugin);
|
||||
// //arp.setTransactionLevel(4);//事务隔离级别
|
||||
// boolean devMode = PropKit.getBoolean(ConstConfig.config_devMode);
|
||||
// arp.setDevMode(devMode); // 设置开发模式
|
||||
// arp.setShowSql(devMode); // 是否显示SQL
|
||||
//
|
||||
// arp.setDialect(new MysqlDialect());
|
||||
// me.add(druidPlugin); // 多数据源继续添加
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configInterceptor(Interceptors me) {
|
||||
me.add(new JQueryParameterFilter());
|
||||
me.add(new ErrorInterceptor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configHandler(Handlers me) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterJFinalStart() {
|
||||
MongoCredential mongoCredential = MongoCredential.createCredential("root", "admin", "CoWR1111".toCharArray());
|
||||
MongoClient mongoClient = new MongoClient(new ServerAddress("120.24.5.249", 3717), Arrays.asList(mongoCredential));
|
||||
mongoDatabase = mongoClient.getDatabase("dict");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package cn.cloudowr.ywxj.shangbao;
|
||||
|
||||
import cn.cloudowr.sdk.jfinal.AbsController;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import org.bson.Document;
|
||||
|
||||
/**
|
||||
* Created by lyf66 on 2017/2/20.
|
||||
*/
|
||||
public class Controller extends AbsController{
|
||||
public void ping() {
|
||||
renderText("ywxj.shangbao pong");
|
||||
}
|
||||
@Override
|
||||
public MongoCollection<Document> getCollection() {
|
||||
MongoDatabase mongoDataBase = Config.getMongoDatabase();
|
||||
MongoCollection<Document> collection = mongoDataBase.getCollection("shangbao");
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.cloudowr.ywxj.shangbao;
|
||||
|
||||
import com.jfinal.core.JFinal;
|
||||
|
||||
/**
|
||||
* Created by lyf66 on 2017/2/16.
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
JFinal.start("src/main/webapp", 4206, "/");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
|
||||
version="3.1">
|
||||
<filter>
|
||||
<filter-name>cn.cloudowr.ywxj.shangbao</filter-name>
|
||||
<filter-class>com.jfinal.core.JFinalFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>configClass</param-name>
|
||||
<param-value>cn.cloudowr.ywxj.shangbao.Config</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>cn.cloudowr.ywxj.shangbao</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
</web-app>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//model
|
||||
shangbao {
|
||||
id,
|
||||
countycode required,
|
||||
usetype required,
|
||||
...other
|
||||
}
|
||||
//route
|
||||
index (
|
||||
pageSize optional default 20,
|
||||
pageNum optional default 1,
|
||||
json optional
|
||||
) {
|
||||
special json: {
|
||||
key: $ex //exists
|
||||
key: $nex //not exists
|
||||
key: $revalue //模糊查询,例:$re^te te开头的value
|
||||
}
|
||||
return dict list json
|
||||
}
|
||||
show (id required) {
|
||||
return dict json
|
||||
}
|
||||
save (json required) {
|
||||
return saved dict json with id
|
||||
}
|
||||
update (id required, json required) {
|
||||
json {
|
||||
$set: {k,v...},
|
||||
$unset: [k1,k2...],
|
||||
$rename: {k,newK...}
|
||||
}
|
||||
return {result : true or false}
|
||||
}
|
||||
delete (id required) {
|
||||
return {result: true or false}
|
||||
}
|
||||
Loading…
Reference in New Issue