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
ca7193c3
Commit
ca7193c3
authored
Aug 29, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
2ab4481d
6866f3b6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
114 additions
and
17 deletions
+114
-17
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
+20
-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
+7
-4
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 @
ca7193c3
...
@@ -82,4 +82,13 @@ public interface FavoritesDao {
...
@@ -82,4 +82,13 @@ public interface FavoritesDao {
* @return
* @return
*/
*/
Favorites
defaultFavorites
(
Long
userId
);
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 @
ca7193c3
...
@@ -40,6 +40,15 @@ public interface FootPrintDao {
...
@@ -40,6 +40,15 @@ public interface FootPrintDao {
*/
*/
int
delete
(
List
<
Long
>
ids
);
int
delete
(
List
<
Long
>
ids
);
/**
* 删除记录
*
* @param userId
* @param itemId
* @return
*/
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
);
/**
/**
* 通过用户id和藏品id获取对应的记录
* 通过用户id和藏品id获取对应的记录
*
*
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
View file @
ca7193c3
...
@@ -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
(
"sort desc,
add
_time desc"
);
example
.
orderBy
(
"sort desc,
update
_time desc"
);
return
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
return
favoritesMapper
.
selectByExampleWithBLOBs
(
example
);
}
}
...
@@ -98,4 +98,15 @@ public class FavoritesDaoImpl implements FavoritesDao {
...
@@ -98,4 +98,15 @@ public class FavoritesDaoImpl implements FavoritesDao {
criteria
.
andSortEqualTo
(
1
);
criteria
.
andSortEqualTo
(
1
);
return
favoritesMapper
.
selectOneByExample
(
example
);
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 @
ca7193c3
...
@@ -9,6 +9,7 @@ import com.wwdz.ch.db.mapper.FootprintMapper;
...
@@ -9,6 +9,7 @@ import com.wwdz.ch.db.mapper.FootprintMapper;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,6 +34,13 @@ public class FootPrintDaoImpl implements FootPrintDao {
...
@@ -33,6 +34,13 @@ public class FootPrintDaoImpl implements FootPrintDao {
FootprintExample
.
Criteria
criteria
=
example
.
createCriteria
();
FootprintExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andDeletedEqualTo
(
false
);
criteria
.
andDeletedEqualTo
(
false
);
// 现在
Date
now
=
new
Date
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
now
);
calendar
.
add
(
Calendar
.
MONTH
,
-
1
);
Date
month
=
calendar
.
getTime
();
criteria
.
andUpdateTimeGreaterThan
(
month
);
example
.
orderBy
(
"update_time desc"
);
example
.
orderBy
(
"update_time desc"
);
PageHelper
.
startPage
(
page
,
size
);
PageHelper
.
startPage
(
page
,
size
);
List
<
Footprint
>
list
=
footprintMapper
.
selectByExample
(
example
);
List
<
Footprint
>
list
=
footprintMapper
.
selectByExample
(
example
);
...
@@ -59,6 +67,18 @@ public class FootPrintDaoImpl implements FootPrintDao {
...
@@ -59,6 +67,18 @@ public class FootPrintDaoImpl implements FootPrintDao {
return
footprintMapper
.
updateByExampleSelective
(
footprint
,
example
);
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
@Override
public
Footprint
selectByUserIdItem
(
Long
userId
,
Long
itemId
)
{
public
Footprint
selectByUserIdItem
(
Long
userId
,
Long
itemId
)
{
FootprintExample
example
=
new
FootprintExample
();
FootprintExample
example
=
new
FootprintExample
();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
ca7193c3
...
@@ -355,6 +355,9 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -355,6 +355,9 @@ public class FavoritesServiceImpl implements FavoritesService {
favoritesItemsRelation
.
setItemId
(
dto
.
getId
());
favoritesItemsRelation
.
setItemId
(
dto
.
getId
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
logger
.
info
(
"【请求结束】收藏藏品成功"
);
logger
.
info
(
"【请求结束】收藏藏品成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -384,6 +387,9 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -384,6 +387,9 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册和钱币的关联
// 删除收藏册和钱币的关联
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
logger
.
info
(
"【请求结束】取消收藏成功"
);
logger
.
info
(
"【请求结束】取消收藏成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -418,6 +424,12 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -418,6 +424,12 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
favoritesItemsRelationDao
.
batchInsert
(
list
);
favoritesItemsRelationDao
.
batchInsert
(
list
);
}
}
// 更新收藏册操作时间
List
<
Long
>
favoritesIds
=
new
ArrayList
<>();
favoritesIds
.
add
(
dto
.
getBeforeFavoritesId
());
favoritesIds
.
add
(
dto
.
getAfterFavoritesId
());
favoritesDao
.
updateTime
(
null
,
favoritesIds
);
logger
.
info
(
"【请求结束】移动藏品成功"
);
logger
.
info
(
"【请求结束】移动藏品成功"
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FootPrintServiceImpl.java
View file @
ca7193c3
...
@@ -96,16 +96,16 @@ public class FootPrintServiceImpl implements FootPrintService {
...
@@ -96,16 +96,16 @@ public class FootPrintServiceImpl implements FootPrintService {
itemResponseVo
.
setHomePageImage
(
getImage
(
item
));
itemResponseVo
.
setHomePageImage
(
getImage
(
item
));
// 设置日期类型
// 设置日期类型
if
(
footprint
.
get
Add
Time
().
compareTo
(
today
)
>=
0
)
{
if
(
footprint
.
get
Update
Time
().
compareTo
(
today
)
>=
0
)
{
itemResponseVo
.
setTimeType
(
1
);
itemResponseVo
.
setTimeType
(
1
);
}
}
if
(
footprint
.
get
AddTime
().
compareTo
(
yesterday
)
>=
0
&&
footprint
.
getAdd
Time
().
compareTo
(
today
)
<
0
)
{
if
(
footprint
.
get
UpdateTime
().
compareTo
(
yesterday
)
>=
0
&&
footprint
.
getUpdate
Time
().
compareTo
(
today
)
<
0
)
{
itemResponseVo
.
setTimeType
(
2
);
itemResponseVo
.
setTimeType
(
2
);
}
}
if
(
footprint
.
get
AddTime
().
compareTo
(
week
)
>=
0
&&
footprint
.
getAdd
Time
().
compareTo
(
yesterday
)
<
0
)
{
if
(
footprint
.
get
UpdateTime
().
compareTo
(
week
)
>=
0
&&
footprint
.
getUpdate
Time
().
compareTo
(
yesterday
)
<
0
)
{
itemResponseVo
.
setTimeType
(
3
);
itemResponseVo
.
setTimeType
(
3
);
}
}
if
(
footprint
.
get
AddTime
().
compareTo
(
month
)
>=
0
&&
footprint
.
getAdd
Time
().
compareTo
(
week
)
<
0
)
{
if
(
footprint
.
get
UpdateTime
().
compareTo
(
month
)
>=
0
&&
footprint
.
getUpdate
Time
().
compareTo
(
week
)
<
0
)
{
itemResponseVo
.
setTimeType
(
4
);
itemResponseVo
.
setTimeType
(
4
);
}
}
...
@@ -197,6 +197,9 @@ public class FootPrintServiceImpl implements FootPrintService {
...
@@ -197,6 +197,9 @@ public class FootPrintServiceImpl implements FootPrintService {
String
countString
=
""
;
String
countString
=
""
;
// 设置收藏数
// 设置收藏数
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
itemId
);
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
itemId
);
if
(
count
<=
0
)
{
return
"0"
;
}
if
(
sourceType
.
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
if
(
sourceType
.
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
count
--;
}
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
ca7193c3
...
@@ -205,6 +205,9 @@ public class ItemServiceImpl implements ItemService {
...
@@ -205,6 +205,9 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
dto
.
getFavoritesId
(),
null
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
item
.
getId
());
map
.
put
(
"id"
,
item
.
getId
());
return
Result
.
success
(
map
);
return
Result
.
success
(
map
);
...
@@ -223,7 +226,18 @@ public class ItemServiceImpl implements ItemService {
...
@@ -223,7 +226,18 @@ public class ItemServiceImpl implements ItemService {
if
(
Objects
.
nonNull
(
dto
.
getType
())
&&
dto
.
getType
().
equals
(
1
))
{
if
(
Objects
.
nonNull
(
dto
.
getType
())
&&
dto
.
getType
().
equals
(
1
))
{
if
(
Objects
.
nonNull
(
dto
.
getUserId
())
&&
!
dto
.
getUserId
().
equals
(
0L
))
{
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
(),
"该藏品已经被移除"
);
return
Result
.
failed
(
ResultCode
.
INVALID_DATA
.
getCode
(),
"该藏品已经被移除"
);
...
@@ -335,6 +349,9 @@ public class ItemServiceImpl implements ItemService {
...
@@ -335,6 +349,9 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 更新收藏册操作时间
favoritesDao
.
updateTime
(
favorites
.
getId
(),
null
);
// 查询收藏数
// 查询收藏数
String
collectCount
=
getCollectCount
(
item
.
getId
(),
item
.
getSourceType
());
String
collectCount
=
getCollectCount
(
item
.
getId
(),
item
.
getSourceType
());
...
@@ -363,6 +380,12 @@ public class ItemServiceImpl implements ItemService {
...
@@ -363,6 +380,12 @@ public class ItemServiceImpl implements ItemService {
return
Result
.
failed
(
"自己发布的藏品不能取消收藏"
);
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
());
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
...
@@ -399,16 +422,26 @@ public class ItemServiceImpl implements ItemService {
...
@@ -399,16 +422,26 @@ public class ItemServiceImpl implements ItemService {
item
.
setUpdateTime
(
now
);
item
.
setUpdateTime
(
now
);
itemDao
.
update
(
item
);
itemDao
.
update
(
item
);
// 删除原来藏品和收藏册关联
// 更新收藏册
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
List
<
Long
>
favoritesIds
=
new
ArrayList
<>();
FavoritesItemsRelation
beforeRelation
=
favoritesItemsRelationDao
.
selectByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
// 新增藏品和收藏册关联
if
(
Objects
.
nonNull
(
beforeRelation
)
&&
!
beforeRelation
.
getFavoritesId
().
equals
(
dto
.
getFavoritesId
()))
{
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
// 更新操作时间
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesIds
.
add
(
beforeRelation
.
getFavoritesId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesIds
.
add
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesDao
.
updateTime
(
null
,
favoritesIds
);
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
// 删除原来藏品和收藏册关联
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
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
dto
.
getId
());
map
.
put
(
"id"
,
dto
.
getId
());
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFootprintController.java
View file @
ca7193c3
...
@@ -46,7 +46,7 @@ public class WxFootprintController {
...
@@ -46,7 +46,7 @@ public class WxFootprintController {
public
Result
delete
(
@RequestBody
FootPrintRequestDto
dto
)
{
public
Result
delete
(
@RequestBody
FootPrintRequestDto
dto
)
{
logger
.
info
(
"【请求开始】用户足迹删除,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
logger
.
info
(
"【请求开始】用户足迹删除,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
if
(
CollectionUtils
.
isEmpty
(
dto
.
getIds
()))
{
if
(
CollectionUtils
.
isEmpty
(
dto
.
getIds
()))
{
return
Result
.
failed
(
"
收藏册id不能为空
"
);
return
Result
.
failed
(
"
请选择藏品
"
);
}
}
return
footPrintService
.
delete
(
dto
);
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