Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
a946f2a1
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,发现更多精彩内容 >>
提交
a946f2a1
编写于
3月 23, 2021
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化自建表查询表数据接口,允许排序和结果集限制
上级
3ed607f5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
109 addition
and
0 deletion
+109
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/table/ActionListRowSelect.java
...ery/assemble/surface/jaxrs/table/ActionListRowSelect.java
+90
-0
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/table/TableAction.java
...com/x/query/assemble/surface/jaxrs/table/TableAction.java
+19
-0
未找到文件。
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/table/ActionListRowSelect.java
0 → 100644
浏览文件 @
a946f2a1
package
com.x.query.assemble.surface.jaxrs.table
;
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.entity.dynamic.DynamicEntity
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
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.query.assemble.surface.Business
;
import
com.x.query.core.entity.schema.Table
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.persistence.EntityManager
;
import
java.util.List
;
class
ActionListRowSelect
extends
BaseAction
{
ActionResult
<
List
<?>>
execute
(
EffectivePerson
effectivePerson
,
String
tableFlag
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
List
<?>>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Table
table
=
emc
.
flag
(
tableFlag
,
Table
.
class
);
Business
business
=
new
Business
(
emc
);
if
(
null
==
table
)
{
throw
new
ExceptionEntityNotExist
(
tableFlag
,
Table
.
class
);
}
if
(!
business
.
editable
(
effectivePerson
,
table
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
,
table
);
}
DynamicEntity
dynamicEntity
=
new
DynamicEntity
(
table
.
getName
());
@SuppressWarnings
(
"unchecked"
)
Class
<?
extends
JpaObject
>
clz
=
(
Class
<
JpaObject
>)
Class
.
forName
(
dynamicEntity
.
className
());
EntityManager
em
=
emc
.
get
(
clz
);
String
sql
=
"SELECT o FROM "
+
clz
.
getName
()
+
" o"
;
if
(
StringUtils
.
isNotBlank
(
wi
.
getWhere
()))
{
sql
+=
" where "
+
wi
.
getWhere
();
}
if
(
StringUtils
.
isNotBlank
(
wi
.
getOrderBy
()))
{
sql
+=
" order by "
+
wi
.
getOrderBy
();
}
List
<?>
list
;
if
(
wi
.
getSize
()!=
null
&&
wi
.
getSize
()>
0
){
list
=
em
.
createQuery
(
sql
).
setMaxResults
(
wi
.
getSize
()).
getResultList
();
}
else
{
list
=
em
.
createQuery
(
sql
).
getResultList
();
}
result
.
setData
(
list
);
return
result
;
}
}
public
static
class
Wi
extends
GsonPropertyObject
{
@FieldDescribe
(
"查询条件,格式为jpql语法,o.name='zhangsan',允许为空"
)
private
String
where
;
@FieldDescribe
(
"排序条件,格式为:o.updateTime desc,允许为空"
)
private
String
orderBy
;
@FieldDescribe
(
"返回结果集数量,允许为空"
)
private
Integer
size
;
public
String
getWhere
()
{
return
where
;
}
public
void
setWhere
(
String
where
)
{
this
.
where
=
where
;
}
public
String
getOrderBy
()
{
return
orderBy
;
}
public
void
setOrderBy
(
String
orderBy
)
{
this
.
orderBy
=
orderBy
;
}
public
Integer
getSize
()
{
return
size
;
}
public
void
setSize
(
Integer
size
)
{
this
.
size
=
size
;
}
}
}
o2server/x_query_assemble_surface/src/main/java/com/x/query/assemble/surface/jaxrs/table/TableAction.java
浏览文件 @
a946f2a1
...
...
@@ -111,6 +111,25 @@ public class TableAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"根据条件获取表中的数据"
,
action
=
ActionListRowSelect
.
class
)
@POST
@Path
(
"list/{tableFlag}/row/select"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
listRowSelect
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@JaxrsParameterDescribe
(
"表标识"
)
@PathParam
(
"tableFlag"
)
String
tableFlag
,
JsonElement
jsonElement
)
{
ActionResult
<
List
<?>>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionListRowSelect
().
execute
(
effectivePerson
,
tableFlag
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
jsonElement
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"通过where 统计数量"
,
action
=
ActionRowCountWhere
.
class
)
@GET
@Path
(
"{tableFlag}/row/count/where/{where}"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录