Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doc_wei
Skyeye
提交
cdd549a0
S
Skyeye
项目概览
doc_wei
/
Skyeye
通知
1173
Star
154
Fork
127
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Skyeye
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cdd549a0
编写于
11月 01, 2018
作者:
doc_wei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
生成文件完成
上级
f26b154c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
173 addition
and
6 deletion
+173
-6
skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java
...common/src/main/java/com/skyeye/common/util/ToolUtil.java
+28
-0
skyeye-dao/src/main/java/com/skyeye/common/dao/CommonDao.java
...ye-dao/src/main/java/com/skyeye/common/dao/CommonDao.java
+5
-0
skyeye-service/src/main/java/com/skyeye/common/service/CommonService.java
...rc/main/java/com/skyeye/common/service/CommonService.java
+2
-0
skyeye-service/src/main/java/com/skyeye/common/service/impl/CommonServiceImpl.java
...ava/com/skyeye/common/service/impl/CommonServiceImpl.java
+83
-0
skyeye-web/src/main/java/com/skyeye/common/controller/CommonController.java
...n/java/com/skyeye/common/controller/CommonController.java
+16
-0
skyeye-web/src/main/resources/dbmapper/CommonMapper.xml
skyeye-web/src/main/resources/dbmapper/CommonMapper.xml
+8
-1
skyeye-web/src/main/resources/mapping/reqmapping.xml
skyeye-web/src/main/resources/mapping/reqmapping.xml
+3
-0
skyeye-web/src/main/webapp/assets/lib/layui/layui.js
skyeye-web/src/main/webapp/assets/lib/layui/layui.js
+7
-2
skyeye-web/src/main/webapp/js/codemodelgroup/usemodelgroup.js
...ye-web/src/main/webapp/js/codemodelgroup/usemodelgroup.js
+20
-3
skyeye-web/src/main/webapp/toolUtil.txt
skyeye-web/src/main/webapp/toolUtil.txt
+1
-0
未找到文件。
skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java
浏览文件 @
cdd549a0
package
com.skyeye.common.util
;
package
com.skyeye.common.util
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.RandomAccessFile
;
import
java.security.MessageDigest
;
import
java.security.MessageDigest
;
import
java.text.DateFormat
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -487,6 +489,32 @@ public class ToolUtil {
...
@@ -487,6 +489,32 @@ public class ToolUtil {
else
else
return
(
new
StringBuilder
()).
append
(
Character
.
toLowerCase
(
s
.
charAt
(
0
))).
append
(
s
.
substring
(
1
)).
toString
();
return
(
new
StringBuilder
()).
append
(
Character
.
toLowerCase
(
s
.
charAt
(
0
))).
append
(
s
.
substring
(
1
)).
toString
();
}
}
/**
* 写入内容到文件
* @param content
* @param fileName
* @return
* @throws Exception
*/
public
static
boolean
writeTxtFile
(
String
content
,
File
fileName
)
throws
Exception
{
RandomAccessFile
mm
=
null
;
boolean
flag
=
false
;
FileOutputStream
o
=
null
;
try
{
o
=
new
FileOutputStream
(
fileName
);
o
.
write
(
content
.
getBytes
(
"GBK"
));
o
.
close
();
flag
=
true
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
mm
!=
null
)
{
mm
.
close
();
}
}
return
flag
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
...
...
skyeye-dao/src/main/java/com/skyeye/common/dao/CommonDao.java
浏览文件 @
cdd549a0
package
com.skyeye.common.dao
;
package
com.skyeye.common.dao
;
import
java.util.List
;
import
java.util.Map
;
public
interface
CommonDao
{
public
interface
CommonDao
{
public
int
insertCodeModelHistory
(
List
<
Map
<
String
,
Object
>>
inBeans
)
throws
Exception
;
}
}
skyeye-service/src/main/java/com/skyeye/common/service/CommonService.java
浏览文件 @
cdd549a0
...
@@ -9,4 +9,6 @@ public interface CommonService {
...
@@ -9,4 +9,6 @@ public interface CommonService {
public
void
uploadFileBase64
(
InputObject
inputObject
,
OutputObject
outputObject
)
throws
Exception
;
public
void
uploadFileBase64
(
InputObject
inputObject
,
OutputObject
outputObject
)
throws
Exception
;
public
void
downloadFileByJsonData
(
InputObject
inputObject
,
OutputObject
outputObject
)
throws
Exception
;
}
}
skyeye-service/src/main/java/com/skyeye/common/service/impl/CommonServiceImpl.java
浏览文件 @
cdd549a0
package
com.skyeye.common.service.impl
;
package
com.skyeye.common.service.impl
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.multipart.commons.CommonsMultipartResolver
;
import
org.springframework.web.multipart.commons.CommonsMultipartResolver
;
import
com.skyeye.common.constans.Constants
;
import
com.skyeye.common.constans.Constants
;
import
com.skyeye.common.dao.CommonDao
;
import
com.skyeye.common.dao.CommonDao
;
import
com.skyeye.common.object.InputObject
;
import
com.skyeye.common.object.InputObject
;
...
@@ -19,6 +32,9 @@ import com.skyeye.common.object.OutputObject;
...
@@ -19,6 +32,9 @@ import com.skyeye.common.object.OutputObject;
import
com.skyeye.common.service.CommonService
;
import
com.skyeye.common.service.CommonService
;
import
com.skyeye.common.util.ToolUtil
;
import
com.skyeye.common.util.ToolUtil
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
@Service
@Service
public
class
CommonServiceImpl
implements
CommonService
{
public
class
CommonServiceImpl
implements
CommonService
{
...
@@ -179,5 +195,72 @@ public class CommonServiceImpl implements CommonService{
...
@@ -179,5 +195,72 @@ public class CommonServiceImpl implements CommonService{
outputObject
.
setreturnMessage
(
"上传失败,数据不合法"
);
outputObject
.
setreturnMessage
(
"上传失败,数据不合法"
);
}
}
}
}
/**
*
* @Title: downloadFileByJsonData
* @Description: 代码生成器下载
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@SuppressWarnings
({
"static-access"
})
@Override
public
void
downloadFileByJsonData
(
InputObject
inputObject
,
OutputObject
outputObject
)
throws
Exception
{
Map
<
String
,
Object
>
map
=
inputObject
.
getParams
();
JSONArray
array
=
JSONArray
.
fromObject
(
map
.
get
(
"jsonData"
).
toString
());
String
tPath
=
inputObject
.
getRequest
().
getSession
().
getServletContext
().
getRealPath
(
"/"
);
String
basePath
=
tPath
.
substring
(
0
,
inputObject
.
getRequest
().
getSession
().
getServletContext
().
getRealPath
(
"/"
).
indexOf
(
Constants
.
PROJECT_WEB
));
List
<
Map
<
String
,
Object
>>
inBeans
=
new
ArrayList
<>();
Map
<
String
,
Object
>
user
=
inputObject
.
getLogParams
();
String
zipName
=
ToolUtil
.
getSurFaceId
()
+
".zip"
;
String
strZipPath
=
basePath
+
"/"
+
zipName
;
ZipOutputStream
out
=
new
ZipOutputStream
(
new
FileOutputStream
(
strZipPath
));
byte
[]
buffer
=
new
byte
[
1024
];
for
(
int
i
=
0
;
i
<
array
.
size
();
i
++){
JSONObject
object
=
(
JSONObject
)
array
.
get
(
i
);
//加入压缩包
ByteArrayInputStream
stream
=
new
ByteArrayInputStream
(
object
.
getString
(
"content"
).
getBytes
());
out
.
putNextEntry
(
new
ZipEntry
(
object
.
getString
(
"fileName"
)
+
"."
+
object
.
getString
(
"modelType"
).
toLowerCase
()));
int
len
;
// 读入需要下载的文件的内容,打包到zip文件
while
((
len
=
stream
.
read
(
buffer
))
>
0
)
{
out
.
write
(
buffer
,
0
,
len
);
}
out
.
closeEntry
();
Map
<
String
,
Object
>
bean
=
new
HashMap
<>();
bean
.
put
(
"id"
,
ToolUtil
.
getSurFaceId
());
bean
.
put
(
"tableName"
,
object
.
getString
(
"tableName"
));
bean
.
put
(
"groupId"
,
object
.
getString
(
"groupId"
));
bean
.
put
(
"modelId"
,
object
.
getString
(
"modelId"
));
bean
.
put
(
"content"
,
object
.
getString
(
"content"
));
bean
.
put
(
"createId"
,
user
.
get
(
"id"
));
bean
.
put
(
"filePath"
,
zipName
);
bean
.
put
(
"createTime"
,
ToolUtil
.
getTimeAndToString
());
inBeans
.
add
(
bean
);
}
out
.
close
();
commonDao
.
insertCodeModelHistory
(
inBeans
);
// //下载
// //获取输入流
// InputStream bis = new BufferedInputStream(new FileInputStream(new File(strZipPath)));
// inputObject.getResponse().setHeader("REQUESTMATION", "DOWNLOAD");
// // 转码,免得文件名中文乱码
// String filename = URLEncoder.encode(zipName, "UTF-8");
// // 设置文件下载头
// inputObject.getResponse().addHeader("Content-Disposition", "attachment;filename=" + filename);
// // 1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
// inputObject.getResponse().setContentType("multipart/form-data");
// BufferedOutputStream out1 = new BufferedOutputStream(inputObject.getResponse().getOutputStream());
// int len = 0;
// while ((len = bis.read()) != -1) {
// out1.write(len);
// out1.flush();
// }
}
}
}
skyeye-web/src/main/java/com/skyeye/common/controller/CommonController.java
浏览文件 @
cdd549a0
...
@@ -46,4 +46,20 @@ public class CommonController {
...
@@ -46,4 +46,20 @@ public class CommonController {
commonService
.
uploadFileBase64
(
inputObject
,
outputObject
);
commonService
.
uploadFileBase64
(
inputObject
,
outputObject
);
}
}
/**
*
* @Title: downloadFileByJsonData
* @Description: 代码生成器下载
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping
(
"/post/CommonController/downloadFileByJsonData"
)
@ResponseBody
public
void
downloadFileByJsonData
(
InputObject
inputObject
,
OutputObject
outputObject
)
throws
Exception
{
commonService
.
downloadFileByJsonData
(
inputObject
,
outputObject
);
}
}
}
skyeye-web/src/main/resources/dbmapper/CommonMapper.xml
浏览文件 @
cdd549a0
...
@@ -2,6 +2,13 @@
...
@@ -2,6 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.skyeye.common.dao.CommonDao"
>
<mapper
namespace=
"com.skyeye.common.dao.CommonDao"
>
<insert
id=
"insertCodeModelHistory"
parameterType=
"java.util.Map"
>
insert into code_model_history
(id, table_name, group_id, model_id, content, file_path, create_id, create_time)
values
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(#{item.id}, #{item.tableName}, #{item.groupId}, #{item.modelId}, #{item.content}, #{item.filePath}, #{item.createId}, #{item.createTime})
</foreach>
</insert>
</mapper>
</mapper>
\ No newline at end of file
skyeye-web/src/main/resources/mapping/reqmapping.xml
浏览文件 @
cdd549a0
...
@@ -337,6 +337,9 @@
...
@@ -337,6 +337,9 @@
<url
id=
"codemodel013"
path=
"/post/CodeModelGroupController/queryCodeModelListByGroupId"
val=
"根据分组id获取模板列表"
allUse=
"1"
>
<url
id=
"codemodel013"
path=
"/post/CodeModelGroupController/queryCodeModelListByGroupId"
val=
"根据分组id获取模板列表"
allUse=
"1"
>
<property
id=
"groupId"
name=
"groupId"
ref=
"required"
var=
"分组id"
/>
<property
id=
"groupId"
name=
"groupId"
ref=
"required"
var=
"分组id"
/>
</url>
</url>
<url
id=
"codemodel014"
path=
"/post/CommonController/downloadFileByJsonData"
val=
"代码生成器下载"
allUse=
"1"
>
<property
id=
"jsonData"
name=
"jsonData"
ref=
"required"
var=
"json数据"
/>
</url>
<!-- 代码生成器系列结束 -->
<!-- 代码生成器系列结束 -->
</controller>
</controller>
\ No newline at end of file
skyeye-web/src/main/webapp/assets/lib/layui/layui.js
浏览文件 @
cdd549a0
...
@@ -672,6 +672,7 @@ var AjaxPostUtil = {
...
@@ -672,6 +672,7 @@ var AjaxPostUtil = {
// 状态改变的处理
// 状态改变的处理
readystatechange
:
function
(
xmlhttp
)
{
readystatechange
:
function
(
xmlhttp
)
{
var
sessionstatus
=
xmlhttp
.
getResponseHeader
(
"
SESSIONSTATUS
"
);
var
sessionstatus
=
xmlhttp
.
getResponseHeader
(
"
SESSIONSTATUS
"
);
var
requestmation
=
xmlhttp
.
getResponseHeader
(
"
REQUESTMATION
"
);
if
(
sessionstatus
==
"
TIMEOUT
"
)
{
//超时跳转
if
(
sessionstatus
==
"
TIMEOUT
"
)
{
//超时跳转
var
win
=
window
;
var
win
=
window
;
while
(
win
!=
win
.
top
){
while
(
win
!=
win
.
top
){
...
@@ -688,8 +689,12 @@ var AjaxPostUtil = {
...
@@ -688,8 +689,12 @@ var AjaxPostUtil = {
break
;
break
;
case
"
json
"
:
case
"
json
"
:
var
jsonText
=
xmlhttp
.
responseText
;
var
jsonText
=
xmlhttp
.
responseText
;
if
(
jsonText
)
{
if
(
requestmation
==
'
DOWNLOAD
'
){
returnValue
=
eval
(
"
(
"
+
jsonText
+
"
)
"
);
returnValue
=
eval
(
'
(
'
+
'
{"returnMessage":"成功","returnCode":0,"total":0,"rows":"","bean":""}
'
+
'
)
'
);
}
else
{
if
(
jsonText
)
{
returnValue
=
eval
(
"
(
"
+
jsonText
+
"
)
"
);
}
}
}
break
;
break
;
default
:
default
:
...
...
skyeye-web/src/main/webapp/js/codemodelgroup/usemodelgroup.js
浏览文件 @
cdd549a0
...
@@ -5,7 +5,7 @@ layui.config({
...
@@ -5,7 +5,7 @@ layui.config({
version
:
skyeyeVersion
version
:
skyeyeVersion
}).
define
([
'
table
'
,
'
jquery
'
,
'
winui
'
,
'
form
'
,
'
codemirror
'
,
'
xml
'
,
'
clike
'
,
'
css
'
,
'
htmlmixed
'
,
'
javascript
'
,
'
nginx
'
,
}).
define
([
'
table
'
,
'
jquery
'
,
'
winui
'
,
'
form
'
,
'
codemirror
'
,
'
xml
'
,
'
clike
'
,
'
css
'
,
'
htmlmixed
'
,
'
javascript
'
,
'
nginx
'
,
'
solr
'
,
'
sql
'
,
'
vue
'
],
function
(
exports
)
{
'
solr
'
,
'
sql
'
,
'
vue
'
],
function
(
exports
)
{
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
//获取窗口索引
winui
.
renderColor
();
winui
.
renderColor
();
var
$
=
layui
.
$
,
var
$
=
layui
.
$
,
...
@@ -25,13 +25,27 @@ layui.config({
...
@@ -25,13 +25,27 @@ layui.config({
// groupId:模板所属分组id
// groupId:模板所属分组id
// modelName:模板别名
// modelName:模板别名
// modelContent:默认内容
// modelContent:默认内容
// fileName:文件名称
// modelType:模板类型
//}
//}
form
.
render
();
form
.
render
();
form
.
on
(
'
submit(formSearch)
'
,
function
(
data
)
{
form
.
on
(
'
submit(formSearch)
'
,
function
(
data
)
{
//表单验证
//表单验证
if
(
winui
.
verifyForm
(
data
.
elem
))
{
if
(
winui
.
verifyForm
(
data
.
elem
))
{
var
subData
=
list
;
for
(
var
i
=
0
;
i
<
subData
.
length
;
i
++
){
subData
[
i
].
modelContent
=
""
;
}
AjaxPostUtil
.
request
({
url
:
reqBasePath
+
"
codemodel014
"
,
params
:{
jsonData
:
JSON
.
stringify
(
subData
)},
type
:
'
json
'
,
callback
:
function
(
json
){
if
(
json
.
returnCode
==
0
){
top
.
winui
.
window
.
msg
(
'
保存成功,请前往生成历史下载。
'
,
{
icon
:
1
,
time
:
2000
});
parent
.
layer
.
close
(
index
);
parent
.
refreshCode
=
'
0
'
;
}
else
{
top
.
winui
.
window
.
msg
(
json
.
returnMessage
,
{
icon
:
2
,
time
:
2000
});
}
}});
}
}
return
false
;
return
false
;
});
});
...
@@ -125,7 +139,9 @@ layui.config({
...
@@ -125,7 +139,9 @@ layui.config({
tableName
:
$
(
"
#tableName
"
).
val
(),
tableName
:
$
(
"
#tableName
"
).
val
(),
groupId
:
parent
.
rowId
,
groupId
:
parent
.
rowId
,
modelName
:
row
.
modelName
,
modelName
:
row
.
modelName
,
modelContent
:
row
.
modelContent
modelContent
:
row
.
modelContent
,
fileName
:
$
(
"
#tableZhName
"
).
val
()
+
row
.
modelName
,
modelType
:
row
.
modelType
,
};
};
insertListIn
(
list
,
s
);
insertListIn
(
list
,
s
);
top
.
winui
.
window
.
msg
(
'
转换成功
'
,
{
icon
:
1
,
time
:
2000
});
top
.
winui
.
window
.
msg
(
'
转换成功
'
,
{
icon
:
1
,
time
:
2000
});
...
@@ -165,6 +181,7 @@ layui.config({
...
@@ -165,6 +181,7 @@ layui.config({
list
[
i
].
content
=
replaceModelContent
(
list
[
i
].
modelContent
,
$
(
"
#ControllerPackageName
"
).
val
(),
$
(
"
#ServicePackageName
"
).
val
(),
list
[
i
].
content
=
replaceModelContent
(
list
[
i
].
modelContent
,
$
(
"
#ControllerPackageName
"
).
val
(),
$
(
"
#ServicePackageName
"
).
val
(),
$
(
"
#ServiceImplPackageName
"
).
val
(),
$
(
"
#DaoPackageName
"
).
val
(),
$
(
"
#tableZhName
"
).
val
(),
$
(
"
#ServiceImplPackageName
"
).
val
(),
$
(
"
#DaoPackageName
"
).
val
(),
$
(
"
#tableZhName
"
).
val
(),
$
(
"
#tableFirstISlowerName
"
).
val
(),
$
(
"
#tableISlowerName
"
).
val
(),
$
(
"
#tableBzName
"
).
val
());
$
(
"
#tableFirstISlowerName
"
).
val
(),
$
(
"
#tableISlowerName
"
).
val
(),
$
(
"
#tableBzName
"
).
val
());
list
[
i
].
fileName
=
$
(
"
#tableZhName
"
).
val
()
+
list
[
i
].
modelName
;
if
(
list
[
i
].
modelId
==
editId
){
if
(
list
[
i
].
modelId
==
editId
){
textEditor
.
setOption
(
'
readOnly
'
,
false
);
textEditor
.
setOption
(
'
readOnly
'
,
false
);
textEditor
.
setValue
(
list
[
i
].
content
);
textEditor
.
setValue
(
list
[
i
].
content
);
...
...
skyeye-web/src/main/webapp/toolUtil.txt
浏览文件 @
cdd549a0
...
@@ -23,3 +23,4 @@ deleteFile(); 删除单个文件
...
@@ -23,3 +23,4 @@ deleteFile(); 删除单个文件
card(); 随机不重复的6-8位
card(); 随机不重复的6-8位
replaceUnderLineAndUpperCase(); 将表名转为Java经常使用的名字,如code_model转CodeModel
replaceUnderLineAndUpperCase(); 将表名转为Java经常使用的名字,如code_model转CodeModel
toLowerCaseFirstOne(); 字符串首字母转小写
toLowerCaseFirstOne(); 字符串首字母转小写
writeTxtFile(); 写入内容到文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录