Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
logwire-bo-persistence
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-persistence
Commits
ee1e0460
Commit
ee1e0460
authored
Feb 08, 2021
by
姜逸青 Jameson Jiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1971 bo重新编写文档和demo,确保文档上的demo没有基本错误
parent
f5fa3ac2
Pipeline
#5687
canceled with stages
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
26 additions
and
125 deletions
+26
-125
BoRelationDefinition.java
src/main/java/logwire/web/bo/BoRelationDefinition.java
+0
-3
CreateOperationHandler.java
...n/java/logwire/web/bo/handler/CreateOperationHandler.java
+0
-1
BoModelBeanLoader.java
src/main/java/logwire/web/bo/loader/BoModelBeanLoader.java
+5
-2
BoRelationBeanDefinitionLoader.java
...logwire/web/bo/loader/BoRelationBeanDefinitionLoader.java
+4
-7
FactoryBuilder.java
src/main/java/logwire/web/bo/loader/FactoryBuilder.java
+15
-0
LoaderUtil.java
src/main/java/logwire/web/bo/loader/LoaderUtil.java
+0
-1
DefaultObjectOperationProvider.java
...gwire/web/bo/provider/DefaultObjectOperationProvider.java
+0
-19
DefaultTypeOperationProvider.java
...logwire/web/bo/provider/DefaultTypeOperationProvider.java
+0
-71
Proxy.java
src/main/java/logwire/web/bo/proxy/Proxy.java
+2
-3
ClassUtil.java
src/main/java/logwire/web/bo/util/ClassUtil.java
+0
-18
No files found.
src/main/java/logwire/web/bo/BoRelationDefinition.java
View file @
ee1e0460
...
...
@@ -2,10 +2,7 @@ package logwire.web.bo;
import
logwire.core.bo.eventhandler.ListOperationEventHandler
;
import
logwire.core.bo.eventhandler.ObjectOperationEventHandler
;
import
logwire.core.bo.eventhandler.TypeOperationEventHandler
;
import
logwire.core.bo.handler.ListOperationHandler
;
import
logwire.core.bo.handler.ObjectOperationHandler
;
import
logwire.core.bo.handler.TypeOperationHandler
;
import
logwire.core.bo.object.BizObject
;
import
logwire.core.meta.Config
;
import
logwire.core.resource.bean.BeanAdapter
;
...
...
src/main/java/logwire/web/bo/handler/CreateOperationHandler.java
View file @
ee1e0460
package
logwire
.
web
.
bo
.
handler
;
import
logwire.core.bo.handler.TypeOperationHandler
;
import
logwire.web.bo.BoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
src/main/java/logwire/web/bo/loader/BoModelBeanLoader.java
View file @
ee1e0460
...
...
@@ -24,7 +24,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
import
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.ParameterizedType
;
...
...
@@ -33,7 +32,11 @@ import java.util.*;
import
java.util.function.Consumer
;
import
java.util.stream.Collectors
;
@Component
/**
* todo bobean加载需要集成AbstractModelBeanLoader,从配置文件中读取是否加载bean
* 仍需要讨论bo建表的必要性,bo目前建表太过简单,需要打model-patch
*/
//@Component
public
class
BoModelBeanLoader
extends
BeanLoader
<
IQuery
,
TenantProject
>
implements
JavaModelBeanLoader
{
@Autowired
...
...
src/main/java/logwire/web/bo/loader/BoRelationBeanDefinitionLoader.java
View file @
ee1e0460
...
...
@@ -2,17 +2,14 @@ package logwire.web.bo.loader;
import
com.google.common.collect.Maps
;
import
logwire.core.bo.annotation.BizModel
;
import
logwire.core.bo.annotation.BizObjectFactory
;
import
logwire.core.bo.annotation.ListOperationProvider
;
import
logwire.core.bo.annotation.ObjectOperationProvider
;
import
logwire.core.bo.annotation.TypeOperationProvider
;
import
logwire.core.bo.eventhandler.ListOperationEventHandler
;
import
logwire.core.bo.eventhandler.ObjectOperationEventHandler
;
import
logwire.core.bo.eventhandler.OperationEventHandler
;
import
logwire.core.bo.eventhandler.TypeOperationEventHandler
;
import
logwire.core.bo.handler.ListOperationHandler
;
import
logwire.core.bo.handler.ObjectOperationHandler
;
import
logwire.core.bo.handler.OperationHandler
;
import
logwire.core.bo.handler.TypeOperationHandler
;
import
logwire.core.bo.object.BizObject
;
import
logwire.core.exceptions.ApplicationException
;
import
logwire.core.resource.BeanLoader
;
...
...
@@ -137,7 +134,7 @@ public class BoRelationBeanDefinitionLoader extends BeanLoader<BoRelationDefinit
}).
collect
(
Collectors
.
groupingBy
(
clazz
->
{
if
(
BizObject
.
class
.
isAssignableFrom
(
clazz
))
{
return
BIZ_OBJECT
;
}
else
if
(
TypeOperationProvider
.
class
.
isAssignableFrom
(
clazz
))
{
}
else
if
(
BizObjectFactory
.
class
.
isAssignableFrom
(
clazz
))
{
return
TYPE_OPERATION_PROVIDER
;
}
else
if
(
ObjectOperationProvider
.
class
.
isAssignableFrom
(
clazz
))
{
return
OBJECT_OPERATION_PROVIDER
;
...
...
@@ -172,7 +169,7 @@ public class BoRelationBeanDefinitionLoader extends BeanLoader<BoRelationDefinit
private
void
addOperationProvider
(
Map
<
String
,
BoRelationDefinition
>
boRelationBeanDefinitions
,
Map
<
String
,
List
<
Class
<?>>>
beanClassMap
)
{
beanClassMap
.
get
(
TYPE_OPERATION_PROVIDER
).
forEach
(
clazz
->
{
Class
<?
extends
BizObject
>
type
=
clazz
.
getAnnotation
(
TypeOperationProvider
.
class
).
type
();
Class
<?
extends
BizObject
>
type
=
clazz
.
getAnnotation
(
BizObjectFactory
.
class
).
type
();
boRelationBeanDefinitions
.
get
(
type
.
getSimpleName
()).
addTypeOperationProvider
(
clazz
);
});
beanClassMap
.
get
(
OBJECT_OPERATION_PROVIDER
).
forEach
(
clazz
->
{
...
...
@@ -275,7 +272,7 @@ public class BoRelationBeanDefinitionLoader extends BeanLoader<BoRelationDefinit
provider
.
addIncludeFilter
(
loaderUtil
.
getAbstractTypeFilter
(
BizObject
.
class
));
provider
.
addIncludeFilter
(
new
AssignableTypeFilter
(
OperationHandler
.
class
));
provider
.
addIncludeFilter
(
new
AssignableTypeFilter
(
OperationEventHandler
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
TypeOperationProvider
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
BizObjectFactory
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
ObjectOperationProvider
.
class
));
provider
.
addIncludeFilter
(
new
AnnotationTypeFilter
(
ListOperationProvider
.
class
));
}
...
...
src/main/java/logwire/web/bo/loader/FactoryBuilder.java
0 → 100644
View file @
ee1e0460
package
logwire
.
web
.
bo
.
loader
;
import
logwire.core.bo.factory.DefaultBizObjectFactory
;
import
logwire.core.bo.object.BizObject
;
import
java.util.Map
;
public
class
FactoryBuilder
{
private
static
Map
<
Class
,
DefaultBizObjectFactory
>
map
;
public
static
<
X
extends
DefaultBizObjectFactory
>
X
build
(
Class
<?
extends
BizObject
>
clazz
){
return
(
X
)
map
.
get
(
clazz
);
}
}
src/main/java/logwire/web/bo/loader/LoaderUtil.java
View file @
ee1e0460
...
...
@@ -2,7 +2,6 @@ package logwire.web.bo.loader;
import
logwire.core.bo.eventhandler.OperationEventHandler
;
import
logwire.core.bo.handler.OperationHandler
;
import
logwire.core.bo.handler.TypeOperationHandler
;
import
logwire.core.bo.object.BizObject
;
import
org.springframework.beans.factory.annotation.AnnotatedBeanDefinition
;
import
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
;
...
...
src/main/java/logwire/web/bo/provider/DefaultObjectOperationProvider.java
deleted
100644 → 0
View file @
f5fa3ac2
package
logwire
.
web
.
bo
.
provider
;
import
logwire.core.bo.annotation.ObjectOperationProvider
;
import
logwire.core.bo.annotation.Operation
;
import
logwire.core.bo.object.BizObject
;
//所有BO Object 默认Operation定义
@ObjectOperationProvider
(
type
=
BizObject
.
class
)
public
interface
DefaultObjectOperationProvider
{
@Operation
()
void
save
();
@Operation
()
void
delete
();
@Operation
()
void
update
(
String
...
fields
);
// 更多操作定义
}
\ No newline at end of file
src/main/java/logwire/web/bo/provider/DefaultTypeOperationProvider.java
deleted
100644 → 0
View file @
f5fa3ac2
package
logwire
.
web
.
bo
.
provider
;
import
logwire.core.bo.annotation.Operation
;
import
logwire.core.bo.annotation.TypeOperationProvider
;
import
logwire.core.bo.list.BizList
;
import
logwire.core.bo.object.BizObject
;
import
logwire.core.bo.select.BizSelect
;
import
java.util.List
;
import
java.util.Map
;
@TypeOperationProvider
(
type
=
BizObject
.
class
)
public
interface
DefaultTypeOperationProvider
{
@Operation
(
label
=
"创建BO对象"
)
<
X
>
X
create
();
@Operation
()
<
X
>
X
createWithDefault
(
Map
defaultValues
);
@Operation
()
<
X
>
X
create
(
String
query
);
@Operation
()
<
X
>
X
find
(
Long
id
);
@Operation
()
<
X
>
X
find
(
Map
fields
);
@Operation
()
<
X
>
X
find
(
String
query
);
@Operation
()
<
X
>
X
find
(
String
query
,
List
fieldValues
);
@Operation
()
<
X
extends
BizObject
>
BizList
<
X
>
createList
();
@Operation
()
<
X
extends
BizObject
>
BizList
<
X
>
createList
(
String
query
);
@Operation
()
<
X
extends
BizObject
>
BizList
<
X
>
createList
(
Map
fields
);
@Operation
()
<
X
extends
BizObject
,
T
extends
BizList
<
X
>>
T
findAll
(
Map
fields
);
@Operation
()
<
X
extends
BizObject
>
BizList
<
X
>
findAll
(
String
query
);
@Operation
()
<
X
extends
BizObject
>
BizList
<
X
>
findAll
(
String
query
,
List
fieldValues
);
@Operation
()
BizSelect
select
();
@Operation
()
BizSelect
select
(
Map
fields
);
@Operation
()
BizSelect
select
(
String
query
);
@Operation
()
<
X
>
X
delete
(
Long
id
);
@Operation
()
List
<
Object
>
findField
(
String
query
,
String
field
);
@Operation
()
List
<
Map
>
findFields
(
String
query
,
String
...
fields
);
// 更多Operation
}
src/main/java/logwire/web/bo/proxy/Proxy.java
View file @
ee1e0460
package
logwire
.
web
.
bo
.
proxy
;
import
com.google.common.collect.Lists
;
import
logwire.core.bo.
handler.ObjectOperationHandler
;
import
logwire.core.bo.
factory.DefaultBizObjectFactory
;
import
logwire.core.bo.object.BizObject
;
import
logwire.web.bo.BoRelationDefinition
;
import
logwire.web.bo.provider.DefaultTypeOperationProvider
;
import
net.bytebuddy.ByteBuddy
;
import
net.bytebuddy.implementation.MethodDelegation
;
import
net.bytebuddy.matcher.ElementMatchers
;
...
...
@@ -28,7 +27,7 @@ public class Proxy {
// 动态生成service
// 若直接继承了BizObject,则动态代理继承DefaultTypeOperationProvider,
// 否则继承父类中的service对应的TypeOperationProvider
Class
superClass
=
Default
TypeOperationProvider
.
class
;
Class
superClass
=
Default
BizObjectFactory
.
class
;
if
(
boClass
.
getSuperclass
()
!=
BizObject
.
class
)
{
// parent TypeOperationProvider
superClass
=
boClass
.
getSuperclass
().
getField
(
"service"
).
getClass
();
...
...
src/main/java/logwire/web/bo/util/ClassUtil.java
deleted
100644 → 0
View file @
f5fa3ac2
package
logwire
.
web
.
bo
.
util
;
public
class
ClassUtil
{
/**
* 校验是否实现了某个类是否实现了这个接口
* @param orign
* @param interfaceClass
* @return
*/
public
static
boolean
isInterfaceClass
(
Class
<?>
orign
,
Class
<?>
interfaceClass
){
for
(
Class
<?>
clazz:
orign
.
getInterfaces
())
{
if
(
clazz
==
interfaceClass
)
return
true
;
}
return
false
;
}
}
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