Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
93d586e0
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
93d586e0
编写于
4月 25, 2022
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加根据组织类型查询组织的接口
上级
730d0c49
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
284 addition
and
5 deletion
+284
-5
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListWithTypeObject.java
...assemble/express/jaxrs/unit/ActionListWithTypeObject.java
+62
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListWithTypes.java
...tion/assemble/express/jaxrs/unit/ActionListWithTypes.java
+81
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListWithTypesObject.java
...ssemble/express/jaxrs/unit/ActionListWithTypesObject.java
+85
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/UnitAction.java
.../organization/assemble/express/jaxrs/unit/UnitAction.java
+56
-5
未找到文件。
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListWithTypeObject.java
0 → 100644
浏览文件 @
93d586e0
package
com.x.organization.assemble.express.jaxrs.unit
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.Unit_
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
class
ActionListWithTypeObject
extends
BaseAction
{
@SuppressWarnings
(
"unchecked"
)
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
String
type
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
type
);
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
List
<
Wo
>)
optional
.
get
());
}
else
{
List
<
Wo
>
wos
=
this
.
list
(
business
,
type
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wos
);
result
.
setData
(
wos
);
}
return
result
;
}
}
public
static
class
Wo
extends
com
.
x
.
base
.
core
.
project
.
organization
.
Unit
{
}
private
List
<
Wo
>
list
(
Business
business
,
String
type
)
throws
Exception
{
List
<
Wo
>
wos
=
new
ArrayList
<>();
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Unit
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
Unit
>
root
=
cq
.
from
(
Unit
.
class
);
Predicate
p
=
cb
.
isMember
(
type
,
root
.
get
(
Unit_
.
typeList
));
List
<
String
>
unitIds
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
Unit_
.
id
)).
where
(
p
)).
getResultList
();
List
<
Unit
>
units
=
business
.
unit
().
pick
(
unitIds
);
units
=
business
.
unit
().
sort
(
units
);
for
(
Unit
o
:
units
)
{
wos
.
add
(
this
.
convert
(
business
,
o
,
Wo
.
class
));
}
return
wos
;
}
}
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListWithTypes.java
0 → 100644
浏览文件 @
93d586e0
package
com.x.organization.assemble.express.jaxrs.unit
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.Unit_
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
class
ActionListWithTypes
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
if
(
ListTools
.
isEmpty
(
wi
.
getTypeList
())){
result
.
setData
(
new
Wo
());
}
Business
business
=
new
Business
(
emc
);
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getTypeList
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
Wo
)
optional
.
get
());
}
else
{
Wo
wo
=
this
.
list
(
business
,
wi
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
result
.
setData
(
wo
);
}
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"组织类型"
)
private
List
<
String
>
typeList
=
new
ArrayList
<>();
public
List
<
String
>
getTypeList
()
{
return
typeList
;
}
public
void
setTypeList
(
List
<
String
>
typeList
)
{
this
.
typeList
=
typeList
;
}
}
public
static
class
Wo
extends
WoUnitListAbstract
{
}
private
Wo
list
(
Business
business
,
Wi
wi
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Unit
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
Unit
>
root
=
cq
.
from
(
Unit
.
class
);
Predicate
p
=
root
.
get
(
Unit_
.
typeList
).
in
(
wi
.
getTypeList
());
List
<
String
>
unitIds
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
Unit_
.
id
)).
where
(
p
)).
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
Wo
wo
=
new
Wo
();
List
<
String
>
list
=
business
.
unit
().
listUnitDistinguishedNameSorted
(
unitIds
);
wo
.
getUnitList
().
addAll
(
list
);
return
wo
;
}
}
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionListWithTypesObject.java
0 → 100644
浏览文件 @
93d586e0
package
com.x.organization.assemble.express.jaxrs.unit
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.Unit_
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
class
ActionListWithTypesObject
extends
BaseAction
{
@SuppressWarnings
(
"unchecked"
)
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
if
(
ListTools
.
isEmpty
(
wi
.
getTypeList
())){
result
.
setData
(
new
ArrayList
<>());
}
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getTypeList
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
List
<
Wo
>)
optional
.
get
());
}
else
{
List
<
Wo
>
wos
=
this
.
list
(
business
,
wi
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wos
);
result
.
setData
(
wos
);
}
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"组织类型"
)
private
List
<
String
>
typeList
=
new
ArrayList
<>();
public
List
<
String
>
getTypeList
()
{
return
typeList
;
}
public
void
setTypeList
(
List
<
String
>
typeList
)
{
this
.
typeList
=
typeList
;
}
}
public
static
class
Wo
extends
com
.
x
.
base
.
core
.
project
.
organization
.
Unit
{
}
private
List
<
Wo
>
list
(
Business
business
,
Wi
wi
)
throws
Exception
{
List
<
Wo
>
wos
=
new
ArrayList
<>();
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Unit
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
Unit
>
root
=
cq
.
from
(
Unit
.
class
);
Predicate
p
=
root
.
get
(
Unit_
.
typeList
).
in
(
wi
.
getTypeList
());
List
<
String
>
unitIds
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
Unit_
.
id
)).
where
(
p
)).
getResultList
();
List
<
Unit
>
units
=
business
.
unit
().
pick
(
unitIds
);
units
=
business
.
unit
().
sort
(
units
);
for
(
Unit
o
:
units
)
{
wos
.
add
(
this
.
convert
(
business
,
o
,
Wo
.
class
));
}
return
wos
;
}
}
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/UnitAction.java
浏览文件 @
93d586e0
...
...
@@ -3,11 +3,7 @@ package com.x.organization.assemble.express.jaxrs.unit;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.*
;
import
javax.ws.rs.container.AsyncResponse
;
import
javax.ws.rs.container.Suspended
;
import
javax.ws.rs.core.Context
;
...
...
@@ -16,6 +12,7 @@ import javax.ws.rs.core.MediaType;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.annotation.JaxrsDescribe
;
import
com.x.base.core.project.annotation.JaxrsMethodDescribe
;
import
com.x.base.core.project.annotation.JaxrsParameterDescribe
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.http.HttpMediaType
;
...
...
@@ -639,4 +636,58 @@ public class UnitAction extends StandardJaxrsAction {
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
,
jsonElement
));
}
@JaxrsMethodDescribe
(
value
=
"批量查询指定组织类型的组织."
,
action
=
ActionListWithTypes
.
class
)
@POST
@Path
(
"list/types"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
listWithTypes
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionListWithTypes
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionListWithTypes
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
,
jsonElement
));
}
@JaxrsMethodDescribe
(
value
=
"批量查询指定组织类型的组织对象."
,
action
=
ActionListWithTypesObject
.
class
)
@POST
@Path
(
"list/types/object"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
listWithTypesObject
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
List
<
ActionListWithTypesObject
.
Wo
>>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionListWithTypesObject
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
,
jsonElement
));
}
@JaxrsMethodDescribe
(
value
=
"查询指定组织类型的组织对象."
,
action
=
ActionListWithTypeObject
.
class
)
@GET
@Path
(
"list/type/{type}/object"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
listWithTypeObject
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"组织类型"
)
@PathParam
(
"type"
)
String
type
)
{
ActionResult
<
List
<
ActionListWithTypeObject
.
Wo
>>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionListWithTypeObject
().
execute
(
effectivePerson
,
type
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
,
null
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录