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
41f6cc6f
Commit
41f6cc6f
authored
Aug 10, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增 小程序收藏接口
parent
fb1d9ead
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+35
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
...rc/main/java/com/wwdz/ch/wx/service/FavoritesService.java
+1
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
...c/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
+20
-0
No files found.
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
41f6cc6f
...
...
@@ -87,6 +87,7 @@ public class FavoritesServiceImpl implements FavoritesService {
}
page
.
setTotal
(
favoritesPage
.
getTotal
());
page
.
setList
(
list
);
logger
.
info
(
"【请求结束】分页查询收藏册列表成功"
);
return
Result
.
success
(
page
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询收藏册列表失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -112,6 +113,7 @@ public class FavoritesServiceImpl implements FavoritesService {
vo
.
setCount
(
favoritesItemsRelationDao
.
countByFavoritesId
(
favorites
.
getId
()));
result
.
add
(
vo
);
}
logger
.
info
(
"【请求结束】查询收藏册列表成功"
);
return
Result
.
success
(
result
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取收藏册列表失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -139,6 +141,7 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites
.
setDeleted
(
false
);
favorites
.
setSort
(
0
);
favoritesDao
.
insert
(
favorites
);
logger
.
info
(
"【请求结束】新增收藏册成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"新增收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -165,11 +168,12 @@ public class FavoritesServiceImpl implements FavoritesService {
favorites
.
setImages
(
dto
.
getImages
());
favorites
.
setUpdateTime
(
new
Date
());
favoritesDao
.
update
(
favorites
);
logger
.
info
(
"【请求结束】修改收藏册成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"
新增
收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"
修改
收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"
新增
收藏册失败"
);
return
Result
.
failed
(
"
修改
收藏册失败"
);
}
}
...
...
@@ -180,6 +184,7 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
Objects
.
isNull
(
favorites
))
{
return
Result
.
failed
(
"数据异常,记录不存在"
);
}
logger
.
info
(
"【请求结束】查看收藏册详情成功"
);
return
Result
.
success
(
favorites
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查看收藏册详情失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -220,6 +225,7 @@ public class FavoritesServiceImpl implements FavoritesService {
}
page
.
setTotal
(
favoritesItemsRelationDao
.
countByFavoritesId
(
dto
.
getId
()));
page
.
setList
(
list
);
logger
.
info
(
"【请求结束】查看收藏册的藏品列表成功"
);
return
Result
.
success
(
page
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查看收藏册的藏品列表失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -238,6 +244,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册
favoritesDao
.
delete
(
dto
.
getId
(),
null
);
logger
.
info
(
"【请求结束】删除收藏册成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"删除收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -272,6 +279,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册
favoritesDao
.
delete
(
null
,
dto
.
getIds
());
logger
.
info
(
"【请求结束】批量删除收藏册成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"批量删除收藏册失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -280,6 +288,29 @@ public class FavoritesServiceImpl implements FavoritesService {
}
}
@Transactional
@Override
public
Result
addItem
(
ItemRequestDto
dto
)
{
try
{
Favorites
favorites
=
favoritesDao
.
info
(
dto
.
getFavoritesId
());
if
(
Objects
.
isNull
(
favorites
))
{
Result
.
failed
(
"数据异常,收藏册不存在"
);
}
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
favorites
.
getUserId
());
favoritesItemsRelation
.
setFavoritesId
(
dto
.
getFavoritesId
());
favoritesItemsRelation
.
setItemId
(
dto
.
getId
());
favoritesItemsRelation
.
setAddTime
(
new
Date
());
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
logger
.
info
(
"【请求结束】收藏藏品成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"收藏藏品失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Result
.
failed
(
"收藏藏品失败"
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
Result
removeItem
(
ItemRequestDto
dto
)
{
...
...
@@ -298,6 +329,7 @@ public class FavoritesServiceImpl implements FavoritesService {
// 删除收藏册和钱币的关联
favoritesItemsRelationDao
.
deleteByChosen
(
dto
.
getFavoritesId
(),
dto
.
getItemIds
());
logger
.
info
(
"【请求结束】取消收藏成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
info
(
"收藏册取消收藏失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
@@ -326,6 +358,7 @@ public class FavoritesServiceImpl implements FavoritesService {
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
favoritesItemsRelationDao
.
batchInsert
(
list
);
}
logger
.
info
(
"【请求结束】移动藏品成功"
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"移动藏品失败,原因:"
+
e
.
getMessage
(),
e
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/FavoritesService.java
View file @
41f6cc6f
...
...
@@ -21,6 +21,7 @@ public interface FavoritesService {
Result
delete
(
FavoritesRequestDto
dto
);
Result
batchDelete
(
FavoritesRequestDto
dto
);
Result
addItem
(
ItemRequestDto
dto
);
Result
removeItem
(
ItemRequestDto
dto
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/WxFavoritesController.java
View file @
41f6cc6f
...
...
@@ -207,6 +207,26 @@ public class WxFavoritesController {
return
favoritesService
.
batchDelete
(
dto
);
}
@ApiOperation
(
value
=
"收藏"
)
@PostMapping
(
"/addItem"
)
public
Result
addItem
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
String
json
=
klDataRequestDto
.
getKl_data
();
logger
.
info
(
"【请求开始】收藏册收藏,请求参数,kl_data:{}"
,
json
);
String
favoritesId
=
JsonUtils
.
getValueByPath
(
json
,
"favoritesId"
);
String
id
=
JsonUtils
.
getValueByPath
(
json
,
"id"
);
if
(
StringUtils
.
isBlank
(
favoritesId
))
{
return
Result
.
failed
(
"收藏册id不能为空"
);
}
if
(
StringUtils
.
isBlank
(
id
))
{
return
Result
.
failed
(
"请选择藏品"
);
}
ItemRequestDto
dto
=
new
ItemRequestDto
();
dto
.
setFavoritesId
(
Long
.
parseLong
(
favoritesId
));
dto
.
setId
(
Long
.
parseLong
(
id
));
return
favoritesService
.
addItem
(
dto
);
}
@ApiOperation
(
value
=
"取消收藏"
)
@PostMapping
(
"/removeItem"
)
public
Result
removeItem
(
@RequestBody
KlDataRequestDto
klDataRequestDto
)
{
...
...
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