-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ywj
committed
Dec 24, 2014
1 parent
f184bb4
commit 331dba1
Showing
75 changed files
with
1,703 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>fastser-dal-all</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
encoding/<project>=UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#fastser-dal-mybatis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.fastser</groupId> | ||
<artifactId>fastser-dal-root</artifactId> | ||
<version>1.0.2</version> | ||
</parent> | ||
|
||
<artifactId>fastser-dal-mybatis</artifactId> | ||
|
||
|
||
<name>fastser-dal-mybatis</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.fastser</groupId> | ||
<artifactId>fastser-dal</artifactId> | ||
<version>1.0.1</version> | ||
</dependency> | ||
|
||
|
||
|
||
<!-- =================================================== --> | ||
<!-- mybatis --> | ||
<!-- =================================================== --> | ||
<dependency> | ||
<groupId>org.mybatis</groupId> | ||
<artifactId>mybatis</artifactId> | ||
<version>3.2.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mybatis</groupId> | ||
<artifactId>mybatis-spring</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
|
||
<!-- ==================== --> | ||
<!-- 测试 --> | ||
<!-- ==================== --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Class-Path: | ||
|
13 changes: 13 additions & 0 deletions
13
fastser-dal-mybatis/src/main/java/org/fastser/dal/mybatis/App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.fastser.dal.mybatis; | ||
|
||
/** | ||
* Hello world! | ||
* | ||
*/ | ||
public class App | ||
{ | ||
public static void main( String[] args ) | ||
{ | ||
System.out.println( "Hello World!" ); | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
fastser-dal-mybatis/src/main/java/org/fastser/dal/mybatis/CommonMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package org.fastser.dal.mybatis; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.apache.ibatis.annotations.DeleteProvider; | ||
import org.apache.ibatis.annotations.InsertProvider; | ||
import org.apache.ibatis.annotations.Options; | ||
import org.apache.ibatis.annotations.ResultType; | ||
import org.apache.ibatis.annotations.SelectKey; | ||
import org.apache.ibatis.annotations.SelectProvider; | ||
import org.apache.ibatis.annotations.UpdateProvider; | ||
import org.apache.ibatis.mapping.StatementType; | ||
import org.fastser.dal.descriptor.Table; | ||
import org.fastser.dal.mybatis.template.SqlTemplate; | ||
|
||
public interface CommonMapper{ | ||
|
||
/** | ||
* 条件查询 | ||
* 自定议显示字段传入 model.params,为空时为所有字段 | ||
* 条件传入model.QueryCriteria | ||
* @param model | ||
* @return | ||
*/ | ||
@SelectProvider(method = "selectByCriteria", type = SqlTemplate.class) | ||
@ResultType(value = Map.class) | ||
List<Map<String, Object>> selectByCriteria(Table model); | ||
|
||
/** | ||
* 新增 | ||
* 所有字段传入 model.params,不能为空 | ||
* @param model | ||
* @return | ||
*/ | ||
//@SelectKey(statement="call identity()", keyProperty="id", before=false, resultType=int.class) | ||
@InsertProvider(method = "insert", type = SqlTemplate.class) | ||
@SelectKey(before=false,keyProperty="params.id",resultType=int.class,statementType=StatementType.STATEMENT,statement="SELECT LAST_INSERT_ID() AS id") | ||
int insert(Table model); | ||
|
||
/** | ||
* 条件删除 | ||
* 条件传入model.QueryCriteria | ||
* @param model | ||
* @return | ||
*/ | ||
@DeleteProvider(method = "deleteByCriteria", type = SqlTemplate.class) | ||
int deleteByCriteria(Table model); | ||
|
||
/** | ||
* 条件更新 | ||
* 更新字段传入 model.params,不能为空 | ||
* 条件传入model.QueryCriteria | ||
* @param model | ||
* @return | ||
*/ | ||
@UpdateProvider(method = "updateByCriteria", type = SqlTemplate.class) | ||
int updateByCriteria(Table model); | ||
|
||
/** | ||
* 主键查询 | ||
* 自定议显示字段传入 model.params,为空时为所有字段 | ||
* 主键参数传入 model.conditions,不能为空 | ||
* @param model | ||
* @return | ||
*/ | ||
@SelectProvider(method = "selectByPrimaryKey", type = SqlTemplate.class) | ||
@ResultType(value = Map.class) | ||
Map<String, Object> selectByPrimaryKey(Table model); | ||
|
||
/** | ||
* 主键删除 | ||
* 主键参数传入 model.conditions,不能为空 | ||
* @param model | ||
* @return | ||
*/ | ||
@DeleteProvider(method = "deleteByPrimaryKey", type = SqlTemplate.class) | ||
int deleteByPrimaryKey(Table model); | ||
|
||
/** | ||
* 主键更新 | ||
* 更新字段传入 model.params,不能为空 | ||
* 主键参数传入 model.conditions,不能为空 | ||
* @param model | ||
* @return | ||
*/ | ||
@UpdateProvider(method = "updateByPrimaryKey", type = SqlTemplate.class) | ||
int updateByPrimaryKey(Table model); | ||
|
||
/** | ||
* 条件count | ||
* 条件传入model.QueryCriteria | ||
* @param model | ||
* @return | ||
*/ | ||
@SelectProvider(method = "countByCriteria", type = SqlTemplate.class) | ||
@ResultType(value = Integer.class) | ||
int countByCriteria(Table model); | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
66 changes: 66 additions & 0 deletions
66
fastser-dal-mybatis/src/main/java/org/fastser/dal/mybatis/MybatisDAL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.fastser.dal.mybatis; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.fastser.dal.core.AbstractBaseDAL; | ||
import org.fastser.dal.core.BaseDAL; | ||
import org.fastser.dal.criteria.QueryCriteria; | ||
import org.fastser.dal.descriptor.QueryResult; | ||
import org.fastser.dal.descriptor.Table; | ||
|
||
public class MybatisDAL extends AbstractBaseDAL implements BaseDAL { | ||
|
||
private CommonMapper commonMapper; | ||
|
||
public void setCommonMapper(CommonMapper commonMapper) { | ||
this.commonMapper = commonMapper; | ||
} | ||
|
||
|
||
@Override | ||
public List<Map<String, Object>> _selectByCriteria(Table table) { | ||
return commonMapper.selectByCriteria(table); | ||
} | ||
|
||
@Override | ||
public int _countByCriteria(Table table) { | ||
return commonMapper.countByCriteria(table); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> _selectByPrimaryKey(Table table) { | ||
return commonMapper.selectByPrimaryKey(table); | ||
} | ||
|
||
@Override | ||
public int _insert(Table table) { | ||
return commonMapper.insert(table); | ||
} | ||
|
||
@Override | ||
public int _updateByCriteria(Table table) { | ||
return commonMapper.updateByCriteria(table); | ||
} | ||
|
||
@Override | ||
public int _updateByPrimaryKey(Table table) { | ||
return commonMapper.updateByPrimaryKey(table); | ||
} | ||
|
||
@Override | ||
public int _deleteByPrimaryKey(Table table) { | ||
return commonMapper.deleteByPrimaryKey(table); | ||
} | ||
|
||
@Override | ||
public int _deleteByCriteria(Table table) { | ||
return commonMapper.deleteByCriteria(table); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...-dal-mybatis/src/main/java/org/fastser/dal/mybatis/resolver/MybatisFieldSqlGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.fastser.dal.mybatis.resolver; | ||
|
||
import org.fastser.dal.descriptor.Column; | ||
import org.fastser.dal.descriptor.resolver.FieldSqlGenerator; | ||
|
||
public class MybatisFieldSqlGenerator implements FieldSqlGenerator { | ||
|
||
@Override | ||
public String buildSingleSql(Column field) { | ||
String javaType = MybatisJavaTypeResolver.calculateJavaType(field.getJdbcType()); | ||
return javaType; | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.