Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
446faeb7
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
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,发现更多精彩内容 >>
提交
446faeb7
编写于
11月 03, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加根据职务名称和组织查询职务信息接口
上级
dc08c237
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
123 addition
and
7 deletion
+123
-7
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/ActionGetWithUnitWithName.java
...ble/express/jaxrs/unitduty/ActionGetWithUnitWithName.java
+104
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/BaseAction.java
...anization/assemble/express/jaxrs/unitduty/BaseAction.java
+1
-7
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/UnitDutyAction.java
...ation/assemble/express/jaxrs/unitduty/UnitDutyAction.java
+18
-0
未找到文件。
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/ActionGetWithUnitWithName.java
0 → 100644
浏览文件 @
446faeb7
package
com.x.organization.assemble.express.jaxrs.unitduty
;
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.entity.JpaObject
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
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.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.UnitDuty
;
import
com.x.organization.core.entity.UnitDuty_
;
import
org.apache.commons.lang3.StringUtils
;
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.List
;
import
java.util.Optional
;
class
ActionGetWithUnitWithName
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
<>();
Business
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isBlank
(
wi
.
getName
())
||
StringUtils
.
isBlank
(
wi
.
getUnit
())){
return
result
;
}
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getName
(),
wi
.
getUnit
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
Wo
)
optional
.
get
());
}
else
{
Wo
wo
=
this
.
getUnitDutity
(
business
,
wi
.
getName
(),
wi
.
getUnit
());
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
result
.
setData
(
wo
);
}
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"职务名称"
)
private
String
name
;
@FieldDescribe
(
"组织"
)
private
String
unit
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
}
public
static
class
Wo
extends
UnitDuty
{
private
static
final
long
serialVersionUID
=
-
8346394290549763465L
;
static
WrapCopier
<
UnitDuty
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
UnitDuty
.
class
,
Wo
.
class
,
null
,
JpaObject
.
FieldsInvisible
);
}
private
Wo
getUnitDutity
(
Business
business
,
String
name
,
String
unitFlag
)
throws
Exception
{
Wo
wo
=
null
;
Unit
unit
=
business
.
unit
().
pick
(
unitFlag
);
if
(
null
!=
unit
)
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
UnitDuty
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
UnitDuty
>
cq
=
cb
.
createQuery
(
UnitDuty
.
class
);
Root
<
UnitDuty
>
root
=
cq
.
from
(
UnitDuty
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
UnitDuty_
.
unit
),
unit
.
getId
());
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
UnitDuty_
.
name
),
name
));
List
<
UnitDuty
>
os
=
em
.
createQuery
(
cq
.
select
(
root
).
where
(
p
)).
getResultList
();
if
(!
os
.
isEmpty
())
{
wo
=
Wo
.
copier
.
copy
(
os
.
get
(
0
));
}
}
return
wo
;
}
}
\ No newline at end of file
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/BaseAction.java
浏览文件 @
446faeb7
...
@@ -15,21 +15,15 @@ import com.x.base.core.project.gson.GsonPropertyObject;
...
@@ -15,21 +15,15 @@ import com.x.base.core.project.gson.GsonPropertyObject;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Group
;
import
com.x.organization.core.entity.Identity
;
import
com.x.organization.core.entity.Identity
;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.PersonAttribute
;
import
com.x.organization.core.entity.Role
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.Unit
;
import
com.x.organization.core.entity.UnitAttribute
;
import
com.x.organization.core.entity.UnitDuty
;
import
com.x.organization.core.entity.UnitDuty
;
import
com.x.organization.core.entity.UnitDuty_
;
import
com.x.organization.core.entity.UnitDuty_
;
import
com.x.organization.core.entity.accredit.Empower
;
class
BaseAction
extends
StandardJaxrsAction
{
class
BaseAction
extends
StandardJaxrsAction
{
CacheCategory
cacheCategory
=
new
CacheCategory
(
Identity
.
class
,
Unit
.
class
,
UnitAttribute
.
class
,
UnitDuty
.
class
,
CacheCategory
cacheCategory
=
new
CacheCategory
(
Identity
.
class
,
Unit
.
class
,
UnitDuty
.
class
);
Role
.
class
,
Person
.
class
,
PersonAttribute
.
class
,
Group
.
class
,
Empower
.
class
);
protected
List
<
String
>
listUnitDutyDistinguishedNameSorted
(
Business
business
,
List
<
String
>
unitDutyIds
)
protected
List
<
String
>
listUnitDutyDistinguishedNameSorted
(
Business
business
,
List
<
String
>
unitDutyIds
)
throws
Exception
{
throws
Exception
{
...
...
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unitduty/UnitDutyAction.java
浏览文件 @
446faeb7
...
@@ -137,4 +137,22 @@ public class UnitDutyAction extends StandardJaxrsAction {
...
@@ -137,4 +137,22 @@ public class UnitDutyAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
@JaxrsMethodDescribe
(
value
=
"根据组织和职务名称获取职务信息."
,
action
=
ActionGetWithUnitWithName
.
class
)
@POST
@Path
(
"find/by/unit/name"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
getWithUnitWithName
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionGetWithUnitWithName
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionGetWithUnitWithName
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录