2.1-SNAPSHOT

This commit is contained in:
zhouhao
2016-10-16 20:00:01 +08:00
parent 45e625b4c3
commit 3f2e656c35
87 changed files with 921 additions and 1890 deletions

17
hsweb-web-bean/README.md Normal file
View File

@@ -0,0 +1,17 @@
## 实体类模块,通用bean,po,和自定义验证器
### 目录结构
```bash
--------src/main/java
---------------------org.hsweb.web.bean
----------------------------common # 通用bean,如增删改查通用参数
------------------------------po # 各个功能的po实体
----------------------------validator # 自定义hibernate-validator
-----------------resources/system
---------------------------------install.sql #首次启动时执行的sql
```
### 说明
po对象都应该继承[GenericPo](src/main/java/org/hsweb/web/bean/po/GenericPo.java)
GenericPo 的泛型为主键的类型,hsweb建议使用String类型,通过createUID()方法手动生成id

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-bean</artifactId>

View File

@@ -0,0 +1,115 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.bean.po.system;
public class SystemVersion implements Comparable<SystemVersion> {
public String name;
public String comment;
public String website;
public int majorVersion = 1;
public int minorVersion = 0;
public int revisionVersion = 0;
public boolean snapshot;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
public int getMajorVersion() {
return majorVersion;
}
public void setMajorVersion(int majorVersion) {
this.majorVersion = majorVersion;
}
public int getMinorVersion() {
return minorVersion;
}
public void setMinorVersion(int minorVersion) {
this.minorVersion = minorVersion;
}
public int getRevisionVersion() {
return revisionVersion;
}
public void setRevisionVersion(int revisionVersion) {
this.revisionVersion = revisionVersion;
}
public boolean isSnapshot() {
return snapshot;
}
public void setSnapshot(boolean snapshot) {
this.snapshot = snapshot;
}
@Override
public int compareTo(SystemVersion o) {
if (null == o) return -1;
if (o.getMajorVersion() > this.getMajorVersion()) return -1;
if (o.getMajorVersion() == this.getMajorVersion()) {
if (o.getMinorVersion() > this.getMinorVersion()) return -1;
if (o.getMinorVersion() == this.getMinorVersion()) {
if (o.getRevisionVersion() > this.getRevisionVersion()) return -1;
if (o.getRevisionVersion() == this.getRevisionVersion()) return 0;
return 1;
} else {
return 1;
}
} else {
return 1;
}
}
public static void main(String[] args) {
SystemVersion systemVersion = new SystemVersion();
systemVersion.setMajorVersion(2);
systemVersion.setMinorVersion(2);
systemVersion.setRevisionVersion(1);
SystemVersion systemVersion2 = new SystemVersion();
systemVersion2.setMajorVersion(3);
systemVersion2.setMinorVersion(2);
systemVersion2.setRevisionVersion(1);
System.out.println(systemVersion.compareTo(systemVersion2));
}
}

View File

