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
11a76673
Commit
11a76673
authored
Aug 11, 2023
by
muhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 小程序藏品接口
parent
c5dd98cf
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
123 additions
and
6 deletions
+123
-6
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
...in/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
+1
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
...o/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
+1
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
...va/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
+10
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WxWebMvcConfiguration.java
...ain/java/com/wwdz/ch/wx/config/WxWebMvcConfiguration.java
+17
-2
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
...c/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
+6
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
...pi/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
+22
-3
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
...ain/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
+66
-0
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/FavoritesItemsRelationDao.java
View file @
11a76673
...
@@ -10,6 +10,7 @@ public interface FavoritesItemsRelationDao {
...
@@ -10,6 +10,7 @@ public interface FavoritesItemsRelationDao {
int
batchInsert
(
List
<
FavoritesItemsRelation
>
list
);
int
batchInsert
(
List
<
FavoritesItemsRelation
>
list
);
int
deleteByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
int
deleteByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
int
deleteByChosen
(
Long
favoritesId
,
List
<
Long
>
itemIds
);
int
deleteByChosen
(
Long
favoritesId
,
List
<
Long
>
itemIds
);
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
);
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
);
FavoritesItemsRelation
selectByUserIdItemId
(
Long
userId
,
Long
itemId
);
FavoritesItemsRelation
selectByUserIdItemId
(
Long
userId
,
Long
itemId
);
PageInfo
<
FavoritesItemsRelation
>
pageByFavoritesId
(
Long
favoritesId
,
int
page
,
int
size
);
PageInfo
<
FavoritesItemsRelation
>
pageByFavoritesId
(
Long
favoritesId
,
int
page
,
int
size
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesDaoImpl.java
View file @
11a76673
...
@@ -59,6 +59,7 @@ public class FavoritesDaoImpl implements FavoritesDao {
...
@@ -59,6 +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"
);
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-dao/src/main/java/com/wwdz/ch/db/impl/FavoritesItemsRelationDaoImpl.java
View file @
11a76673
...
@@ -41,6 +41,16 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
...
@@ -41,6 +41,16 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
criteria
.
andItemIdIn
(
itemIds
);
criteria
.
andItemIdIn
(
itemIds
);
return
favoritesItemsRelationMapper
.
deleteByExample
(
example
);
return
favoritesItemsRelationMapper
.
deleteByExample
(
example
);
}
}
@Override
public
int
deleteByUserIdItemId
(
Long
userId
,
Long
itemId
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andItemIdEqualTo
(
itemId
);
return
favoritesItemsRelationMapper
.
deleteByExample
(
example
);
}
@Override
@Override
public
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
)
{
public
List
<
FavoritesItemsRelation
>
listByFavoritesId
(
Long
favoritesId
,
List
<
Long
>
favoritesIds
)
{
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
FavoritesItemsRelationExample
example
=
new
FavoritesItemsRelationExample
();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/config/WxWebMvcConfiguration.java
View file @
11a76673
package
com.wwdz.ch.wx.config
;
package
com.wwdz.ch.wx.config
;
import
java.util.List
;
import
com.wwdz.ch.wx.annotation.support.LoginUserHandlerMethodArgumentResolver
;
import
com.wwdz.ch.wx.annotation.support.LoginUserHandlerMethodArgumentResolver
;
import
com.wwdz.ch.wx.interceptor.LoginInterceptor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
@Configuration
public
class
WxWebMvcConfiguration
implements
WebMvcConfigurer
{
public
class
WxWebMvcConfiguration
implements
WebMvcConfigurer
{
@Bean
LoginInterceptor
loginInterceptor
()
{
return
new
LoginInterceptor
();
}
@Autowired
@Autowired
private
LoginUserHandlerMethodArgumentResolver
loginUserHandlerMethodArgumentResolver
;
private
LoginUserHandlerMethodArgumentResolver
loginUserHandlerMethodArgumentResolver
;
...
@@ -17,4 +24,12 @@ public class WxWebMvcConfiguration implements WebMvcConfigurer {
...
@@ -17,4 +24,12 @@ public class WxWebMvcConfiguration implements WebMvcConfigurer {
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
argumentResolvers
.
add
(
loginUserHandlerMethodArgumentResolver
);
argumentResolvers
.
add
(
loginUserHandlerMethodArgumentResolver
);
}
}
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
loginInterceptor
())
.
addPathPatterns
(
"/**"
)
.
excludePathPatterns
(
"/*.html"
,
"/**/*.html"
,
"/**/*.css"
,
"/**/*.js"
,
"/wx/user/loginByWx"
,
"/wx/user/loginByMobile"
,
"/wx/user/loginRegCaptcha"
,
"/wx/user/updateRegCaptcha"
);
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/FavoritesServiceImpl.java
View file @
11a76673
package
com.wwdz.ch.wx.impl
;
package
com.wwdz.ch.wx.impl
;
import
com.github.pagehelper.PageInfo
;
import
com.github.pagehelper.PageInfo
;
import
com.wwdz.ch.core.consts.CommonEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
import
com.wwdz.ch.db.dao.FavoritesItemsRelationDao
;
...
@@ -223,7 +224,11 @@ public class FavoritesServiceImpl implements FavoritesService {
...
@@ -223,7 +224,11 @@ public class FavoritesServiceImpl implements FavoritesService {
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
())
?
1
:
0
);
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
relation
.
getItemId
())
?
1
:
0
);
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
countByItemId
(
relation
.
getItemId
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
if
(
item
.
getSourceType
().
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
vo
.
setCollectCount
(
count
);
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/ItemServiceImpl.java
View file @
11a76673
...
@@ -64,7 +64,11 @@ public class ItemServiceImpl implements ItemService {
...
@@ -64,7 +64,11 @@ public class ItemServiceImpl implements ItemService {
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setPrice
(
String
.
valueOf
(
item
.
getPrice
()
*
100
));
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setDetail
(
item
.
getDetail
());
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
vo
.
setIsCollected
(
favoritesItemsRelationDao
.
isCollected
(
dto
.
getUserId
(),
item
.
getId
())
?
1
:
0
);
vo
.
setCollectCount
(
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
()));
long
count
=
favoritesItemsRelationDao
.
countByItemId
(
item
.
getId
());
if
(
item
.
getSourceType
().
equals
(
CommonEnum
.
SourceTypeEnum
.
USER_UPLOAD
.
getCode
()))
{
count
--;
}
vo
.
setCollectCount
(
count
);
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
AgentTranceResponseVo
agentTranceResponseVo
=
new
AgentTranceResponseVo
();
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
agentTranceResponseVo
.
setAgentTraceInfo_
(
""
);
...
@@ -120,7 +124,10 @@ public class ItemServiceImpl implements ItemService {
...
@@ -120,7 +124,10 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setItemId
(
item
.
getId
());
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelation
.
setAddTime
(
now
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
return
Result
.
success
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
item
.
getId
());
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"发布藏品失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"发布藏品失败,原因:"
+
e
.
getMessage
(),
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
...
@@ -208,6 +215,18 @@ public class ItemServiceImpl implements ItemService {
...
@@ -208,6 +215,18 @@ public class ItemServiceImpl implements ItemService {
return
Result
.
failed
(
"数据异常,该藏品不存在"
);
return
Result
.
failed
(
"数据异常,该藏品不存在"
);
}
}
item
.
setName
(
dto
.
getName
());
item
.
setCid
(
dto
.
getCid
());
item
.
setImages
(
dto
.
getImages
());
item
.
setPrice
(
Long
.
parseLong
(
dto
.
getPrice
())
/
100
);
item
.
setDetail
(
dto
.
getDetail
());
Date
now
=
new
Date
();
item
.
setUpdateTime
(
now
);
itemDao
.
update
(
item
);
// 删除原来藏品和收藏册关联
favoritesItemsRelationDao
.
deleteByUserIdItemId
(
dto
.
getUserId
(),
dto
.
getId
());
// 新增藏品和收藏册关联
// 新增藏品和收藏册关联
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
FavoritesItemsRelation
favoritesItemsRelation
=
new
FavoritesItemsRelation
();
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
favoritesItemsRelation
.
setUserId
(
dto
.
getUserId
());
...
@@ -216,7 +235,7 @@ public class ItemServiceImpl implements ItemService {
...
@@ -216,7 +235,7 @@ public class ItemServiceImpl implements ItemService {
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
favoritesItemsRelationDao
.
insert
(
favoritesItemsRelation
);
return
Result
.
success
();
return
Result
.
success
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"
收藏
藏品失败,原因:"
+
e
.
getMessage
(),
e
);
logger
.
error
(
"
修改
藏品失败,原因:"
+
e
.
getMessage
(),
e
);
return
Result
.
failed
(
"收藏藏品失败"
);
return
Result
.
failed
(
"收藏藏品失败"
);
}
}
}
}
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/interceptor/LoginInterceptor.java
0 → 100644
View file @
11a76673
package
com.wwdz.ch.wx.interceptor
;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.wx.service.UserTokenManager
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
@Component
public
class
LoginInterceptor
implements
HandlerInterceptor
{
Logger
logger
=
LoggerFactory
.
getLogger
(
LoginInterceptor
.
class
);
@Autowired
private
UserTokenManager
userTokenManager
;
/***
* 在请求处理之前进行调用(Controller方法调用之前)
*/
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
logger
.
info
(
"-------------进入拦截器"
);
String
token
=
request
.
getHeader
(
"kl_token"
);
if
(
StringUtils
.
isBlank
(
token
))
{
return
true
;
}
if
(
StringUtils
.
isNotBlank
(
token
))
{
Long
userId
=
userTokenManager
.
getUserId
(
token
);
if
(
Objects
.
nonNull
(
userId
))
{
return
true
;
}
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"code"
,
401
);
map
.
put
(
"success"
,
false
);
map
.
put
(
"message"
,
"未登录!"
);
map
.
put
(
"result"
,
null
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
getWriter
().
write
(
JSON
.
toJSONString
(
map
));
return
false
;
}
/***
* 请求处理之后进行调用,但是在视图被渲染之前(Controller方法调用之后)
*/
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
ModelAndView
modelAndView
)
throws
Exception
{
}
/***
* 整个请求结束之后被调用,也就是在DispatchServlet渲染了对应的视图之后执行(主要用于进行资源清理工作)
*/
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
}
}
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