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
JeeSpringCloud
Commits
8b643e22
"vscode:/vscode.git/clone" did not exist on "17b1f37ce44b2c38be42c6064ef3d0e9b8bec8f8"
Commit
8b643e22
authored
Oct 12, 2018
by
HuangBingGui
Browse files
no commit message
parent
563ff060
Changes
385
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 385+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/BarController.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.echarts.web
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.jeespring.common.web.AbstractBaseController
;
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/bar"
)
public
class
BarController
extends
AbstractBaseController
{
private
static
final
long
serialVersionUID
=
-
6886697421555222670L
;
private
List
<
String
>
xAxisData
;
private
Map
<
String
,
List
<
Double
>>
yAxisData
;
private
Map
<
String
,
Integer
>
yAxisIndex
;
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
//x轴数据
request
.
setAttribute
(
"xAxisData"
,
getxAxisData
());
//y轴数据
request
.
setAttribute
(
"yAxisData"
,
getyAxisData
());
//Y轴双轴情况下的位置定位
request
.
setAttribute
(
"yAxisIndex"
,
getyAxisIndex
());
return
"modules/echarts/bar"
;
}
public
List
<
String
>
getxAxisData
(){
xAxisData
=
new
ArrayList
<
String
>();
xAxisData
.
add
(
"2015-10-10"
);
xAxisData
.
add
(
"2015-10-11"
);
xAxisData
.
add
(
"2015-10-12"
);
xAxisData
.
add
(
"2015-10-13"
);
xAxisData
.
add
(
"2015-10-14"
);
return
xAxisData
;
}
public
Map
<
String
,
List
<
Double
>>
getyAxisData
(){
Random
random
=
new
Random
();
yAxisData
=
new
HashMap
<
String
,
List
<
Double
>>();
List
<
Double
>
data1
=
new
ArrayList
<
Double
>();
data1
.
add
(
random
.
nextDouble
());
data1
.
add
(
random
.
nextDouble
());
data1
.
add
(
random
.
nextDouble
());
data1
.
add
(
random
.
nextDouble
());
data1
.
add
(
random
.
nextDouble
());
yAxisData
.
put
(
"柱状一"
,
data1
);
List
<
Double
>
data2
=
new
ArrayList
<
Double
>();
data2
.
add
(
random
.
nextDouble
());
data2
.
add
(
random
.
nextDouble
());
data2
.
add
(
random
.
nextDouble
());
data2
.
add
(
random
.
nextDouble
());
data2
.
add
(
random
.
nextDouble
());
yAxisData
.
put
(
"柱状二"
,
data2
);
return
yAxisData
;
}
public
Map
<
String
,
Integer
>
getyAxisIndex
(){
yAxisIndex
=
new
HashMap
<
String
,
Integer
>();
yAxisIndex
.
put
(
"柱状一"
,
0
);
yAxisIndex
.
put
(
"柱状二"
,
1
);
return
yAxisIndex
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/ChinaWeatherDataBeanController.java
0 → 100644
View file @
8b643e22
/**
* Copyright © 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.echarts.web
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.ConstraintViolationException
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.utils.MyBeanUtils
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.echarts.entity.ChinaWeatherDataBean
;
import
com.jeespring.modules.echarts.service.ChinaWeatherDataBeanService
;
/**
* 城市气温Controller
* @author JeeSpring
* @version 2016-05-26
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/chinaWeatherDataBean"
)
public
class
ChinaWeatherDataBeanController
extends
AbstractBaseController
{
@Autowired
private
ChinaWeatherDataBeanService
chinaWeatherDataBeanService
;
@ModelAttribute
public
ChinaWeatherDataBean
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
ChinaWeatherDataBean
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
chinaWeatherDataBeanService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
ChinaWeatherDataBean
();
}
return
entity
;
}
/**
* 城市气温列表页面
*/
@RequiresPermissions
(
"echarts:chinaWeatherDataBean:list"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
ChinaWeatherDataBean
chinaWeatherDataBean
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
ChinaWeatherDataBean
>
page
=
chinaWeatherDataBeanService
.
findPage
(
new
Page
<
ChinaWeatherDataBean
>(
request
,
response
),
chinaWeatherDataBean
);
model
.
addAttribute
(
"page"
,
page
);
//折线图列表数据
//X轴的数据
List
<
String
>
xAxisData
=
new
ArrayList
<
String
>();
//Y轴的数据
Map
<
String
,
List
<
Double
>>
yAxisData
=
new
HashMap
<
String
,
List
<
Double
>>();
//Y轴双轴情况下的位置定位
Map
<
String
,
Integer
>
yAxisIndex
=
new
HashMap
<
String
,
Integer
>();
List
<
ChinaWeatherDataBean
>
weatherDataList
=
chinaWeatherDataBeanService
.
findList
(
chinaWeatherDataBean
);
List
<
Double
>
beijingMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
beijingMinTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
changchunMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
changchunMinTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
shenyangMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
shenyangMinTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
haerbinMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
haerbinMinTemp
=
new
ArrayList
<
Double
>();
for
(
ChinaWeatherDataBean
chinaWeatherDataBeanTemp:
weatherDataList
){
//x轴数据
xAxisData
.
add
(
chinaWeatherDataBeanTemp
.
getDatestr
().
toLocaleString
());
//北京最高温度
beijingMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getBeijingMaxTemp
());
//北京最低温度
beijingMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getBeijingMinTemp
());
//长春最高温度
changchunMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getChangchunMaxTemp
());
//长春最高温度
changchunMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getChangchunMinTemp
());
//沈阳最高温度
shenyangMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getShenyangMaxTemp
());
//沈阳最高温度
shenyangMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getShenyangMinTemp
());
//哈尔滨最高温度
haerbinMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getHaerbinMaxTemp
());
//哈尔滨最高温度
haerbinMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getHaerbinMinTemp
());
}
//y轴数据
yAxisData
.
put
(
"北京 最高温度"
,
beijingMaxTemp
);
yAxisData
.
put
(
"北京 最低温度"
,
beijingMinTemp
);
yAxisData
.
put
(
"长春 最高温度"
,
changchunMaxTemp
);
yAxisData
.
put
(
"长春 最低温度"
,
changchunMinTemp
);
yAxisData
.
put
(
"沈阳 最高温度"
,
shenyangMaxTemp
);
yAxisData
.
put
(
"沈阳 最低温度"
,
shenyangMinTemp
);
yAxisData
.
put
(
"哈尔滨 最高温度"
,
haerbinMinTemp
);
yAxisData
.
put
(
"哈尔滨 最低温度"
,
haerbinMinTemp
);
//Y轴双轴情况下的位置定位
yAxisIndex
.
put
(
"北京 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"长春 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"沈阳 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"哈尔滨 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"北京 最低温度"
,
1
);
//1表示Y轴右轴
yAxisIndex
.
put
(
"长春 最低温度"
,
1
);
//1表示Y轴右轴
yAxisIndex
.
put
(
"沈阳 最低温度"
,
1
);
//1表示Y轴右轴
yAxisIndex
.
put
(
"哈尔滨 最低温度"
,
1
);
//1表示Y轴右轴
request
.
setAttribute
(
"yAxisIndex"
,
yAxisIndex
);
request
.
setAttribute
(
"xAxisData"
,
xAxisData
);
request
.
setAttribute
(
"yAxisData"
,
yAxisData
);
return
"modules/echarts/chinaWeatherDataBeanList"
;
}
/**
* 查看,增加,编辑城市气温表单页面
*/
@RequiresPermissions
(
value
={
"echarts:chinaWeatherDataBean:view"
,
"echarts:chinaWeatherDataBean:add"
,
"echarts:chinaWeatherDataBean:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
ChinaWeatherDataBean
chinaWeatherDataBean
,
Model
model
)
{
model
.
addAttribute
(
"chinaWeatherDataBean"
,
chinaWeatherDataBean
);
return
"modules/echarts/chinaWeatherDataBeanForm"
;
}
/**
* 保存城市气温
*/
@RequiresPermissions
(
value
={
"echarts:chinaWeatherDataBean:add"
,
"echarts:chinaWeatherDataBean:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
ChinaWeatherDataBean
chinaWeatherDataBean
,
Model
model
,
RedirectAttributes
redirectAttributes
)
throws
Exception
{
if
(!
beanValidator
(
model
,
chinaWeatherDataBean
)){
return
form
(
chinaWeatherDataBean
,
model
);
}
if
(!
chinaWeatherDataBean
.
getIsNewRecord
()){
//编辑表单保存
ChinaWeatherDataBean
t
=
chinaWeatherDataBeanService
.
get
(
chinaWeatherDataBean
.
getId
());
//从数据库取出记录的值
MyBeanUtils
.
copyBeanNotNull2Bean
(
chinaWeatherDataBean
,
t
);
//将编辑表单中的非NULL值覆盖数据库记录中的值
chinaWeatherDataBeanService
.
save
(
t
);
//保存
}
else
{
//新增表单保存
chinaWeatherDataBeanService
.
save
(
chinaWeatherDataBean
);
//保存
}
addMessage
(
redirectAttributes
,
"保存城市气温成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/chinaWeatherDataBean/?repage"
;
}
/**
* 删除城市气温
*/
@RequiresPermissions
(
"echarts:chinaWeatherDataBean:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
ChinaWeatherDataBean
chinaWeatherDataBean
,
RedirectAttributes
redirectAttributes
)
{
chinaWeatherDataBeanService
.
delete
(
chinaWeatherDataBean
);
addMessage
(
redirectAttributes
,
"删除城市气温成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/chinaWeatherDataBean/?repage"
;
}
/**
* 批量删除城市气温
*/
@RequiresPermissions
(
"echarts:chinaWeatherDataBean:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
chinaWeatherDataBeanService
.
delete
(
chinaWeatherDataBeanService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除城市气温成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/chinaWeatherDataBean/?repage"
;
}
/**
* 导出excel文件
*/
@RequiresPermissions
(
"echarts:chinaWeatherDataBean:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
ChinaWeatherDataBean
chinaWeatherDataBean
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"城市气温"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
ChinaWeatherDataBean
>
page
=
chinaWeatherDataBeanService
.
findPage
(
new
Page
<
ChinaWeatherDataBean
>(
request
,
response
,
-
1
),
chinaWeatherDataBean
);
new
ExportExcel
(
"城市气温"
,
ChinaWeatherDataBean
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出城市气温记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/chinaWeatherDataBean/?repage"
;
}
/**
* 导入Excel数据
*/
@RequiresPermissions
(
"echarts:chinaWeatherDataBean:import"
)
@RequestMapping
(
value
=
"import"
,
method
=
RequestMethod
.
POST
)
public
String
importFile
(
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
try
{
int
successNum
=
0
;
int
failureNum
=
0
;
StringBuilder
failureMsg
=
new
StringBuilder
();
ImportExcel
ei
=
new
ImportExcel
(
file
,
1
,
0
);
List
<
ChinaWeatherDataBean
>
list
=
ei
.
getDataList
(
ChinaWeatherDataBean
.
class
);
for
(
ChinaWeatherDataBean
chinaWeatherDataBean
:
list
){
try
{
chinaWeatherDataBeanService
.
save
(
chinaWeatherDataBean
);
successNum
++;
}
catch
(
ConstraintViolationException
ex
){
failureNum
++;
}
catch
(
Exception
ex
)
{
failureNum
++;
}
}
if
(
failureNum
>
0
){
failureMsg
.
insert
(
0
,
",失败 "
+
failureNum
+
" 条城市气温记录。"
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条城市气温记录"
+
failureMsg
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入城市气温失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/chinaWeatherDataBean/?repage"
;
}
/**
* 下载导入城市气温数据模板
*/
@RequiresPermissions
(
"echarts:chinaWeatherDataBean:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"城市气温数据导入模板.xlsx"
;
List
<
ChinaWeatherDataBean
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"城市气温数据"
,
ChinaWeatherDataBean
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/chinaWeatherDataBean/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/LineController.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.echarts.web
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.echarts.entity.ChinaWeatherDataBean
;
import
com.jeespring.modules.echarts.service.ChinaWeatherDataBeanService
;
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/line"
)
public
class
LineController
extends
AbstractBaseController
{
private
static
final
long
serialVersionUID
=
-
6886697421555222670L
;
@Autowired
private
ChinaWeatherDataBeanService
chinaWeatherDataBeanService
;
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
index
(
ChinaWeatherDataBean
chinaWeatherDataBean
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
//X轴的数据
List
<
String
>
xAxisData
=
new
ArrayList
<
String
>();
//Y轴的数据
Map
<
String
,
List
<
Double
>>
yAxisData
=
new
HashMap
<
String
,
List
<
Double
>>();
//Y轴双轴情况下的位置定位
Map
<
String
,
Integer
>
yAxisIndex
=
new
HashMap
<
String
,
Integer
>();
List
<
ChinaWeatherDataBean
>
weatherDataList
=
chinaWeatherDataBeanService
.
findList
(
chinaWeatherDataBean
);
List
<
Double
>
beijingMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
beijingMinTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
changchunMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
changchunMinTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
shenyangMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
shenyangMinTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
haerbinMaxTemp
=
new
ArrayList
<
Double
>();
List
<
Double
>
haerbinMinTemp
=
new
ArrayList
<
Double
>();
for
(
ChinaWeatherDataBean
chinaWeatherDataBeanTemp:
weatherDataList
){
//x轴数据
xAxisData
.
add
(
chinaWeatherDataBeanTemp
.
getDatestr
().
toLocaleString
());
//北京最高温度
beijingMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getBeijingMaxTemp
());
//北京最低温度
beijingMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getBeijingMinTemp
());
//长春最高温度
changchunMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getChangchunMaxTemp
());
//长春最高温度
changchunMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getChangchunMinTemp
());
//沈阳最高温度
shenyangMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getShenyangMaxTemp
());
//沈阳最高温度
shenyangMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getShenyangMinTemp
());
//哈尔滨最高温度
haerbinMaxTemp
.
add
(
chinaWeatherDataBeanTemp
.
getHaerbinMaxTemp
());
//哈尔滨最高温度
haerbinMinTemp
.
add
(
chinaWeatherDataBeanTemp
.
getHaerbinMinTemp
());
}
//y轴数据
yAxisData
.
put
(
"北京 最高温度"
,
beijingMaxTemp
);
yAxisData
.
put
(
"北京 最低温度"
,
beijingMinTemp
);
yAxisData
.
put
(
"长春 最高温度"
,
changchunMaxTemp
);
yAxisData
.
put
(
"长春 最低温度"
,
changchunMinTemp
);
yAxisData
.
put
(
"沈阳 最高温度"
,
shenyangMaxTemp
);
yAxisData
.
put
(
"沈阳 最低温度"
,
shenyangMinTemp
);
yAxisData
.
put
(
"哈尔滨 最高温度"
,
haerbinMinTemp
);
yAxisData
.
put
(
"哈尔滨 最低温度"
,
haerbinMinTemp
);
//Y轴双轴情况下的位置定位
yAxisIndex
.
put
(
"北京 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"长春 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"沈阳 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"哈尔滨 最高温度"
,
0
);
//0表示Y轴左轴
yAxisIndex
.
put
(
"北京 最低温度"
,
1
);
//1表示Y轴右轴
yAxisIndex
.
put
(
"长春 最低温度"
,
1
);
//1表示Y轴右轴
yAxisIndex
.
put
(
"沈阳 最低温度"
,
1
);
//1表示Y轴右轴
yAxisIndex
.
put
(
"哈尔滨 最低温度"
,
1
);
//1表示Y轴右轴
request
.
setAttribute
(
"yAxisIndex"
,
yAxisIndex
);
request
.
setAttribute
(
"xAxisData"
,
xAxisData
);
request
.
setAttribute
(
"yAxisData"
,
yAxisData
);
return
"modules/echarts/line"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/LineDoubleNumController.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.echarts.web
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.jeespring.common.web.AbstractBaseController
;
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/linedoublenum"
)
public
class
LineDoubleNumController
extends
AbstractBaseController
{
private
static
final
long
serialVersionUID
=
-
6886697421555222670L
;
private
Map
<
String
,
Double
[][]>
axisDataArr
;
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
//x+y轴数据Double[x轴数据][y轴数据]
request
.
setAttribute
(
"axisDataArr"
,
getaxisDataArr
());
return
"modules/echarts/lineDoubleNum"
;
}
public
Map
<
String
,
Double
[][]>
getaxisDataArr
(){
Random
random
=
new
Random
();
axisDataArr
=
new
HashMap
<
String
,
Double
[][]>();
Double
[][]
data1
=
new
Double
[
10
][
2
];
for
(
int
i
=
0
;
i
<
10
;
i
++){
data1
[
i
][
0
]=
i
+
0.0
;
data1
[
i
][
1
]=
random
.
nextInt
(
10
)+
0.0
;
}
axisDataArr
.
put
(
"曲线一"
,
data1
);
Double
[][]
data2
=
new
Double
[
10
][
2
];
for
(
int
i
=
0
;
i
<
10
;
i
++){
data2
[
i
][
0
]=
i
+
1.0
;
data2
[
i
][
1
]=
random
.
nextInt
(
10
)+
0.0
;
}
axisDataArr
.
put
(
"曲线二"
,
data2
);
return
axisDataArr
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/PieClassController.java
0 → 100644
View file @
8b643e22
/**
* Copyright © 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.echarts.web
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.ConstraintViolationException
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.utils.MyBeanUtils
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.modules.echarts.entity.PieClass
;
import
com.jeespring.modules.echarts.service.PieClassService
;
/**
* 班级Controller
* @author lgf
* @version 2016-05-26
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/pieClass"
)
public
class
PieClassController
extends
AbstractBaseController
{
@Autowired
private
PieClassService
pieClassService
;
@ModelAttribute
public
PieClass
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
PieClass
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
pieClassService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
PieClass
();
}
return
entity
;
}
/**
* 班级列表页面
*/
@RequiresPermissions
(
"echarts:pieClass:list"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
PieClass
pieClass
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
PieClass
>
page
=
pieClassService
.
findPage
(
new
Page
<
PieClass
>(
request
,
response
),
pieClass
);
model
.
addAttribute
(
"page"
,
page
);
//生成报表数据
Map
<
String
,
Object
>
orientData
=
new
HashMap
<
String
,
Object
>();
List
<
PieClass
>
list
=
pieClassService
.
findList
(
pieClass
);
for
(
PieClass
pie:
list
){
orientData
.
put
(
pie
.
getClassName
(),
pie
.
getNum
());
}
model
.
addAttribute
(
"orientData"
,
orientData
);
return
"modules/echarts/pieClassList"
;
}
/**
* 查看,增加,编辑班级表单页面
*/
@RequiresPermissions
(
value
={
"echarts:pieClass:view"
,
"echarts:pieClass:add"
,
"echarts:pieClass:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
PieClass
pieClass
,
Model
model
)
{
model
.
addAttribute
(
"pieClass"
,
pieClass
);
return
"modules/echarts/pieClassForm"
;
}
/**
* 保存班级
*/
@RequiresPermissions
(
value
={
"echarts:pieClass:add"
,
"echarts:pieClass:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
PieClass
pieClass
,
Model
model
,
RedirectAttributes
redirectAttributes
)
throws
Exception
{
if
(!
beanValidator
(
model
,
pieClass
)){
return
form
(
pieClass
,
model
);
}
if
(!
pieClass
.
getIsNewRecord
()){
//编辑表单保存
PieClass
t
=
pieClassService
.
get
(
pieClass
.
getId
());
//从数据库取出记录的值
MyBeanUtils
.
copyBeanNotNull2Bean
(
pieClass
,
t
);
//将编辑表单中的非NULL值覆盖数据库记录中的值
pieClassService
.
save
(
t
);
//保存
}
else
{
//新增表单保存
pieClassService
.
save
(
pieClass
);
//保存
}
addMessage
(
redirectAttributes
,
"保存班级成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/pieClass/?repage"
;
}
/**
* 删除班级
*/
@RequiresPermissions
(
"echarts:pieClass:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
PieClass
pieClass
,
RedirectAttributes
redirectAttributes
)
{
pieClassService
.
delete
(
pieClass
);
addMessage
(
redirectAttributes
,
"删除班级成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/pieClass/?repage"
;
}
/**
* 批量删除班级
*/
@RequiresPermissions
(
"echarts:pieClass:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
pieClassService
.
delete
(
pieClassService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除班级成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/pieClass/?repage"
;
}
/**
* 导出excel文件
*/
@RequiresPermissions
(
"echarts:pieClass:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
PieClass
pieClass
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"班级"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
PieClass
>
page
=
pieClassService
.
findPage
(
new
Page
<
PieClass
>(
request
,
response
,
-
1
),
pieClass
);
new
ExportExcel
(
"班级"
,
PieClass
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出班级记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/pieClass/?repage"
;
}
/**
* 导入Excel数据
*/
@RequiresPermissions
(
"echarts:pieClass:import"
)
@RequestMapping
(
value
=
"import"
,
method
=
RequestMethod
.
POST
)
public
String
importFile
(
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
try
{
int
successNum
=
0
;
int
failureNum
=
0
;
StringBuilder
failureMsg
=
new
StringBuilder
();
ImportExcel
ei
=
new
ImportExcel
(
file
,
1
,
0
);
List
<
PieClass
>
list
=
ei
.
getDataList
(
PieClass
.
class
);
for
(
PieClass
pieClass
:
list
){
try
{
pieClassService
.
save
(
pieClass
);
successNum
++;
}
catch
(
ConstraintViolationException
ex
){
failureNum
++;
}
catch
(
Exception
ex
)
{
failureNum
++;
}
}
if
(
failureNum
>
0
){
failureMsg
.
insert
(
0
,
",失败 "
+
failureNum
+
" 条班级记录。"
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条班级记录"
+
failureMsg
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入班级失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/pieClass/?repage"
;
}
/**
* 下载导入班级数据模板
*/
@RequiresPermissions
(
"echarts:pieClass:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"班级数据导入模板.xlsx"
;
List
<
PieClass
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"班级数据"
,
PieClass
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/echarts/pieClass/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/PieController.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.echarts.web
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.jeespring.common.web.AbstractBaseController
;
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/pie"
)
public
class
PieController
extends
AbstractBaseController
{
private
static
final
long
serialVersionUID
=
7375363226310112119L
;
private
Map
<
String
,
Object
>
orientData
;
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
request
.
setAttribute
(
"orientData"
,
getorientData
());
return
"modules/echarts/pie"
;
}
public
Map
<
String
,
Object
>
getorientData
(){
orientData
=
new
HashMap
<
String
,
Object
>();
orientData
.
put
(
"直接访问"
,
335
);
orientData
.
put
(
"邮件营销"
,
310
);
orientData
.
put
(
"联盟广告"
,
234
);
orientData
.
put
(
"视频广告"
,
135
);
orientData
.
put
(
"搜索引擎"
,
1548
);
return
orientData
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/echarts/web/RadarController.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.echarts.web
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.jeespring.common.web.AbstractBaseController
;
@Controller
@RequestMapping
(
value
=
"${adminPath}/echarts/radar"
)
public
class
RadarController
extends
AbstractBaseController
{
private
static
final
long
serialVersionUID
=
7375363226310112119L
;
private
List
<
Map
<
String
,
Object
>>
orientData
;
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
request
.
setAttribute
(
"orientData"
,
getorientData8
());
return
"modules/echarts/radar"
;
}
public
List
<
Map
<
String
,
Object
>>
getorientData8
(){
orientData
=
new
ArrayList
<
Map
<
String
,
Object
>>();
Double
[]
dataArr1
=
new
Double
[]{
0.1
*
100
,
0.2
*
100
,
0.3
*
100
,
0.1
*
100
,
0.05
*
100
,
0.05
*
100
,
0.1
*
100
,
0.1
*
100
};
Map
<
String
,
Object
>
mapData1
=
new
HashMap
<
String
,
Object
>();
mapData1
.
put
(
"dataArr"
,
dataArr1
);
mapData1
.
put
(
"title"
,
"玫瑰图1"
);
orientData
.
add
(
mapData1
);
Double
[]
dataArr2
=
new
Double
[]{
0.05
*
100
,
0.05
*
100
,
0.1
*
100
,
0.1
*
100
,
0.1
*
100
,
0.2
*
100
,
0.3
*
100
,
0.1
*
100
};
Map
<
String
,
Object
>
mapData2
=
new
HashMap
<
String
,
Object
>();
mapData2
.
put
(
"dataArr"
,
dataArr2
);
mapData2
.
put
(
"title"
,
"玫瑰图2"
);
orientData
.
add
(
mapData2
);
return
orientData
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/dao/GenDataBaseDictDao.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.gen.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.gen.entity.GenTable
;
import
com.jeespring.modules.gen.entity.GenTableColumn
;
import
java.util.List
;
@Mapper
public
interface
GenDataBaseDictDao
extends
InterfaceBaseDao
<
GenTableColumn
>
{
List
<
GenTable
>
findTableList
(
GenTable
paramGenTable
);
List
<
GenTableColumn
>
findTableColumnList
(
GenTable
paramGenTable
);
List
<
String
>
findTablePK
(
GenTable
paramGenTable
);
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/dao/GenSchemeDao.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.gen.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.gen.entity.GenScheme
;
@Mapper
public
interface
GenSchemeDao
extends
InterfaceBaseDao
<
GenScheme
>
{}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/dao/GenTableColumnDao.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.gen.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.gen.entity.GenTable
;
import
com.jeespring.modules.gen.entity.GenTableColumn
;
@Mapper
public
interface
GenTableColumnDao
extends
InterfaceBaseDao
<
GenTableColumn
>
{
void
deleteByGenTable
(
GenTable
paramGenTable
);
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/dao/GenTableDao.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.gen.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.gen.entity.GenTable
;
import
org.apache.ibatis.annotations.Param
;
@Mapper
public
interface
GenTableDao
extends
InterfaceBaseDao
<
GenTable
>
{
int
buildTable
(
@Param
(
"sql"
)
String
paramString
);
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/dao/GenTemplateDao.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.gen.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.gen.entity.GenTemplate
;
@Mapper
public
interface
GenTemplateDao
extends
InterfaceBaseDao
<
GenTemplate
>
{}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenCategory.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:43
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenCategory.java
package
com.jeespring.modules.gen.entity
;
import
com.jeespring.modules.sys.entity.Dict
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
(
name
=
"category"
)
public
class
GenCategory
extends
Dict
{
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
String
>
template
;
private
List
<
String
>
childTableTemplate
;
public
static
String
CATEGORY_REF
=
"category-ref:"
;
@XmlElement
(
name
=
"template"
)
public
List
<
String
>
getTemplate
()
{
return
this
.
template
;
}
public
void
setTemplate
(
List
<
String
>
template
)
{
this
.
template
=
template
;
}
@XmlElementWrapper
(
name
=
"childTable"
)
@XmlElement
(
name
=
"template"
)
public
List
<
String
>
getChildTableTemplate
()
{
return
this
.
childTableTemplate
;
}
public
void
setChildTableTemplate
(
List
<
String
>
childTableTemplate
)
{
this
.
childTableTemplate
=
childTableTemplate
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenConfig.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:48
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenConfig.java
package
com.jeespring.modules.gen.entity
;
import
java.io.Serializable
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
com.jeespring.modules.sys.entity.Dict
;
@XmlRootElement
(
name
=
"config"
)
public
class
GenConfig
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
List
<
GenCategory
>
categoryList
;
private
List
<
Dict
>
javaTypeList
;
private
List
<
Dict
>
queryTypeList
;
private
List
<
Dict
>
showTypeList
;
@XmlElementWrapper
(
name
=
"category"
)
@XmlElement
(
name
=
"category"
)
public
List
<
GenCategory
>
getCategoryList
()
{
return
this
.
categoryList
;
}
public
void
setCategoryList
(
List
<
GenCategory
>
categoryList
)
{
this
.
categoryList
=
categoryList
;
}
@XmlElementWrapper
(
name
=
"javaType"
)
@XmlElement
(
name
=
"dict"
)
public
List
<
Dict
>
getJavaTypeList
()
{
return
this
.
javaTypeList
;
}
public
void
setJavaTypeList
(
List
<
Dict
>
javaTypeList
)
{
this
.
javaTypeList
=
javaTypeList
;
}
@XmlElementWrapper
(
name
=
"queryType"
)
@XmlElement
(
name
=
"dict"
)
public
List
<
Dict
>
getQueryTypeList
()
{
return
this
.
queryTypeList
;
}
public
void
setQueryTypeList
(
List
<
Dict
>
queryTypeList
)
{
this
.
queryTypeList
=
queryTypeList
;
}
@XmlElementWrapper
(
name
=
"showType"
)
@XmlElement
(
name
=
"dict"
)
public
List
<
Dict
>
getShowTypeList
()
{
return
this
.
showTypeList
;
}
public
void
setShowTypeList
(
List
<
Dict
>
showTypeList
)
{
this
.
showTypeList
=
showTypeList
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenScheme.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:53
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenScheme.java
package
com.jeespring.modules.gen.entity
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
org.hibernate.validator.constraints.Length
;
public
class
GenScheme
extends
AbstractBaseEntity
<
GenScheme
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
category
;
private
String
packageName
;
private
String
moduleName
;
private
String
subModuleName
;
private
String
functionName
;
private
String
functionNameSimple
;
private
String
functionAuthor
;
private
GenTable
genTable
;
private
String
flag
;
private
Boolean
replaceFile
;
public
GenScheme
()
{}
public
GenScheme
(
String
id
)
{
super
(
id
);
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
this
.
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPackageName
()
{
return
this
.
packageName
;
}
public
void
setPackageName
(
String
packageName
)
{
this
.
packageName
=
packageName
;
}
public
String
getModuleName
()
{
return
this
.
moduleName
;
}
public
void
setModuleName
(
String
moduleName
)
{
this
.
moduleName
=
moduleName
;
}
public
String
getSubModuleName
()
{
return
this
.
subModuleName
;
}
public
void
setSubModuleName
(
String
subModuleName
)
{
this
.
subModuleName
=
subModuleName
;
}
public
String
getCategory
()
{
return
this
.
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
public
String
getFunctionName
()
{
return
this
.
functionName
;
}
public
void
setFunctionName
(
String
functionName
)
{
this
.
functionName
=
functionName
;
}
public
String
getFunctionNameSimple
()
{
return
this
.
functionNameSimple
;
}
public
void
setFunctionNameSimple
(
String
functionNameSimple
)
{
this
.
functionNameSimple
=
functionNameSimple
;
}
public
String
getFunctionAuthor
()
{
return
this
.
functionAuthor
;
}
public
void
setFunctionAuthor
(
String
functionAuthor
)
{
this
.
functionAuthor
=
functionAuthor
;
}
public
GenTable
getGenTable
()
{
return
this
.
genTable
;
}
public
void
setGenTable
(
GenTable
genTable
)
{
this
.
genTable
=
genTable
;
}
public
String
getFlag
()
{
return
this
.
flag
;
}
public
void
setFlag
(
String
flag
)
{
this
.
flag
=
flag
;
}
public
Boolean
getReplaceFile
()
{
return
this
.
replaceFile
;
}
public
void
setReplaceFile
(
Boolean
replaceFile
)
{
this
.
replaceFile
=
replaceFile
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenTable.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:58
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTable.java
package
com.jeespring.modules.gen.entity
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.hibernate.validator.constraints.Length
;
public
class
GenTable
extends
AbstractBaseEntity
<
GenTable
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
pk
;
private
String
comments
;
private
String
tableType
;
private
String
className
;
private
String
parentTable
;
private
String
parentTableFk
;
private
String
isSync
;
private
List
<
GenTableColumn
>
columnList
=
(
List
)
Lists
.
newArrayList
();
private
String
nameLike
;
private
List
<
String
>
pkList
;
private
GenTable
parent
;
private
List
<
GenTable
>
childList
=
(
List
)
Lists
.
newArrayList
();
public
GenTable
()
{}
public
GenTable
(
String
id
)
{
super
(
id
);
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
StringUtils
.
lowerCase
(
this
.
name
);
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPk
()
{
if
(
this
.
pk
==
""
||
this
.
pk
==
null
)
this
.
pk
=
"id"
;
return
this
.
pk
;
}
public
void
setPk
(
String
pk
)
{
this
.
pk
=
pk
;
}
public
String
getComments
()
{
return
this
.
comments
;
}
public
void
setComments
(
String
comments
)
{
this
.
comments
=
comments
;
}
public
String
getClassName
()
{
return
this
.
className
;
}
public
void
setClassName
(
String
className
)
{
this
.
className
=
className
;
}
public
String
getParentTable
()
{
return
StringUtils
.
lowerCase
(
this
.
parentTable
);
}
public
void
setParentTable
(
String
parentTable
)
{
this
.
parentTable
=
parentTable
;
}
public
String
getParentTableFk
()
{
return
StringUtils
.
lowerCase
(
this
.
parentTableFk
);
}
public
void
setParentTableFk
(
String
parentTableFk
)
{
this
.
parentTableFk
=
parentTableFk
;
}
public
List
<
String
>
getPkList
()
{
return
this
.
pkList
;
}
public
void
setPkList
(
List
<
String
>
pkList
)
{
this
.
pkList
=
pkList
;
if
(
this
.
pkList
.
size
()>=
1
){
this
.
pk
=
this
.
pkList
.
get
(
0
);
}
}
public
String
getNameLike
()
{
return
this
.
nameLike
;
}
public
void
setNameLike
(
String
nameLike
)
{
this
.
nameLike
=
nameLike
;
}
public
GenTable
getParent
()
{
return
this
.
parent
;
}
public
void
setParent
(
GenTable
parent
)
{
this
.
parent
=
parent
;
}
public
List
<
GenTableColumn
>
getColumnList
()
{
return
this
.
columnList
;
}
public
void
setColumnList
(
List
<
GenTableColumn
>
columnList
)
{
this
.
columnList
=
columnList
;
}
public
List
<
GenTable
>
getChildList
()
{
return
this
.
childList
;
}
public
void
setChildList
(
List
<
GenTable
>
childList
)
{
this
.
childList
=
childList
;
}
public
String
getNameAndComments
()
{
return
getName
()
+
(
this
.
comments
==
null
?
""
:
new
StringBuilder
(
" : "
).
append
(
this
.
comments
).
toString
());
}
public
List
<
String
>
getImportList
()
{
List
importList
=
Lists
.
newArrayList
();
for
(
Iterator
iterator
=
getColumnList
().
iterator
();
iterator
.
hasNext
();)
{
GenTableColumn
column
=
(
GenTableColumn
)
iterator
.
next
();
if
((
column
.
getIsNotBaseField
().
booleanValue
()
||
"1"
.
equals
(
column
.
getIsQuery
())
&&
"between"
.
equals
(
column
.
getQueryType
())
&&
(
"createDate"
.
equals
(
column
.
getSimpleJavaField
())
||
"updateDate"
.
equals
(
column
.
getSimpleJavaField
())))
&&
StringUtils
.
indexOf
(
column
.
getJavaType
(),
"."
)
!=
-
1
&&
!
importList
.
contains
(
column
.
getJavaType
()))
importList
.
add
(
column
.
getJavaType
());
if
(
column
.
getIsNotBaseField
().
booleanValue
())
{
for
(
Iterator
iterator1
=
column
.
getAnnotationList
().
iterator
();
iterator1
.
hasNext
();)
{
String
ann
=
(
String
)
iterator1
.
next
();
if
(!
importList
.
contains
(
StringUtils
.
substringBeforeLast
(
ann
,
"("
)))
importList
.
add
(
StringUtils
.
substringBeforeLast
(
ann
,
"("
));
}
}
}
if
(
getChildList
()
!=
null
&&
getChildList
().
size
()
>
0
)
{
if
(!
importList
.
contains
(
"java.util.List"
))
importList
.
add
(
"java.util.List"
);
if
(!
importList
.
contains
(
"com.google.common.collect.Lists"
))
importList
.
add
(
"com.google.common.collect.Lists"
);
}
return
importList
;
}
public
Boolean
getParentExists
()
{
if
((
this
.
parent
!=
null
)
&&
(
StringUtils
.
isNotBlank
(
this
.
parentTable
))
&&
(
StringUtils
.
isNotBlank
(
this
.
parentTableFk
)))
{
return
Boolean
.
valueOf
(
true
);
}
return
Boolean
.
valueOf
(
false
);
}
public
Boolean
getCreateDateExists
()
{
for
(
GenTableColumn
c
:
this
.
columnList
)
{
if
(
"create_date"
.
equals
(
c
.
getName
()))
{
return
Boolean
.
valueOf
(
true
);
}
}
return
Boolean
.
valueOf
(
false
);
}
public
Boolean
getUpdateDateExists
()
{
for
(
GenTableColumn
c
:
this
.
columnList
)
{
if
(
"update_date"
.
equals
(
c
.
getName
()))
{
return
Boolean
.
valueOf
(
true
);
}
}
return
Boolean
.
valueOf
(
false
);
}
public
Boolean
getDelFlagExists
()
{
for
(
GenTableColumn
c
:
this
.
columnList
)
{
if
(
"del_flag"
.
equals
(
c
.
getName
()))
{
return
Boolean
.
valueOf
(
true
);
}
}
return
Boolean
.
valueOf
(
false
);
}
public
void
setIsSync
(
String
isSync
)
{
this
.
isSync
=
isSync
;
}
public
String
getIsSync
()
{
return
this
.
isSync
;
}
public
void
setTableType
(
String
tableType
)
{
this
.
tableType
=
tableType
;
}
public
String
getTableType
()
{
return
this
.
tableType
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenTableColumn.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:24:02
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTableColumn.java
package
com.jeespring.modules.gen.entity
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
java.util.List
;
import
org.hibernate.validator.constraints.Length
;
public
class
GenTableColumn
extends
AbstractBaseEntity
<
GenTableColumn
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
GenTable
genTable
;
private
String
name
;
private
String
comments
;
private
String
jdbcType
;
private
String
javaType
;
private
String
javaField
;
private
String
isPk
;
private
String
isNull
;
private
String
isInsert
;
private
String
isEdit
;
private
String
isList
;
private
String
isQuery
;
private
String
queryType
;
private
String
showType
;
private
String
dictType
;
private
Integer
sort
;
private
String
autoIncrement
;
public
GenTableColumn
()
{}
public
GenTableColumn
(
String
id
)
{
super
(
id
);
}
public
GenTableColumn
(
GenTable
genTable
)
{
this
.
genTable
=
genTable
;
}
public
GenTable
getGenTable
()
{
return
this
.
genTable
;
}
public
void
setGenTable
(
GenTable
genTable
)
{
this
.
genTable
=
genTable
;
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
StringUtils
.
lowerCase
(
this
.
name
);
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getComments
()
{
return
this
.
comments
;
}
public
void
setComments
(
String
comments
)
{
this
.
comments
=
comments
;
}
public
String
getJdbcType
()
{
return
StringUtils
.
lowerCase
(
this
.
jdbcType
);
}
public
void
setJdbcType
(
String
jdbcType
)
{
this
.
jdbcType
=
jdbcType
;
}
public
String
getJavaType
()
{
return
this
.
javaType
;
}
public
void
setJavaType
(
String
javaType
)
{
this
.
javaType
=
javaType
;
}
public
String
getJavaField
()
{
return
this
.
javaField
;
}
public
void
setJavaField
(
String
javaField
)
{
this
.
javaField
=
javaField
;
}
public
String
getIsPk
()
{
return
this
.
isPk
;
}
public
void
setIsPk
(
String
isPk
)
{
this
.
isPk
=
isPk
;
}
public
String
getIsNull
()
{
return
this
.
isNull
;
}
public
void
setIsNull
(
String
isNull
)
{
this
.
isNull
=
isNull
;
}
public
String
getIsInsert
()
{
return
this
.
isInsert
;
}
public
void
setIsInsert
(
String
isInsert
)
{
this
.
isInsert
=
isInsert
;
}
public
String
getIsEdit
()
{
return
this
.
isEdit
;
}
public
void
setIsEdit
(
String
isEdit
)
{
this
.
isEdit
=
isEdit
;
}
public
String
getIsList
()
{
return
this
.
isList
;
}
public
void
setIsList
(
String
isList
)
{
this
.
isList
=
isList
;
}
public
String
getIsQuery
()
{
return
this
.
isQuery
;
}
public
void
setIsQuery
(
String
isQuery
)
{
this
.
isQuery
=
isQuery
;
}
public
String
getQueryType
()
{
return
this
.
queryType
;
}
public
void
setQueryType
(
String
queryType
)
{
this
.
queryType
=
queryType
;
}
public
String
getShowType
()
{
return
this
.
showType
;
}
public
void
setShowType
(
String
showType
)
{
this
.
showType
=
showType
;
}
public
String
getDictType
()
{
return
this
.
dictType
==
null
?
""
:
this
.
dictType
;
}
public
void
setDictType
(
String
dictType
)
{
this
.
dictType
=
dictType
;
}
public
Integer
getSort
()
{
return
this
.
sort
;
}
public
void
setSort
(
Integer
sort
)
{
this
.
sort
=
sort
;
}
public
String
getNameAndComments
()
{
return
getName
()
+
(
this
.
comments
==
null
?
""
:
new
StringBuilder
(
" : "
).
append
(
this
.
comments
).
toString
());
}
public
String
getDataLength
()
{
String
[]
ss
=
StringUtils
.
split
(
StringUtils
.
substringBetween
(
getJdbcType
(),
"("
,
")"
),
","
);
if
((
ss
!=
null
)
&&
(
ss
.
length
==
1
))
{
return
ss
[
0
];
}
return
"0"
;
}
public
String
getSimpleJavaType
()
{
if
(
"This"
.
equals
(
getJavaType
()))
{
return
StringUtils
.
capitalize
(
this
.
genTable
.
getClassName
());
}
return
StringUtils
.
indexOf
(
getJavaType
(),
"."
)
!=
-
1
?
StringUtils
.
substringAfterLast
(
getJavaType
(),
"."
)
:
getJavaType
();
}
public
String
getSimpleJavaField
()
{
return
StringUtils
.
substringBefore
(
getJavaField
(),
"."
);
}
public
String
getJavaFieldId
()
{
return
StringUtils
.
substringBefore
(
getJavaField
(),
"|"
);
}
public
String
getJavaFieldName
()
{
String
[][]
ss
=
getJavaFieldAttrs
();
return
ss
.
length
>
0
?
getSimpleJavaField
()
+
"."
+
ss
[
0
][
0
]
:
""
;
}
public
String
[][]
getJavaFieldAttrs
()
{
String
[]
ss
=
StringUtils
.
split
(
StringUtils
.
substringAfter
(
getJavaField
(),
"|"
),
"|"
);
String
[][]
sss
=
new
String
[
ss
.
length
][
2
];
if
(
ss
!=
null
)
{
for
(
int
i
=
0
;
i
<
ss
.
length
;
i
++)
{
sss
[
i
][
0
]
=
ss
[
i
];
sss
[
i
][
1
]
=
StringUtils
.
toUnderScoreCase
(
ss
[
i
]);
}
}
return
sss
;
}
public
List
<
String
>
getAnnotationList
()
{
List
<
String
>
list
=
Lists
.
newArrayList
();
if
(
"This"
.
equals
(
getJavaType
()))
{
list
.
add
(
"com.fasterxml.jackson.annotation.JsonBackReference"
);
}
if
(
"java.util.Date"
.
equals
(
getJavaType
()))
{
list
.
add
(
"com.fasterxml.jackson.annotation.JsonFormat(pattern = \"yyyy-MM-dd HH:mm:ss\")"
);
}
if
((!
"1"
.
equals
(
getIsNull
()))
&&
(!
"String"
.
equals
(
getJavaType
())))
{
list
.
add
(
"javax.validation.constraints.NotNull(message=\""
+
getComments
()
+
"不能为空\")"
);
}
else
if
((!
"1"
.
equals
(
getIsNull
()))
&&
(
"String"
.
equals
(
getJavaType
()))
&&
(!
"0"
.
equals
(
getDataLength
())))
{
list
.
add
(
"org.hibernate.validator.constraints.Length(min=1, max="
+
getDataLength
()
+
", message=\""
+
getComments
()
+
"长度必须介于 1 和 "
+
getDataLength
()
+
" 之间\")"
);
}
else
if
((
"String"
.
equals
(
getJavaType
()))
&&
(!
"0"
.
equals
(
getDataLength
())))
{
list
.
add
(
"org.hibernate.validator.constraints.Length(min=0, max="
+
getDataLength
()
+
", message=\""
+
getComments
()
+
"长度必须介于 0 和 "
+
getDataLength
()
+
" 之间\")"
);
}
return
list
;
}
public
List
<
String
>
getSimpleAnnotationList
()
{
List
<
String
>
list
=
Lists
.
newArrayList
();
for
(
String
ann
:
getAnnotationList
())
{
list
.
add
(
StringUtils
.
substringAfterLast
(
ann
,
"."
));
}
return
list
;
}
public
Boolean
getIsNotBaseField
()
{
if
((!
StringUtils
.
equals
(
getSimpleJavaField
(),
"id"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"remarks"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"createBy"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"createDate"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"updateBy"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"updateDate"
))
&&
(!
StringUtils
.
equals
(
getSimpleJavaField
(),
"delFlag"
)))
{
return
Boolean
.
valueOf
(
true
);
}
return
Boolean
.
valueOf
(
false
);
}
public
String
getAutoIncrement
()
{
return
this
.
autoIncrement
;
}
public
void
setAutoIncrement
(
String
autoIncrement
)
{
this
.
autoIncrement
=
autoIncrement
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/entity/GenTemplate.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:24:06
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenTemplate.java
package
com.jeespring.modules.gen.entity
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlTransient
;
import
org.hibernate.validator.constraints.Length
;
@XmlRootElement
(
name
=
"template"
)
public
class
GenTemplate
extends
AbstractBaseEntity
<
GenTemplate
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
category
;
private
String
filePath
;
private
String
fileName
;
private
String
content
;
public
GenTemplate
()
{}
public
GenTemplate
(
String
id
)
{
super
(
id
);
}
@Length
(
min
=
1
,
max
=
200
)
public
String
getName
()
{
return
this
.
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getFileName
()
{
return
this
.
fileName
;
}
public
void
setFileName
(
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
String
getFilePath
()
{
return
this
.
filePath
;
}
public
void
setFilePath
(
String
filePath
)
{
this
.
filePath
=
filePath
;
}
public
String
getContent
()
{
return
this
.
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getCategory
()
{
return
this
.
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
@XmlTransient
public
List
<
String
>
getCategoryList
()
{
if
(
this
.
category
==
null
)
{
return
(
List
)
Lists
.
newArrayList
();
}
return
Lists
.
newArrayList
(
StringUtils
.
split
(
this
.
category
,
","
));
}
public
void
setCategoryList
(
List
<
String
>
categoryList
)
{
if
(
categoryList
==
null
)
{
this
.
category
=
""
;
}
else
{
this
.
category
=
(
","
+
StringUtils
.
join
(
categoryList
,
","
)
+
","
);
}
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/service/CgAutoListService.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:22
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: CgAutoListService.java
package
com.jeespring.modules.gen.service
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.modules.gen.dao.*
;
import
com.jeespring.modules.gen.entity.*
;
import
com.jeespring.modules.gen.template.FreemarkerHelper
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
CgAutoListService
extends
AbstractService
{
public
CgAutoListService
()
{
}
public
GenTable
get
(
String
id
)
{
GenTable
genTable
=
genTableDao
.
get
(
id
);
GenTableColumn
genTableColumn
=
new
GenTableColumn
();
genTableColumn
.
setGenTable
(
new
GenTable
(
genTable
.
getId
()));
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
genTableColumn
));
return
genTable
;
}
public
Page
find
(
Page
page
,
GenTable
genTable
)
{
genTable
.
setPage
(
page
);
page
.
setList
(
genTableDao
.
findList
(
genTable
));
return
page
;
}
public
List
findAll
()
{
return
genTableDao
.
findAllList
(
new
GenTable
());
}
public
List
findTableListFormDb
(
GenTable
genTable
)
{
return
genDataBaseDictDao
.
findTableList
(
genTable
);
}
public
boolean
checkTableName
(
String
tableName
)
{
if
(
StringUtils
.
isBlank
(
tableName
))
return
true
;
GenTable
genTable
=
new
GenTable
();
genTable
.
setName
(
tableName
);
List
list
=
genTableDao
.
findList
(
genTable
);
return
list
.
size
()
==
0
;
}
public
boolean
checkTableNameFromDB
(
String
tableName
)
{
if
(
StringUtils
.
isBlank
(
tableName
))
return
true
;
GenTable
genTable
=
new
GenTable
();
genTable
.
setName
(
tableName
);
List
list
=
genDataBaseDictDao
.
findTableList
(
genTable
);
return
list
.
size
()
==
0
;
}
public
String
generateCode
(
GenScheme
genScheme
)
{
StringBuilder
result
=
new
StringBuilder
();
GenTable
genTable
=
genTableDao
.
get
(
genScheme
.
getGenTable
().
getId
());
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
genTable
.
getId
()))));
com
.
jeespring
.
modules
.
gen
.
entity
.
GenConfig
config
=
GenUtils
.
getConfig
();
genScheme
.
setGenTable
(
genTable
);
java
.
util
.
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
FreemarkerHelper
viewEngine
=
new
FreemarkerHelper
();
String
html
=
viewEngine
.
parseTemplate
(
"/com/jeespring/modules/gen/template/viewList.ftl"
,
model
);
return
html
;
}
public
String
generateListCode
(
GenScheme
genScheme
)
{
StringBuilder
result
=
new
StringBuilder
();
GenTable
genTable
=
genTableDao
.
get
(
genScheme
.
getGenTable
().
getId
());
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
genTable
.
getId
()))));
com
.
jeespring
.
modules
.
gen
.
entity
.
GenConfig
config
=
GenUtils
.
getConfig
();
genScheme
.
setGenTable
(
genTable
);
java
.
util
.
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
FreemarkerHelper
viewEngine
=
new
FreemarkerHelper
();
String
html
=
viewEngine
.
parseTemplate
(
"/com/jeespring/modules/gen/template/findList.ftl"
,
model
);
return
html
;
}
@Autowired
private
GenTableDao
genTableDao
;
@Autowired
private
GenTableColumnDao
genTableColumnDao
;
@Autowired
private
GenDataBaseDictDao
genDataBaseDictDao
;
}
JeeSpringCloud/src/main/java/com/jeespring/modules/gen/service/GenSchemeService.java
0 → 100644
View file @
8b643e22
// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:26
// Home Page: http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: GenSchemeService.java
package
com.jeespring.modules.gen.service
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.modules.gen.dao.*
;
import
com.jeespring.modules.gen.entity.*
;
import
com.jeespring.modules.gen.util.GenUtils
;
import
java.util.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
GenSchemeService
extends
AbstractService
{
public
GenSchemeService
()
{
}
public
GenScheme
get
(
String
id
)
{
return
genSchemeDao
.
get
(
id
);
}
public
Page
find
(
Page
page
,
GenScheme
genScheme
)
{
GenUtils
.
getTemplatePath
();
genScheme
.
setPage
(
page
);
page
.
setList
(
genSchemeDao
.
findList
(
genScheme
));
return
page
;
}
@Transactional
(
readOnly
=
false
)
public
String
save
(
GenScheme
genScheme
)
{
if
(
StringUtils
.
isBlank
(
genScheme
.
getId
()))
{
genScheme
.
preInsert
();
genSchemeDao
.
insert
(
genScheme
);
}
else
{
genScheme
.
preUpdate
();
genSchemeDao
.
update
(
genScheme
);
}
return
generateCode
(
genScheme
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
GenScheme
genScheme
)
{
genSchemeDao
.
delete
(
genScheme
);
}
private
String
generateCode
(
GenScheme
genScheme
)
{
StringBuilder
result
=
new
StringBuilder
();
GenTable
genTable
=
genTableDao
.
get
(
genScheme
.
getGenTable
().
getId
());
genTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
genTable
.
getId
()))));
GenConfig
config
=
GenUtils
.
getConfig
();
List
templateList
=
GenUtils
.
getTemplateList
(
config
,
genScheme
.
getCategory
(),
false
);
List
childTableTemplateList
=
GenUtils
.
getTemplateList
(
config
,
genScheme
.
getCategory
(),
true
);
if
(
childTableTemplateList
.
size
()
>
0
)
{
GenTable
parentTable
=
new
GenTable
();
parentTable
.
setParentTable
(
genTable
.
getName
());
genTable
.
setChildList
(
genTableDao
.
findList
(
parentTable
));
}
for
(
Iterator
iterator
=
genTable
.
getChildList
().
iterator
();
iterator
.
hasNext
();)
{
GenTable
childTable
=
(
GenTable
)
iterator
.
next
();
childTable
.
setParent
(
genTable
);
childTable
.
setColumnList
(
genTableColumnDao
.
findList
(
new
GenTableColumn
(
new
GenTable
(
childTable
.
getId
()))));
genScheme
.
setGenTable
(
childTable
);
Map
childTableModel
=
GenUtils
.
getDataModel
(
genScheme
);
GenTemplate
tpl
;
for
(
Iterator
iterator2
=
childTableTemplateList
.
iterator
();
iterator2
.
hasNext
();
result
.
append
(
GenUtils
.
generateToFile
(
tpl
,
childTableModel
,
true
)))
tpl
=
(
GenTemplate
)
iterator2
.
next
();
}
genScheme
.
setGenTable
(
genTable
);
Map
model
=
GenUtils
.
getDataModel
(
genScheme
);
GenTemplate
tpl
;
for
(
Iterator
iterator1
=
templateList
.
iterator
();
iterator1
.
hasNext
();
result
.
append
(
GenUtils
.
generateToFile
(
tpl
,
model
,
true
)))
tpl
=
(
GenTemplate
)
iterator1
.
next
();
return
result
.
toString
();
}
public
GenScheme
findUniqueByProperty
(
String
propertyName
,
String
value
)
{
return
genSchemeDao
.
findUniqueByProperty
(
propertyName
,
value
);
}
@Autowired
private
GenSchemeDao
genSchemeDao
;
@Autowired
private
GenTableDao
genTableDao
;
@Autowired
private
GenTableColumnDao
genTableColumnDao
;
}
Prev
1
…
7
8
9
10
11
12
13
14
15
…
20
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