Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
16187b87
o2oa
项目概览
fuyue82
/
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,发现更多精彩内容 >>
提交
16187b87
编写于
10月 16, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加校验身份是否是指定组织的成员接口;
增加校验用户是否在指定组织中注册身份接口;
上级
4047a4d4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
253 addition
and
0 deletion
+253
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionHasIdentity.java
...zation/assemble/express/jaxrs/unit/ActionHasIdentity.java
+104
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionHasPerson.java
...nization/assemble/express/jaxrs/unit/ActionHasPerson.java
+113
-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
+36
-0
未找到文件。
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionHasIdentity.java
0 → 100644
浏览文件 @
16187b87
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.jaxrs.WrapBoolean
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Identity
;
import
com.x.organization.core.entity.Unit
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
import
java.util.Optional
;
class
ActionHasIdentity
extends
BaseAction
{
/*** 校验身份是否是指定组织的成员 */
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Business
business
=
new
Business
(
emc
);
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getIdentity
(),
wi
.
getUnit
(),
wi
.
getRecursive
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
Wo
)
optional
.
get
());
}
else
{
Wo
wo
=
new
Wo
();
wo
.
setValue
(
this
.
hasIdentity
(
business
,
wi
));
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
result
.
setData
(
wo
);
}
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"*身份"
)
private
String
identity
;
@FieldDescribe
(
"*组织"
)
private
String
unit
;
@FieldDescribe
(
"*是否递归查找组织(true|false)"
)
private
Boolean
recursive
=
true
;
public
String
getIdentity
()
{
return
identity
;
}
public
void
setIdentity
(
String
identity
)
{
this
.
identity
=
identity
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
Boolean
getRecursive
()
{
return
recursive
;
}
public
void
setRecursive
(
Boolean
recursive
)
{
this
.
recursive
=
recursive
;
}
}
public
static
class
Wo
extends
WrapBoolean
{
}
private
boolean
hasIdentity
(
Business
business
,
Wi
wi
)
throws
Exception
{
boolean
result
=
false
;
if
(
StringUtils
.
isNotBlank
(
wi
.
getIdentity
())
&&
StringUtils
.
isNotBlank
(
wi
.
getUnit
()))
{
Identity
identity
=
business
.
identity
().
pick
(
wi
.
getIdentity
());
Unit
unit
=
business
.
unit
().
pick
(
wi
.
getUnit
());
if
(
identity
!=
null
&&
unit
!=
null
)
{
if
(
unit
.
getId
().
equals
(
identity
.
getUnit
()))
{
result
=
true
;
}
else
if
(
BooleanUtils
.
isTrue
(
wi
.
getRecursive
()))
{
List
<
String
>
units
=
business
.
unit
().
listSupNested
(
identity
.
getUnit
());
if
(
units
.
contains
(
unit
.
getId
()))
{
result
=
true
;
}
}
}
}
return
result
;
}
}
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/ActionHasPerson.java
0 → 100644
浏览文件 @
16187b87
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.jaxrs.WrapBoolean
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.core.entity.Identity
;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.Unit
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
import
java.util.Optional
;
class
ActionHasPerson
extends
BaseAction
{
/*** 校验用户是否在指定组织中注册身份 */
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Business
business
=
new
Business
(
emc
);
CacheKey
cacheKey
=
new
CacheKey
(
this
.
getClass
(),
wi
.
getPerson
(),
wi
.
getUnit
(),
wi
.
getRecursive
());
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
result
.
setData
((
Wo
)
optional
.
get
());
}
else
{
Wo
wo
=
new
Wo
();
wo
.
setValue
(
this
.
hasIdentity
(
business
,
wi
));
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
result
.
setData
(
wo
);
}
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"*用户"
)
private
String
person
;
@FieldDescribe
(
"*组织"
)
private
String
unit
;
@FieldDescribe
(
"*是否递归查找组织(true|false)"
)
private
Boolean
recursive
=
true
;
public
String
getPerson
()
{
return
person
;
}
public
void
setPerson
(
String
person
)
{
this
.
person
=
person
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
Boolean
getRecursive
()
{
return
recursive
;
}
public
void
setRecursive
(
Boolean
recursive
)
{
this
.
recursive
=
recursive
;
}
}
public
static
class
Wo
extends
WrapBoolean
{
}
private
boolean
hasIdentity
(
Business
business
,
Wi
wi
)
throws
Exception
{
boolean
result
=
false
;
if
(
StringUtils
.
isNotBlank
(
wi
.
getPerson
())
&&
StringUtils
.
isNotBlank
(
wi
.
getUnit
()))
{
Person
person
=
business
.
person
().
pick
(
wi
.
getPerson
());
if
(
person
!=
null
)
{
List
<
Identity
>
identityList
=
business
.
identity
().
listByPerson
(
person
.
getId
());
Unit
unit
=
business
.
unit
().
pick
(
wi
.
getUnit
());
if
(
identityList
!=
null
&&
!
identityList
.
isEmpty
()
&&
unit
!=
null
)
{
List
<
String
>
units
=
ListTools
.
extractProperty
(
identityList
,
Identity
.
unit_FIELDNAME
,
String
.
class
,
true
,
true
);
if
(
units
.
contains
(
unit
.
getId
()))
{
result
=
true
;
}
else
if
(
BooleanUtils
.
isTrue
(
wi
.
getRecursive
()))
{
for
(
String
unitId
:
units
){
List
<
String
>
units2
=
business
.
unit
().
listSupNested
(
unitId
);
if
(
units2
.
contains
(
unit
.
getId
()))
{
result
=
true
;
break
;
}
}
}
}
}
}
return
result
;
}
}
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/unit/UnitAction.java
浏览文件 @
16187b87
...
...
@@ -585,4 +585,40 @@ public class UnitAction extends StandardJaxrsAction {
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"校验身份是否是指定组织的成员."
,
action
=
ActionHasIdentity
.
class
)
@POST
@Path
(
"check/unit/has/identity"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
checkHasIdentity
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionHasIdentity
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionHasIdentity
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"校验用户是否在指定组织中注册身份."
,
action
=
ActionHasPerson
.
class
)
@POST
@Path
(
"check/unit/has/person"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
checkHasPerson
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionHasPerson
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionHasPerson
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录