Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Springboot Plus
Commits
d60932de
Commit
d60932de
authored
Aug 25, 2021
by
andnnl
Browse files
时间范围查询条件字段都需要加@Query
parent
cd8cb3a6
Changes
5
Hide whitespace changes
Inline
Side-by-side
admin-core/src/main/resources/codeTemplate/java/controller.java
View file @
d60932de
...
...
@@ -96,12 +96,17 @@ public class ${entity.name}Controller{
\
@PostMapping
(
MODEL
+
"/list.json"
)
\
@Function
(
"${basicfunctionCode}.query"
)
\
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
$
{
entity
.
name
}
Query
condtion
)
public
JsonResult
<
PageResult
<
$
{
entity
.
name
}>>
list
(
$
{
entity
.
name
}
Query
condition
)
{
PageResult
<
$
{
entity
.
name
}>
pageResult
=
$
{
service
}.
queryByCondition
(
condition
);
return
JsonResult
.
success
(
pageResult
);
}
/* public JsonResult<PageQuery> list(${entity.name}Query condtion)
{
PageQuery page = condtion.getPageQuery();
${service}.queryByCondition(page);
return JsonResult.success(page);
}
}
*/
\
@PostMapping
(
MODEL
+
"/add.json"
)
\
@Function
(
"${basicfunctionCode}.add"
)
...
...
@@ -151,20 +156,26 @@ public class ${entity.name}Controller{
\
@PostMapping
(
MODEL
+
"/excel/export.json"
)
\
@Function
(
"${basicfunctionCode}.export"
)
\
@ResponseBody
public
JsonResult
<
String
>
export
(
HttpServletResponse
response
,
$
{
entity
.
name
}
Query
condtion
)
{
public
JsonResult
<
String
>
export
(
HttpServletResponse
response
,
$
{
entity
.
name
}
Query
cond
i
tion
)
{
/**
* 1)需要用你自己编写一个的excel模板
* 2)通常excel导出需要关联更多数据,因此${service}.queryByCondition方法经常不符合需求,需要重写一个为模板导出的查询
* 3)参考ConsoleDictController来实现模板导入导出
*/
String
excelTemplate
=
"excelTemplates/${target.urlBase}/${entity.code}/你的excel模板文件名字.xls"
;
PageQuery
<
$
{
entity
.
name
}>
page
=
condtion
.
getPageQuery
();
// PageQuery<${entity.name}> page = condtion.getPageQuery();
PageRequest
<
$
{
entity
.
name
>
page
=
condition
.
getPageRequest
();
condition
.
setPage
(
1
);
condition
.
setLimit
(
Integer
.
MAX_VALUE
);
//取出全部符合条件的
page
.
setPageSize
(
Integer
.
MAX_VALUE
);
page
.
setPageNumber
(
1
);
page
.
setTotalRow
(
Integer
.
MAX_VALUE
);
// page.setPageSize(Integer.MAX_VALUE);
// page.setPageNumber(1);
// page.setTotalRow(Integer.MAX_VALUE);
//本次导出需要的数据
PageResult
<
$
{
entity
.
name
}>
pageResult
=
$
{
service
}.
queryByCondition
(
condition
);
//本次导出需要的数据
List
<
$
{
entity
.
name
}>
list
=
$
{
service
}.
queryByCondition
(
page
).
getList
();
List
<
$
{
entity
.
name
}>
list
=
pageResult
.
getList
();
// List<${entity.name}> list =${service}.queryByCondition(page).getList();
try
(
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
excelTemplate
))
{
if
(
is
==
null
)
{
throw
new
PlatformException
(
"模板资源不存在:"
+
excelTemplate
);
...
...
admin-core/src/main/resources/codeTemplate/java/dao.java
View file @
d60932de
package
${
package
};
import
java.util.List
;
import
java.util.Map
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
org.beetl.sql.mapper.BaseMapper
;
...
...
@@ -9,6 +10,7 @@ import org.beetl.sql.core.page.PageRequest;
import
org.beetl.sql.core.page.PageResult
;
import
org.beetl.sql.mapper.BaseMapper
;
import
org.beetl.sql.mapper.annotation.Root
;
import
org.springframework.stereotype.Component
;
import
${
basePackage
}.
entity
.*;
...
...
@@ -16,6 +18,7 @@ import ${basePackage}.entity.*;
* ${entity.displayName} Dao
*/
\
@SqlResource
(
"${entity.system}.${entity.code}"
)
\
@Component
public
interface
${
entity
.
name
}
Dao
extends
BaseMapper
<
$
{
entity
.
name
}>{
public
PageResult
<
$
{
entity
.
name
}>
queryByCondition
(
PageRequest
request
,
\
@Root
Map
params
);
public
void
batchDel
$
{
entity
.
name
}
ByIds
(
List
<
Long
>
ids
);
...
...
admin-core/src/main/resources/codeTemplate/java/pojo.java
View file @
d60932de
...
...
@@ -6,8 +6,13 @@ import javax.validation.constraints.NotBlank;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Null
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.ibeetl.admin.core.entity.BaseEntity
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
org.beetl.sql.annotation.entity.AutoID
;
import
org.beetl.sql.annotation.entity.SeqID
;
import
org.beetl.sql.annotation.entity.InsertIgnore
;
import
org.beetl.sql.annotation.entity.UpdateIgnore
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
...
...
@@ -17,9 +22,7 @@ import java.math.*;
import
com.ibeetl.admin.core.annotation.Dict
;
import
com.ibeetl.admin.core.entity.BaseEntity
;
import
org.beetl.sql.core.annotatoin.InsertIgnore
;
import
org.beetl.sql.core.annotatoin.Version
;
import
org.beetl.sql.core.annotatoin.LogicDelete
;
/*
...
...
admin-core/src/main/resources/codeTemplate/java/query.java
View file @
d60932de
...
...
@@ -22,7 +22,9 @@ public class ${entity.name}Query extends PageParam {
@
}
else
if
(
attr
.
dateTimeRange
)
{
\
@Query
(
name
=
"${attr.displayName}"
,
display
=
true
,
type
=
Query
.
TYPE_DATETIME_BETWEEN
)
private
String
$
{
attr
.
name
};
\
@Query
(
name
=
"${attr.displayName}"
,
display
=
false
)
private
Date
$
{
strutil
.
replace
(
attr
.
name
,
"Range"
,
""
)}
Start
;
\
@Query
(
name
=
"${attr.displayName}"
,
display
=
false
)
private
Date
$
{
strutil
.
replace
(
attr
.
name
,
"Range"
,
""
)}
End
;
@
}
else
{
\
@Query
(
name
=
"${attr.displayName}"
,
display
=
true
)
...
...
@@ -31,6 +33,7 @@ public class ${entity.name}Query extends PageParam {
@
}
@for
(
attr
in
attrs
)
{
@if
(
attr
.
dateRange
)
{
public
String
get
$
{
upperFirst
(
attr
.
name
)}(){
return
$
{
attr
.
name
};
}
...
...
admin-core/src/main/resources/codeTemplate/java/service.java
View file @
d60932de
...
...
@@ -13,7 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
org.beetl.sql.core.page.PageRequest
;
import
org.beetl.sql.core.page.PageResult
;
...
...
@@ -29,8 +30,16 @@ public class ${entity.name}Service extends CoreBaseService<${entity.name}>{
\
@Autowired
private
$
{
entity
.
name
}
Dao
$
{
entity
.
code
}
Dao
;
public
PageQuery
<
$
{
entity
.
name
}>
queryByCondition
(
PageQuery
query
){
PageQuery
ret
=
$
{
entity
.
code
}
Dao
.
queryByCondition
(
query
);
// public PageQuery<${entity.name}>queryByCondition(PageQuery query){
// PageQuery ret = ${entity.code}Dao.queryByCondition(query);
// queryListAfter(ret.getList());
// return ret;
// }
public
PageResult
<
$
{
entity
.
name
}>
queryByCondition
(
$
{
entity
.
name
}
Query
condition
)
{
PageRequest
pageRequest
=
condition
.
getPageRequest
();
Map
params
=
condition
.
getPageParam
();
PageResult
ret
=
$
{
entity
.
code
}
Dao
.
queryByCondition
(
pageRequest
,
params
);
queryListAfter
(
ret
.
getList
());
return
ret
;
}
...
...
Write
Preview
Supports
Markdown
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