Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
browser-backend
Commits
5d86aa5a
Commit
5d86aa5a
authored
Sep 19, 2020
by
xuxinpc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将收藏夹相关接口移动到 tempController
parent
64f719e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
TempController.java
...gec/browserbackend/browser/controller/TempController.java
+66
-0
No files found.
src/main/java/com/edgec/browserbackend/browser/controller/TempController.java
View file @
5d86aa5a
package
com
.
edgec
.
browserbackend
.
browser
.
controller
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.browser.domain.UserCode
;
import
com.edgec.browserbackend.browser.dto.FavoriteUrl
;
import
com.edgec.browserbackend.browser.service.ShopService
;
import
com.edgec.browserbackend.browser.service.TempService
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.security.Principal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 一些临时执行的代码可以放在这里,方便删除
*/
...
...
@@ -15,6 +24,9 @@ public class TempController {
@Autowired
private
TempService
tempService
;
@Autowired
private
ShopService
shopService
;
/**
* 记住用户明文密码
*/
...
...
@@ -28,4 +40,58 @@ public class TempController {
return
tempService
.
getPassword
(
ip
);
}
/**
* 店铺收藏夹
*/
@GetMapping
(
"/favorites/{shopId}"
)
public
ResultDto
getFavoritesByShopId
(
Principal
principal
,
@PathVariable
(
"shopId"
)
String
shopId
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
List
<
FavoriteUrl
>
list
=
shopService
.
getFavoritesByShopId
(
principal
.
getName
(),
shopId
);
resultDto
.
setData
(
list
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
dealClientRequestException
(
resultDto
,
e
);
}
return
resultDto
;
}
/**
* 店铺收藏夹 删除收藏
*/
@DeleteMapping
(
"/favorites/{shopId}"
)
public
ResultDto
deleteFavoritesByShopId
(
Principal
principal
,
@PathVariable
(
"shopId"
)
String
shopId
,
@RequestBody
FavoriteUrl
favoriteUrl
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
resultDto
.
setData
(
shopService
.
deleteFavoritesByShopId
(
principal
.
getName
(),
shopId
,
favoriteUrl
));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
dealClientRequestException
(
resultDto
,
e
);
}
return
resultDto
;
}
/**
* 店铺收藏夹 新增收藏
*/
@PostMapping
(
"/favorites/{shopId}"
)
public
ResultDto
saveFavoritesByShopId
(
Principal
principal
,
@PathVariable
(
"shopId"
)
String
shopId
,
@RequestBody
FavoriteUrl
favoriteUrl
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
resultDto
.
setData
(
shopService
.
saveFavoritesByShopId
(
principal
.
getName
(),
shopId
,
favoriteUrl
));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
dealClientRequestException
(
resultDto
,
e
);
}
return
resultDto
;
}
private
void
dealClientRequestException
(
ResultDto
resultDto
,
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
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