-
Notifications
You must be signed in to change notification settings - Fork 41
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
Showing
68 changed files
with
3,120 additions
and
1,343 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
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
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
22 changes: 22 additions & 0 deletions
22
smpe-common/src/main/java/marchsoft/annotation/Queries.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,22 @@ | ||
package marchsoft.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* 多个关联查询注解,用于mapper层查询方法上 | ||
* 使用方法类比 @Results ,里面套多个 @Query | ||
* Queries({ | ||
* @ Query(),@Query(),... | ||
* }) | ||
* | ||
* @author Wangmingcan | ||
* Date: 2021/01/12 09:35 | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD}) | ||
public @interface Queries { | ||
|
||
Query[] value() default {}; | ||
|
||
} |
106 changes: 30 additions & 76 deletions
106
smpe-common/src/main/java/marchsoft/annotation/Query.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 |
---|---|---|
@@ -1,76 +1,30 @@ | ||
package marchsoft.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* 辅助查询(暂时禁止使用) | ||
* | ||
* @author jiaoqianjin | ||
* Date: 2020/11/16 14:35 | ||
*/ | ||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Deprecated | ||
public @interface Query { | ||
|
||
// 基本对象的属性名 | ||
String propName() default ""; | ||
|
||
// 查询方式 | ||
Type type() default Type.EQUAL; | ||
|
||
/** | ||
* 连接查询的属性名,如User类中的dept | ||
*/ | ||
String joinName() default ""; | ||
|
||
/** | ||
* 默认左连接 | ||
*/ | ||
Join join() default Join.LEFT; | ||
|
||
/** | ||
* 多字段模糊搜索,仅支持String类型字段,多个用逗号隔开, 如@Query(blurry = "email,username") | ||
*/ | ||
String blurry() default ""; | ||
|
||
enum Type { | ||
// 相等 | ||
EQUAL | ||
// 大于等于 | ||
, GREATER_THAN | ||
// 小于等于 | ||
, LESS_THAN | ||
// 中模糊查询 | ||
, INNER_LIKE | ||
// 左模糊查询 | ||
, LEFT_LIKE | ||
// 右模糊查询 | ||
, RIGHT_LIKE | ||
// 小于 | ||
, LESS_THAN_NQ | ||
// 包含 | ||
, IN | ||
// 不等于 | ||
, NOT_EQUAL | ||
// between | ||
, BETWEEN | ||
// 不为空 | ||
, NOT_NULL | ||
// 为空 | ||
, IS_NULL | ||
} | ||
|
||
/** | ||
* 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询 | ||
*/ | ||
enum Join { | ||
/** 简单连接查询 */ | ||
LEFT, RIGHT, INNER | ||
} | ||
|
||
} | ||
|
||
package marchsoft.annotation; | ||
import java.lang.annotation.*; | ||
|
||
/** | ||
* 重新实现 @One、@Many注解 | ||
* 关联查询注解,用于mapper层查询方法上 | ||
* 仅需关联查询一个属性时,可以直接使用@Query | ||
* 如果需要使用多个@Query,请先使用@Queries套在外层(类似 @Results) | ||
* 参数、作用基本和原@One保持一致,既可以用于一对一也可以一对多 | ||
* | ||
* @author Wangmingcan | ||
* Date: 2021/01/12 09:35 | ||
*/ | ||
@Documented | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Repeatable(Queries.class) | ||
public @interface Query { | ||
|
||
/** 被关联的列,一般为id,请保证和实体类中属性名称一致,驼峰下划线都可以 | ||
* 如关联的列为dept_id,填deptId和dept_id都可以*/ | ||
String column() default ""; | ||
|
||
/** 关联的属性 ,和实体类中需要封装的属性名称保持一致*/ | ||
String property() default ""; | ||
|
||
/** 执行的查询方法,建议填写mapper层的全限定方法名 ,方法返回值必须和property类型一致*/ | ||
String select() default ""; | ||
|
||
} |
Oops, something went wrong.