Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
914d0c9f
Commit
914d0c9f
authored
Oct 15, 2021
by
王亚雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/bugfix-20211015'
parents
5cf99e31
0bae3870
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
25 deletions
+30
-25
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+1
-1
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+5
-4
HttpServletHelper.java
...main/java/com/tanpu/community/util/HttpServletHelper.java
+24
-20
No files found.
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
914d0c9f
...
@@ -78,7 +78,7 @@ public class HomePageController {
...
@@ -78,7 +78,7 @@ public class HomePageController {
@ApiOperation
(
"查询关注/粉丝列表"
)
@ApiOperation
(
"查询关注/粉丝列表"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
Page
<
FollowQo
>>
queryFollowList
(
@RequestBody
QueryFollowReq
req
)
{
public
CommonResp
<
Page
<
FollowQo
>>
queryFollowList
(
@RequestBody
QueryFollowReq
req
)
{
String
selfUserId
=
httpServletHelper
.
getCurren
tUserId
();
String
selfUserId
=
userHolder
.
ge
tUserId
();
// 为空查询当前用户自己的粉丝/关注列表
// 为空查询当前用户自己的粉丝/关注列表
if
(
StringUtils
.
isEmpty
(
req
.
getUserId
())
&&
StringUtils
.
isNotEmpty
(
selfUserId
))
{
if
(
StringUtils
.
isEmpty
(
req
.
getUserId
())
&&
StringUtils
.
isNotEmpty
(
selfUserId
))
{
req
.
setUserId
(
selfUserId
);
req
.
setUserId
(
selfUserId
);
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
914d0c9f
...
@@ -264,20 +264,21 @@ public class HomePageManager {
...
@@ -264,20 +264,21 @@ public class HomePageManager {
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIdsPage
.
getContent
());
List
<
UserInfoResp
>
userInfoNews
=
feignClientForFatools
.
queryUserListNew
(
userIdsPage
.
getContent
());
List
<
FollowQo
>
followQos
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
List
<
FollowQo
>
followQos
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
judgeFollowed
(
followQos
,
userId
);
followQos
=
judgeFollowed
(
followQos
,
userId
);
}
}
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
}
}
//判断返回列表中的用户是否被当前用户关注
//判断返回列表中的用户是否被当前用户关注
public
void
judgeFollowed
(
List
<
FollowQo
>
followQos
,
@NotEmpty
String
followerId
)
{
public
List
<
FollowQo
>
judgeFollowed
(
List
<
FollowQo
>
followQos
,
@NotEmpty
String
followerId
)
{
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByFansId
(
followerId
));
Set
<
String
>
idolSet
=
new
HashSet
<>(
followRelService
.
queryIdolsByFansId
(
followerId
));
followQos
.
stream
().
peek
(
o
->
{
return
followQos
.
stream
().
map
(
o
->
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
if
(
idolSet
.
contains
(
o
.
getUserId
()))
{
o
.
setFollowed
(
true
);
o
.
setFollowed
(
true
);
}
}
});
return
o
;
}).
collect
(
Collectors
.
toList
());
}
}
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
...
...
community-service/src/main/java/com/tanpu/community/util/HttpServletHelper.java
View file @
914d0c9f
package
com
.
tanpu
.
community
.
util
;
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -26,28 +27,31 @@ import java.util.Optional;
...
@@ -26,28 +27,31 @@ import java.util.Optional;
public
class
HttpServletHelper
{
public
class
HttpServletHelper
{
@Resource
@Resource
private
RedisHelper
redisHelper
;
private
RedisHelper
redisHelper
;
@Resource
private
UserHolder
userHolder
;
public
String
getCurrentUserId
()
{
public
String
getCurrentUserId
()
{
String
userId
=
null
;
// String userId = null;
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
currentRequestAttributes
()).
getRequest
();
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
String
clientEnv
=
request
.
getHeader
(
RedisKeyConstant
.
ENV
);
// String clientEnv = request.getHeader(RedisKeyConstant.ENV);
if
(
isAndroid
(
clientEnv
)
||
isIOS
(
clientEnv
)
||
isPc
(
clientEnv
)
||
isMiniProgram
(
clientEnv
))
{
// if (isAndroid(clientEnv) || isIOS(clientEnv) || isPc(clientEnv) || isMiniProgram(clientEnv)) {
// android,ios,pc,小程序用token
// // android,ios,pc,小程序用token
String
token
=
request
.
getHeader
(
RedisKeyConstant
.
TAMP_TOKEN
);
// String token = request.getHeader(RedisKeyConstant.TAMP_TOKEN);
// redis获取的value,都带有 "",这里去掉
// // redis获取的value,都带有 "",这里去掉
userId
=
StringUtils
.
remove
(
redisHelper
.
get
(
RedisKeyConstant
.
REDIS_PREFIX_TOKEN
+
token
),
"\""
);
// userId = StringUtils.remove(redisHelper.get(RedisKeyConstant.REDIS_PREFIX_TOKEN + token), "\"");
}
else
{
// } else {
// 用cookie
// // 用cookie
Cookie
[]
cookies
=
request
.
getCookies
();
// Cookie[] cookies = request.getCookies();
if
(
cookies
!=
null
)
{
// if (cookies != null) {
Optional
<
Cookie
>
first
=
Arrays
.
stream
(
request
.
getCookies
())
// Optional<Cookie> first = Arrays.stream(request.getCookies())
.
filter
(
cookie
->
StringUtils
.
equalsIgnoreCase
(
RedisKeyConstant
.
SESSION_COOKIE_NAME
,
cookie
.
getName
()))
// .filter(cookie -> StringUtils.equalsIgnoreCase(RedisKeyConstant.SESSION_COOKIE_NAME, cookie.getName()))
.
findFirst
();
// .findFirst();
if
(
first
.
isPresent
())
{
// if (first.isPresent()) {
userId
=
first
.
get
().
getValue
();
// userId = first.get().getValue();
}
// }
}
// }
}
// }
String
userId
=
userHolder
.
getUserId
();
log
.
debug
(
"当前登录用户Id: {}"
,
userId
);
log
.
debug
(
"当前登录用户Id: {}"
,
userId
);
return
userId
;
return
userId
;
}
}
...
...
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