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
ad1fa2f3
Commit
ad1fa2f3
authored
Aug 16, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 小程序藏品列表
parent
c5b761a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
...o/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
+2
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+37
-1
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
View file @
ad1fa2f3
...
@@ -49,7 +49,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
...
@@ -49,7 +49,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
example
.
orderBy
(
"add_time desc"
);
example
.
orderBy
(
"
sort desc,
add_time desc"
);
return
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
return
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
}
}
...
@@ -59,7 +59,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
...
@@ -59,7 +59,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
example
.
orderBy
(
"add_time desc"
);
example
.
orderBy
(
"
sort desc,
add_time desc"
);
PageHelper
.
startPage
(
page
,
size
);
PageHelper
.
startPage
(
page
,
size
);
List
<
Favorites
>
list
=
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
List
<
Favorites
>
list
=
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
return
new
PageInfo
<>(
list
);
return
new
PageInfo
<>(
list
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
ad1fa2f3
...
@@ -284,6 +284,10 @@ public class ItemServiceImpl implements ItemService {
...
@@ -284,6 +284,10 @@ public class ItemServiceImpl implements ItemService {
if
(
dto
.
getUserId
().
equals
(
0L
))
{
if
(
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"您尚未登录,请先登录"
);
return
Result
.
failed
(
"您尚未登录,请先登录"
);
}
}
Item
item
=
itemDao
.
findDetails
(
dto
.
getId
());
if
(
Objects
.
isNull
(
item
))
{
return
Result
.
failed
(
"数据异常,藏品不存在"
);
}
// 判断是否收藏过
// 判断是否收藏过
if
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
dto
.
getId
()))
{
if
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
dto
.
getId
()))
{
return
Result
.
failed
(
"您已经收藏过该藏品"
);
return
Result
.
failed
(
"您已经收藏过该藏品"
);
...
@@ -302,8 +306,21 @@ public class ItemServiceImpl implements ItemService {
...
@@ -302,8 +306,21 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 查询收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
dto
.
getId
());
if
(
item
.
getSourceType
().
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
String
collectCount
=
"0"
;
if
(
count
<
1000
)
{
collectCount
=
String
.
valueOf
(
count
);
}
else
{
collectCount
=
String
.
format
(
"%.1f"
,
(
double
)
count
/
1000
)
+
"k"
;
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"favoritesId"
,
favorites
.
getId
());
map
.
put
(
"favoritesId"
,
favorites
.
getId
());
map
.
put
(
"collectCount"
,
collectCount
);
return
Result
.
success
(
map
);
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"首页收藏失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"首页收藏失败,原因:"
+
e
.
getMessage
(),
e
);
...
@@ -318,13 +335,32 @@ public class ItemServiceImpl implements ItemService {
...
@@ -318,13 +335,32 @@ public class ItemServiceImpl implements ItemService {
if
(
dto
.
getUserId
().
equals
(
0L
))
{
if
(
dto
.
getUserId
().
equals
(
0L
))
{
return
Result
.
failed
(
"您尚未登录,请先登录"
);
return
Result
.
failed
(
"您尚未登录,请先登录"
);
}
}
Item
item
=
itemDao
.
findDetails
(
dto
.
getId
());
if
(
Objects
.
isNull
(
item
))
{
return
Result
.
failed
(
"数据异常,藏品不存在"
);
}
if
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
dto
.
getId
()))
{
if
(
userItemsRelationDao
.
isExisted
(
dto
.
getUserId
(),
dto
.
getId
()))
{
return
Result
.
failed
(
"自己发布的藏品不能取消收藏"
);
return
Result
.
failed
(
"自己发布的藏品不能取消收藏"
);
}
}
// 删除藏品和收藏册关联
// 删除藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
return
Result
.
success
();
// 查询收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
dto
.
getId
());
if
(
item
.
getSourceType
().
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
String
collectCount
=
"0"
;
if
(
count
<
1000
)
{
collectCount
=
String
.
valueOf
(
count
);
}
else
{
collectCount
=
String
.
format
(
"%.1f"
,
(
double
)
count
/
1000
)
+
"k"
;
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"collectCount"
,
collectCount
);
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"首页取消收藏失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"首页取消收藏失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"首页取消收藏失败"
);
return
Result
.
failed
(
"首页取消收藏失败"
);
...
...
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