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
98ca1176
Commit
98ca1176
authored
Mar 13, 2018
by
李家智
Browse files
test
parent
bd3d0133
Changes
13
Hide whitespace changes
Inline
Side-by-side
admin-console/src/main/java/com/ibeetl/admin/console/dao/CmsBlogDao.java
deleted
100644 → 0
View file @
bd3d0133
package
com.ibeetl.admin.console.dao
;
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
com.ibeetl.admin.console.entity.*
;
/**
* CmsBlog Dao
*/
@SqlResource
(
"console.cmsBlog"
)
public
interface
CmsBlogDao
extends
BaseMapper
<
CmsBlog
>{
public
PageQuery
<
CmsBlog
>
queryByCondition
(
PageQuery
query
);
public
void
batchDelCmsBlogByIds
(
List
<
Long
>
ids
);
}
\ No newline at end of file
admin-console/src/main/java/com/ibeetl/admin/console/entity/CmsBlog.java
deleted
100644 → 0
View file @
bd3d0133
package
com.ibeetl.admin.console.entity
;
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
;
/*
*
* gen by Spring Boot2 Admin 2018-02-24
*/
public
class
CmsBlog
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
private
Integer
id
;
private
String
title
;
private
String
content
;
private
Date
createTime
;
private
Integer
createUserId
;
private
String
type
;
public
CmsBlog
()
{
}
public
Integer
getId
(){
return
id
;
}
public
void
setId
(
Integer
id
){
this
.
id
=
id
;
}
public
String
getTitle
(){
return
title
;
}
public
void
setTitle
(
String
title
){
this
.
title
=
title
;
}
public
String
getContent
(){
return
content
;
}
public
void
setContent
(
String
content
){
this
.
content
=
content
;
}
public
Date
getCreateTime
(){
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
){
this
.
createTime
=
createTime
;
}
public
Integer
getCreateUserId
(){
return
createUserId
;
}
public
void
setCreateUserId
(
Integer
createUserId
){
this
.
createUserId
=
createUserId
;
}
public
String
getType
(){
return
type
;
}
public
void
setType
(
String
type
){
this
.
type
=
type
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/service/CmsBlogService.java
deleted
100644 → 0
View file @
bd3d0133
package
com.ibeetl.admin.console.service
;
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
com.ibeetl.admin.console.dao.CmsBlogDao
;
import
com.ibeetl.admin.console.entity.CmsBlog
;
import
com.ibeetl.admin.core.service.BaseService
;
/**
* CmsBlog Service
*/
@Service
@Transactional
public
class
CmsBlogService
extends
BaseService
<
CmsBlog
>{
@Autowired
private
CmsBlogDao
cmsBlogDao
;
public
PageQuery
<
CmsBlog
>
queryByCondition
(
PageQuery
query
){
PageQuery
ret
=
cmsBlogDao
.
queryByCondition
(
query
);
queryListAfter
(
ret
.
getList
());
return
ret
;
}
public
void
batchDelCmsBlog
(
List
<
Long
>
ids
){
try
{
cmsBlogDao
.
batchDelCmsBlogByIds
(
ids
);
}
catch
(
Exception
e
)
{
throw
new
PlatformException
(
"批量删除CmsBlog失败"
,
e
);
}
}
}
\ No newline at end of file
admin-console/src/main/java/com/ibeetl/admin/console/web/CmsBlogController.java
deleted
100644 → 0
View file @
bd3d0133
package
com.ibeetl.admin.console.web
;
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
com.ibeetl.admin.console.entity.*
;
import
com.ibeetl.admin.console.service.*
;
import
com.ibeetl.admin.console.web.query.*
;
/**
* CmsBlog 接口
*/
@Controller
public
class
CmsBlogController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/cmsBlog"
;
@Autowired
private
CmsBlogService
cmsBlogService
;
/* 页面 */
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"cmsBlog.query"
)
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/cmsBlog/index.html"
)
;
view
.
addObject
(
"search"
,
CmsBlogQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"cmsBlog.edit"
)
@ResponseBody
public
ModelAndView
edit
(
Integer
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/cmsBlog/edit.html"
);
CmsBlog
cmsBlog
=
cmsBlogService
.
queryById
(
id
);
view
.
addObject
(
"cmsBlog"
,
cmsBlog
);
return
view
;
}
@GetMapping
(
MODEL
+
"/add.do"
)
@Function
(
"cmsBlog.add"
)
@ResponseBody
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/cmsBlog/add.html"
);
return
view
;
}
/* ajax json */
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"cmsBlog.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
CmsBlogQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
cmsBlogService
.
queryByCondition
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"cmsBlog.add"
)
@ResponseBody
public
JsonResult
add
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CmsBlog
cmsBlog
)
{
cmsBlogService
.
save
(
cmsBlog
);
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"cmsBlog.update"
)
@ResponseBody
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CmsBlog
cmsBlog
)
{
boolean
success
=
cmsBlogService
.
update
(
cmsBlog
);
if
(
success
)
{
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
@GetMapping
(
MODEL
+
"/view.json"
)
@Function
(
"cmsBlog.query"
)
@ResponseBody
public
JsonResult
<
CmsBlog
>
queryInfo
(
Integer
id
)
{
CmsBlog
cmsBlog
=
cmsBlogService
.
queryById
(
id
);
return
JsonResult
.
success
(
cmsBlog
);
}
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"cmsBlog.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
if
(
ids
.
endsWith
(
","
))
{
ids
=
StringUtils
.
substringBeforeLast
(
ids
,
","
);
}
List
<
Long
>
idList
=
ConvertUtil
.
str2longs
(
ids
);
cmsBlogService
.
batchDelCmsBlog
(
idList
);
return
new
JsonResult
().
success
();
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/DictConsoleController.java
View file @
98ca1176
...
...
@@ -158,6 +158,7 @@ public class DictConsoleController{
Context
context
=
new
Context
();
context
.
putVar
(
"dicts"
,
dicts
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
os
.
close
();
//下载参考FileSystemContorller
return
JsonResult
.
success
(
item
.
getPath
());
}
catch
(
IOException
e
)
{
...
...
admin-console/src/main/resources/sql/console/blog.md
deleted
100644 → 0
View file @
bd3d0133
queryByCondition
===
select
@pageTag(){
t.*
@}
from cms_blog t
where 1=1
@//数据权限,该sql语句功能点
and #function("blog.query")#
batchDelCmsBlogByIds
===
*
批量逻辑删除
update cms_blog set del_flag = 1 where id in( #join(ids)#)
admin-console/src/main/resources/sql/console/cmsBlog.md
deleted
100644 → 0
View file @
bd3d0133
queryByCondition
===
select
@pageTag(){
t.*
@}
from cms_blog t
where 1=1
@//数据权限,该sql语句功能点
and #function("cmsBlog.query")#
batchDelCmsBlogByIds
===
*
批量逻辑删除
update cms_blog set del_flag = 1 where id in( #join(ids)#)
admin-core/src/main/resources/codeTemplate/html/add.html
View file @
98ca1176
...
...
@@ -32,7 +32,7 @@
@if(entity.attachment){
<div
class=
"layui-row"
>
<!-- 业务对象得有一个字段保存附件id,假设是attachmentId -->
<layui:attachment
name=
"attachmentId"
batchFileUUID=
"\${uuid()}"
isNew=
"true"
/>
<layui:attachment
name=
"attachmentId"
batchFileUUID=
"\${uuid()}"
bizType=
"entity.name"
isNew=
"true"
/>
</div>
@}
<layui:submitButtons
id=
"addButton"
/>
...
...
admin-core/src/main/resources/codeTemplate/html/index.html
View file @
98ca1176
...
...
@@ -7,8 +7,8 @@
<layui:accessButton
function=
"${entity.code}.edit"
action=
"edit"
>
编辑
</layui:accessButton>
<layui:accessButton
function=
"${entity.code}.del"
action=
"del"
>
删除
</layui:accessButton>
@if(entity.includeExcel){
<layui:accessButton
function=
"${entity.code}.export
Excel
"
action=
"export
Excel"
>
导出excel
</layui:accessButton>
<layui:accessButton
function=
"${entity.code}.import
Excel
"
action=
"import
Excel"
>
导入excel
</layui:accessButton>
<layui:accessButton
function=
"${entity.code}.export
Document
"
action=
"export
Document"
>
导出
</layui:accessButton>
<layui:accessButton
function=
"${entity.code}.import
Document
"
action=
"import
Document"
>
导入
</layui:accessButton>
@}
</div>
...
...
admin-core/src/main/resources/codeTemplate/java/controller.java
View file @
98ca1176
package
${
package
};
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
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.jxls.common.Context
;
import
org.jxls.reader.ReaderBuilder
;
import
org.jxls.reader.ReaderConfig
;
import
org.jxls.reader.XLSReadMessage
;
import
org.jxls.reader.XLSReadStatus
;
import
org.jxls.reader.XLSReader
;
import
org.jxls.util.JxlsHelper
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.web.dto.DictExcelImportData
;
import
com.ibeetl.admin.console.web.query.UserQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.file.FileItem
;
import
com.ibeetl.admin.core.file.FileService
;
import
com.ibeetl.admin.core.web.JsonResult
;
import
com.ibeetl.admin.core.util.*
;
import
${
basePackage
}.
entity
.*;
...
...
@@ -36,7 +59,9 @@ public class ${entity.name}Controller{
@var
service
=
entity
.
code
+
"Service"
;
\
@Autowired
private
$
{
entity
.
name
}
Service
$
{
service
};
@Autowired
FileService
fileService
;
/* 页面 */
\
@GetMapping
(
MODEL
+
"/index.do"
)
...
...
@@ -120,5 +145,58 @@ public class ${entity.name}Controller{
$
{
service
}.
batchDel
$
{
entity
.
name
}(
idList
);
return
new
JsonResult
().
success
();
}
@if
(
entity
.
includeExcel
){
\
@PostMapping
(
MODEL
+
"/excel/export.json"
)
\
@Function
(
"${entity.code}.export"
)
\
@ResponseBody
public
JsonResult
<
String
>
export
(
HttpServletResponse
response
,
$
{
entity
.
name
}
Query
condtion
)
{
/**
* 1)需要用你自己编写一个的excel模板
* 2)通常excel导出需要关联更多数据,因此${service}.queryByCondition方法经常不符合需求,需要重写一个为模板导出的查询
* 3)参考ConsoleDictController来实现模板导入导出
*/
String
excelTemplate
=
"excelTemplates/${target.urlBase}/${entity.code}/你的excel模板文件名字.xls"
;
PageQuery
<
$
{
entity
.
name
}>
page
=
condtion
.
getPageQuery
();
//取出全部符合条件的
page
.
setPageSize
(
Integer
.
MAX_VALUE
);
page
.
setPageNumber
(
1
);
page
.
setTotalRow
(
Integer
.
MAX_VALUE
);
//本次导出需要的数据
List
<
$
{
entity
.
name
}>
list
=
$
{
service
}.
queryByCondition
(
page
).
getList
();
try
(
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
excelTemplate
))
{
if
(
is
==
null
)
{
throw
new
PlatformException
(
"模板资源不存在:"
+
excelTemplate
);
}
FileItem
item
=
fileService
.
createFileTemp
(
"${entity.displayName}_"
+
DateUtil
.
now
(
"yyyyMMddHHmmss"
)
".xls"
);
OutputStream
os
=
item
.
openOutpuStream
();
Context
context
=
new
Context
();
context
.
putVar
(
"list"
,
list
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
os
.
close
();
//下载参考FileSystemContorller
return
JsonResult
.
success
(
item
.
getPath
());
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
e
.
getMessage
());
}
}
\
@PostMapping
(
MODEL
+
"/excel/import.do"
)
\
@Function
(
"${entity.code}.import"
)
\
@ResponseBody
public
JsonResult
importExcel
(
\
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
if
(
file
.
isEmpty
())
{
return
JsonResult
.
fail
();
}
InputStream
ins
=
file
.
getInputStream
();
/*解析模板并导入到数据库里,参考DictConsoleContorller,使用jxls reader读取excel数据*/
ins
.
close
();
return
JsonResult
.
success
();
}
@
}
}
admin-core/src/main/resources/codeTemplate/js/entityApi.js
View file @
98ca1176
...
...
@@ -12,6 +12,15 @@ layui.define([], function(exports) {
callback
();
})
}
@
if
(
entity
.
includeExcel
){
,
exportExcel
:
function
(
form
,
callback
){
var
formPara
=
form
.
serializeJson
();
Common
.
post
(
"
/${target.urlBase}/${entity.code}/excel/export.json
"
,
formPara
,
function
(
fileId
)
{
callback
(
fileId
);
})
}
@}
};
exports
(
'
${entity.code}Api
'
,
api
);
...
...
admin-core/src/main/resources/codeTemplate/js/index.js
View file @
98ca1176
...
...
@@ -37,7 +37,7 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) {
return
Common
.
getDate
(
d
.
$
{
attr
.
name
});
},
@}
width
:
100
,
width
:
100
}
$
{
!
attrLP
.
last
?
"
,
"
}
@}
...
...
@@ -71,13 +71,23 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) {
}
@
if
(
entity
.
includeExcel
){
,
exportExcel
:
function
()
{
Common
.
alert
(
"
未完成的导出功能,参考数据字典到处
"
)
exportDocument
:
function
()
{
layui
.
use
([
'
${entity.code}Api
'
],
function
()
{
var
$
{
entity
.
code
}
Api
=
layui
.
$
{
entity
.
code
}
Api
Common
.
openConfirm
(
"
确认要导出这些${entity.displayName}数据?
"
,
function
()
{
$
{
entity
.
code
}
Api
.
exportExcel
(
$
(
"
#searchForm
"
),
function
(
fileId
)
{
Lib
.
download
(
fileId
);
})
})
});
},
importExcel
:
function
(){
//参考数据字典导入导出
Common
.
alert
(
"
未完成的导入功能能,参考数据字段导入
"
)
importDocument
:
function
(){
var
uploadUrl
=
Common
.
ctxPath
+
"
/${target.urlBase}/${entity.code}/excel/import.do
"
;
//模板,
var
templatePath
=
"
/${target.urlBase}/${entity.code}/${entity.code}_upload_template.xls
"
;
//公共的简单上传文件处理
var
url
=
"
/core/file/simpleUpload.do?uploadUrl=
"
+
uploadUrl
+
"
&templatePath=
"
+
templatePath
;
Common
.
openDlg
(
url
,
"
${entity.displayName}管理>上传
"
);
}
@}
};
...
...
admin-core/src/main/resources/templates/core/codeGen/edit.html
View file @
98ca1176
...
...
@@ -72,7 +72,7 @@
<label
class=
"layui-form-label"
>
系统包名
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"basePackage"
value=
"com.ibeetl.
admin.console
"
class=
"layui-input"
>
value=
"com.ibeetl.
cms
"
class=
"layui-input"
>
</div>
</div>
</div>
...
...
@@ -102,14 +102,14 @@
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
urlBase
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"urlBase"
value=
"
admin
"
class=
"layui-input"
>
<input
type=
"text"
name=
"urlBase"
value=
"
cms
"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
system
</label>
<div
class=
"layui-input-inline"
>
<input
type=
"text"
name=
"entity.system"
value=
"c
onsole
"
<input
type=
"text"
name=
"entity.system"
value=
"c
ms
"
class=
"layui-input"
>
</div>
</div>
...
...
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