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
321361c9
Commit
321361c9
authored
Feb 21, 2018
by
xiandafu
Browse files
init
parent
2971e3f1
Changes
449
Hide whitespace changes
Inline
Side-by-side
admin-core/src/main/java/com/ibeetl/admin/core/web/SimulateController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.web
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.beetl.ext.simulate.WebSimulate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
/**
* 模拟所有还未实现的视图,或者json,或者直接访问相应的html页面
* @author xiandafu
*
*/
@Controller
public
class
SimulateController
{
@Autowired
WebSimulate
webSimulate
;
@RequestMapping
(
"/**/*.do"
)
public
void
simluateWeb
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
response
.
setContentType
(
"text/html;charset=UTF-8"
);
webSimulate
.
execute
(
request
,
response
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/web/query/PageParam.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.web.query
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.beetl.sql.core.engine.PageQuery
;
/**
* 子类继承此类获得翻页功能
* @author lijiazhi
*/
public
class
PageParam
{
private
Integer
page
=
null
;
private
Integer
limit
=
null
;
public
Integer
getPage
()
{
return
page
;
}
public
void
setPage
(
Integer
page
)
{
this
.
page
=
page
;
}
@JsonIgnore
public
PageQuery
getPageQuery
()
{
PageQuery
query
=
new
PageQuery
();
query
.
setParas
(
this
);
if
(
page
!=
null
)
{
query
.
setPageNumber
(
page
);
query
.
setPageSize
(
limit
);
}
return
query
;
}
public
Integer
getLimit
()
{
return
limit
;
}
public
void
setLimit
(
Integer
limit
)
{
this
.
limit
=
limit
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/web/query/QueryData.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.web.query
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
QueryData
{
List
<
QueryItem
>
all
=
new
ArrayList
<>();
List
<
QueryItem
>
defaultItems
=
new
ArrayList
<>();
public
List
<
QueryItem
>
getQueryItems
(){
return
all
;
}
public
List
<
QueryItem
>
getDefaultItems
(){
return
defaultItems
;
}
public
void
addQueryItem
(
QueryItem
item
){
all
.
add
(
item
);
if
(
item
.
isShow
()){
defaultItems
.
add
(
item
);
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/web/query/QueryItem.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.web.query
;
/**
* 查询选项
* @author lijiazhi
*
*/
public
class
QueryItem
{
private
String
fieldName
;
private
String
name
;
private
int
type
=
1
;
private
boolean
show
=
false
;
private
String
dictName
=
""
;
private
boolean
fuzzy
=
false
;
private
String
group
=
null
;
public
String
getFieldName
()
{
return
fieldName
;
}
public
void
setFieldName
(
String
fieldName
)
{
this
.
fieldName
=
fieldName
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
int
getType
()
{
return
type
;
}
public
void
setType
(
int
type
)
{
this
.
type
=
type
;
}
public
boolean
isShow
()
{
return
show
;
}
public
void
setShow
(
boolean
show
)
{
this
.
show
=
show
;
}
public
String
getDictName
()
{
return
dictName
;
}
public
void
setDictName
(
String
dictName
)
{
this
.
dictName
=
dictName
;
}
public
boolean
isFuzzy
()
{
return
fuzzy
;
}
public
void
setFuzzy
(
boolean
fuzzy
)
{
this
.
fuzzy
=
fuzzy
;
}
public
String
getGroup
()
{
return
group
;
}
public
void
setGroup
(
String
group
)
{
this
.
group
=
group
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/web/query/QueryParser.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.web.query
;
import
java.lang.reflect.Field
;
import
java.util.concurrent.ConcurrentHashMap
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.util.ClassLoaderUtil
;
/**
* 页面查询条件
* @author lijiazhi
*
*/
public
class
QueryParser
{
ConcurrentHashMap
<
String
,
QueryData
>
cache
=
new
ConcurrentHashMap
<>
();
public
QueryData
getData
(
String
querClass
){
if
(
cache
.
containsKey
(
querClass
)){
return
cache
.
get
(
querClass
);
}
Class
cls
=
ClassLoaderUtil
.
loadClass
(
querClass
);
Field
[]
fs
=
cls
.
getDeclaredFields
();
QueryData
data
=
new
QueryData
();
for
(
Field
f:
fs
){
Query
query
=
f
.
getAnnotation
(
Query
.
class
);
if
(
query
==
null
){
continue
;
}
QueryItem
item
=
new
QueryItem
();
item
.
setFieldName
(
f
.
getName
());
item
.
setName
(
query
.
name
());
item
.
setShow
(
query
.
display
());
item
.
setType
(
query
.
type
());
item
.
setDictName
(
query
.
dict
());
item
.
setFuzzy
(
query
.
fuzzy
());
item
.
setGroup
(
query
.
group
());
data
.
addQueryItem
(
item
);
}
cache
.
put
(
querClass
,
data
);
return
data
;
}
}
admin-core/src/main/resources/META-INF/spring-devtools.properties
0 → 100644
View file @
321361c9
restart.include.beetl
=
/beetl-2.7.12.jar
restart.include.beetlsql
=
/beetlsql-2.8.5.jar
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/html/add.html
0 → 100644
View file @
321361c9
<!--# layout("/common/layout.html",{"jsBase":"/js/${target.urlBase}/${entity.code}/"}){ -->
<form
class=
"layui-form layui-form-pane"
id=
"addForm"
action=
"/${target.urlBase}/${entity.code}/add.json"
>
@ var list = entity.generalList;
@ var size = list.~size; /*一行显示俩个,生成后在根据显示要求调整*/
@ for(var i=0;i
<size
;
i
++){
@
var
item0=
list[i];
@
var
item1=
(size-i==1)?null:list[i+1];
@
i=
i+1;
@
var
array =
[item0,item1];
<
div
class=
"layui-row"
>
<div
class=
"layui-form-item"
>
@for(item in array){
@if(item==null){continue;}
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
${item.displayName}
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"${item.name}"
class=
"layui-input"
>
</div>
</div>
@}
</div>
</div>
@}
<layui:submitButtons
id=
"addButton"
/>
</form>
<!--#} -->
<script>
layui
.
use
([
'
add
'
],
function
(){
var
$
{
entity
.
code
}
Add
=
layui
.
add
$
{
entity
.
code
}
Add
.
init
();
});
</script>
admin-core/src/main/resources/codeTemplate/html/edit.html
0 → 100644
View file @
321361c9
<!--# layout("/common/layout.html",{"jsBase":"/js/${target.urlBase}/${entity.code}/"}){ -->
<form
class=
"layui-form layui-form-pane"
id=
"updateForm"
action=
"/${target.urlBase}/${entity.code}/update.json"
>
@ var list = entity.generalList;
@ var size = list.~size; /*一行显示俩个,生成后在根据显示要求调整*/
@ for(var i=0;i
<size
;
i
++){
@
var
item0=
list[i];
@
var
item1=
(size-i==1)?null:list[i+1];
@
i=
i+1;
@
var
array =
[item0,item1];
<
div
class=
"layui-row"
>
<div
class=
"layui-form-item"
>
@for(item in array){
@if(item==null){continue;}
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
${item.displayName}
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"${item.name}"
value=
"\${${entity.code}.${item.name}}"
class=
"layui-input"
>
</div>
</div>
@}
</div>
</div>
@}
<input
type=
"hidden"
name=
"${entity.idAttribute.name}"
value=
\${${entity.code}.${entity.idAttribute.name}}
/>
<layui:submitButtons
id=
"updateButton"
/>
</form>
<!--#} -->
<script>
layui
.
use
([
'
edit
'
],
function
(){
var
$
{
entity
.
code
}
Edit
=
layui
.
edit
$
{
entity
.
code
}
Edit
.
init
();
});
</script>
admin-core/src/main/resources/codeTemplate/html/index.html
0 → 100644
View file @
321361c9
<!--#layout("/common/layout.html",{"jsBase":"/js/${target.urlBase}/${entity.code}/"}){ -->
<layui:searchForm
formId=
"searchForm"
condition=
"\${search}"
>
</layui:searchForm>
<div
class=
"layui-btn-group"
>
<layui:accessButton
function=
"${entity.code}.add"
action=
"add"
>
增加
</layui:accessButton>
<layui:accessButton
function=
"${entity.code}.edit"
action=
"edit"
>
编辑
</layui:accessButton>
<layui:accessButton
function=
"${entity.code}.del"
action=
"del"
>
删除
</layui:accessButton>
</div>
<table
id=
"${entity.code}Table"
lay-filter=
"${entity.code}Table"
></table>
<!--#} -->
<script>
layui
.
use
([
'
index
'
],
function
(){
var
index
=
layui
.
index
index
.
init
();
});
</script>
admin-core/src/main/resources/codeTemplate/java/controller.java
0 → 100644
View file @
321361c9
package
${
package
};
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.web.JsonResult
;
import
com.ibeetl.admin.core.util.*
;
import
${
basePackage
}.
entity
.*;
import
${
basePackage
}.
service
.*;
import
${
basePackage
}.
web
.
query
.*;
/**
* ${entity.displayName} 接口
*/
\
@Controller
public
class
${
entity
.
name
}
Controller
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/${target.urlBase}/${entity.code}"
;
@var
service
=
entity
.
code
+
"Service"
;
\
@Autowired
private
$
{
entity
.
name
}
Service
$
{
service
};
/* 页面 */
\
@GetMapping
(
MODEL
+
"/index.do"
)
\
@Function
(
"${entity.code}.query"
)
\
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/${target.urlBase}/${entity.code}/index.html"
)
;
view
.
addObject
(
"search"
,
$
{
entity
.
name
}
Query
.
class
.
getName
());
return
view
;
}
\
@GetMapping
(
MODEL
+
"/edit.do"
)
\
@Function
(
"${entity.code}.edit"
)
\
@ResponseBody
public
ModelAndView
edit
(
$
{
entity
.
idAttribute
.
javaType
}
$
{
entity
.
idAttribute
.
name
})
{
ModelAndView
view
=
new
ModelAndView
(
"/${target.urlBase}/${entity.code}/edit.html"
);
$
{
entity
.
name
}
$
{
entity
.
code
}
=
$
{
service
}.
queryById
(
$
{
entity
.
idAttribute
.
name
});
view
.
addObject
(
"${entity.code}"
,
$
{
entity
.
code
});
return
view
;
}
\
@GetMapping
(
MODEL
+
"/add.do"
)
\
@Function
(
"${entity.code}.add"
)
\
@ResponseBody
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/${target.urlBase}/${entity.code}/add.html"
);
return
view
;
}
/* ajax json */
\
@PostMapping
(
MODEL
+
"/list.json"
)
\
@Function
(
"${entity.code}.query"
)
\
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
$
{
entity
.
name
}
Query
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
$
{
service
}.
queryByCondition
(
page
);
return
JsonResult
.
success
(
page
);
}
\
@PostMapping
(
MODEL
+
"/add.json"
)
\
@Function
(
"${entity.code}.add"
)
\
@ResponseBody
public
JsonResult
add
(
\
@Validated
(
ValidateConfig
.
ADD
.
class
)
$
{
entity
.
name
}
$
{
entity
.
code
})
{
$
{
service
}.
save
(
$
{
entity
.
code
});
return
new
JsonResult
().
success
();
}
\
@PostMapping
(
MODEL
+
"/update.json"
)
\
@Function
(
"${entity.code}.update"
)
\
@ResponseBody
public
JsonResult
<
String
>
update
(
\
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
$
{
entity
.
name
}
$
{
entity
.
code
})
{
boolean
success
=
$
{
service
}.
update
(
$
{
entity
.
code
});
if
(
success
)
{
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
\
@GetMapping
(
MODEL
+
"/view.json"
)
\
@Function
(
"${entity.code}.query"
)
\
@ResponseBody
public
JsonResult
<
$
{
entity
.
name
}>
queryInfo
(
$
{
entity
.
idAttribute
.
javaType
}
$
{
entity
.
idAttribute
.
name
})
{
$
{
entity
.
name
}
$
{
entity
.
code
}
=
$
{
service
}.
queryById
(
$
{
entity
.
idAttribute
.
name
});
return
JsonResult
.
success
(
$
{
entity
.
code
});
}
\
@PostMapping
(
MODEL
+
"/delete.json"
)
\
@Function
(
"${entity.code}.delete"
)
\
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
if
(
ids
.
endsWith
(
","
))
{
ids
=
StringUtils
.
substringBeforeLast
(
ids
,
","
);
}
List
<
Long
>
idList
=
ConvertUtil
.
str2longs
(
ids
);
$
{
service
}.
batchDel
$
{
entity
.
name
}(
idList
);
return
new
JsonResult
().
success
();
}
}
admin-core/src/main/resources/codeTemplate/java/dao.java
0 → 100644
View file @
321361c9
package
${
package
};
import
java.util.List
;
import
org.beetl.sql.core.annotatoin.SqlResource
;
import
org.beetl.sql.core.mapper.BaseMapper
;
import
org.beetl.sql.core.engine.PageQuery
;
import
${
basePackage
}.
entity
.*;
/**
* ${entity.displayName} Dao
*/
\
@SqlResource
(
"${entity.system}.${entity.code}"
)
public
interface
${
entity
.
name
}
Dao
extends
BaseMapper
<
$
{
entity
.
name
}>{
public
PageQuery
<
$
{
entity
.
name
}>
queryByCondition
(
PageQuery
query
);
public
void
batchDel
$
{
entity
.
name
}
ByIds
(
List
<
Long
>
ids
);
}
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/java/pojo.java
0 → 100644
View file @
321361c9
package
${
package
};
import
java.util.Date
;
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.util.ValidateConfig
;
import
org.beetl.sql.core.TailBean
;
import
java.math.*
;
import
com.ibeetl.admin.core.entity.BaseEntity
;
/*
* ${comment}
* gen by Spring Boot2 Admin ${date(),"yyyy-MM-dd"}
*/
public
class
${
className
}
extends
BaseEntity
{
@for
(
attr
in
attrs
){
@if
(!
isEmpty
(
attr
.
comment
)){
//${attr.comment}
@
}
@if
(
attr
.
isId
)
{
\
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
\
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
\
@AutoID
@
}
private
$
{
attr
.
type
}
$
{
attr
.
name
}
;
@
}
public
$
{
className
}()
{
}
@for
(
attr
in
attrs
){
@if
(!
isEmpty
(
attr
.
comment
)){
/**${attr.comment}
*\@return
*/
@
}
public
$
{
attr
.
type
}
get
$
{
attr
.
methodName
}(){
return
$
{
attr
.
name
};
}
@if
(!
isEmpty
(
attr
.
comment
)){
/**${attr.comment}
*\@param ${attr.name}
*/
@
}
public
void
set
$
{
attr
.
methodName
}(
$
{
attr
.
type
}
$
{
attr
.
name
}){
this
.
$
{
attr
.
name
}
=
$
{
attr
.
name
};
}
@
}
}
admin-core/src/main/resources/codeTemplate/java/query.java
0 → 100644
View file @
321361c9
package
${
package
};
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
import
com.ibeetl.admin.core.web.query.PageParam
;
import
java.util.Date
;
/**
*${entity.displayName}查询
*/
public
class
${
entity
.
name
}
Query
extends
PageParam
{
@for
(
attr
in
attrs
)
{
\
@Query
(
name
=
"${attr.displayName}"
,
display
=
true
)
private
$
{
attr
.
javaType
}
$
{
attr
.
name
};
@
}
@for
(
attr
in
attrs
)
{
public
$
{
attr
.
javaType
}
get
$
{
upperFirst
(
attr
.
name
)}(){
return
$
{
attr
.
name
};
}
public
void
set
$
{
upperFirst
(
attr
.
name
)}(
$
{
attr
.
javaType
}
$
{
attr
.
name
}
){
this
.
$
{
attr
.
name
}
=
$
{
attr
.
name
};
}
@
}
}
admin-core/src/main/resources/codeTemplate/java/service.java
0 → 100644
View file @
321361c9
package
${
package
};
import
java.util.List
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
${
basePackage
}.
dao
.
$
{
entity
.
name
}
Dao
;
import
${
basePackage
}.
entity
.
$
{
entity
.
name
};
import
com.ibeetl.admin.core.service.BaseService
;
/**
* ${entity.displayName} Service
*/
\
@Service
\
@Transactional
public
class
${
entity
.
name
}
Service
extends
BaseService
<
$
{
entity
.
name
}>{
\
@Autowired
private
$
{
entity
.
name
}
Dao
$
{
entity
.
code
}
Dao
;
public
PageQuery
<
$
{
entity
.
name
}>
queryByCondition
(
PageQuery
query
){
PageQuery
ret
=
$
{
entity
.
code
}
Dao
.
queryByCondition
(
query
);
queryListAfter
(
ret
.
getList
());
return
ret
;
}
public
void
batchDel
$
{
entity
.
name
}(
List
<
Long
>
ids
){
try
{
$
{
entity
.
code
}
Dao
.
batchDel
$
{
entity
.
name
}
ByIds
(
ids
);
}
catch
(
Exception
e
)
{
throw
new
PlatformException
(
"批量删除${entity.displayName}失败"
,
e
);
}
}
}
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/js/add.js
0 → 100644
View file @
321361c9
layui
.
define
([
'
form
'
,
'
laydate
'
,
'
table
'
,
'
${entity.code}Api
'
],
function
(
exports
)
{
var
form
=
layui
.
form
;
var
$
{
entity
.
code
}
Api
=
layui
.
$
{
entity
.
code
}
Api
;
var
index
=
layui
.
index
;
var
view
=
{
init
:
function
(){
Lib
.
initGenrealForm
(
$
(
"
#addForm
"
),
form
);
this
.
initSubmit
();
},
initSubmit
:
function
(){
$
(
"
#addButton
"
).
click
(
function
(){
$
{
entity
.
code
}
Api
.
add$
{
upperFirst
(
entity
.
code
)}(
function
(){
parent
.
window
.
dataReload
();
Common
.
info
(
"
添加成功
"
);
Lib
.
closeFrame
();
});
});
$
(
"
#addButton-cancel
"
).
click
(
function
(){
Lib
.
closeFrame
();
});
}
}
exports
(
'
add
'
,
view
);
});
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/js/del.js
0 → 100644
View file @
321361c9
layui
.
define
([
'
table
'
,
'
${entity.code}Api
'
],
function
(
exports
)
{
var
$
{
entity
.
code
}
Api
=
layui
.
$
{
entity
.
code
}
Api
;
var
table
=
layui
.
table
;
var
view
=
{
init
:
function
(){
},
delBatch
:
function
(){
var
data
=
Common
.
getMoreDataFromTable
(
table
,
"
${entity.code}Table
"
);
if
(
data
==
null
){
return
;
}
Common
.
openConfirm
(
"
确认要删除这些${entity.displayName}?
"
,
function
(){
var
ids
=
Common
.
concatBatchId
(
data
,
"
${entity.idAttribute.name}
"
);
$
{
entity
.
code
}
Api
.
del
(
ids
,
function
(){
Common
.
info
(
"
删除成功
"
);
dataReload
();
})
})
}
}
exports
(
'
del
'
,
view
);
});
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/js/edit.js
0 → 100644
View file @
321361c9
layui
.
define
([
'
form
'
,
'
laydate
'
,
'
table
'
,
'
${entity.code}Api
'
],
function
(
exports
)
{
var
form
=
layui
.
form
;
var
$
{
entity
.
code
}
Api
=
layui
.
$
{
entity
.
code
}
Api
;
var
index
=
layui
.
index
;
var
view
=
{
init
:
function
(){
Lib
.
initGenrealForm
(
$
(
"
#updateForm
"
),
form
);
this
.
initSubmit
();
},
initSubmit
:
function
(){
$
(
"
#updateButton
"
).
click
(
function
(){
$
{
entity
.
code
}
Api
.
update$
{
upperFirst
(
entity
.
code
)}(
function
(){
parent
.
window
.
dataReload
();
Common
.
info
(
"
更新成功
"
);
Lib
.
closeFrame
();
});
});
$
(
"
#updateButton-cancel
"
).
click
(
function
(){
Lib
.
closeFrame
();
});
}
}
exports
(
'
edit
'
,
view
);
});
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/js/entityApi.js
0 → 100644
View file @
321361c9
/*访问后台的代码*/
layui
.
define
([],
function
(
exports
)
{
var
api
=
{
update$
{
upperFirst
(
entity
.
code
)}:
function
(
callback
){
Lib
.
submitForm
(
$
(
'
#updateForm
'
),{},
callback
)
},
add$
{
upperFirst
(
entity
.
code
)}:
function
(
callback
){
Lib
.
submitForm
(
$
(
'
#addForm
'
),{},
callback
)
},
del
:
function
(
ids
,
callback
){
Common
.
post
(
"
/${target.urlBase}/${entity.code}/delete.json
"
,{
"
ids
"
:
ids
},
function
(){
callback
();
})
}
};
exports
(
'
${entity.code}Api
'
,
api
);
});
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/js/index.js
0 → 100644
View file @
321361c9
layui
.
define
([
'
form
'
,
'
laydate
'
,
'
table
'
],
function
(
exports
)
{
var
form
=
layui
.
form
;
var
laydate
=
layui
.
laydate
;
var
table
=
layui
.
table
;
var
$
{
entity
.
code
}
Table
=
null
;
var
view
=
{
init
:
function
(){
this
.
initTable
();
this
.
initSearchForm
();
this
.
initToolBar
();
window
.
dataReload
=
function
(){
Lib
.
doSearchForm
(
$
(
"
#searchForm
"
),
$
{
entity
.
code
}
Table
,
form
)
}
},
initTable
:
function
(){
$
{
entity
.
code
}
Table
=
table
.
render
({
elem
:
'
#${entity.code}Table
'
,
height
:
Lib
.
getTableHeight
(
1
),
method
:
'
post
'
,
url
:
Common
.
CTX
+
'
/${target.urlBase}/${entity.code}/list.json
'
//数据接口
,
page
:
Lib
.
tablePage
//开启分页
,
limit
:
10
,
cols
:
[
[
//表头
{
type
:
'
checkbox
'
,
fixed
:
'
left
'
,
},
@
for
(
attr
in
entity
.
list
){
{
field
:
'
${attr.name}
'
,
title
:
'
${attr.displayName}
'
,
@
if
(
attrLP
.
first
){
fixed
:
'
left
'
,
@}
@
if
(
attr
.
javaType
==
"
date
"
){
templet
:
function
(
d
){
return
Common
.
getDate
(
d
.
$
{
attr
.
name
});
},
@}
width
:
100
,
}
$
{
!
attrLP
.
last
?
"
,
"
}
@}
]
]
});
},
initSearchForm
:
function
(){
Lib
.
initSearchForm
(
$
(
"
#searchForm
"
),
$
{
entity
.
code
}
Table
,
form
);
},
initToolBar
:
function
(){
toolbar
=
{
add
:
function
()
{
//获取选中数据
var
url
=
"
/${target.urlBase}/${entity.code}/add.do
"
;
Common
.
openDlg
(
url
,
"
${entity.displayName}管理>新增
"
);
},
edit
:
function
()
{
//获取选中数目
var
data
=
Common
.
getOneFromTable
(
table
,
"
${entity.code}Table
"
);
if
(
data
==
null
){
return
;
}
var
url
=
"
/${target.urlBase}/${entity.code}/edit.do?${entity.idAttribute.name}=
"
+
data
.
$
{
entity
.
idAttribute
.
name
};
Common
.
openDlg
(
url
,
"
${entity.displayName}管理>
"
+
data
.
$
{
entity
.
nameAttribute
.
name
}
+
"
>编辑
"
);
},
del
:
function
()
{
layui
.
use
([
'
del
'
],
function
(){
var
delView
=
layui
.
del
delView
.
delBatch
();
});
}
};
$
(
'
.ext-toolbar
'
).
on
(
'
click
'
,
function
()
{
var
type
=
$
(
this
).
data
(
'
type
'
);
toolbar
[
type
]
?
toolbar
[
type
].
call
(
this
)
:
''
;
});
}
}
exports
(
'
index
'
,
view
);
});
\ No newline at end of file
admin-core/src/main/resources/codeTemplate/md/entity.md
0 → 100644
View file @
321361c9
queryByCondition
===
select
\@pageTag(){
t.*
\@}
from ${entity.tableName} t
where 1=1
\@//数据权限,该sql语句功能点
and #function("${entity.code}.query")#
@for(attr in entity.list){
@if(attr.showInQuery){
\@if(!isEmpty(${attr.name})){
and t.${attr.colName} =#${attr.name}#
\@}
@}
@}
batchDel${entity.name}ByIds
===
*
批量逻辑删除
update ${entity.tableName} set del_flag = 1 where ${entity.idAttribute.colName} in( #join(ids)#)
Prev
1
…
10
11
12
13
14
15
16
17
18
…
23
Next
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