Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
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
quanku
qk_backend
Commits
d2376720
Commit
d2376720
authored
Mar 26, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修复1
parent
c4665ea2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
4 deletions
+69
-4
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
+9
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
...wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
+60
-4
No files found.
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
View file @
d2376720
package
com.wwdz.ch.core.util
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.consts.MediaTypeEnum
;
import
com.wwdz.ch.core.entity.ImageInfo
;
import
com.xxdxxs.utils.CommonUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -12,6 +15,7 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -123,6 +127,11 @@ public class MediaUtil {
}
/**
* 获取图片的长宽
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/SupplierItemServiceImpl.java
View file @
d2376720
...
...
@@ -3,7 +3,9 @@ package com.wwdz.ch.wx.impl.distribution;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.consts.DistributionEnum
;
import
com.wwdz.ch.core.consts.MediaTypeEnum
;
import
com.wwdz.ch.core.consts.ResultCode
;
import
com.wwdz.ch.core.storage.QiniuStorage
;
import
com.wwdz.ch.core.type.PageSearchResult
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.CacheUtil
;
...
...
@@ -21,10 +23,7 @@ import com.wwdz.ch.wx.entity.vo.distribution.AuctionRecordRowVo;
import
com.wwdz.ch.wx.service.distribution.CollectionItemsRelationService
;
import
com.wwdz.ch.wx.service.distribution.DistributionOrderService
;
import
com.wwdz.ch.wx.service.distribution.SupplierItemService
;
import
com.xxdxxs.utils.DateUtils
;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.JsonUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
com.xxdxxs.utils.*
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.slf4j.Logger
;
...
...
@@ -34,7 +33,14 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.net.URL
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.*
;
...
...
@@ -94,6 +100,8 @@ public class SupplierItemServiceImpl implements SupplierItemService {
@Autowired
CollectionShareRecordDao
collectionShareRecordDao
;
@Autowired
private
QiniuStorage
qiniuStorage
;
@Override
...
...
@@ -539,6 +547,9 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItem
.
setSupplyPrice
(
0L
);
supplierItem
.
setRebate
(
new
BigDecimal
(
"0"
));
supplierItem
.
setImages
(
dto
.
getImages
());
if
(
StringUtils
.
hasLength
(
dto
.
getVideos
()))
{
supplierItem
.
setVideos
(
getVideosImage
(
dto
.
getVideos
()));
}
supplierItem
.
setVideos
(
dto
.
getVideos
());
supplierItem
.
setSort
(
1
);
supplierItem
.
setBuyLimitNum
(
1
);
...
...
@@ -850,4 +861,49 @@ public class SupplierItemServiceImpl implements SupplierItemService {
}
return
Result
.
failed
();
}
private
String
getVideosImage
(
String
vedios
)
{
String
video
=
""
;
String
[]
images
=
vedios
.
split
(
";"
);
StringBuffer
stringBuffer
=
new
StringBuffer
();
Arrays
.
stream
(
images
).
parallel
().
forEach
(
image
->
{
if
(
stringBuffer
.
length
()
!=
0
)
{
stringBuffer
.
append
(
";"
);
}
try
{
String
cutImage
=
MediaUtil
.
getImageByCutVedio
(
image
);
URL
url
=
new
URL
(
cutImage
);
InputStream
inputStream
=
url
.
openStream
();
BufferedImage
bufferedImage
=
ImageIO
.
read
(
inputStream
);
String
keyName
=
CommConsts
.
UPLOAD_PRE_DIRECTORY
+
CommonUtils
.
getUUID
()
+
"_"
+
bufferedImage
.
getWidth
()
+
"x"
+
bufferedImage
.
getHeight
()
+
"."
+
MediaTypeEnum
.
IMAGE_JPG
.
getExt
();
InputStream
imageStream
=
bufferedImageToInputStream
(
bufferedImage
,
MediaTypeEnum
.
IMAGE_JPG
.
getExt
());
qiniuStorage
.
store
(
imageStream
,
1
,
MediaTypeEnum
.
IMAGE_JPG
.
getMime
(),
keyName
);
String
urlOfSize
=
qiniuStorage
.
generateUrl
(
keyName
);
stringBuffer
.
append
(
image
).
append
(
","
).
append
(
urlOfSize
);
}
catch
(
Exception
e
)
{
stringBuffer
.
append
(
image
);
logger
.
error
(
"视频图片上传失败"
,
e
);
}
});
video
=
stringBuffer
.
toString
();
return
video
;
}
/**
* 将BufferedImage转换为InputStream
*
* @param image 数据源
* @param type 图片格式
* @return
*/
private
static
InputStream
bufferedImageToInputStream
(
BufferedImage
image
,
String
type
)
{
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
ImageIO
.
write
(
image
,
type
,
os
);
return
new
ByteArrayInputStream
(
os
.
toByteArray
());
}
catch
(
IOException
e
)
{
logger
.
error
(
"bufferedImageToInputStream 出错,原因: {}"
,
e
);
}
return
null
;
}
}
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