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
4dcbe68a
Commit
4dcbe68a
authored
Sep 13, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 藏品收藏数
parent
3dfd0b80
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
237 deletions
+42
-237
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
+3
-5
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+4
-76
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
+4
-78
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+15
-78
ch-wx-api/src/main/java/com/wwdz/ch/wx/util/StringUtil.java
ch-wx-api/src/main/java/com/wwdz/ch/wx/util/StringUtil.java
+16
-0
No files found.
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
View file @
4dcbe68a
package
com.wwdz.ch.core.util
;
package
com.wwdz.ch.core.util
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.entity.ImageInfo
;
import
com.wwdz.ch.core.entity.ImageInfo
;
import
com.xxdxxs.utils.CommonUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -113,9 +111,9 @@ public class MediaUtil {
...
@@ -113,9 +111,9 @@ public class MediaUtil {
}
}
}
}
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
videos
))
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
videos
))
{
String
[]
v
edi
oImage
=
videos
.
split
(
";"
);
String
[]
v
ide
oImage
=
videos
.
split
(
";"
);
if
(
v
edi
oImage
[
0
].
contains
(
","
))
{
if
(
v
ide
oImage
[
0
].
contains
(
","
))
{
String
[]
video
=
v
edi
oImage
[
0
].
split
(
","
);
String
[]
video
=
v
ide
oImage
[
0
].
split
(
","
);
homePageMap
=
getAspect
(
video
[
1
]);
homePageMap
=
getAspect
(
video
[
1
]);
homePageMap
.
put
(
"url"
,
video
[
1
]);
homePageMap
.
put
(
"url"
,
video
[
1
]);
homePageMap
.
put
(
"type"
,
1
);
homePageMap
.
put
(
"type"
,
1
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
4dcbe68a
package
com.wwdz.ch.wx.impl
;
package
com.wwdz.ch.wx.impl
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.MediaUtil
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.ItemDao
;
import
com.wwdz.ch.db.dao.ItemDao
;
...
@@ -21,7 +21,6 @@ import com.wwdz.ch.wx.entity.vo.ItemResponseVo;
...
@@ -21,7 +21,6 @@ import com.wwdz.ch.wx.entity.vo.ItemResponseVo;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
com.wwdz.ch.wx.service.FavoritesService
;
import
com.wwdz.ch.wx.util.StringUtil
;
import
com.wwdz.ch.wx.util.StringUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -251,10 +250,11 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -251,10 +250,11 @@ public class FavoritesServiceImpl implements FavoritesService {
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
}
}
// 设置收藏数
// 设置收藏数
vo
.
setCollectCount
(
getCollectCount
(
item
.
getId
(),
item
.
getSourceType
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
vo
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
// 设置图片或视频
// 设置图片或视频
vo
.
setHomePageImage
(
getImage
(
item
));
vo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
item
.
getImages
(),
item
.
getVideos
()
));
agentTranceResponseVo
.
setDetail
(
vo
);
agentTranceResponseVo
.
setDetail
(
vo
);
list
.
add
(
agentTranceResponseVo
);
list
.
add
(
agentTranceResponseVo
);
}
}
...
@@ -396,78 +396,6 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -396,78 +396,6 @@ public class FavoritesServiceImpl implements FavoritesService {
}
}
}
}
/**
* 获取展示图片
*
* @param item
* @return
*/
private
Map
<
String
,
Object
>
getImage
(
Item
item
)
{
Map
<
String
,
Object
>
homePageMap
=
new
HashMap
<>();
homePageMap
.
put
(
"url"
,
""
);
homePageMap
.
put
(
"type"
,
2
);
homePageMap
.
put
(
"width"
,
"0"
);
homePageMap
.
put
(
"height"
,
"0"
);
if
(
StringUtils
.
isNotBlank
(
item
.
getImages
()))
{
String
[]
image
=
item
.
getImages
().
split
(
";"
);
homePageMap
.
put
(
"url"
,
image
[
0
]);
if
(
image
[
0
].
contains
(
"_"
))
{
homePageMap
=
getAspect
(
image
[
0
]);
homePageMap
.
put
(
"url"
,
image
[
0
]);
homePageMap
.
put
(
"type"
,
2
);
}
}
if
(
StringUtils
.
isNotBlank
(
item
.
getVideos
()))
{
String
[]
vedioImage
=
item
.
getVideos
().
split
(
";"
);
if
(
vedioImage
[
0
].
contains
(
","
))
{
String
[]
video
=
vedioImage
[
0
].
split
(
","
);
homePageMap
=
getAspect
(
video
[
1
]);
homePageMap
.
put
(
"url"
,
video
[
1
]);
homePageMap
.
put
(
"type"
,
1
);
}
}
return
homePageMap
;
}
/**
* 获取图片的长宽
*
* @param image
* @return
*/
private
Map
<
String
,
Object
>
getAspect
(
String
image
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
String
[]
_image
=
image
.
split
(
"_"
);
String
[]
infoImage
=
_image
[
1
].
split
(
"\\."
);
String
[]
result
=
infoImage
[
0
].
split
(
"x"
);
map
.
put
(
"width"
,
result
[
0
]);
map
.
put
(
"height"
,
result
[
1
]);
return
map
;
}
/**
* 获取藏品的收藏数
*
* @param itemId
* @param sourceType
* @return
*/
private
String
getCollectCount
(
Long
itemId
,
Integer
sourceType
)
{
String
countString
=
""
;
// 设置收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
itemId
);
if
(
sourceType
.
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
if
(
count
<
1000
)
{
countString
=
String
.
valueOf
(
count
);
}
else
{
countString
=
String
.
format
(
"%.1f"
,
(
double
)
count
/
1000
)
+
"k"
;
}
return
countString
;
}
/**
/**
* 获取格式化后的金额
* 获取格式化后的金额
*
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
View file @
4dcbe68a
package
com.wwdz.ch.wx.impl
;
package
com.wwdz.ch.wx.impl
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.util.MediaUtil
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.FootPrintDao
;
import
com.wwdz.ch.db.dao.FootPrintDao
;
import
com.wwdz.ch.db.dao.ItemDao
;
import
com.wwdz.ch.db.dao.ItemDao
;
...
@@ -17,7 +17,6 @@ import com.wwdz.ch.wx.service.FootPrintService;
...
@@ -17,7 +17,6 @@ import com.wwdz.ch.wx.service.FootPrintService;
import
com.wwdz.ch.wx.util.StringUtil
;
import
com.wwdz.ch.wx.util.StringUtil
;
import
com.xxdxxs.utils.DateUtils
;
import
com.xxdxxs.utils.DateUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -104,9 +103,10 @@ public class FootPrintServiceImpl implements FootPrintService {
...
@@ -104,9 +103,10 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
footprint
.
getItemId
(),
null
)
?
1
:
0
);
itemResponseVo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
footprint
.
getItemId
(),
null
)
?
1
:
0
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
// 设置收藏数
// 设置收藏数
itemResponseVo
.
setCollectCount
(
getCollectCount
(
item
.
getId
(),
item
.
getSourceType
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
itemResponseVo
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
// 设置图片或视频
// 设置图片或视频
itemResponseVo
.
setHomePageImage
(
getImage
(
item
));
itemResponseVo
.
setHomePageImage
(
MediaUtil
.
getHomePageImage
(
item
.
getImages
(),
item
.
getVideos
()
));
// 设置日期类型
// 设置日期类型
if
(
footprint
.
getUpdateTime
().
compareTo
(
today
)
>=
0
)
{
if
(
footprint
.
getUpdateTime
().
compareTo
(
today
)
>=
0
)
{
...
@@ -150,80 +150,6 @@ public class FootPrintServiceImpl implements FootPrintService {
...
@@ -150,80 +150,6 @@ public class FootPrintServiceImpl implements FootPrintService {
}
}
}
}
/**
* 获取展示图片
*
* @param item
* @return
*/
private
Map
<
String
,
Object
>
getImage
(
Item
item
)
{
Map
<
String
,
Object
>
homePageMap
=
new
HashMap
<>();
homePageMap
.
put
(
"url"
,
""
);
homePageMap
.
put
(
"type"
,
2
);
homePageMap
.
put
(
"width"
,
"0"
);
homePageMap
.
put
(
"height"
,
"0"
);
if
(
StringUtils
.
isNotBlank
(
item
.
getImages
()))
{
String
[]
image
=
item
.
getImages
().
split
(
";"
);
homePageMap
.
put
(
"url"
,
image
[
0
]);
if
(
image
[
0
].
contains
(
"_"
))
{
homePageMap
=
getAspect
(
image
[
0
]);
homePageMap
.
put
(
"url"
,
image
[
0
]);
homePageMap
.
put
(
"type"
,
2
);
}
}
if
(
StringUtils
.
isNotBlank
(
item
.
getVideos
()))
{
String
[]
vedioImage
=
item
.
getVideos
().
split
(
";"
);
if
(
vedioImage
[
0
].
contains
(
","
))
{
String
[]
video
=
vedioImage
[
0
].
split
(
","
);
homePageMap
=
getAspect
(
video
[
1
]);
homePageMap
.
put
(
"url"
,
video
[
1
]);
homePageMap
.
put
(
"type"
,
1
);
}
}
return
homePageMap
;
}
/**
* 获取图片的长宽
*
* @param image
* @return
*/
private
Map
<
String
,
Object
>
getAspect
(
String
image
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
String
[]
_image
=
image
.
split
(
"_"
);
String
[]
infoImage
=
_image
[
1
].
split
(
"\\."
);
String
[]
result
=
infoImage
[
0
].
split
(
"x"
);
map
.
put
(
"width"
,
result
[
0
]);
map
.
put
(
"height"
,
result
[
1
]);
return
map
;
}
/**
* 获取藏品的收藏数
*
* @param itemId
* @param sourceType
* @return
*/
private
String
getCollectCount
(
Long
itemId
,
Integer
sourceType
)
{
String
countString
=
""
;
// 设置收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
itemId
);
if
(
count
<=
0
)
{
return
"0"
;
}
if
(
sourceType
.
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
if
(
count
<
1000
)
{
countString
=
String
.
valueOf
(
count
);
}
else
{
countString
=
String
.
format
(
"%.1f"
,
(
double
)
count
/
1000
)
+
"k"
;
}
return
countString
;
}
/**
/**
* 获取格式化后的金额
* 获取格式化后的金额
*
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
4dcbe68a
...
@@ -142,7 +142,7 @@ public class ItemServiceImpl implements ItemService {
...
@@ -142,7 +142,7 @@ public class ItemServiceImpl implements ItemService {
// 设置价格
// 设置价格
vo
.
setPrice
(
getPrice
(
es
.
getPrice
()));
vo
.
setPrice
(
getPrice
(
es
.
getPrice
()));
// 设置图片或视频
// 设置图片或视频
vo
.
setHomePageImage
(
get
Image
(
es
.
getImages
(),
es
.
getVideos
()));
vo
.
setHomePageImage
(
MediaUtil
.
getHomePage
Image
(
es
.
getImages
(),
es
.
getVideos
()));
// 设置是否收藏和是否是自己发布的
// 设置是否收藏和是否是自己发布的
vo
.
setIsCollected
(
0
);
vo
.
setIsCollected
(
0
);
vo
.
setIsMine
(
0
);
vo
.
setIsMine
(
0
);
...
@@ -151,7 +151,8 @@ public class ItemServiceImpl implements ItemService {
...
@@ -151,7 +151,8 @@ public class ItemServiceImpl implements ItemService {
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
es
.
getId
())
?
1
:
0
);
vo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
es
.
getId
())
?
1
:
0
);
}
}
// 设置收藏数
// 设置收藏数
vo
.
setCollectCount
(
getCollectCount
(
es
.
getId
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
es
.
getId
());
vo
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
@@ -208,7 +209,7 @@ public class ItemServiceImpl implements ItemService {
...
@@ -208,7 +209,7 @@ public class ItemServiceImpl implements ItemService {
// 设置价格
// 设置价格
vo
.
setPrice
(
getPrice
(
item
.
getPrice
()));
vo
.
setPrice
(
getPrice
(
item
.
getPrice
()));
// 设置图片或视频
// 设置图片或视频
vo
.
setHomePageImage
(
get
Image
(
item
.
getImages
(),
item
.
getVideos
()));
vo
.
setHomePageImage
(
MediaUtil
.
getHomePage
Image
(
item
.
getImages
(),
item
.
getVideos
()));
// 设置是否收藏和是否是自己发布的
// 设置是否收藏和是否是自己发布的
vo
.
setIsCollected
(
0
);
vo
.
setIsCollected
(
0
);
vo
.
setIsMine
(
1
);
vo
.
setIsMine
(
1
);
...
@@ -216,7 +217,8 @@ public class ItemServiceImpl implements ItemService {
...
@@ -216,7 +217,8 @@ public class ItemServiceImpl implements ItemService {
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
(),
null
)
?
1
:
0
);
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
(),
null
)
?
1
:
0
);
}
}
// 设置收藏数
// 设置收藏数
vo
.
setCollectCount
(
getCollectCount
(
item
.
getId
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
vo
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
@@ -276,9 +278,10 @@ public class ItemServiceImpl implements ItemService {
...
@@ -276,9 +278,10 @@ public class ItemServiceImpl implements ItemService {
itemResponseVo
.
setIsCollected
(
1
);
itemResponseVo
.
setIsCollected
(
1
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
itemResponseVo
.
setIsMine
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
// 设置收藏数
// 设置收藏数
itemResponseVo
.
setCollectCount
(
getCollectCount
(
item
.
getId
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
itemResponseVo
.
setCollectCount
(
StringUtil
.
formatCount
(
count
));
// 设置图片或视频
// 设置图片或视频
itemResponseVo
.
setHomePageImage
(
get
Image
(
item
.
getImages
(),
item
.
getVideos
()));
itemResponseVo
.
setHomePageImage
(
MediaUtil
.
getHomePage
Image
(
item
.
getImages
(),
item
.
getVideos
()));
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
@@ -511,7 +514,8 @@ public class ItemServiceImpl implements ItemService {
...
@@ -511,7 +514,8 @@ public class ItemServiceImpl implements ItemService {
}
}
// 查询收藏数
// 查询收藏数
String
collectCount
=
getCollectCount
(
item
.
getId
());
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
String
collectCount
=
StringUtil
.
formatCount
(
count
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"collectCount"
,
collectCount
);
map
.
put
(
"collectCount"
,
collectCount
);
...
@@ -541,7 +545,8 @@ public class ItemServiceImpl implements ItemService {
...
@@ -541,7 +545,8 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
// 查询收藏数
// 查询收藏数
String
collectCount
=
getCollectCount
(
item
.
getId
());
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
String
collectCount
=
StringUtil
.
formatCount
(
count
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"collectCount"
,
collectCount
);
map
.
put
(
"collectCount"
,
collectCount
);
...
@@ -791,40 +796,6 @@ public class ItemServiceImpl implements ItemService {
...
@@ -791,40 +796,6 @@ public class ItemServiceImpl implements ItemService {
return
null
;
return
null
;
}
}
/**
* 获取展示图片
*
* @param images
* @param videos
* @return
*/
private
Map
<
String
,
Object
>
getImage
(
String
images
,
String
videos
)
{
Map
<
String
,
Object
>
homePageMap
=
new
HashMap
<>();
homePageMap
.
put
(
"url"
,
""
);
homePageMap
.
put
(
"type"
,
2
);
homePageMap
.
put
(
"width"
,
"0"
);
homePageMap
.
put
(
"height"
,
"0"
);
if
(
StringUtils
.
isNotBlank
(
images
))
{
String
[]
image
=
images
.
split
(
";"
);
homePageMap
.
put
(
"url"
,
image
[
0
]);
if
(
image
[
0
].
contains
(
"_"
))
{
homePageMap
=
getAspect
(
image
[
0
]);
homePageMap
.
put
(
"url"
,
image
[
0
]);
homePageMap
.
put
(
"type"
,
2
);
}
}
if
(
StringUtils
.
isNotBlank
(
videos
))
{
String
[]
vedioImage
=
videos
.
split
(
";"
);
if
(
vedioImage
[
0
].
contains
(
","
))
{
String
[]
video
=
vedioImage
[
0
].
split
(
","
);
homePageMap
=
getAspect
(
video
[
1
]);
homePageMap
.
put
(
"url"
,
video
[
1
]);
homePageMap
.
put
(
"type"
,
1
);
}
}
return
homePageMap
;
}
/**
/**
* 获取图片对象列表
* 获取图片对象列表
*
*
...
@@ -837,7 +808,7 @@ public class ItemServiceImpl implements ItemService {
...
@@ -837,7 +808,7 @@ public class ItemServiceImpl implements ItemService {
for
(
int
i
=
0
;
i
<
image
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
image
.
length
;
i
++)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
image
[
i
].
contains
(
"_"
))
{
if
(
image
[
i
].
contains
(
"_"
))
{
map
=
getAspect
(
image
[
i
]);
map
=
MediaUtil
.
getAspect
(
image
[
i
]);
}
else
{
}
else
{
map
.
put
(
"width"
,
"0"
);
map
.
put
(
"width"
,
"0"
);
map
.
put
(
"type"
,
"0"
);
map
.
put
(
"type"
,
"0"
);
...
@@ -862,7 +833,7 @@ public class ItemServiceImpl implements ItemService {
...
@@ -862,7 +833,7 @@ public class ItemServiceImpl implements ItemService {
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
if
(
video
[
i
].
contains
(
","
))
{
if
(
video
[
i
].
contains
(
","
))
{
String
[]
image
=
video
[
i
].
split
(
","
);
String
[]
image
=
video
[
i
].
split
(
","
);
map
=
getAspect
(
image
[
1
]);
map
=
MediaUtil
.
getAspect
(
image
[
1
]);
map
.
put
(
"url"
,
image
[
0
]);
map
.
put
(
"url"
,
image
[
0
]);
}
else
{
}
else
{
map
.
put
(
"width"
,
"0"
);
map
.
put
(
"width"
,
"0"
);
...
@@ -875,40 +846,6 @@ public class ItemServiceImpl implements ItemService {
...
@@ -875,40 +846,6 @@ public class ItemServiceImpl implements ItemService {
return
list
;
return
list
;
}
}
/**
* 获取图片的长宽
*
* @param image
* @return
*/
private
Map
<
String
,
Object
>
getAspect
(
String
image
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
String
[]
_image
=
image
.
split
(
"_"
);
String
[]
infoImage
=
_image
[
1
].
split
(
"\\."
);
String
[]
result
=
infoImage
[
0
].
split
(
"x"
);
map
.
put
(
"width"
,
result
[
0
]);
map
.
put
(
"height"
,
result
[
1
]);
return
map
;
}
/**
* 获取藏品的收藏数
*
* @param itemId
* @return
*/
private
String
getCollectCount
(
Long
itemId
)
{
String
countString
=
""
;
// 设置收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
itemId
);
if
(
count
<
1000
)
{
countString
=
String
.
valueOf
(
count
);
}
else
{
countString
=
String
.
format
(
"%.1f"
,
(
double
)
count
/
1000
)
+
"k"
;
}
return
countString
;
}
/**
/**
* 获取格式化后的金额
* 获取格式化后的金额
*
*
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/util/StringUtil.java
View file @
4dcbe68a
...
@@ -49,4 +49,20 @@ public class StringUtil {
...
@@ -49,4 +49,20 @@ public class StringUtil {
}
}
return
sb
.
toString
();
return
sb
.
toString
();
}
}
/**
* 格式化数量(1000转换成k)
*
* @param count
* @return
*/
public
static
String
formatCount
(
long
count
)
{
String
countString
=
""
;
if
(
count
<
1000
)
{
countString
=
String
.
valueOf
(
count
);
}
else
{
countString
=
String
.
format
(
"%.1f"
,
(
double
)
count
/
1000
)
+
"k"
;
}
return
countString
;
}
}
}
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