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
4106c8d5
Commit
4106c8d5
authored
Sep 30, 2020
by
刘可心
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传图片
parent
ed9a65a7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
SettingController.java
...ava/com/archser/aserver/controller/SettingController.java
+64
-0
No files found.
src/main/java/com/archser/aserver/controller/SettingController.java
View file @
4106c8d5
...
@@ -2,8 +2,10 @@ package com.archser.aserver.controller;
...
@@ -2,8 +2,10 @@ package com.archser.aserver.controller;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
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.interceptor.JwtInterceptor
;
...
@@ -19,6 +21,8 @@ import com.jfinal.kit.PathKit;
...
@@ -19,6 +21,8 @@ import com.jfinal.kit.PathKit;
import
com.jfinal.kit.Ret
;
import
com.jfinal.kit.Ret
;
import
com.jfinal.plugin.activerecord.Db
;
import
com.jfinal.plugin.activerecord.Db
;
import
com.jfinal.plugin.activerecord.tx.Tx
;
import
com.jfinal.plugin.activerecord.tx.Tx
;
import
com.jfinal.upload.UploadFile
;
import
sun.misc.BASE64Decoder
;
import
sun.misc.BASE64Encoder
;
import
sun.misc.BASE64Encoder
;
/**
/**
...
@@ -238,4 +242,64 @@ public class SettingController extends Controller {
...
@@ -238,4 +242,64 @@ public class SettingController extends Controller {
}
}
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 end */
/** xiaoying 20200715 YZJ-4212 功能操作中没有应用管理的日志 end */
}
}
/**
* LiuKexin 202000930 更换系统图标和名称
*/
public
void
changeSetting
()
{
UploadFile
file
=
getFile
();
//没有更换图标
if
(
file
==
null
)
{
renderJson
(
Ret
.
ok
(
"msg"
,
"修改成功"
));
return
;
}
//新图标的路径
String
uploadPath
=
file
.
getUploadPath
()
+
File
.
separator
+
file
.
getFileName
();
//转化成base64
String
logoUrl
=
ImageToBase64
(
uploadPath
);
//图标路径
String
filePath
=
PathKit
.
getRootClassPath
()+
File
.
separator
+
"logo.png"
;
// 对字节数组字符串进行Base64解码并生成图片
boolean
success
=
Base64ToImange
(
logoUrl
,
filePath
);
new
File
(
uploadPath
).
delete
();
if
(
success
)
{
renderJson
(
Ret
.
ok
(
"msg"
,
"修改成功"
));
}
else
{
renderJson
(
Ret
.
fail
(
"msg"
,
"图片上传失败"
));
}
}
/**
* LiuKexin 20200930 对字节数组字符串进行Base64解码并生成图片
* @param logoUrl
* @param filePath
* @return
*/
private
boolean
Base64ToImange
(
String
logoUrl
,
String
filePath
)
{
if
(
logoUrl
==
null
)
// 图像数据为空
return
false
;
BASE64Decoder
decoder
=
new
BASE64Decoder
();
try
{
// Base64解码
byte
[]
bytes
=
decoder
.
decodeBuffer
(
logoUrl
);
for
(
int
i
=
0
;
i
<
bytes
.
length
;
++
i
)
{
if
(
bytes
[
i
]
<
0
)
{
// 调整异常数据
bytes
[
i
]
+=
256
;
}
}
// 生成图片
OutputStream
out
=
new
FileOutputStream
(
filePath
);
out
.
write
(
bytes
);
out
.
flush
();
out
.
close
();
return
true
;
}
catch
(
Exception
e
)
{
return
false
;
}
}
}
}
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