@@ -4,9 +4,6 @@ import org.hsweb.web.bean.po.GenericPo;
import java.util.List;
/**
* Created by zhouhao on 16-5-19.
*/
public class Template extends GenericPo<String> {
private String name;

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-web-concurrent</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-concurrent-cache</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-web-concurrent</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-concurrent-lock</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-controller</artifactId>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-core</artifactId>

View File

@@ -19,13 +19,11 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.util.Assert;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhouhao on 16-4-23.
*/
@Configuration
@EnableConfigurationProperties({DataSourceProperties.class})
@AutoConfigureAfter({DataSourceAutoConfiguration.class})

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.core.datasource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
@Component
public class DataSourceHolder {
private static DynamicDataSource dynamicDataSource;
private static DataSource defaultDataSource;
private static DatabaseType defaultDatabaseType;
@Autowired(required = false)
private DataSource dataSource;
@PostConstruct
public void init() throws SQLException {
if (null != dataSource) {
Connection connection = null;
try {
connection = dataSource.getConnection();
install(dataSource, DatabaseType.fromJdbcUrl(connection.getMetaData().getURL()));
dataSource = null;
} finally {
if (null != connection)
connection.close();
}
}
}
public static DataSource getActiveSource() {
if (dynamicDataSource != null) {
return dynamicDataSource.getActiveDataSource();
}
return defaultDataSource;
}
public static DatabaseType getActiveDatabaseType() {
if (dynamicDataSource != null) {
return dynamicDataSource.getActiveDataBaseType();
}
return defaultDatabaseType;
}
public static DataSource getDefaultDataSource() {
return defaultDataSource;
}
public static DatabaseType getDefaultDatabaseType() {
return defaultDatabaseType;
}
public static void install(DynamicDataSource dynamicDataSource) {
if (DataSourceHolder.dynamicDataSource != null) {
throw new UnsupportedOperationException();
}
DataSourceHolder.dynamicDataSource = dynamicDataSource;
}
public static void install(DataSource dataSource, DatabaseType databaseType) {
if (DataSourceHolder.defaultDataSource != null) {
throw new UnsupportedOperationException();
}
DataSourceHolder.defaultDataSource = dataSource;
DataSourceHolder.defaultDatabaseType = databaseType;
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.core.datasource;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
public enum DatabaseType {
unknown(null, null, null),
mysql("com.mysql.jdbc.Driver", "com.mysql.jdbc.jdbc2.optional.MysqlXADataSource", "select 1"),
h2("org.h2.Driver", "org.h2.jdbcx.JdbcDataSource", "select 1"),
oracle("oracle.jdbc.driver.OracleDriver", "oracle.jdbc.xa.client.OracleXADataSource", "select 1 from dual");
DatabaseType(String driverClassName, String xaDataSourceClassName, String testQuery) {
this.driverClassName = driverClassName;
this.testQuery = testQuery;
this.xaDataSourceClassName = xaDataSourceClassName;
}
private final String testQuery;
private final String driverClassName;
private final String xaDataSourceClassName;
public String getDriverClassName() {
return driverClassName;
}
public String getXaDataSourceClassName() {
return xaDataSourceClassName;
}
public String getTestQuery() {
return testQuery;
}
public static DatabaseType fromJdbcUrl(String url) {
if (StringUtils.hasLength(url)) {
Assert.isTrue(url.startsWith("jdbc"), "URL must start with 'jdbc'");
String urlWithoutPrefix = url.substring("jdbc".length()).toLowerCase();
for (DatabaseType driver : values()) {
String prefix = ":" + driver.name().toLowerCase() + ":";
if (driver != unknown && urlWithoutPrefix.startsWith(prefix)) {
return driver;
}
}
}
return unknown;
}
}

View File

@@ -23,15 +23,11 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
import javax.sql.CommonDataSource;
import javax.sql.DataSource;
/**
* @author zhouhao
*/
public interface DynamicDataSource extends DataSource {
String DATA_SOURCE_FLAG = "data-source-id";
String DATA_SOURCE_FLAG_LAST = "data-source-id-last";
static void useLast() {
use(ThreadLocalUtils.get(DATA_SOURCE_FLAG_LAST));
}
@@ -55,4 +51,6 @@ public interface DynamicDataSource extends DataSource {
}
DataSource getActiveDataSource();
DatabaseType getActiveDataBaseType();
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.core.datasource;
import javax.sql.DataSource;
public class DynamicDataSourceHolder {
private static DynamicDataSource dynamicDataSource;
public static DataSource getActiveSource() {
if (dynamicDataSource != null) {
return dynamicDataSource.getActiveDataSource();
}
return null;
}
public static void install(DynamicDataSource dynamicDataSource) {
if (DynamicDataSourceHolder.dynamicDataSource != null) {
throw new UnsupportedOperationException();
}
DynamicDataSourceHolder.dynamicDataSource = dynamicDataSource;
}
}

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-web-dao</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-dao-api</artifactId>

View File

@@ -10,7 +10,7 @@
<dependency>
<groupId>org.hsweb</groupId>
<artifactId>hsweb-web-dao-mybatis</artifactId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</dependency>
```

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-web-dao</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-dao-mybatis</artifactId>

View File

@@ -14,14 +14,16 @@
* limitations under the License.
*/
package org.hsweb.web.mybatis.dynamic;
package org.hsweb.web.mybatis;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.hsweb.web.core.datasource.DataSourceHolder;
import org.hsweb.web.datasource.dynamic.DynamicDataSourceAutoConfiguration;
import org.hsweb.web.mybatis.MybatisProperties;
import org.hsweb.web.mybatis.dynamic.DynamicDataSourceSqlSessionFactoryBuilder;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.boot.autoconfigure.MybatisProperties;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -30,16 +32,23 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.util.StringUtils;
import javax.sql.DataSource;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
@Configuration
@AutoConfigureAfter(DynamicDataSourceAutoConfiguration.class)
@EnableConfigurationProperties(MybatisProperties.class)
@ConditionalOnProperty(prefix = "mybatis", value = "dynamic-datasource")
public class DynamicDataSourceMyBatisAutoConfiguration {
public class MyBatisAutoConfiguration {
@Autowired
private MybatisProperties properties;
@@ -51,12 +60,23 @@ public class DynamicDataSourceMyBatisAutoConfiguration {
private ResourceLoader resourceLoader = new DefaultResourceLoader();
@Autowired(required = false)
private DatabaseIdProvider databaseIdProvider;
private DatabaseIdProvider databaseIdProvider = new DatabaseIdProvider() {
@Override
public void setProperties(Properties p) {
}
@Override
public String getDatabaseId(DataSource dataSource) throws SQLException {
return DataSourceHolder.getActiveDatabaseType().name();
}
};
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean factory = new SqlSessionFactoryBean();
factory.setSqlSessionFactoryBuilder(new DynamicDataSourceSqlSessionFactoryBuilder());
if (properties.isDynamicDatasource())
factory.setSqlSessionFactoryBuilder(new DynamicDataSourceSqlSessionFactoryBuilder());
factory.setDataSource(dataSource);
factory.setVfs(SpringBootVFS.class);
if (StringUtils.hasText(this.properties.getConfig())) {
@@ -70,8 +90,13 @@ public class DynamicDataSourceMyBatisAutoConfiguration {
factory.setDatabaseIdProvider(this.databaseIdProvider);
}
factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
String typeHandlers = "org.hsweb.web.mybatis.handler";
if (this.properties.getTypeHandlersPackage() != null) {
typeHandlers = typeHandlers + ";" + this.properties.getTypeHandlersPackage();
}
factory.setTypeHandlersPackage(typeHandlers);
factory.setMapperLocations(this.properties.resolveMapperLocations());
return factory.getObject();
}
}

View File

@@ -1,9 +1,12 @@
package org.hsweb.web.mybatis;
import org.hsweb.web.datasource.dynamic.DynamicDataSourceAutoConfiguration;
import org.hsweb.web.mybatis.utils.ResultMapsUtils;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -12,6 +15,8 @@ import javax.annotation.PostConstruct;
@Configuration
@ComponentScan(basePackages = {"org.hsweb.web.mybatis"})
@MapperScan(basePackages = {"org.hsweb.web.dao"})
@AutoConfigureAfter(DynamicDataSourceAutoConfiguration.class)
@EnableConfigurationProperties(MybatisProperties.class)
public class MybatisDaoAutoConfiguration {
@Autowired

View File

@@ -0,0 +1,101 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.mybatis;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
public class MybatisProperties extends org.mybatis.spring.boot.autoconfigure.MybatisProperties {
private static final String defaultMapperLocation = "classpath*:org/hsweb/web/dao/impl/mybatis/mapper/**/*.xml";
private String type = "oracle";
private boolean dynamicDatasource = false;
private String[] mapperLocationExcludes = null;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String[] getMapperLocationExcludes() {
return mapperLocationExcludes;
}
public void setMapperLocationExcludes(String[] mapperLocationExcludes) {
this.mapperLocationExcludes = mapperLocationExcludes;
}
public boolean isDynamicDatasource() {
return dynamicDatasource;
}
public void setDynamicDatasource(boolean dynamicDatasource) {
this.dynamicDatasource = dynamicDatasource;
}
@Override
public String[] getMapperLocations() {
return super.getMapperLocations();
}
public Resource[] resolveMapperLocations() {
Map<String, Resource> resources = new HashMap<>();
Set<String> locations;
if (this.getMapperLocations() == null)
locations = new HashSet<>();
else
locations = Arrays.stream(getMapperLocations()).collect(Collectors.toSet());
locations.add(defaultMapperLocation);
for (String mapperLocation : locations) {
Resource[] mappers;
try {
mappers = new PathMatchingResourcePatternResolver().getResources(mapperLocation);
for (Resource mapper : mappers) {
resources.put(mapper.getURL().toString(), mapper);
}
} catch (IOException e) {
}
}
if (mapperLocationExcludes != null && mapperLocationExcludes.length > 0)
{
for (String mapperLocationExclude : mapperLocationExcludes) {
try {
Resource[] excludesMappers = new PathMatchingResourcePatternResolver().getResources(mapperLocationExclude);
for (Resource excludesMapper : excludesMappers) {
resources.remove(excludesMapper.getURL().toString());
}
} catch (IOException e) {
}
}
}
Resource[] mapperLocations = new Resource[resources.size()];
mapperLocations = resources.values().
toArray(mapperLocations);
return mapperLocations;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.mybatis.builder;
import org.hsweb.web.core.datasource.DataSourceHolder;
import org.hsweb.web.core.datasource.DatabaseType;
/**
* @author zhouhao
*/
public class SqlBuilder {
private static boolean dynamic;
public static final Object current() {
DatabaseType type = dynamic
? DataSourceHolder.getActiveDatabaseType()
: DataSourceHolder.getDefaultDatabaseType();
switch (type) {
case mysql:
return MysqlParamBuilder.instance();
default:
return DefaultSqlParamBuilder.instance();
}
}
public static void setDynamic(boolean dynamic) {
SqlBuilder.dynamic = dynamic;
}
}

View File

@@ -23,6 +23,6 @@ import org.apache.ibatis.session.SqlSessionFactoryBuilder;
public class DynamicDataSourceSqlSessionFactoryBuilder extends SqlSessionFactoryBuilder {
@Override
public SqlSessionFactory build(Configuration config) {
return new DynamicSqlSessionFactory(config);
return new DynamicSqlSessionFactory(config);
}
}

View File

@@ -25,7 +25,7 @@ import org.apache.ibatis.session.defaults.DefaultSqlSession;
import org.apache.ibatis.transaction.Transaction;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.hsweb.web.core.datasource.DynamicDataSourceHolder;
import org.hsweb.web.core.datasource.DataSourceHolder;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -91,7 +91,7 @@ public class DynamicSqlSessionFactory implements SqlSessionFactory {
try {
final Environment environment = getConfiguration().getEnvironment();
final TransactionFactory transactionFactory = getTransactionFactoryFromEnvironment(environment);
DataSource ds = DynamicDataSourceHolder.getActiveSource();
DataSource ds = DataSourceHolder.getActiveSource();
if (ds == null) ds = environment.getDataSource();
tx = transactionFactory.newTransaction(ds, level, autoCommit);
final Executor executor = getConfiguration().newExecutor(tx, execType);

View File

@@ -5,24 +5,24 @@
<mapper namespace="BasicMapper">
<!--通用查询条件-->
<sql id="buildWhere">
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildWhere(resultMapId,tableName,#this['_parameter'].terms)}
${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildWhere(resultMapId,tableName,#this['_parameter'].terms)}
</sql>
<!--生成查询字段-->
<sql id="buildSelectField">
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildSelectFields(resultMapId,tableName,#this['_parameter'])}
${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildSelectFields(resultMapId,tableName,#this['_parameter'])}
</sql>
<!--生成修改字段-->
<sql id="buildUpdateField">
<set>
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildUpdateFields(resultMapId,#this['_parameter'])}
${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildUpdateFields(resultMapId,#this['_parameter'])}
</set>
</sql>
<!--生成排序字段-->
<sql id="buildSortField">
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildOrder(resultMapId,tableName,#this['_parameter'])}
${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildOrder(resultMapId,tableName,#this['_parameter'])}
</sql>
<!--生成查询sql-->
@@ -49,7 +49,7 @@
<!--生成InsertSql-->
<sql id="buildInsertSql">
insert into ${tableName} ${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildInsertSql(resultMapId,#this['_parameter'])}
insert into ${tableName} ${@org.hsweb.web.mybatis.builder.SqlBuilder@current().buildInsertSql(resultMapId,#this['_parameter'])}
</sql>
<!--生成UpdateSql-->

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="BasicMapper">
<!--通用查询条件-->
<sql id="buildWhere">
${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildWhere(resultMapId,tableName,#this['_parameter'].terms)}
</sql>
<!--生成查询字段-->
<sql id="buildSelectField">
${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildSelectFields(resultMapId,tableName,#this['_parameter'])}
</sql>
<!--生成修改字段-->
<sql id="buildUpdateField">
<set>
${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildUpdateFields(resultMapId,#this['_parameter'])}
</set>
</sql>
<!--生成排序字段-->
<sql id="buildSortField">
${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildOrder(resultMapId,tableName,#this['_parameter'])}
</sql>
<!--生成查询sql-->
<sql id="buildSelectSql">
select
<include refid="BasicMapper.buildSelectField"/>
from ${tableName}
<where>
<include refid="BasicMapper.buildWhere"/>
</where>
<include refid="BasicMapper.buildSortField"/>
</sql>
<!--生成删除sql-->
<sql id="buildDeleteSql">
delete ${tableName} from ${tableName}
<where>
<include refid="BasicMapper.buildWhere"/>
<if test="terms.size()==0">
1=2
</if>
</where>
</sql>
<!--生成InsertSql-->
<sql id="buildInsertSql">
insert into ${tableName} ${@org.hsweb.web.mybatis.builder.MysqlParamBuilder@instance().buildInsertSql(resultMapId,#this['_parameter'])}
</sql>
<!--生成UpdateSql-->
<sql id="buildUpdateSql">
update ${tableName}
<include refid="BasicMapper.buildUpdateField"/>
<where>
<include refid="BasicMapper.buildWhere"/>
<if test="terms.size()==0">
u_id=#{data.id}
</if>
</where>
</sql>
<!--生成查询数量sql-->
<sql id="buildTotalSql">
select count(0) as "total" from ${tableName}
<where>
<include refid="BasicMapper.buildWhere"/>
</where>
</sql>
</mapper>

View File

@@ -1,214 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="BasicMapper">
<sql id="buildWhereV2">
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildWhere($fieldsInfo,#this['_parameter'].terms)}
</sql>
<!--通用查询条件-->
<sql id="buildWhere">
<include refid="BasicMapper.buildWhereV2"/>
<!--动态生成查询条件-->
<!--<foreach item="item" index="index" collection="$fields">-->
<!--<if test="#this['term.'+item]!=null">-->
<!--AND `${$tableName}`.`${item}`=#{term.${item}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOT']!=null">-->
<!--AND `${$tableName}`.`${item}`!=#{term.${item+'$NOT'}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$LIKE']!=null">-->
<!--AND ${$tableName}.${item} like #{term.${item+'$LIKE'}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOTLIKE']!=null">-->
<!--AND ${$tableName}.${item} not like #{term.${item+'$LIKE'}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$IN']!=null">-->
<!--AND `${$tableName}`.`${item}` IN-->
<!--<foreach item="it" index="i" collection="#this['term.'+item+'$IN']" open="(" separator="," close=")">-->
<!--#{it}-->
<!--</foreach>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOTIN']!=null">-->
<!--AND `${$tableName}`.`${item}` NOT IN-->
<!--<foreach item="it" index="i" collection="#this['term.'+item+'$NOTIN']" open="(" separator="," close=")">-->
<!--#{it}-->
<!--</foreach>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$ISNULL']!=null">-->
<!--AND `${$tableName}`.`${item}` IS NULL-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOTNULL']!=null">-->
<!--AND `${$tableName}`.`${item}` IS NOT NULL-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$GT']!=null">-->
<!--AND `${$tableName}`.`${item}` &gt;=#{term.${item+'$GT'}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$LT']!=null">-->
<!--AND `${$tableName}`.`${item}` &lt;=#{term.${item+'$LT'}}-->
<!--</if>-->
<!--</foreach>-->
<!--动态生成查询条件结束-->
</sql>
<!--生成查询字段-->
<sql id="buildSelectField">
<bind name="fieldHasLen" value="false"/>
<choose>
<!--指定查询的字段-->
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="" separator="," close="">
<if test="item in $fields">
<bind name="fieldHasLen" value="true"/>
${$tableName}.${item} as `${item}`
</if>
</foreach>
</when>
<!--指定不查询的字段-->
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
<if test="!(item in excludes)">
<bind name="fieldHasLen" value="true"/>
${$tableName}.${item} as `${item}`
</if>
</foreach>
</when>
<otherwise> <bind name="fieldHasLen" value="true"/>*</otherwise>
</choose>
<if test="!fieldHasLen">*</if>
</sql>
<!--生成修改字段-->
<sql id="buildUpdateField">
<set>
<choose>
<!--指定要修改的字段-->
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="" separator="," close="">
<if test="item in $fields">
`${item}`=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<!--指定不修改的字段-->
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
<if test="!(item in excludes)">
`${item}`= #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<!--修改所有-->
<otherwise>
<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
<if test="data[item] != null">
`${item}`=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</otherwise>
</choose>
</set>
</sql>
<!--生成插入字段-->
<sql id="buildInsertField">
<choose>
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
<if test="item in $fields">`${item}`</if>
</foreach>
</when>
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
<if test="!(item in excludes)">`${item}`</if>
</foreach>
</when>
<otherwise>
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">`${item}`</foreach>
</otherwise>
</choose>
</sql>
<!--生成插入值-->
<sql id="buildInsertValues">
<choose>
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
<if test="item in $fields">
#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
<if test="!(item in excludes)">
#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<otherwise>
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</foreach>
</otherwise>
</choose>
</sql>
<!--生成排序字段-->
<sql id="buildSortField">
<bind name="fieldHasLen" value="false"/>
<choose>
<!--指定排序的字段-->
<when test="sortField!=null and sortField.size()>0">
<foreach item="item" index="index" collection="sortField" open="" separator="," close="">
<if test="item in $fields">
<if test="!fieldHasLen"> order by </if>${$tableName}.${item}
<bind name="fieldHasLen" value="true"/>
</if>
</foreach>
<if test="fieldHasLen"> ${sortOrder}</if>
</when>
</choose>
</sql>
<!--生成查询sql-->
<sql id="buildSelectSql">
select
<include refid="BasicMapper.buildSelectField"/>
from ${$tableName}
<where>
<include refid="BasicMapper.buildWhereV2"/>
<!--<include refid="BasicMapper.buildWhere"/>-->
</where>
<include refid="BasicMapper.buildSortField"/>
</sql>
<!--生成InsertSql-->
<sql id="buildInsertSql">
insert into ${$tableName}
<include refid="BasicMapper.buildInsertField"/>
values
<include refid="BasicMapper.buildInsertValues"/>
</sql>
<!--生成UpdateSql-->
<sql id="buildUpdateSql">
update ${$tableName}
<include refid="BasicMapper.buildUpdateField"/>
<where>
<include refid="BasicMapper.buildWhereV2"/>
<!--<include refid="BasicMapper.buildWhere"/>-->
<if test="term.size()==0">
u_id=#{data.u_id}
</if>
</where>
</sql>
<!--生成查询数量sql-->
<sql id="buildTotalSql">
select count(0) as "total" from ${$tableName}
<where>
<include refid="BasicMapper.buildWhereV2"/>
<!--<include refid="BasicMapper.buildWhere"/>-->
</where>
</sql>
</mapper>

View File

@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.form.FormMapper">
<resultMap id="FormResultMap" type="org.hsweb.web.bean.po.form.Form">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="html" column="html" javaType="String" jdbcType="VARCHAR"/>
<result property="meta" column="meta" javaType="String" jdbcType="VARCHAR"/>
<result property="config" column="config" javaType="String" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="version" column="version" javaType="int" jdbcType="INTEGER"/>
<result property="revision" column="revision" javaType="int" jdbcType="INTEGER"/>
<result property="release" column="release" javaType="int" jdbcType="INTEGER"/>
<result property="using" column="using" javaType="boolean" jdbcType="INTEGER"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="updateDate" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="classifiedId" column="classified_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'FormResultMap'"/>
<bind name="tableName" value="'s_form'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="FormResultMap">
select * from s_form WHERE u_id=#{id}
</select>
<select id="selectUsing" parameterType="string" resultMap="FormResultMap">
select * from s_form WHERE `using`=1 and `name`=#{name}
</select>
<select id="selectLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">
<include refid="config"/>
<!--定义字段配置-->
<bind name="tableName" value="'t2'"/>
<!--定义表名-->
select
<!--动态生成要查询的字段-->
<include refid="BasicMapper.buildSelectField"/>
from (
select s_form.name,max(s_form.version) as version from s_form s_form
<bind name="tableName" value="'s_form'"/>
<where>
<!--动态查询条件-->
<include refid="BasicMapper.buildWhere"/>
</where>
group by name) t1
left join s_form t2 on t1.name=t2.name and t1.version =t2.version
<bind name="tableName" value="'t2'"/>
<include refid="BasicMapper.buildSortField"/>
</select>
<select id="countLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
select count(0) as total from (
select s_form.name,max(s_form.version) as version from s_form s_form
<where>
<include refid="BasicMapper.buildWhere"/>
</where>
group by name) t1
left join s_form t2 on t1.name=t2.name and t1.version =t2.version
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.module.ModuleMapper">
<resultMap id="ModuleResultMap" type="org.hsweb.web.bean.po.module.Module">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="uri" column="uri" javaType="String" jdbcType="VARCHAR"/>
<result property="icon" column="icon" javaType="String" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" javaType="String" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
<result property="optional" column="optional" javaType="String" jdbcType="VARCHAR"/>
<result property="sortIndex" column="sort_index" javaType="long" jdbcType="INTEGER"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'ModuleResultMap'"/>
<bind name="tableName" value="'s_modules'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="ModuleResultMap">
select * from s_modules WHERE u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ModuleResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.user.UserMapper">
<resultMap id="UserResultMap" type="org.hsweb.web.bean.po.user.User">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="username" column="username" javaType="String" jdbcType="VARCHAR"/>
<result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="email" column="email" javaType="String" jdbcType="VARCHAR"/>
<result property="phone" column="phone" javaType="String" jdbcType="VARCHAR"/>
<result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="updateDate" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<collection property="userRoles" column="u_id" ofType="UserRole"
select="org.hsweb.web.dao.role.UserRoleMapper.selectByUserId"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'UserResultMap'"/>
<bind name="tableName" value="'s_user'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="updatePassword" parameterType="org.hsweb.web.bean.po.user.User">
update s_user set password=#{password,jdbcType=VARCHAR} where u_id = #{id}
</update>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByUserName" parameterType="string" resultMap="UserResultMap">
select * from s_user where username=#{username}
</select>
<select id="selectByPk" parameterType="string" resultMap="UserResultMap">
select * from s_user where u_id=#{u_id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,245 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="BasicMapper">
<sql id="buildWhereV2">
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildWhere($fieldsInfo,#this['_parameter'].terms)}
</sql>
<sql id="buildSelectFieldV2">
${@org.hsweb.web.mybatis.builder.DefaultSqlParamBuilder@instance().buildSelectFields($fieldsInfo,#this['_parameter'])}
</sql>
<!--通用查询条件-->
<sql id="buildWhere">
<include refid="BasicMapper.buildWhereV2"/>
<!--动态生成查询条件-->
<!--<foreach item="item" index="index" collection="$fields">-->
<!--<if test="#this['term.'+item]!=null">-->
<!--<choose>-->
<!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
<!--AND ${$tableName}.${item}=to_date(#{term.${item}},'YYYY-MM-DD HH24:MI:SS')-->
<!--</when>-->
<!--<otherwise>AND ${$tableName}.${item}=#{term.${item}}</otherwise>-->
<!--</choose>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOT']!=null">-->
<!--<choose>-->
<!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
<!--AND ${$tableName}.${item}!=to_date(#{term.${item+'$NOT'}},'YYYY-MM-DD HH24:MI:SS')-->
<!--</when>-->
<!--<otherwise>AND ${$tableName}.${item}!=#{term.${item+'$NOT'}}</otherwise>-->
<!--</choose>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$LIKE']!=null">-->
<!--AND ${$tableName}.${item} like #{term.${item+'$LIKE'}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOTLIKE']!=null">-->
<!--AND ${$tableName}.${item} not like #{term.${item+'$LIKE'}}-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$IN']!=null">-->
<!--AND ${$tableName}.${item} IN-->
<!--<foreach item="it" index="i" collection="#this['term.'+item+'$IN']" open="(" separator="," close=")">-->
<!--#{it}-->
<!--</foreach>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOTIN']!=null">-->
<!--AND ${$tableName}.${item} NOT IN-->
<!--<foreach item="it" index="i" collection="#this['term.'+item+'$NOTIN']" open="(" separator="," close=")">-->
<!--#{it}-->
<!--</foreach>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$ISNULL']!=null">-->
<!--AND ${$tableName}.${item} IS NULL-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$NOTNULL']!=null">-->
<!--AND ${$tableName}.${item} IS NOT NULL-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$GT']!=null">-->
<!--<choose>-->
<!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
<!--AND ${$tableName}.${item} &gt;=to_date(#{term.${item+'$GT'}},'YYYY-MM-DD HH24:MI:SS')-->
<!--</when>-->
<!--<when test="$fieldsInfo[item]['javaType'] == 'number' ">-->
<!--AND ${$tableName}.${item} &gt;=#{term.${item+'$GT'}}-->
<!--</when>-->
<!--<otherwise></otherwise>-->
<!--</choose>-->
<!--</if>-->
<!--<if test="#this['term.'+item+'$LT']!=null">-->
<!--<choose>-->
<!--<when test="$fieldsInfo[item]['javaType'] == 'date' ">-->
<!--AND ${$tableName}.${item} &lt;=to_date(#{term.${item+'$LT'}},'YYYY-MM-DD HH24:MI:SS')-->
<!--</when>-->
<!--<when test="$fieldsInfo[item]['javaType'] == 'number' ">-->
<!--AND ${$tableName}.${item} &lt;=#{term.${item+'$LT'}}-->
<!--</when>-->
<!--<otherwise></otherwise>-->
<!--</choose>-->
<!--</if>-->
<!--</foreach>-->
<!--动态生成查询条件结束-->
</sql>
<!--生成查询字段-->
<sql id="buildSelectField">
<include refid="BasicMapper.buildSelectFieldV2"/>
<!--<bind name="fieldHasLen" value="false"/>-->
<!--<choose>-->
<!--&lt;!&ndash;指定查询的字段&ndash;&gt;-->
<!--<when test="includes!=null and includes.size()>0">-->
<!--<foreach item="item" index="index" collection="includes" open="" separator="," close="">-->
<!--<if test="item in $fields">-->
<!--<bind name="fieldHasLen" value="true"/>-->
<!--${$tableName}.${item} as "${item}"-->
<!--</if>-->
<!--</foreach>-->
<!--</when>-->
<!--&lt;!&ndash;指定不查询的字段&ndash;&gt;-->
<!--<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">-->
<!--<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">-->
<!--<if test="!(item in excludes)">-->
<!--<bind name="fieldHasLen" value="true"/>-->
<!--${$tableName}.${item} as "${item}"-->
<!--</if>-->
<!--</foreach>-->
<!--</when>-->
<!--<otherwise><bind name="fieldHasLen" value="true"/>*-->
<!--</otherwise>-->
<!--</choose>-->
<!--<if test="!fieldHasLen">*</if>-->
</sql>
<!--生成修改字段-->
<sql id="buildUpdateField">
<set>
<choose>
<!--指定要修改的字段-->
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="" separator="," close="">
<if test="item in $fields">
${item}=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<!--指定不修改的字段-->
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
<if test="!(item in excludes)">
${item}= #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<!--修改所有-->
<otherwise>
<foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
<if test="data[item] != null">
${item}=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</otherwise>
</choose>
</set>
</sql>
<!--生成插入字段-->
<sql id="buildInsertField">
<choose>
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
<if test="item in $fields">${item}</if>
</foreach>
</when>
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
<if test="!(item in excludes)">${item}</if>
</foreach>
</when>
<otherwise>
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">${item}</foreach>
</otherwise>
</choose>
</sql>
<!--生成插入值-->
<sql id="buildInsertValues">
<choose>
<when test="includes!=null and includes.size()>0">
<foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
<if test="item in $fields">
#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
<if test="!(item in excludes)">
#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</if>
</foreach>
</when>
<otherwise>
<foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
</foreach>
</otherwise>
</choose>
</sql>
<!--生成排序字段-->
<sql id="buildSortField">
<bind name="fieldHasLen" value="false"/>
<choose>
<!--指定排序的字段-->
<when test="sortField!=null and sortField.size()>0">
<foreach item="item" index="index" collection="sortField" open="" separator="," close="">
<if test="item in $fields">
<if test="!fieldHasLen">order by</if>${$tableName}.${item}
<bind name="fieldHasLen" value="true"/>
</if>
</foreach>
<if test="fieldHasLen">${sortOrder}</if>
</when>
</choose>
</sql>
<!--生成查询sql-->
<sql id="buildSelectSql">
select
<include refid="BasicMapper.buildSelectField"/>
from ${$tableName}
<where>
<include refid="BasicMapper.buildWhereV2"/>
<!--<include refid="BasicMapper.buildWhere"/>-->
</where>
<include refid="BasicMapper.buildSortField"/>
</sql>
<!--生成InsertSql-->
<sql id="buildInsertSql">
insert into ${$tableName}
<include refid="BasicMapper.buildInsertField"/>
values
<include refid="BasicMapper.buildInsertValues"/>
</sql>
<!--生成UpdateSql-->
<sql id="buildUpdateSql">
update ${$tableName}
<include refid="BasicMapper.buildUpdateField"/>
<where>
<include refid="BasicMapper.buildWhereV2"/>
<!--<include refid="BasicMapper.buildWhere"/>-->
<if test="terms.size()==0">
u_id=#{data.u_id}
</if>
</where>
</sql>
<!--生成查询数量sql-->
<sql id="buildTotalSql">
select count(0) as "total" from ${$tableName}
<where>
<include refid="BasicMapper.buildWhereV2"/>
<!--<include refid="BasicMapper.buildWhere"/>-->
</where>
</sql>
</mapper>

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.classified.ClassifiedMapper">
<resultMap id="ClassifiedResultMap" type="org.hsweb.web.bean.po.classified.Classified">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="icon" column="icon" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="config" column="config" javaType="java.lang.String" jdbcType="CLOB"/>
<result property="sortIndex" column="sort_index" javaType="int" jdbcType="INTEGER"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'ClassifiedResultMap'"/>
<bind name="tableName" value="'s_classified'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="ClassifiedResultMap">
select * from s_classified where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ClassifiedResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.config.ConfigMapper">
<resultMap id="ConfigResultMap" type="org.hsweb.web.bean.po.config.Config">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="content" column="content" javaType="String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="classifiedId" column="classified_id" javaType="String" jdbcType="VARCHAR"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'ConfigResultMap'"/>
<bind name="tableName" value="'s_config'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="ConfigResultMap">
select * from s_config where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ConfigResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.datasource.DataSourceMapper">
<resultMap id="DataSourceResultMap" type="org.hsweb.web.bean.po.datasource.DataSource">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="driver" column="driver" javaType="String" jdbcType="VARCHAR"/>
<result property="url" column="url" javaType="String" jdbcType="VARCHAR"/>
<result property="username" column="username" javaType="String" jdbcType="VARCHAR"/>
<result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
<result property="testSql" column="test_sql" javaType="String" jdbcType="VARCHAR"/>
<result property="enabled" column="enabled" javaType="int" jdbcType="NUMERIC"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="properties" column="properties" javaType="java.util.Map" jdbcType="CLOB"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'DataSourceResultMap'"/>
<bind name="tableName" value="'s_data_source'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="DataSourceResultMap">
select * from s_data_source where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="DataSourceResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.history.HistoryMapper">
<resultMap id="HistoryResultMap" type="org.hsweb.web.bean.po.history.History">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
<result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
<result property="primaryKeyName" column="primary_key_name" javaType="String" jdbcType="VARCHAR"/>
<result property="primaryKeyValue" column="primary_key_value" javaType="String" jdbcType="VARCHAR"/>
<result property="changeBefore" column="change_before" javaType="String" jdbcType="VARCHAR"/>
<result property="changeAfter" column="change_after" javaType="String" jdbcType="INTEGER"/>
<result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'HistoryResultMap'"/>
<bind name="tableName" value="'s_history'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="HistoryResultMap">
select * from s_history WHERE u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="HistoryResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.module.ModuleMetaMapper">
<resultMap id="ModuleMetaResultMap" type="org.hsweb.web.bean.po.module.ModuleMeta">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="key" column="key" javaType="String" jdbcType="VARCHAR"/>
<result property="moduleId" column="module_id" javaType="String" jdbcType="VARCHAR"/>
<result property="roleId" column="role_id" javaType="String" jdbcType="VARCHAR"/>
<result property="meta" column="meta" javaType="String" jdbcType="CLOB"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="status" column="status" javaType="int" jdbcType="INTEGER"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'ModuleMetaResultMap'"/>
<bind name="tableName" value="'s_module_meta'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="ModuleMetaResultMap">
select * from s_module_meta WHERE u_id=#{u_id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ModuleMetaResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,65 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2015-2016 http://hsweb.me
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.plan.QueryPlanMapper">
<resultMap id="QueryPlanResultMap" type="org.hsweb.web.bean.po.plan.QueryPlan">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
<result property="config" column="config" javaType="String" jdbcType="CLOB"/>
<result property="sharing" column="sharing" javaType="boolean" jdbcType="INTEGER"/>
<result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'QueryPlanResultMap'"/>
<bind name="tableName" value="'s_query_plan'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="QueryPlanResultMap">
select * from s_query_plan where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="QueryPlanResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.profile.UserProfileMapper">
<resultMap id="UserProfileResultMap" type="org.hsweb.web.bean.po.profile.UserProfile">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" javaType="String" jdbcType="VARCHAR"/>
<result property="content" column="content" javaType="String" jdbcType="VARCHAR"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'UserProfileResultMap'"/>
<bind name="tableName" value="'s_user_profile'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="UserProfileResultMap">
select * from s_user_profile where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserProfileResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2015-2016 http://hsweb.me
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.quartz.QuartzJobHistoryMapper">
<resultMap id="QuartzJobHistoryResultMap" type="org.hsweb.web.bean.po.quartz.QuartzJobHistory">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="jobId" column="job_id" javaType="String" jdbcType="VARCHAR"/>
<result property="startTime" column="start_time" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="endTime" column="end_time" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="result" column="result" javaType="String" jdbcType="CLOB"/>
<result property="status" column="status" javaType="byte" jdbcType="NUMERIC"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'QuartzJobHistoryResultMap'"/>
<bind name="tableName" value="'S_QUARTZ_JOB_HIS'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="QuartzJobHistoryResultMap">
select * from S_QUARTZ_JOB_HIS where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="QuartzJobHistoryResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,67 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Copyright 2015-2016 http://hsweb.me
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.quartz.QuartzJobMapper">
<resultMap id="QuartzJobResultMap" type="org.hsweb.web.bean.po.quartz.QuartzJob">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="cron" column="cron" javaType="String" jdbcType="VARCHAR"/>
<result property="script" column="script" javaType="String" jdbcType="CLOB"/>
<result property="language" column="language" javaType="String" jdbcType="VARCHAR"/>
<result property="enabled" column="enabled" javaType="boolean" jdbcType="NUMERIC"/>
<result property="parameters" column="parameters" javaType="String" jdbcType="CLOB"/>
<result property="type" column="type" javaType="byte" jdbcType="NUMERIC"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'QuartzJobResultMap'"/>
<bind name="tableName" value="'S_QUARTZ_JOB'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="QuartzJobResultMap">
select * from S_QUARTZ_JOB where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="QuartzJobResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.resource.ResourcesMapper">
<resultMap id="ResourcesResultMap" type="org.hsweb.web.bean.po.resource.Resources" >
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR" />
<result property="name" column="name" javaType="String" jdbcType="VARCHAR" />
<result property="path" column="path" javaType="String" jdbcType="VARCHAR" />
<result property="creatorId" column="creator_id" javaType="String" jdbcType="VARCHAR" />
<result property="md5" column="md5" javaType="String" jdbcType="VARCHAR" />
<result property="type" column="type" javaType="String" jdbcType="VARCHAR" />
<result property="size" column="size" javaType="long" jdbcType="NUMERIC" />
<result property="status" column="status" javaType="int" jdbcType="INTEGER" />
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP" />
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'ResourcesResultMap'"/>
<bind name="tableName" value="'s_resources'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="ResourcesResultMap">
select * from s_resources WHERE u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ResourcesResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.role.RoleMapper">
<resultMap id="RoleResultMap" type="org.hsweb.web.bean.po.role.Role">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
<collection property="modules" column="u_id" ofType="RoleModule"
select="org.hsweb.web.dao.role.RoleModuleMapper.selectByRoleId"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'RoleResultMap'"/>
<bind name="tableName" value="'s_role'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="RoleResultMap">
select * from s_role where u_id=#{id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="RoleResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.role.RoleModuleMapper">
<resultMap id="RoleModuleResultMap" type="org.hsweb.web.bean.po.role.RoleModule" >
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR" />
<result property="moduleId" column="module_id" javaType="String" jdbcType="VARCHAR" />
<result property="roleId" column="role_id" javaType="String" jdbcType="VARCHAR" />
<result property="actions" column="actions" javaType="java.util.List" jdbcType="VARCHAR"
typeHandler="org.hsweb.web.mybatis.handler.JsonArrayHandler" />
<collection property="module" column="module_id" ofType="Module" select="org.hsweb.web.dao.module.ModuleMapper.selectByPk"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'RoleModuleResultMap'"/>
<bind name="tableName" value="'s_role_modules'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<delete id="deleteByRoleId" parameterType="string" >
delete from s_role_modules where role_id=#{role_id}
</delete>
<delete id="deleteByModuleId" parameterType="string" >
delete from s_role_modules where module_id=#{module_id}
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByRoleId" parameterType="string" resultMap="RoleModuleResultMap">
select * from s_role_modules where role_id=#{role_id}
</select>
<select id="selectByPk" parameterType="string" resultMap="RoleModuleResultMap">
select * from s_role_modules where u_id=#{u_id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="RoleModuleResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.role.UserRoleMapper">
<resultMap id="UserRoleResultMap" type="org.hsweb.web.bean.po.role.UserRole">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="userId" column="user_id" javaType="String" jdbcType="VARCHAR"/>
<result property="roleId" column="role_id" javaType="String" jdbcType="VARCHAR"/>
<collection property="role" column="role_id" jdbcType="VARCHAR" ofType="Role"
select="org.hsweb.web.dao.role.RoleMapper.selectByPk"></collection>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'UserRoleResultMap'"/>
<bind name="tableName" value="'s_user_role'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<delete id="deleteByUserId" parameterType="String">
delete from s_user_role where user_id=#{userId}
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByUserId" parameterType="string" resultMap="UserRoleResultMap">
select * from s_user_role where user_id=#{user_id}
</select>
<select id="selectByPk" parameterType="string" resultMap="UserRoleResultMap">
select * from s_user_role where u_id=#{u_id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserRoleResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.script.DynamicScriptMapper">
<resultMap id="DynamicScriptResultMap" type="org.hsweb.web.bean.po.script.DynamicScript" >
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR" />
<result property="name" column="name" javaType="String" jdbcType="VARCHAR" />
<result property="type" column="type" javaType="String" jdbcType="VARCHAR" />
<result property="content" column="content" javaType="String" jdbcType="VARCHAR" />
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR" />
<result property="classifiedId" column="classified_id" javaType="String" jdbcType="VARCHAR" />
<result property="status" column="status" javaType="int" jdbcType="INTEGER" />
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'DynamicScriptResultMap'"/>
<bind name="tableName" value="'s_script'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam">
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="DynamicScriptResultMap">
select * from s_script where u_id=#{u_id}
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="DynamicScriptResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -1,97 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.hsweb.web.dao.template.TemplateMapper">
<resultMap id="TemplateResultMap" type="org.hsweb.web.bean.po.template.Template">
<id property="id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
<result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
<result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
<result property="template" column="template" javaType="String" jdbcType="CLOB"/>
<result property="classifiedId" column="classified_id" javaType="String" jdbcType="VARCHAR"/>
<result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
<result property="script" column="script" javaType="String" jdbcType="CLOB"/>
<result property="css" column="css" javaType="String" jdbcType="CLOB"/>
<result property="cssLinks" column="css_links" javaType="java.util.List" jdbcType="CLOB"
typeHandler="org.hsweb.web.mybatis.handler.JsonArrayHandler"/>
<result property="scriptLinks" column="script_links" javaType="java.util.List" jdbcType="CLOB"
typeHandler="org.hsweb.web.mybatis.handler.JsonArrayHandler"/>
<result property="version" column="version" javaType="int" jdbcType="INTEGER"/>
<result property="revision" column="revision" javaType="int" jdbcType="INTEGER"/>
<result property="release" column="release" javaType="int" jdbcType="INTEGER"/>
<result property="using" column="using" javaType="boolean" jdbcType="INTEGER"/>
</resultMap>
<!--用于动态生成sql所需的配置-->
<sql id="config">
<bind name="resultMapId" value="'TemplateResultMap'"/>
<bind name="tableName" value="'s_template'"/>
</sql>
<insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" >
<include refid="config"/>
<include refid="BasicMapper.buildInsertSql"/>
</insert>
<delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
<include refid="config"/>
<include refid="BasicMapper.buildDeleteSql"/>
</delete>
<update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
<include refid="config"/>
<include refid="BasicMapper.buildUpdateSql"/>
</update>
<select id="selectByPk" parameterType="string" resultMap="TemplateResultMap">
select * from s_template WHERE u_id=#{id}
</select>
<select id="selectUsing" parameterType="string" resultMap="TemplateResultMap">
select * from s_template WHERE using=1 and name=#{name}
</select>
<select id="selectLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="TemplateResultMap">
<include refid="config"/>
<!--定义字段配置-->
<bind name="tableName" value="'t2'"/>
<!--定义表名-->
select
<!--动态生成要查询的字段-->
<include refid="BasicMapper.buildSelectField"/>
from (
select s_template.name,max(s_template.version) as version from s_template s_template
<where>
<!--动态查询条件-->
<include refid="BasicMapper.buildWhere"/>
</where>
group by name) t1
left join s_template t2 on t1.name=t2.name and t1.version =t2.version
<bind name="tableName" value="'t2'"/>
<include refid="BasicMapper.buildSortField"/>
</select>
<select id="countLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
select count(0) as total from (
select s_template.name,max(s_form.version) as version from s_template s_template
<where>
<include refid="BasicMapper.buildWhere"/>
</where>
group by name) t1
left join s_template t2 on t1.name=t2.name and t1.version =t2.version
</select>
<select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="TemplateResultMap">
<include refid="config"/>
<include refid="BasicMapper.buildSelectSql"/>
</select>
<select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
<include refid="config"/>
<include refid="BasicMapper.buildTotalSql"/>
</select>
</mapper>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -20,11 +20,11 @@ import com.atomikos.icatch.jta.UserTransactionImp;
import com.atomikos.icatch.jta.UserTransactionManager;
import com.atomikos.jdbc.AtomikosDataSourceBean;
import org.hsweb.web.core.datasource.DynamicDataSource;
import org.hsweb.web.core.datasource.DynamicDataSourceHolder;
import org.hsweb.web.core.datasource.DataSourceHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -36,11 +36,12 @@ import javax.transaction.SystemException;
@Configuration
@ConditionalOnMissingBean(DynamicDataSource.class)
@EnableConfigurationProperties(DynamicDataSourceProperties.class)
@ComponentScan("org.hsweb.web.datasource.dynamic")
public class DynamicDataSourceAutoConfiguration {
@Autowired
private DataSourceProperties properties;
private DynamicDataSourceProperties properties;
/**
* 默认数据库链接
@@ -49,18 +50,14 @@ public class DynamicDataSourceAutoConfiguration {
@Bean(initMethod = "init", name = "dataSource", destroyMethod = "close")
public DataSource dataSource() {
AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean();
dataSourceBean.getXaProperties().putAll(properties.getXa().getProperties());
dataSourceBean.setXaDataSourceClassName(properties.getXa().getDataSourceClassName());
dataSourceBean.setUniqueResourceName("core");
dataSourceBean.setMinPoolSize(5);
dataSourceBean.setMaxPoolSize(200);
properties.putProperties(dataSourceBean);
return dataSourceBean;
}
@Bean(name = "dynamicDataSource")
public DynamicXaDataSourceImpl dynamicXaDataSource(@Qualifier("dataSource") DataSource dataSource) {
DynamicXaDataSourceImpl dynamicXaDataSource = new DynamicXaDataSourceImpl(dataSource);
DynamicDataSourceHolder.install(dynamicXaDataSource);
DynamicXaDataSourceImpl dynamicXaDataSource = new DynamicXaDataSourceImpl(dataSource, properties.getType());
DataSourceHolder.install(dynamicXaDataSource);
return dynamicXaDataSource;
}
@@ -74,7 +71,7 @@ public class DynamicDataSourceAutoConfiguration {
@Bean
public UserTransactionImp userTransaction() throws SystemException {
UserTransactionImp userTransactionImp = new UserTransactionImp();
userTransactionImp.setTransactionTimeout(300);
userTransactionImp.setTransactionTimeout(properties.getTransactionTimeout());
return userTransactionImp;
}

View File

@@ -0,0 +1,262 @@
/*
* Copyright 2015-2016 http://hsweb.me
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hsweb.web.datasource.dynamic;
import com.atomikos.jdbc.AtomikosDataSourceBean;
import org.hsweb.web.core.datasource.DatabaseType;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
/**
* @author zhouhao
* @see com.atomikos.jdbc.AbstractDataSourceBean
* @since 2.1
*/
@ConfigurationProperties(prefix = "hsweb.dynamicDatasource")
public class DynamicDataSourceProperties
implements BeanClassLoaderAware, InitializingBean {
private static final List<String> supportDatasourceType;
private String name = "core";
private DatabaseType type = DatabaseType.h2;
private String datasourceName = null;
private String username = "sa";
private String password = "";
private String url = "jdbc:h2:file:./data/h2db;DB_CLOSE_ON_EXIT=FALSE";
private String testQuery = null;
private int loginTimeout = -1;
private int maxLifetime = -1;
private int minPoolSize = 2;
private int maxPoolSize = 20;
private int borrowConnectionTimeout = 30;
private int reapTimeout = 0;
private int maxIdleTime = 60;
private int maintenanceInterval = 60;
private int defaultIsolationLevel = -1;
private int transactionTimeout = 300;
private Properties properties = null;
private ClassLoader classLoader = null;
static {
supportDatasourceType = new LinkedList<>();
supportDatasourceType.add("com.alibaba.druid.pool.xa.DruidXADataSource");
}
public int getTransactionTimeout() {
return transactionTimeout;
}
public void setTransactionTimeout(int transactionTimeout) {
this.transactionTimeout = transactionTimeout;
}
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(String datasourceName) {
this.datasourceName = datasourceName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DatabaseType getType() {
if (type == null) {
type = DatabaseType.fromJdbcUrl(getUrl());
}
return type;
}
public void setType(DatabaseType type) {
this.type = type;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getTestQuery() {
return testQuery;
}
public void setTestQuery(String testQuery) {
this.testQuery = testQuery;
}
public int getLoginTimeout() {
return loginTimeout;
}
public void setLoginTimeout(int loginTimeout) {
this.loginTimeout = loginTimeout;
}
public int getMaxLifetime() {
return maxLifetime;
}
public void setMaxLifetime(int maxLifetime) {
this.maxLifetime = maxLifetime;
}
public int getMinPoolSize() {
return minPoolSize;
}
public void setMinPoolSize(int minPoolSize) {
this.minPoolSize = minPoolSize;
}
public int getMaxPoolSize() {
return maxPoolSize;
}
public void setMaxPoolSize(int maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public int getBorrowConnectionTimeout() {
return borrowConnectionTimeout;
}
public void setBorrowConnectionTimeout(int borrowConnectionTimeout) {
this.borrowConnectionTimeout = borrowConnectionTimeout;
}
public int getReapTimeout() {
return reapTimeout;
}
public void setReapTimeout(int reapTimeout) {
this.reapTimeout = reapTimeout;
}
public int getMaxIdleTime() {
return maxIdleTime;
}
public void setMaxIdleTime(int maxIdleTime) {
this.maxIdleTime = maxIdleTime;
}
public int getMaintenanceInterval() {
return maintenanceInterval;
}
public void setMaintenanceInterval(int maintenanceInterval) {
this.maintenanceInterval = maintenanceInterval;
}
public int getDefaultIsolationLevel() {
return defaultIsolationLevel;
}
public void setDefaultIsolationLevel(int defaultIsolationLevel) {
this.defaultIsolationLevel = defaultIsolationLevel;
}
public Properties getProperties() {
if (properties == null) {
properties = new Properties();
}
properties.put("username", getUsername());
properties.put("password", getPassword());
properties.put("url", getUrl());
return properties;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
@Override
public void afterPropertiesSet() throws Exception {
if (datasourceName == null) {
datasourceName = lookupSupportDatasourceName();
}
if (!StringUtils.hasText(testQuery)) testQuery = getType().getTestQuery();
}
public String lookupSupportDatasourceName() throws ClassNotFoundException {
for (String dsClass : supportDatasourceType) {
try {
ClassUtils.forName(dsClass, classLoader);
return dsClass;
} catch (ClassNotFoundException e) {
}
}
return getType().getXaDataSourceClassName();
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
public void putProperties(AtomikosDataSourceBean dataSourceBean) {
dataSourceBean.setXaProperties(this.getProperties());
dataSourceBean.setXaDataSourceClassName(this.getDatasourceName());
dataSourceBean.setUniqueResourceName(this.getName());
dataSourceBean.setMinPoolSize(this.getMinPoolSize());
dataSourceBean.setMaxPoolSize(this.getMaxPoolSize());
dataSourceBean.setTestQuery(this.getTestQuery());
dataSourceBean.setBorrowConnectionTimeout(this.getBorrowConnectionTimeout());
dataSourceBean.setMaintenanceInterval(this.getMaintenanceInterval());
dataSourceBean.setDefaultIsolationLevel(this.getDefaultIsolationLevel());
dataSourceBean.setMaxLifetime(this.getMaxLifetime());
dataSourceBean.setMaxIdleTime(this.getMaxIdleTime());
dataSourceBean.setReapTimeout(this.getReapTimeout());
try {
dataSourceBean.setLoginTimeout(this.getLoginTimeout());
} catch (SQLException e) {
}
}
}

View File

@@ -18,8 +18,11 @@ package org.hsweb.web.datasource.dynamic;
import com.atomikos.jdbc.AtomikosDataSourceBean;
import com.atomikos.jdbc.AtomikosSQLException;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtilsBean;
import org.hsweb.concurrent.lock.LockFactory;
import org.hsweb.web.bean.po.datasource.DataSource;
import org.hsweb.web.core.datasource.DatabaseType;
import org.hsweb.web.core.datasource.DynamicDataSource;
import org.hsweb.web.core.exception.NotFoundException;
import org.hsweb.web.service.datasource.DataSourceService;
@@ -27,6 +30,7 @@ import org.hsweb.web.service.datasource.DynamicDataSourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.stereotype.Service;
@@ -35,6 +39,8 @@ import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -60,6 +66,11 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
return getCache(id).getDataSource();
}
@Override
public String getDataBaseType(String id) {
return getCache(id).getDatabaseType().name();
}
@Override
@PreDestroy
public void destroyAll() throws Exception {
@@ -109,7 +120,8 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
}
//加载datasource到缓存
javax.sql.DataSource dataSource = createDataSource(old);
cacheInfo = new CacheInfo(old.getHash(), dataSource);
DatabaseType databaseType = DatabaseType.fromJdbcUrl(old.getUrl());
cacheInfo = new CacheInfo(old.getHash(), dataSource, databaseType);
cache.put(id, cacheInfo);
} finally {
try {
@@ -123,32 +135,33 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
}
}
@Autowired
private DataSourceProperties properties;
protected javax.sql.DataSource createDataSource(DataSource dataSource) {
AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean();
Properties xaProperties = new Properties();
if (dataSource.getProperties() != null)
xaProperties.putAll(dataSource.getProperties());
if (dataSource.getDriver().contains("mysql")) {
dataSourceBean.setXaDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");
xaProperties.put("pinGlobalTxToPhysicalConnection", true);
xaProperties.put("user", dataSource.getUsername());
xaProperties.put("password", dataSource.getPassword());
xaProperties.put("url", dataSource.getUrl());
} else {
dataSourceBean.setXaDataSourceClassName(properties.getXa().getDataSourceClassName());
xaProperties.put("username", dataSource.getUsername());
xaProperties.put("password", dataSource.getPassword());
xaProperties.put("url", dataSource.getUrl());
xaProperties.put("driverClassName", dataSource.getDriver());
DynamicDataSourceProperties properties = new DynamicDataSourceProperties();
properties.setName("ds_" + dataSource.getId());
properties.setBeanClassLoader(this.getClass().getClassLoader());
properties.setUsername(dataSource.getUsername());
properties.setPassword(dataSource.getPassword());
properties.setUrl(dataSource.getUrl());
properties.setType(DatabaseType.fromJdbcUrl(dataSource.getUrl()));
properties.setTestQuery(dataSource.getTestSql());
try {
properties.afterPropertiesSet();
} catch (Exception e) {
throw new RuntimeException(e);
}
dataSourceBean.setXaProperties(xaProperties);
dataSourceBean.setUniqueResourceName("ds_" + dataSource.getId());
dataSourceBean.setMaxPoolSize(200);
dataSourceBean.setMinPoolSize(5);
dataSourceBean.setBorrowConnectionTimeout(60);
Map<String, Object> otherProperties = dataSource.getProperties();
if (otherProperties != null) {
PropertyUtilsBean propertyUtilsBean = BeanUtilsBean.getInstance().getPropertyUtils();
otherProperties.forEach((k, v) -> {
try {
propertyUtilsBean.setProperty(properties, k, v);
} catch (Exception e) {
logger.warn("设置动态数据源配置失败", e);
}
});
}
AtomikosDataSourceBean dataSourceBean = new AtomikosDataSourceBean();
properties.putProperties(dataSourceBean);
boolean[] success = new boolean[1];
//异步初始化
new Thread(() -> {
@@ -183,13 +196,14 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
}
class CacheInfo {
int hash;
int hash;
DatabaseType databaseType;
javax.sql.DataSource dataSource;
public CacheInfo(int hash, javax.sql.DataSource dataSource) {
public CacheInfo(int hash, javax.sql.DataSource dataSource, DatabaseType type) {
this.hash = hash;
this.dataSource = dataSource;
this.databaseType = type;
}
public int getHash() {
@@ -199,6 +213,10 @@ public class DynamicDataSourceServiceImpl implements DynamicDataSourceService {
public javax.sql.DataSource getDataSource() {
return dataSource;
}
public DatabaseType getDatabaseType() {
return databaseType;
}
}
}

View File

@@ -17,11 +17,13 @@
package org.hsweb.web.datasource.dynamic;
import com.atomikos.jdbc.AtomikosDataSourceBean;
import org.hsweb.web.core.datasource.DatabaseType;
import org.hsweb.web.core.datasource.DynamicDataSource;
import org.hsweb.web.service.datasource.DynamicDataSourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.AbstractDataSource;
import org.springframework.util.Assert;
import javax.sql.DataSource;
import javax.sql.XAConnection;
@@ -32,12 +34,15 @@ import java.sql.SQLException;
public class DynamicXaDataSourceImpl extends AbstractDataSource implements DynamicDataSource, XADataSource, Closeable {
private Logger logger = LoggerFactory.getLogger(DynamicDataSource.class);
private javax.sql.DataSource defaultDataSource;
private javax.sql.DataSource defaultDataSource;
private DatabaseType defaultDatabaseType;
protected DynamicDataSourceService dynamicDataSourceService;
public DynamicXaDataSourceImpl(javax.sql.DataSource defaultDataSource) {
public DynamicXaDataSourceImpl(javax.sql.DataSource defaultDataSource, DatabaseType defaultDatabaseType) {
Assert.notNull(defaultDataSource);
Assert.notNull(defaultDatabaseType);
this.defaultDataSource = defaultDataSource;
this.defaultDatabaseType = defaultDatabaseType;
}
@Override
@@ -59,6 +64,15 @@ public class DynamicXaDataSourceImpl extends AbstractDataSource implements Dynam
return dataSource;
}
@Override
public DatabaseType getActiveDataBaseType() {
String sourceId = DynamicDataSource.getActiveDataSourceId();
if (sourceId == null || dynamicDataSourceService == null) return defaultDatabaseType;
String type = dynamicDataSourceService.getDataBaseType(sourceId);
if (type == null) return defaultDatabaseType;
return DatabaseType.valueOf(type);
}
public XADataSource getActiveXADataSource() {
DataSource activeDs = getActiveDataSource();
XADataSource xaDataSource;
@@ -72,11 +86,8 @@ public class DynamicXaDataSourceImpl extends AbstractDataSource implements Dynam
return xaDataSource;
}
public void setDefaultDataSource(DataSource defaultDataSource) {
this.defaultDataSource = defaultDataSource;
}
public void setDynamicDataSourceService(DynamicDataSourceService dynamicDataSourceService) {
public synchronized void setDynamicDataSourceService(DynamicDataSourceService dynamicDataSourceService) {
if (this.dynamicDataSourceService != null) throw new UnsupportedOperationException();
this.dynamicDataSourceService = dynamicDataSourceService;
}
@@ -92,7 +103,8 @@ public class DynamicXaDataSourceImpl extends AbstractDataSource implements Dynam
public void close() {
try {
dynamicDataSourceService.destroyAll();
if (dynamicDataSourceService != null)
dynamicDataSourceService.destroyAll();
} catch (Exception e) {
logger.error("close datasource error", e);
}

View File

@@ -0,0 +1,35 @@
{
"groups": [
{
"name": "hsweb.dynamic-datasource",
"type": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties",
"sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
}
],
"properties": [
{
"name": "hsweb.dynamic-datasource.name",
"type": "java.lang.String",
"sourceType": "org.hsweb.web.datasource.dynamic.DynamicDataSourceProperties"
}
],
"hints": [
{
"name": "hsweb.dynamic-datasource.type",
"values": [
{
"value": "h2",
"description": "use h2 database."
},
{
"value": "mysql",
"description": "use mysql database."
},
{
"value": "oracle",
"description": "use oracle database."
}
]
}
]
}

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-web-oauth2</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-web-oauth2</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-web-oauth2</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-web-oauth2</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-web-oauth2</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-web-service</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>hsweb-web-service-api</artifactId>

View File

@@ -25,6 +25,8 @@ public interface DynamicDataSourceService {
DataSource getDataSource(String id);
void destroyAll()throws Exception;
String getDataBaseType(String id);
void destroyAll() throws Exception;
}

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-web-service</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -18,6 +18,10 @@
<artifactId>hsweb-web-datasource</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
@@ -30,11 +34,11 @@
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<scope>test</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-redis</artifactId>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<dependency>
<groupId>javax.el</groupId>
@@ -74,7 +78,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.25</version>
<version>1.0.26</version>
<scope>test</scope>
</dependency>

View File

@@ -22,6 +22,7 @@ import org.hsweb.web.bean.po.datasource.DataSource;
import org.hsweb.web.core.Install;
import org.hsweb.web.core.datasource.DynamicDataSource;
import org.hsweb.web.service.datasource.DataSourceService;
import org.hsweb.web.service.form.FormService;
import org.hsweb.web.service.impl.AbstractTestCase;
import org.hsweb.web.service.user.UserService;
import org.junit.Before;
@@ -46,6 +47,10 @@ public class DatasourceTests extends AbstractTestCase {
private UserService userService;
@Resource
Install install;
@Resource
private FormService formService;
@PostConstruct
public void init() {
testService.setSqlExecutor(sqlExecutor);
@@ -76,12 +81,12 @@ public class DatasourceTests extends AbstractTestCase {
//使用test数据源进行查询
DynamicDataSource.use("test");
userService.select(QueryParam.build());
}
@Test
public void testGetFieldList() throws Exception {
testService.test();
formService.select(QueryParam.build());
System.out.println(1);
}
}

View File

@@ -16,22 +16,11 @@
package org.hsweb.web.service.impl.lock;
import org.hsweb.concureent.cache.RedisCacheManagerAutoConfig;
import org.hsweb.concurrent.lock.LockFactory;
import org.hsweb.web.bean.po.user.User;
import org.hsweb.web.service.impl.AbstractTestCase;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
@@ -41,29 +30,6 @@ public class LockTest extends AbstractTestCase {
@Resource
private LockFactory lockFactory;
@Autowired
private RedisTemplate redisTemplate;
@Test
public void testCache() {
redisTemplate.execute((RedisCallback<? extends Object>) connection -> {
for (int i = 0; i < 50000; i++) {
User user = new User();
user.setName("test" + i);
try {
JdkSerializationRedisSerializer s = new JdkSerializationRedisSerializer();
connection.lPush("test".getBytes(), s.serialize(user));
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
});
long l = System.currentTimeMillis();
System.out.println(redisTemplate.opsForList().range("test", 0, -1).size());
System.out.println(System.currentTimeMillis() - l);
}
@Test
public void testLock() throws InterruptedException {
Lock lock = lockFactory.createLock("test_lock");

View File

@@ -2,80 +2,37 @@ package org.hsweb.web.service.impl.template;
import org.hsweb.web.bean.common.QueryParam;
import org.hsweb.web.bean.po.template.Template;
import org.hsweb.web.service.impl.AbstractTestCase;
import org.hsweb.web.dao.template.TemplateMapper;
import org.hsweb.web.service.template.TemplateService;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;
import org.mockito.Mock;
import org.mockito.MockSettings;
import org.mockito.MockitoAnnotations;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* Created by zhouhao on 16-5-23.
*/
@Rollback
@Transactional
public class TemplateServiceImplTest extends AbstractTestCase {
public class TemplateServiceImplTest {
@Resource
@Mock
private TemplateService templateService;
private String templateId;
@Before
public void setUp() throws Exception {
Template template = new Template();
template.setName("test");
template.setCssLinks(Arrays.asList("http://***/template.css", "/test.css"));
template.setScriptLinks(Arrays.asList("http://***/template.js", "/test.js"));
template.setTemplate("你好:{{user.name}}");
template.setType("default");
templateService.insert(template);
templateId = template.getId();
testDeploy();
MockitoAnnotations.initMocks(this);
TemplateMapper templateMapper = mock(TemplateMapper.class);
System.out.println(templateMapper.select(QueryParam.build()));
System.out.println(templateMapper.insert(null));
}
@Test
public void testCreateNewVersion() throws Exception {
String id = templateService.createNewVersion(templateId);
Template newVersion = templateService.selectByPk(id);
Assert.assertEquals(newVersion.getVersion(), 1);
Assert.assertEquals(newVersion.getCssLinks().size(), 2);
Assert.assertEquals(newVersion.getScriptLinks().size(), 2);
Assert.assertEquals(newVersion.getTemplate(), "你好:{{user.name}}");
public void test() {
System.out.println(templateService.insert(null));
}
@Test
public void testSelectLatestList() throws Exception {
List<Template> list = templateService.selectLatestList(new QueryParam());
Assert.assertEquals(list.size(), 1);
Assert.assertEquals(list.get(0).getVersion(), 1);
}
public void testDeploy() throws Exception {
templateService.deploy(templateId);
Template template = templateService.selectDeploy("test");
Assert.assertEquals(template.getId(), templateId);
}
@After
public void testUnDeploy() throws Exception {
templateService.unDeploy(templateId);
Template template = templateService.selectDeploy("test");
Assert.assertNotNull(template);
}
@Test
public void testSelectByVersion() throws Exception {
Template template = templateService.selectByVersion("name", 2);
Assert.assertNull(template);
}
}

View File

@@ -9,50 +9,12 @@ spring:
redis:
host: 127.0.0.1
port: 6379
datasource:
xa:
dataSourceClassName: com.alibaba.druid.pool.xa.DruidXADataSource
properties:
url: jdbc:h2:file:./data/h2db;DB_CLOSE_ON_EXIT=FALSE
driverClassName: org.h2.Driver
username: sa
password:
# filters: stat
# maxActive: 20
# initialSize: 1
# maxWait: 60000
# minIdle: 1
# timeBetweenEvictionRunsMillis: 60000
# minEvictableIdleTimeMillis: 300000
# validationQuery: select 'x'
# testWhileIdle: true
# testOnBorrow: false
# testOnReturn: false
# poolPreparedStatements: false
# maxOpenPreparedStatements: 20
name: core
url: jdbc:h2:file:./data/h2db;DB_CLOSE_ON_EXIT=FALSE
driverClassName: org.h2.Driver
username: sa
password:
type: com.alibaba.druid.pool.xa.DruidXADataSource
filters: stat
maxActive: 20
initialSize: 1
maxWait: 60000
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
# schema: classpath:h2.sql
mybatis:
type-aliases-package: org.hsweb.web.bean.po
mapper-locations: classpath*:org/hsweb/web/dao/impl/mybatis/mapper/oracle/**/*.xml
type: oracle
config: classpath:mybatis-config.xml
typeHandlers-package: org.hsweb.web.mybatis.handler
# dynamic-datasource: on
# dynamic-datasource: on
hsweb:
dynamic-datasource:
url: jdbc:mysql://127.0.0.1:3306/hsweb?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: 19920622

View File

@@ -21,7 +21,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<modules>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>hsweb-framework</artifactId>
<groupId>org.hsweb</groupId>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -6,7 +6,7 @@
<groupId>org.hsweb</groupId>
<artifactId>hsweb-framework</artifactId>
<packaging>pom</packaging>
<version>2.0-SNAPSHOT</version>
<version>2.1-SNAPSHOT</version>
<modules>
<module>hsweb-web-dao</module>
<module>hsweb-web-service</module>
@@ -257,6 +257,11 @@
<artifactId>hsweb-web-service-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.hsweb</groupId>
<artifactId>hsweb-web-service-simple</artifactId>