Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
aserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
15所TongWeb
aserver
Commits
61f257c9
Commit
61f257c9
authored
Jul 15, 2020
by
Dyml
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'GJYZJ_V1.0' of
http://gitlab.archser.com/common/aserver
parents
0ff7dd92
ecacdf0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
210 additions
and
172 deletions
+210
-172
SettingController.java
...ava/com/archser/aserver/controller/SettingController.java
+210
-172
No files found.
src/main/java/com/archser/aserver/controller/SettingController.java
View file @
61f257c9
...
@@ -6,7 +6,9 @@ import java.io.IOException;
...
@@ -6,7 +6,9 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
com.archser.aserver.interceptor.JwtInterceptor
;
import
com.archser.aserver.model.Config
;
import
com.archser.aserver.model.Config
;
import
com.archser.aserver.service.LogService
;
import
com.archser.aserver.service.SystemService
;
import
com.archser.aserver.service.SystemService
;
import
com.archser.aserver.validator.SettingValidator
;
import
com.archser.aserver.validator.SettingValidator
;
import
com.jfinal.aop.Before
;
import
com.jfinal.aop.Before
;
...
@@ -28,176 +30,212 @@ import sun.misc.BASE64Encoder;
...
@@ -28,176 +30,212 @@ import sun.misc.BASE64Encoder;
@SuppressWarnings
(
"restriction"
)
@SuppressWarnings
(
"restriction"
)
public
class
SettingController
extends
Controller
{
public
class
SettingController
extends
Controller
{
/**
@Inject
* 通用的获取配置方法
private
LogService
logService
;
*
* @param name
/**
*/
* 通用的获取配置方法
@Before
(
SettingValidator
.
class
)
*
public
void
index
(
String
name
)
{
* @param name
String
val
=
null
;
*/
try
{
@Before
(
SettingValidator
.
class
)
val
=
this
.
getConfig
(
name
);
public
void
index
(
String
name
)
{
}
catch
(
Exception
e
)
{
String
val
=
null
;
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
try
{
}
val
=
this
.
getConfig
(
name
);
}
catch
(
Exception
e
)
{
this
.
renderJson
(
Ret
.
ok
(
name
,
val
));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
}
}
/**
this
.
renderJson
(
Ret
.
ok
(
name
,
val
));
* 获取所有配置
}
*/
public
void
all
()
{
/**
this
.
renderJson
(
Ret
.
ok
(
"configs"
,
Config
.
dao
.
findAll
()));
* 获取所有配置
}
*/
public
void
all
()
{
@Inject
this
.
renderJson
(
Ret
.
ok
(
"configs"
,
Config
.
dao
.
findAll
()));
private
SystemService
systemService
;
}
/**
@Inject
*
private
SystemService
systemService
;
*/
public
void
findConfigList
()
{
/**
String
searchText
=
this
.
getPara
(
"searchText"
);
*
List
<
Config
>
configs
=
systemService
.
findConfigList
(
searchText
);
*/
this
.
renderJson
(
Ret
.
ok
(
"configs"
,
configs
));
public
void
findConfigList
()
{
}
String
searchText
=
this
.
getPara
(
"searchText"
);
List
<
Config
>
configs
=
systemService
.
findConfigList
(
searchText
);
/**
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 start */
* 获取单点登录地址<br>
if
(
configs
!=
null
&&
configs
.
size
()
!=
0
)
{
* 常用配置项
this
.
renderJson
(
Ret
.
ok
(
"configs"
,
configs
));
*/
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
@Clear
"应用管理-配置-查询数据包含:"
+
searchText
+
"的数据"
,
"aserver"
);
// @Before(UnifiedErrorInterceptor.class)
}
else
{
public
void
sso
()
{
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
String
val
=
null
;
"应用管理-配置-查询数据失败"
,
"aserver"
);
try
{
}
val
=
this
.
getConfig
(
"sso"
);
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 end */
}
catch
(
Exception
e
)
{
}
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
}
/**
* 获取单点登录地址<br>
this
.
renderJson
(
Ret
.
ok
(
"sso"
,
val
));
* 常用配置项
}
*/
@Clear
/**
// @Before(UnifiedErrorInterceptor.class)
* 获取设置信息<br>
public
void
sso
()
{
* 常用配置项
String
val
=
null
;
*/
try
{
public
void
search
()
{
val
=
this
.
getConfig
(
"sso"
);
String
val
=
null
;
}
catch
(
Exception
e
)
{
try
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
val
=
this
.
getConfig
(
"search"
);
}
}
catch
(
Exception
e
)
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
this
.
renderJson
(
Ret
.
ok
(
"sso"
,
val
));
}
}
this
.
renderJson
(
Ret
.
ok
(
"search"
,
val
));
/**
}
* 获取设置信息<br>
* 常用配置项
/**
*/
* 获取设置信息<br>
public
void
search
()
{
* 常用配置项
String
val
=
null
;
*/
try
{
public
void
logoUrl
()
{
val
=
this
.
getConfig
(
"search"
);
String
filePath
=
PathKit
.
getWebRootPath
()
+
File
.
separator
+
"logo"
+
File
.
separator
+
"logo.png"
;
}
catch
(
Exception
e
)
{
this
.
renderJson
(
Ret
.
ok
(
"logoUrl"
,
ImageToBase64
(
filePath
)));
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
}
}
private
static
String
ImageToBase64
(
String
imgPath
)
{
this
.
renderJson
(
Ret
.
ok
(
"search"
,
val
));
byte
[]
data
=
null
;
}
// 读取图片字节数组
try
{
/**
InputStream
in
=
new
FileInputStream
(
imgPath
);
* 获取设置信息<br>
data
=
new
byte
[
in
.
available
()];
* 常用配置项
in
.
read
(
data
);
*/
in
.
close
();
public
void
logoUrl
()
{
}
catch
(
IOException
e
)
{
String
filePath
=
e
.
printStackTrace
();
PathKit
.
getWebRootPath
()
+
File
.
separator
+
"logo"
+
File
.
separator
+
"logo.png"
;
}
this
.
renderJson
(
Ret
.
ok
(
"logoUrl"
,
ImageToBase64
(
filePath
)));
// 对字节数组Base64编码
}
BASE64Encoder
encoder
=
new
BASE64Encoder
();
// 返回Base64编码过的字节数组字符串
private
static
String
ImageToBase64
(
String
imgPath
)
{
return
encoder
.
encode
(
Objects
.
requireNonNull
(
data
));
byte
[]
data
=
null
;
// System.out.println("本地图片转换Base64:" + encoder.encode(Objects.requireNonNull(data)));
// 读取图片字节数组
}
try
{
// public void logoUrl() {
InputStream
in
=
new
FileInputStream
(
imgPath
);
// String val = null;
data
=
new
byte
[
in
.
available
()];
// try {
in
.
read
(
data
);
// val = this.getConfig("logoUrl");
in
.
close
();
// } catch (Exception e) {
}
catch
(
IOException
e
)
{
// this.renderJson(Ret.fail("msg", e.getMessage()));
e
.
printStackTrace
();
// }
}
// this.renderJson(Ret.ok("logoUrl", val));
// 对字节数组Base64编码
// }
BASE64Encoder
encoder
=
new
BASE64Encoder
();
// 返回Base64编码过的字节数组字符串
return
encoder
.
encode
(
Objects
.
requireNonNull
(
data
));
public
void
getServerName
()
{
// System.out.println("本地图片转换Base64:" + encoder.encode(Objects.requireNonNull(data)));
String
val
=
null
;
}
try
{
// public void logoUrl() {
val
=
this
.
getConfig
(
"serverName"
);
// String val = null;
}
catch
(
Exception
e
)
{
// try {
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
// val = this.getConfig("logoUrl");
}
// } catch (Exception e) {
// this.renderJson(Ret.fail("msg", e.getMessage()));
this
.
renderJson
(
Ret
.
ok
(
"serverName"
,
val
));
// }
}
// this.renderJson(Ret.ok("logoUrl", val));
// }
/**
* 获取配置项目
*
public
void
getServerName
()
{
* @param name
String
val
=
null
;
* @return
try
{
* @throws Exception
val
=
this
.
getConfig
(
"serverName"
);
*/
}
catch
(
Exception
e
)
{
private
String
getConfig
(
String
name
)
throws
Exception
{
this
.
renderJson
(
Ret
.
fail
(
"msg"
,
e
.
getMessage
()));
String
val
=
Db
.
queryStr
(
Db
.
getSql
(
"getConfigByName"
),
name
);
}
if
(
val
==
null
)
{
throw
new
Exception
(
"配置项不存在(name='"
+
name
+
"')"
);
this
.
renderJson
(
Ret
.
ok
(
"serverName"
,
val
));
}
}
return
val
;
/**
}
* 获取配置项目
*
/**
* @param name
* @used 添加修改配置
* @return
*/
* @throws Exception
@Before
(
Tx
.
class
)
*/
public
void
add
()
{
private
String
getConfig
(
String
name
)
throws
Exception
{
Config
config
=
getModel
(
Config
.
class
,
""
,
true
);
String
val
=
Db
.
queryStr
(
Db
.
getSql
(
"getConfigByName"
),
name
);
if
(
config
==
null
)
{
if
(
val
==
null
)
{
renderJson
(
Ret
.
fail
(
"msg"
,
"请填写完整数据"
));
throw
new
Exception
(
"配置项不存在(name='"
+
name
+
"')"
);
}
else
if
(
config
.
getId
()
==
null
||
config
.
getId
()
==
0
)
{
}
config
.
set
(
"ID"
,
Config
.
SEQ_NEXTVAL
);
config
.
save
();
return
val
;
renderJson
(
Ret
.
ok
(
"ok"
,
"添加成功"
));
}
}
else
if
(
config
.
getId
()
!=
0
)
{
config
.
update
();
/**
renderJson
(
Ret
.
ok
(
"ok"
,
"修改成功"
));
* @used 添加修改配置
}
*/
}
@Before
(
Tx
.
class
)
public
void
add
()
{
/**
Config
config
=
getModel
(
Config
.
class
,
""
,
true
);
* @used 删除配置
Boolean
success
=
false
;
*/
if
(
config
==
null
)
{
@Before
(
Tx
.
class
)
renderJson
(
Ret
.
fail
(
"msg"
,
"请填写完整数据"
));
public
void
dele
()
{
}
else
if
(
config
.
getId
()
==
null
||
config
.
getId
()
==
0
)
{
String
ids
=
this
.
getPara
(
"ids"
);
config
.
set
(
"ID"
,
Config
.
SEQ_NEXTVAL
);
String
[]
idsArray
=
ids
.
split
(
","
);
success
=
config
.
save
();
if
(
ids
==
null
||
idsArray
.
length
==
0
)
{
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 start */
renderJson
(
Ret
.
fail
(
"msg"
,
"请选择数据"
));
if
(
success
)
{
}
renderJson
(
Ret
.
ok
(
"ok"
,
"添加成功"
));
Boolean
success
=
false
;
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
for
(
String
id
:
idsArray
)
{
"应用管理-配置-添加配置-配置名称为-"
+
config
.
getName
()
+
"-添加成功"
,
"aserver"
);
Config
config
=
new
Config
();
}
else
{
config
.
setId
(
Integer
.
valueOf
(
id
));
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
success
=
config
.
delete
();
"应用管理-配置-添加配置-配置名称为-"
+
config
.
getName
()
+
"-添加失败"
,
"aserver"
);
}
}
if
(
success
)
{
}
else
if
(
config
.
getId
()
!=
0
)
{
renderJson
(
Ret
.
ok
());
success
=
config
.
update
();
}
else
{
if
(
success
)
{
renderJson
(
Ret
.
fail
(
"msg"
,
"删除数据出错"
));
renderJson
(
Ret
.
ok
(
"ok"
,
"修改成功"
));
}
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
}
"应用管理-配置-编辑配置-配置名称为-"
+
config
.
getName
()
+
"-修改成功"
,
"aserver"
);
}
else
{
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"应用管理-配置-编辑配置-配置名称为-"
+
config
.
getName
()
+
"-修改失败"
,
"aserver"
);
}
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 end */
}
}
/**
* @used 删除配置
*/
@Before
(
Tx
.
class
)
public
void
dele
()
{
String
ids
=
this
.
getPara
(
"ids"
);
String
[]
idsArray
=
ids
.
split
(
","
);
if
(
ids
==
null
||
idsArray
.
length
==
0
)
{
renderJson
(
Ret
.
fail
(
"msg"
,
"请选择数据"
));
}
Boolean
success
=
false
;
StringBuilder
sb
=
new
StringBuilder
();
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 start */
for
(
String
id
:
idsArray
)
{
sb
.
append
(
Config
.
dao
.
findById
(
Integer
.
valueOf
(
id
)).
getName
()
+
","
);
success
=
Config
.
dao
.
deleteById
(
Integer
.
valueOf
(
id
));
}
if
(
success
)
{
renderJson
(
Ret
.
ok
());
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"应用管理-配置-删除配置-配置名称为-"
+
sb
.
substring
(
0
,
sb
.
lastIndexOf
(
","
))
+
"-删除成功"
,
"aserver"
);
}
else
{
renderJson
(
Ret
.
fail
(
"msg"
,
"删除数据出错"
));
logService
.
saveAsLog
(
"operate"
,
getAttr
(
"username"
),
JwtInterceptor
.
getIpAddr
(
getRequest
()),
"应用管理-配置-删除配置-配置名称为-"
+
sb
.
substring
(
0
,
sb
.
lastIndexOf
(
","
))
+
"-删除失败"
,
"aserver"
);
}
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 end */
}
}
}
Write
Preview
Markdown
is supported
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