Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
logwire-bo-sdk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
薛涛 Toby Xue
logwire-bo-sdk
Commits
fbe6ce2b
Commit
fbe6ce2b
authored
Feb 08, 2021
by
姜逸青 Jameson Jiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1971 bo重新编写文档和demo,确保文档上的demo没有基本错误
parent
c2477866
Pipeline
#5689
canceled with stages
Changes
22
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
220 additions
and
76 deletions
+220
-76
BizObjectFactory.java
...ain/java/logwire/core/bo/annotation/BizObjectFactory.java
+2
-2
Operation.java
src/main/java/logwire/core/bo/annotation/Operation.java
+2
-0
TypeOperationEventHandler.java
...gwire/core/bo/eventhandler/TypeOperationEventHandler.java
+0
-14
BizObjectFactoryEventHandler.java
...logwire/core/bo/factory/BizObjectFactoryEventHandler.java
+11
-0
BizObjectFactoryHandler.java
...java/logwire/core/bo/factory/BizObjectFactoryHandler.java
+22
-0
DefaultBizObjectFactory.java
...java/logwire/core/bo/factory/DefaultBizObjectFactory.java
+49
-0
SmartBizObjectFactoryHandler.java
...logwire/core/bo/factory/SmartBizObjectFactoryHandler.java
+11
-0
BizItem.java
src/main/java/logwire/core/bo/field/BizItem.java
+10
-4
BizMany.java
src/main/java/logwire/core/bo/field/BizMany.java
+4
-2
BizOne.java
src/main/java/logwire/core/bo/field/BizOne.java
+6
-2
ObjectOperationHandler.java
.../java/logwire/core/bo/handler/ObjectOperationHandler.java
+0
-16
TypeOperationHandler.java
...in/java/logwire/core/bo/handler/TypeOperationHandler.java
+0
-13
BizList.java
src/main/java/logwire/core/bo/list/BizList.java
+12
-6
BizObject.java
src/main/java/logwire/core/bo/object/BizObject.java
+11
-9
User.java
src/main/java/logwire/core/bo/object/User.java
+1
-0
DefaultListOperationProvider.java
.../core/bo/operation/list/DefaultListOperationProvider.java
+20
-0
DefaultObjectOperationProvider.java
...e/bo/operation/object/DefaultObjectOperationProvider.java
+21
-0
ObjectOperationEventHandler.java
...core/bo/operation/object/ObjectOperationEventHandler.java
+14
-0
ObjectOperationHandler.java
...wire/core/bo/operation/object/ObjectOperationHandler.java
+13
-0
SmartObjectOperationHandler.java
...core/bo/operation/object/SmartObjectOperationHandler.java
+11
-0
BizChildSelect.java
src/main/java/logwire/core/bo/select/BizChildSelect.java
+0
-4
BizSelect.java
src/main/java/logwire/core/bo/select/BizSelect.java
+0
-4
No files found.
src/main/java/logwire/core/bo/annotation/
TypeOperationProvider
.java
→
src/main/java/logwire/core/bo/annotation/
BizObjectFactory
.java
View file @
fbe6ce2b
...
@@ -8,10 +8,10 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -8,10 +8,10 @@ import java.lang.annotation.RetentionPolicy;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
/**
/**
*
Type级Operation声明注解
*
BO工厂类,用来创建BO或找到BO
*/
*/
@Target
({
ElementType
.
TYPE
})
@Target
({
ElementType
.
TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
TypeOperationProvider
{
public
@interface
BizObjectFactory
{
Class
<?
extends
BizObject
>
type
();
Class
<?
extends
BizObject
>
type
();
}
}
src/main/java/logwire/core/bo/annotation/Operation.java
View file @
fbe6ce2b
...
@@ -12,6 +12,8 @@ import java.lang.annotation.Target;
...
@@ -12,6 +12,8 @@ import java.lang.annotation.Target;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Operation
{
public
@interface
Operation
{
String
name
();
String
label
()
default
""
;
String
label
()
default
""
;
OperationArg
[]
args
()
default
{};
OperationArg
[]
args
()
default
{};
...
...
src/main/java/logwire/core/bo/eventhandler/TypeOperationEventHandler.java
deleted
100644 → 0
View file @
c2477866
package
logwire
.
core
.
bo
.
eventhandler
;
import
logwire.core.bo.object.BizObject
;
public
interface
TypeOperationEventHandler
<
X
extends
BizObject
>
extends
OperationEventHandler
{
default
void
doBefore
(
Class
<
X
>
xClass
,
Object
...
args
)
{
//调用行为同名方法
}
default
void
doAfter
(
Class
<
X
>
xClass
,
Object
result
,
Object
...
args
)
{
//调用行为同名方法
}
}
\ No newline at end of file
src/main/java/logwire/core/bo/factory/BizObjectFactoryEventHandler.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
factory
;
import
logwire.core.bo.object.BizObject
;
public
interface
BizObjectFactoryEventHandler
<
X
extends
BizObject
>
{
String
getOperationName
();
void
doBefore
(
Class
<
X
>
xClass
,
Object
...
args
);
void
doAfter
(
Class
<
X
>
xClass
,
Object
result
,
Object
...
args
);
}
\ No newline at end of file
src/main/java/logwire/core/bo/factory/BizObjectFactoryHandler.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
factory
;
import
logwire.core.bo.object.BizObject
;
public
interface
BizObjectFactoryHandler
<
X
extends
BizObject
>
{
String
getOperationName
();
// 取消enable这个参数,配置文件和程序里都有配置会导致混淆
// 只会从配置文件中读取,只有在配置文件中配置的,才会进行加载
//boolean isEnabled();
//取消order参数,按照配置文件中的顺序来执行
//default int getOrder(){return 1000;}
default
boolean
accept
(
Class
<
X
>
xClass
,
Object
...
args
)
{
return
true
;
}
Object
execute
(
Class
<
X
>
xClass
,
Object
...
args
);
}
src/main/java/logwire/core/bo/factory/DefaultBizObjectFactory.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
factory
;
import
logwire.core.bo.annotation.Operation
;
import
logwire.core.bo.list.BizList
;
import
logwire.core.bo.object.BizObject
;
import
java.util.Map
;
/**
* BOFactory默认实现的接口
* @param <X> BO类
*/
public
interface
DefaultBizObjectFactory
<
X
extends
BizObject
>
{
@Operation
(
name
=
"create"
,
label
=
"创建BO对象"
)
X
create
();
@Operation
(
name
=
"createByDefault"
)
X
createByDefault
(
Map
defaultValues
);
@Operation
(
name
=
"findById"
)
X
findById
(
Long
id
);
@Operation
(
name
=
"findOne"
)
X
findOne
(
Map
fields
);
/* 暂不支持lql
@Operation()
X find(String query);
@Operation()
X find(String query, List fieldValues);
*/
@Operation
(
name
=
"createList"
)
BizList
<
X
>
createList
();
@Operation
(
name
=
"createListByDefault"
)
BizList
<
X
>
createListByDefault
(
Map
fields
);
@Operation
(
name
=
"find"
)
BizList
<
X
>
find
(
Map
fields
);
/* 暂不支持lql
@Operation()
BizList<X> find(String query);
@Operation()
BizList<X> find(String query, List fieldValues);
*/
@Operation
(
name
=
"findAll"
)
BizList
<
X
>
findAll
();
/* 暂不支持lql
@Operation()
List<Object> findField(String query, String field);
@Operation()
List<Map> findFields(String query, String...fields);
*/
// 更多Operation
}
src/main/java/logwire/core/bo/factory/SmartBizObjectFactoryHandler.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
factory
;
import
logwire.core.bo.object.BizObject
;
public
interface
SmartBizObjectFactoryHandler
<
X
extends
BizObject
>
extends
BizObjectFactoryHandler
<
X
>
{
default
Object
execute
(
Class
<
X
>
xClass
,
Object
...
args
)
{
//调用与Operation同名方法
//目的增加代码可读性
return
null
;
}
}
src/main/java/logwire/core/bo/field/BizItem.java
View file @
fbe6ce2b
...
@@ -6,18 +6,24 @@ import logwire.core.bo.list.BizList;
...
@@ -6,18 +6,24 @@ import logwire.core.bo.list.BizList;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.util.Map
;
import
java.util.Map
;
/**
* 一对多关系字段
* @param <X>
*/
public
interface
BizItem
<
X
extends
BizObject
>
extends
Iterable
<
X
>
{
public
interface
BizItem
<
X
extends
BizObject
>
extends
Iterable
<
X
>
{
boolean
isChanged
();
boolean
isChanged
();
X
find
(
String
field
,
Object
value
);
X
find
One
(
String
field
,
Object
value
);
X
find
(
Map
<
String
,
Field
>
fields
);
X
find
One
(
Map
<
String
,
Field
>
fields
);
X
create
();
X
create
();
X
create
(
Map
<
String
,
Field
>
fields
);
X
create
(
Map
<
String
,
Field
>
fields
);
BizList
<
X
>
find
All
(
String
field
,
Object
value
);
BizList
<
X
>
find
(
String
field
,
Object
value
);
BizList
<
X
>
findAll
(
Map
fields
);
BizList
<
X
>
find
(
Map
fields
);
BizList
<
X
>
findAll
();
}
}
src/main/java/logwire/core/bo/field/BizMany.java
View file @
fbe6ce2b
...
@@ -3,7 +3,7 @@ package logwire.core.bo.field;
...
@@ -3,7 +3,7 @@ package logwire.core.bo.field;
import
logwire.core.bo.object.BizObject
;
import
logwire.core.bo.object.BizObject
;
import
logwire.core.bo.list.BizList
;
import
logwire.core.bo.list.BizList
;
public
interface
BizMany
<
X
extends
BizObject
>
extends
Iterable
<
Object
>
{
public
interface
BizMany
<
X
extends
BizObject
>
extends
Iterable
<
X
>
{
void
add
(
Long
id
);
void
add
(
Long
id
);
void
remove
(
Long
id
);
void
remove
(
Long
id
);
...
@@ -12,5 +12,7 @@ public interface BizMany<X extends BizObject> extends Iterable<Object> {
...
@@ -12,5 +12,7 @@ public interface BizMany<X extends BizObject> extends Iterable<Object> {
void
remove
(
X
object
);
void
remove
(
X
object
);
void
allAll
(
BizList
<
X
>
list
);
void
addAll
(
BizList
<
X
>
list
);
BizList
<
X
>
findAll
();
}
}
src/main/java/logwire/core/bo/field/BizOne.java
View file @
fbe6ce2b
...
@@ -2,10 +2,14 @@ package logwire.core.bo.field;
...
@@ -2,10 +2,14 @@ package logwire.core.bo.field;
import
logwire.core.bo.object.ModelObject
;
import
logwire.core.bo.object.ModelObject
;
/**
* 多对一关系字段
* @param <X>
*/
public
interface
BizOne
<
X
extends
ModelObject
>
{
public
interface
BizOne
<
X
extends
ModelObject
>
{
Long
get
Value
();
Long
get
Id
();
void
set
Value
(
Long
value
);
void
set
Id
(
Long
id
);
X
getObject
();
X
getObject
();
}
}
src/main/java/logwire/core/bo/handler/ObjectOperationHandler.java
deleted
100644 → 0
View file @
c2477866
package
logwire
.
core
.
bo
.
handler
;
import
logwire.core.bo.object.BizObject
;
public
interface
ObjectOperationHandler
<
X
extends
BizObject
>
extends
OperationHandler
{
default
String
getQuery
()
{
return
""
;
}
default
boolean
accept
(
X
x
,
Object
...
args
)
{
return
true
;
}
Object
execute
(
X
x
,
Object
...
args
);
}
src/main/java/logwire/core/bo/handler/TypeOperationHandler.java
deleted
100644 → 0
View file @
c2477866
package
logwire
.
core
.
bo
.
handler
;
import
logwire.core.bo.object.BizObject
;
public
interface
TypeOperationHandler
<
X
extends
BizObject
>
extends
OperationHandler
{
default
boolean
accept
(
Class
<
X
>
xClass
,
Object
...
args
)
{
return
true
;
}
Object
execute
(
Class
<
X
>
xClass
,
Object
...
args
);
}
src/main/java/logwire/core/bo/list/BizList.java
View file @
fbe6ce2b
...
@@ -6,21 +6,27 @@ import java.util.Map;
...
@@ -6,21 +6,27 @@ import java.util.Map;
public
interface
BizList
<
X
extends
BizObject
>
extends
Iterable
<
X
>
{
public
interface
BizList
<
X
extends
BizObject
>
extends
Iterable
<
X
>
{
X
find
(
String
field
,
Object
value
);
De
X
find
(
Map
fields
);
X
find
One
(
String
field
,
Object
value
);
X
findOne
(
Map
fields
);
/* 暂不支持lql
X find(String query);
X find(String query);
*/
X
create
();
X
create
();
X
create
(
Map
fields
);
X
create
(
Map
fields
);
X
create
(
String
query
);
BizList
<
X
>
find
(
String
field
,
Object
value
);
BizList
<
X
>
find
All
(
String
field
,
Object
value
);
BizList
<
X
>
find
(
Map
fields
);
BizList
<
X
>
findAll
(
Map
fields
);
/* 暂不支持lql
BizList<X> find(String query);
*/
BizList
<
X
>
findAll
(
String
query
);
BizList
<
X
>
findAll
();
}
}
\ No newline at end of file
src/main/java/logwire/core/bo/object/BizObject.java
View file @
fbe6ce2b
...
@@ -13,34 +13,36 @@ import java.util.Map;
...
@@ -13,34 +13,36 @@ import java.util.Map;
* BO 子表字段(多对多、数组、大文本)生成的Model,audit/version/domain都为false
* BO 子表字段(多对多、数组、大文本)生成的Model,audit/version/domain都为false
*/
*/
public
abstract
class
BizObject
extends
ModelObject
{
public
abstract
class
BizObject
extends
ModelObject
{
/**
* 事务类型 insert/update/delete
*/
String
txCode
;
/**
String
txCode
;
//事务类型 insert/update/delete
* 当事务类型为update时,记录修改过的字段
*/
Map
updatedFields
;
//当事务类型为update时,记录修改过的字段
Map
<
String
,
Object
>
updatedFields
;
@Column
(
label
=
"主键"
)
Long
id
;
// BO 的ID全部为雪花ID
Long
id
;
// BO 的ID全部为雪花ID
@Column
(
label
=
"版本号"
)
int
version
;
int
version
;
@Column
(
label
=
"BO名称"
)
@Column
(
label
=
"BO名称"
)
String
boName
;
String
boName
=
this
.
getClass
().
getSimpleName
()
;
@Column
(
label
=
"创建用户"
)
BizOne
<
User
>
insert_user
;
BizOne
<
User
>
insert_user
;
@Column
(
label
=
"创建时间"
)
OffsetDateTime
insert_date
;
OffsetDateTime
insert_date
;
@Column
(
label
=
"最后修改用户"
)
BizOne
<
User
>
update_user
;
BizOne
<
User
>
update_user
;
@Column
(
label
=
"最后修改时间"
)
OffsetDateTime
update_date
;
OffsetDateTime
update_date
;
@Composite
(
label
=
"项目扩展字段"
,
prefix
=
"exp_"
)
@Composite
(
label
=
"项目扩展字段"
,
prefix
=
"exp_"
)
BizExpando
exps
;
BizExpando
exps
;
@Column
(
label
=
"域"
)
String
domain_name
;
String
domain_name
;
...
...
src/main/java/logwire/core/bo/object/User.java
View file @
fbe6ce2b
...
@@ -10,6 +10,7 @@ public abstract class User extends ModelObject {
...
@@ -10,6 +10,7 @@ public abstract class User extends ModelObject {
@Column
(
label
=
"xid"
)
@Column
(
label
=
"xid"
)
String
userXid
;
String
userXid
;
@Override
public
Object
getId
()
{
public
Object
getId
()
{
return
userGid
;
return
userGid
;
}
}
...
...
src/main/java/logwire/core/bo/operation/list/DefaultListOperationProvider.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
operation
.
list
;
import
logwire.core.bo.annotation.ListOperationProvider
;
import
logwire.core.bo.annotation.Operation
;
import
logwire.core.bo.object.BizObject
;
//所有BO Object 默认ListOperation定义
@ListOperationProvider
(
type
=
BizObject
.
class
)
public
interface
DefaultListOperationProvider
<
X
extends
BizObject
>
{
@Operation
(
name
=
"getProvider"
)
DefaultListOperationProvider
<
X
>
getProvider
();
@Operation
(
name
=
"save"
)
void
save
();
@Operation
(
name
=
"delete"
)
void
delete
();
@Operation
(
name
=
"insert"
)
void
insert
();
@Operation
(
name
=
"update"
)
void
update
(
String
...
fields
);
}
\ No newline at end of file
src/main/java/logwire/core/bo/operation/object/DefaultObjectOperationProvider.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
operation
.
object
;
import
logwire.core.bo.annotation.ObjectOperationProvider
;
import
logwire.core.bo.annotation.Operation
;
import
logwire.core.bo.object.BizObject
;
import
java.util.Map
;
//所有BO Object 默认Operation定义
@ObjectOperationProvider
(
type
=
BizObject
.
class
)
public
interface
DefaultObjectOperationProvider
<
X
extends
BizObject
>
{
@Operation
(
name
=
"save"
)
void
save
();
@Operation
(
name
=
"delete"
)
void
delete
();
@Operation
(
name
=
"update"
)
void
update
(
Map
fields
);
// 更多操作定义
}
\ No newline at end of file
src/main/java/logwire/core/bo/
eventhandler
/ObjectOperationEventHandler.java
→
src/main/java/logwire/core/bo/
operation/object
/ObjectOperationEventHandler.java
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
eventhandler
;
package
logwire
.
core
.
bo
.
operation
.
object
;
import
logwire.core.bo.object.BizObject
;
import
logwire.core.bo.object.BizObject
;
public
interface
ObjectOperationEventHandler
<
X
extends
BizObject
>
extends
OperationEventHandler
{
public
interface
ObjectOperationEventHandler
<
X
extends
BizObject
>
{
String
getOperationName
();
default
String
getQuery
()
{
default
boolean
isAfter
()
{
return
true
;}
return
""
;
default
void
doBefore
(
X
x
,
Object
...
args
){
}
default
void
doBefore
(
X
x
,
Object
...
args
)
{
//调用行为同名方法
//调用行为同名方法
}
}
default
void
doAfter
(
X
x
,
Object
result
,
Object
...
args
){
default
void
doAfter
(
X
x
,
Object
result
,
Object
...
args
)
{
//调用行为同名方法
//调用行为同名方法
}
}
}
}
src/main/java/logwire/core/bo/operation/object/ObjectOperationHandler.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
operation
.
object
;
import
logwire.core.bo.object.BizObject
;
public
interface
ObjectOperationHandler
<
X
extends
BizObject
>
{
String
getOperationName
();
/*boolean isEnabled();
default int getOrder(){return 1000;}*/
default
boolean
accept
(
X
x
,
Object
...
args
){
return
true
;}
Object
execute
(
X
x
,
Object
...
args
);
}
src/main/java/logwire/core/bo/operation/object/SmartObjectOperationHandler.java
0 → 100644
View file @
fbe6ce2b
package
logwire
.
core
.
bo
.
operation
.
object
;
import
logwire.core.bo.object.BizObject
;
public
interface
SmartObjectOperationHandler
<
X
extends
BizObject
>
extends
ObjectOperationHandler
<
X
>
{
default
Object
execute
(
X
x
,
Object
...
args
)
{
//调用与Operation同名方法
//目的增加代码可读性
return
null
;
}
}
src/main/java/logwire/core/bo/select/BizChildSelect.java
deleted
100644 → 0
View file @
c2477866
package
logwire
.
core
.
bo
.
select
;
public
interface
BizChildSelect
extends
BizSelect
{
}
src/main/java/logwire/core/bo/select/BizSelect.java
deleted
100644 → 0
View file @
c2477866
package
logwire
.
core
.
bo
.
select
;
public
interface
BizSelect
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment