Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zjsgfa_mysql
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyun
zjsgfa_mysql
Commits
6e66bc18
Commit
6e66bc18
authored
Jul 24, 2025
by
jiang'yun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
0965313c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
0 deletions
+128
-0
src/main/java/com/ruoyi/project/common/CommonController.java
+44
-0
src/main/java/com/ruoyi/project/zjsgfa/service/impl/JcxxHseServiceImpl.java
+11
-0
src/main/java/com/ruoyi/project/zjsgfa/service/impl/JcxxJkzpServiceImpl.java
+29
-0
src/main/java/com/ruoyi/project/zjsgfa/service/impl/SjHseServiceImpl.java
+15
-0
src/main/java/com/ruoyi/project/zjsgfa/service/impl/SjJkzpServiceImpl.java
+29
-0
No files found.
src/main/java/com/ruoyi/project/common/CommonController.java
View file @
6e66bc18
package
com
.
ruoyi
.
project
.
common
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -8,6 +10,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.util.Base64Utils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -95,6 +98,47 @@ public class CommonController
}
/**
* 通用上传请求(单个)
*/
@PostMapping
(
"/uploadToBase64"
)
public
AjaxResult
uploadToBase64
(
MultipartFile
file
)
throws
Exception
{
// 验证文件是否为空
if
(
file
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"上传的文件为空"
);
}
// 获取文件原始名称,提取扩展名
String
originalFilename
=
file
.
getOriginalFilename
();
if
(
originalFilename
==
null
||
!
originalFilename
.
contains
(
"."
))
{
throw
new
IllegalArgumentException
(
"文件名称无效"
);
}
String
extension
=
originalFilename
.
substring
(
originalFilename
.
lastIndexOf
(
"."
)
+
1
).
toLowerCase
();
// 验证图片格式
if
(!
isValidImageExtension
(
extension
))
{
throw
new
IllegalArgumentException
(
"不支持的图片格式: "
+
extension
);
}
// 读取文件字节并转换为Base64
byte
[]
bytes
=
file
.
getBytes
();
String
base64Encoded
=
Base64Utils
.
encodeToString
(
bytes
);
AjaxResult
ajax
=
AjaxResult
.
success
();
ajax
.
put
(
"url"
,
"data:image/"
+
extension
+
";base64,"
+
base64Encoded
);
return
ajax
;
}
/**
* 验证图片文件扩展名是否合法
*/
private
static
boolean
isValidImageExtension
(
String
extension
)
{
return
"jpg"
.
equals
(
extension
)
||
"jpeg"
.
equals
(
extension
)
||
"png"
.
equals
(
extension
)
||
"gif"
.
equals
(
extension
)
||
"bmp"
.
equals
(
extension
)
||
"webp"
.
equals
(
extension
);
}
/**
* 通用上传请求(多个)
*/
@PostMapping
(
"/uploads"
)
...
...
src/main/java/com/ruoyi/project/zjsgfa/service/impl/JcxxHseServiceImpl.java
View file @
6e66bc18
package
com
.
ruoyi
.
project
.
zjsgfa
.
service
.
impl
;
import
java.util.List
;
import
cn.hutool.core.codec.Base64
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.zjsgfa.mapper.JcxxHseMapper
;
...
...
@@ -53,6 +56,10 @@ public class JcxxHseServiceImpl implements IJcxxHseService
@Override
public
int
insertJcxxHse
(
JcxxHse
jcxxHse
)
{
if
(
StringUtils
.
isNotEmpty
(
jcxxHse
.
getHse
())){
String
s
=
new
String
(
Base64
.
decode
(
jcxxHse
.
getHse
()));
jcxxHse
.
setHse
(
s
);
}
return
jcxxHseMapper
.
insertJcxxHse
(
jcxxHse
);
}
...
...
@@ -65,6 +72,10 @@ public class JcxxHseServiceImpl implements IJcxxHseService
@Override
public
int
updateJcxxHse
(
JcxxHse
jcxxHse
)
{
if
(
StringUtils
.
isNotEmpty
(
jcxxHse
.
getHse
())){
String
s
=
new
String
(
Base64
.
decode
(
jcxxHse
.
getHse
()));
jcxxHse
.
setHse
(
s
);
}
jcxxHse
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
jcxxHseMapper
.
updateJcxxHse
(
jcxxHse
);
}
...
...
src/main/java/com/ruoyi/project/zjsgfa/service/impl/JcxxJkzpServiceImpl.java
View file @
6e66bc18
package
com
.
ruoyi
.
project
.
zjsgfa
.
service
.
impl
;
import
java.util.List
;
import
cn.hutool.core.codec.Base64
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.zjsgfa.mapper.JcxxJkzpMapper
;
...
...
@@ -53,6 +56,19 @@ public class JcxxJkzpServiceImpl implements IJcxxJkzpService
@Override
public
int
insertJcxxJkzp
(
JcxxJkzp
jcxxJkzp
)
{
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getZjkzz
())){
jcxxJkzp
.
setZjkzz
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getZjkzz
())));
}
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getClcb
())){
jcxxJkzp
.
setClcb
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getClcb
())));
}
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getJlgh
())){
jcxxJkzp
.
setJlgh
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getJlgh
())));
}
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getSyyq
())){
jcxxJkzp
.
setSyyq
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getSyyq
())));
}
return
jcxxJkzpMapper
.
insertJcxxJkzp
(
jcxxJkzp
);
}
...
...
@@ -65,6 +81,19 @@ public class JcxxJkzpServiceImpl implements IJcxxJkzpService
@Override
public
int
updateJcxxJkzp
(
JcxxJkzp
jcxxJkzp
)
{
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getZjkzz
())){
jcxxJkzp
.
setZjkzz
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getZjkzz
())));
}
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getClcb
())){
jcxxJkzp
.
setClcb
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getClcb
())));
}
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getJlgh
())){
jcxxJkzp
.
setJlgh
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getJlgh
())));
}
if
(
StringUtils
.
isNotEmpty
(
jcxxJkzp
.
getSyyq
())){
jcxxJkzp
.
setSyyq
(
new
String
(
Base64
.
decode
(
jcxxJkzp
.
getSyyq
())));
}
jcxxJkzp
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
jcxxJkzpMapper
.
updateJcxxJkzp
(
jcxxJkzp
);
}
...
...
src/main/java/com/ruoyi/project/zjsgfa/service/impl/SjHseServiceImpl.java
View file @
6e66bc18
package
com
.
ruoyi
.
project
.
zjsgfa
.
service
.
impl
;
import
java.util.List
;
import
cn.hutool.core.codec.Base64
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.zjsgfa.mapper.SjHseMapper
;
...
...
@@ -53,6 +56,12 @@ public class SjHseServiceImpl implements ISjHseService
@Override
public
int
insertSjHse
(
SjHse
sjHse
)
{
//解密
if
(
StringUtils
.
isNotEmpty
(
sjHse
.
getHse
())){
String
s
=
new
String
(
Base64
.
decode
(
sjHse
.
getHse
()));
sjHse
.
setHse
(
s
);
}
return
sjHseMapper
.
insertSjHse
(
sjHse
);
}
...
...
@@ -65,6 +74,12 @@ public class SjHseServiceImpl implements ISjHseService
@Override
public
int
updateSjHse
(
SjHse
sjHse
)
{
//解密
if
(
StringUtils
.
isNotEmpty
(
sjHse
.
getHse
())){
String
s
=
new
String
(
Base64
.
decode
(
sjHse
.
getHse
()));
sjHse
.
setHse
(
s
);
}
sjHse
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
sjHseMapper
.
updateSjHse
(
sjHse
);
}
...
...
src/main/java/com/ruoyi/project/zjsgfa/service/impl/SjJkzpServiceImpl.java
View file @
6e66bc18
package
com
.
ruoyi
.
project
.
zjsgfa
.
service
.
impl
;
import
java.util.List
;
import
cn.hutool.core.codec.Base64
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.project.zjsgfa.mapper.SjJkzpMapper
;
...
...
@@ -53,6 +56,19 @@ public class SjJkzpServiceImpl implements ISjJkzpService
@Override
public
int
insertSjJkzp
(
SjJkzp
sjJkzp
)
{
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getZjkzz
())){
sjJkzp
.
setZjkzz
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getZjkzz
())));
}
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getClcb
())){
sjJkzp
.
setClcb
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getClcb
())));
}
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getJlgh
())){
sjJkzp
.
setJlgh
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getJlgh
())));
}
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getSyyq
())){
sjJkzp
.
setSyyq
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getSyyq
())));
}
return
sjJkzpMapper
.
insertSjJkzp
(
sjJkzp
);
}
...
...
@@ -65,6 +81,19 @@ public class SjJkzpServiceImpl implements ISjJkzpService
@Override
public
int
updateSjJkzp
(
SjJkzp
sjJkzp
)
{
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getZjkzz
())){
sjJkzp
.
setZjkzz
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getZjkzz
())));
}
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getClcb
())){
sjJkzp
.
setClcb
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getClcb
())));
}
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getJlgh
())){
sjJkzp
.
setJlgh
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getJlgh
())));
}
if
(
StringUtils
.
isNotEmpty
(
sjJkzp
.
getSyyq
())){
sjJkzp
.
setSyyq
(
new
String
(
Base64
.
decode
(
sjJkzp
.
getSyyq
())));
}
sjJkzp
.
setUpdateTime
(
DateUtils
.
getNowDate
());
return
sjJkzpMapper
.
updateSjJkzp
(
sjJkzp
);
}
...
...
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