Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
6481d28a
Commit
6481d28a
authored
Apr 13, 2023
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存页面截图接口修改为文件路径存储
parent
d8182ee8
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
portal-manager/src/main/java/com/mortals/xhx/common/utils/ImageBase64.java
...c/main/java/com/mortals/xhx/common/utils/ImageBase64.java
+49
-0
portal-manager/src/main/java/com/mortals/xhx/module/page/service/impl/PageInfoServiceImpl.java
...als/xhx/module/page/service/impl/PageInfoServiceImpl.java
+28
-0
No files found.
portal-manager/src/main/java/com/mortals/xhx/common/utils/ImageBase64.java
0 → 100644
View file @
6481d28a
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/page/service/impl/PageInfoServiceImpl.java
View file @
6481d28a
package
com.mortals.xhx.module.page.service.impl
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.common.utils.ImageBase64
;
import
com.mortals.xhx.module.page.model.PageInfoQuery
;
import
lombok.Getter
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.exception.AppException
;
...
...
@@ -21,6 +24,10 @@ import java.util.Date;
@Service
(
"pageInfoService"
)
public
class
PageInfoServiceImpl
extends
AbstractCRUDServiceImpl
<
PageInfoDao
,
PageInfoEntity
,
Long
>
implements
PageInfoService
{
@Value
(
"${upload.path}"
)
@Getter
private
String
filePath
;
@Override
protected
void
saveBefore
(
PageInfoEntity
entity
,
Context
context
)
throws
AppException
{
this
.
validData
(
entity
,
context
);
...
...
@@ -47,6 +54,7 @@ public class PageInfoServiceImpl extends AbstractCRUDServiceImpl<PageInfoDao, Pa
query
.
setDeviceNum
(
entity
.
getDeviceNum
());
PageInfoEntity
pageInfoEntity
=
this
.
selectOne
(
query
);
if
(
pageInfoEntity
==
null
){
doSaveImageBase64
(
entity
,
""
);
entity
.
setCreateTime
(
new
Date
());
int
iRet
=
this
.
dao
.
insert
(
entity
);
if
(
iRet
==
0
)
{
...
...
@@ -56,6 +64,7 @@ public class PageInfoServiceImpl extends AbstractCRUDServiceImpl<PageInfoDao, Pa
return
entity
;
}
}
else
{
doSaveImageBase64
(
entity
,
pageInfoEntity
.
getScreenUrl
());
PageInfoEntity
updateEntity
=
new
PageInfoEntity
();
updateEntity
.
setId
(
pageInfoEntity
.
getId
());
updateEntity
.
setScreenUrl
(
pageInfoEntity
.
getScreenUrl
());
...
...
@@ -69,6 +78,25 @@ public class PageInfoServiceImpl extends AbstractCRUDServiceImpl<PageInfoDao, Pa
return
entity
;
}
}
}
private
void
doSaveImageBase64
(
PageInfoEntity
entity
,
String
oldName
){
String
base64
=
String
.
valueOf
(
entity
.
getScreenUrl
());
if
(
StringUtils
.
isEmpty
(
base64
)){
throw
new
AppException
(
"图片不能为空"
);
}
String
imageName
=
new
Date
().
getTime
()
+
".png"
;
String
imagePath
=
"/file/uploadfile/"
+
imageName
;
if
(
StringUtils
.
isNotEmpty
(
oldName
)){
imagePath
=
oldName
;
}
String
filePath
=
this
.
filePath
.
endsWith
(
"/"
)
?
this
.
filePath
:
this
.
filePath
+
"/"
+
imagePath
;
try
{
ImageBase64
.
convertImg
(
base64
.
trim
(),
filePath
);
entity
.
setScreenUrl
(
imagePath
);
}
catch
(
Exception
e
){
log
.
error
(
"base64图片转换异常"
,
e
.
fillInStackTrace
());
entity
.
setScreenUrl
(
""
);
}
}
}
\ No newline at end of file
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