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
8f0580b4
Commit
8f0580b4
authored
Aug 28, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 足迹和收藏册
parent
b707a6f9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
102 additions
and
13 deletions
+102
-13
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesDao.java
+9
-0
ch-dao/src/main/java/com/wwdz/ch/db/dao/FootPrintDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/FootPrintDao.java
+9
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
...o/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
+12
-1
ch-dao/src/main/java/com/wwdz/ch/db/impl/FootPrintDaoImpl.java
...o/src/main/java/com/wwdz/ch/db/impl/FootPrintDaoImpl.java
+12
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+12
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
+3
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+44
-11
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
...c/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
+1
-1
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesDao.java
View file @
8f0580b4
...
...
@@ -82,4 +82,13 @@ public interface FavoritesDao {
* @return
*/
Favorites
defaultFavorites
(
Long
userId
);
/**
* 更新时间
*
* @param id
* @param ids
* @return
*/
int
updateTime
(
Long
id
,
List
<
Long
>
ids
);
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/FootPrintDao.java
View file @
8f0580b4
...
...
@@ -40,6 +40,15 @@ public interface FootPrintDao {
*/
int
delete
(
List
<
Long
>
ids
);
/**
* 删除记录
*
* @param userId
* @param itemId
* @return
*/
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
);
/**
* 通过用户id和藏品id获取对应的记录
*
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
View file @
8f0580b4
...
...
@@ -49,7 +49,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andDeletedEqualTo
(
false
);
example
.
orderBy
(
"sort desc,
add
_time desc"
);
example
.
orderBy
(
"sort desc,
update
_time desc"
);
return
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
}
...
...
@@ -98,4 +98,15 @@ public class FavoritesDaoImpl implements FavoritesDao {
criteria
.
andSortEqualTo
(
1
);
return
favoritesMapper
.
selectOneByExample
(
example
);
}
@Override
public
int
updateTime
(
Long
id
,
List
<
Long
>
ids
)
{
FavoritesExample
example
=
new
FavoritesExample
();
FavoritesExample
.
Criteria
criteria
=
example
.
createCriteria
();
JdbcHelper
.
ifPresent
(
id
,
criteria:
:
andIdEqualTo
);
JdbcHelper
.
ifPresent
(
ids
,
criteria:
:
andIdIn
);
Favorites
favorites
=
new
Favorites
();
favorites
.
setUpdateTime
(
new
Date
());
return
favoritesMapper
.
updateByExampleSelective
(
favorites
,
example
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/FootPrintDaoImpl.java
View file @
8f0580b4
...
...
@@ -59,6 +59,18 @@ public class FootPrintDaoImpl implements FootPrintDao {
return
footprintMapper
.
updateByExampleSelective
(
footprint
,
example
);
}
@Override
public
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
)
{
FootprintExample
example
=
new
FootprintExample
();
FootprintExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andItemIdEqualTo
(
itemId
);
Footprint
footprint
=
new
Footprint
();
footprint
.
setDeleted
(
true
);
footprint
.
setUpdateTime
(
new
Date
());
return
footprintMapper
.
updateByExampleSelective
(
footprint
,
example
);
}
@Override
public
Footprint
selectByUserIdItem
(
Long
userId
,
Long
itemId
)
{
FootprintExample
example
=
new
FootprintExample
();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
8f0580b4
...
...
@@ -355,6 +355,9 @@ public class FavoritesServiceImpl implements FavoritesService {
favoritesItemsRelation
.
setItemId
(
dto
.
getId
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
logger
.
info
(
"【请求结束】收藏藏品成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
...
...
@@ -384,6 +387,9 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册和钱币的关联
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
logger
.
info
(
"【请求结束】取消收藏成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
...
...
@@ -418,6 +424,12 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
favoritesItemsRelationDao
.
batchInsert
(
list
);
}
// 更新收藏册操作时间
List
<
Long
>
favoritesIds
=
new
ArrayList
<>();
favoritesIds
.
add
(
dto
.
getBeforeFavoritesId
());
favoritesIds
.
add
(
dto
.
getAfterFavoritesId
());
favoritesDao
.
updateTime
(
null
,
favoritesIds
);
logger
.
info
(
"【请求结束】移动藏品成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
View file @
8f0580b4
...
...
@@ -197,6 +197,9 @@ public class FootPrintServiceImpl implements FootPrintService {
String
countString
=
""
;
// 设置收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
itemId
);
if
(
count
<=
0
)
{
return
"0"
;
}
if
(
sourceType
.
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
8f0580b4
...
...
@@ -205,6 +205,9 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
item
.
getId
());
return
Result
.
success
(
map
);
...
...
@@ -223,7 +226,18 @@ public class ItemServiceImpl implements ItemService {
if
(
Objects
.
nonNull
(
dto
.
getType
())
&&
dto
.
getType
().
equals
(
1
))
{
if
(
Objects
.
nonNull
(
dto
.
getUserId
())
&&
!
dto
.
getUserId
().
equals
(
0L
))
{
// 如果当前用户已收藏该藏品,则删除收藏关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
FavoritesItemsRelation
favoritesItemsRelation
=
favoritesItemsRelationDao
.
selectByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
if
(
Objects
.
nonNull
(
favoritesItemsRelation
))
{
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
favoritesItemsRelation
.
getFavoritesId
(),
null
);
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
}
}
}
if
(
Objects
.
nonNull
(
dto
.
getType
())
&&
dto
.
getType
().
equals
(
2
))
{
if
(
Objects
.
nonNull
(
dto
.
getUserId
())
&&
!
dto
.
getUserId
().
equals
(
0L
))
{
// 删除用户足迹
footPrintDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
}
}
return
Result
.
failed
(
ResultCode
.
INVALID_DATA
.
getCode
(),
"该藏品已经被移除"
);
...
...
@@ -335,6 +349,9 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
favorites
.
getId
(),
null
);
// 查询收藏数
String
collectCount
=
getCollectCount
(
item
.
getId
(),
item
.
getSourceType
());
...
...
@@ -363,6 +380,12 @@ public class ItemServiceImpl implements ItemService {
return
Result
.
failed
(
"自己发布的藏品不能取消收藏"
);
}
// 更新收藏册操作时间
FavoritesItemsRelation
favoritesItemsRelation
=
favoritesItemsRelationDao
.
selectByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
if
(
Objects
.
nonNull
(
favoritesItemsRelation
))
{
favoritesDao
.
updateTime
(
favoritesItemsRelation
.
getFavoritesId
(),
null
);
}
// 删除藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
...
...
@@ -399,16 +422,26 @@ public class ItemServiceImpl implements ItemService {
item
.
setUpdateTime
(
now
);
itemDao
.
update
(
item
);
// 删除原来藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
// 新增藏品和收藏册关联
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册
List
<
Long
>
favoritesIds
=
new
ArrayList
<>();
FavoritesItemsRelation
beforeRelation
=
favoritesItemsRelationDao
.
selectByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
if
(
Objects
.
nonNull
(
beforeRelation
)
&&
!
beforeRelation
.
getFavoritesId
().
equals
(
dto
.
getFavoritesId
()))
{
// 更新操作时间
favoritesIds
.
add
(
beforeRelation
.
getFavoritesId
());
favoritesIds
.
add
(
dto
.
getFavoritesId
());
favoritesDao
.
updateTime
(
null
,
favoritesIds
);
// 删除原来藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
// 新增藏品和收藏册关联
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
dto
.
getId
());
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
View file @
8f0580b4
...
...
@@ -46,7 +46,7 @@ public class WxFootprintController {
public
Result
delete
(
@RequestBody
FootPrintRequestDto
dto
)
{
logger
.
info
(
"【请求开始】用户足迹删除,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
CollectionUtils
.
isEmpty
(
dto
.
getIds
()))
{
return
Result
.
failed
(
"
收藏册id不能为空
"
);
return
Result
.
failed
(
"
请选择藏品
"
);
}
return
footPrintService
.
delete
(
dto
);
}
...
...
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