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
6b638eac
Commit
6b638eac
authored
Sep 24, 2021
by
王亚雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游客权限
parent
0efc6dbf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
23 deletions
+108
-23
RedisKeyConstant.java
...a/com/tanpu/community/api/constants/RedisKeyConstant.java
+8
-0
HomePageController.java
...va/com/tanpu/community/controller/HomePageController.java
+14
-7
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+2
-3
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+12
-12
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+3
-1
HttpServletHelper.java
...main/java/com/tanpu/community/util/HttpServletHelper.java
+69
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/constants/RedisKeyConstant.java
View file @
6b638eac
...
...
@@ -2,6 +2,14 @@ package com.tanpu.community.api.constants;
public
class
RedisKeyConstant
{
public
static
final
String
ENV
=
"env"
;
// token app 小程序用
public
static
final
String
TAMP_TOKEN
=
"tampToken"
;
// H5 cookie
public
static
final
String
SESSION_COOKIE_NAME
=
"qimsession"
;
// redis token 前缀
public
static
final
String
REDIS_PREFIX_TOKEN
=
"s:sid:"
;
//点赞量
public
static
final
String
THEME_LIKE_COUNT
=
"THEME_LIKE_COUNT_"
;
//收藏量
...
...
community-service/src/main/java/com/tanpu/community/controller/HomePageController.java
View file @
6b638eac
...
...
@@ -15,14 +15,19 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.manager.HomePageManager
;
import
com.tanpu.community.manager.ThemeManager
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
com.tanpu.community.util.HttpServletHelper
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
...
...
@@ -41,13 +46,15 @@ public class HomePageController {
@Resource
private
UserHolder
userHolder
;
@Resource
HttpServletHelper
httpServletHelper
;
// 用户信息查询 (供圈子服务调用)
@ApiOperation
(
value
=
"个人中心 查询"
)
@GetMapping
(
value
=
"/queryUserInfoNew"
)
@AuthLogin
public
CommonResp
<
UserInfoResp
>
queryUsersListNew
(
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
)
{
String
userIdMyself
=
userHolder
.
getUserId
();
return
CommonResp
.
success
(
homePageManager
.
queryUsersInfo
(
userIdMyself
,
userId
));
public
CommonResp
<
UserInfoResp
>
queryUsersListNew
(
@RequestParam
(
value
=
"userId"
)
String
userId
)
{
String
selfUserId
=
httpServletHelper
.
getCurrentUserId
();
return
CommonResp
.
success
(
homePageManager
.
queryUsersInfo
(
selfUserId
,
userId
));
}
// 理财师客户列表查询 (供圈子服务调用)
...
...
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
6b638eac
...
...
@@ -44,12 +44,11 @@ public class ThemeController {
return
CommonResp
.
success
(
result
);
}
@AuthLogin
@ApiOperation
(
"主题正文"
)
@GetMapping
(
value
=
"/detail"
)
@ResponseBody
public
CommonResp
<
ThemeQo
>
getDetail
(
@RequestParam
(
value
=
"themeId"
)
String
themeId
)
{
String
userId
=
userHolder
.
getUserId
();
public
CommonResp
<
ThemeQo
>
getDetail
(
@RequestParam
(
value
=
"themeId"
)
String
themeId
,
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
)
{
return
themeManager
.
getThemeDetail
(
themeId
,
userId
);
}
...
...
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
6b638eac
...
...
@@ -88,23 +88,23 @@ public class HomePageManager {
//查询 个人中心 相关信息
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUserInfoNew
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUserInfoNew
(
userId
);
if
(
queryUsersListNew
.
isNotSuccess
()
||
!
ObjectUtils
.
anyNotNull
(
queryUsersListNew
.
getData
()))
throw
new
BizException
(
"内部接口调用失败"
);
UserInfoResp
userInfoNew
=
queryUsersListNew
.
getData
();
if
(
StringUtils
.
isNotBlank
(
userId
)
&&
!
StringUtils
.
equals
(
userIdMyself
,
userId
))
{
//查询别人的个人主页
// 关注 按钮的显示逻辑
FollowRelEntity
followRelEntity
=
followRelService
.
queryRecord
(
userId
,
userIdMyself
);
if
(
ObjectUtils
.
allNotNull
(
followRelEntity
)
&&
BizStatus
.
DeleteTag
.
tag_init
==
followRelEntity
.
getDeleteTag
())
{
userInfoNew
.
setShowFollowStatus
(
ShowFollowStatusEnum
.
FOLLOWED
.
getCode
());
// 已关注
}
else
{
userInfoNew
.
setShowFollowStatus
(
ShowFollowStatusEnum
.
NOT_FOLLOWED
.
getCode
());
// 未关注
if
(
StringUtils
.
isNotBlank
(
userIdMyself
))
{
if
(!
StringUtils
.
equals
(
userIdMyself
,
userId
))
{
// 查询别人的个人主页
// 关注 按钮的显示逻辑
FollowRelEntity
followRelEntity
=
followRelService
.
queryRecord
(
userId
,
userIdMyself
);
if
(
ObjectUtils
.
allNotNull
(
followRelEntity
)
&&
BizStatus
.
DeleteTag
.
tag_init
==
followRelEntity
.
getDeleteTag
())
{
userInfoNew
.
setShowFollowStatus
(
ShowFollowStatusEnum
.
FOLLOWED
.
getCode
());
// 已关注
}
else
{
userInfoNew
.
setShowFollowStatus
(
ShowFollowStatusEnum
.
NOT_FOLLOWED
.
getCode
());
// 未关注
}
if
(
userInfoNew
.
getWorkshopStatus
()
==
2
)
userInfoNew
.
setWorkshopStatus
(
1
);
//别人的主页不需要展示 工作室
}
if
(
userInfoNew
.
getWorkshopStatus
()
==
2
)
userInfoNew
.
setWorkshopStatus
(
1
);
//别人的主页不需要展示 工作室
}
else
{
// 查询自己的主页
userId
=
userIdMyself
;
}
//获取粉丝数 关注数
getFansNUmAndFollowNum
(
userInfoNew
);
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
6b638eac
...
...
@@ -690,7 +690,9 @@ public class ThemeManager {
buildThemeQoExtraInfo
(
themeQo
);
// 添加用户相关信息
buildThemeExtraInfoByUser
(
userId
,
themeQo
);
if
(
StringUtils
.
isNotEmpty
(
userId
))
{
buildThemeExtraInfoByUser
(
userId
,
themeQo
);
}
return
CommonResp
.
success
(
themeQo
);
}
...
...
community-service/src/main/java/com/tanpu/community/util/HttpServletHelper.java
0 → 100644
View file @
6b638eac
package
com
.
tanpu
.
community
.
util
;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.community.api.constants.RedisKeyConstant
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpCookie
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Arrays
;
import
java.util.Optional
;
/**
* @Description TODO
* @Author wangyalei
* @Date 2021/9/23 下午8:31
**/
@Slf4j
@Service
public
class
HttpServletHelper
{
@Resource
private
RedisHelper
redisHelper
;
public
String
getCurrentUserId
()
{
String
userId
=
null
;
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
currentRequestAttributes
()).
getRequest
();
String
clientEnv
=
request
.
getHeader
(
RedisKeyConstant
.
ENV
);
if
(
isAndroid
(
clientEnv
)
||
isIOS
(
clientEnv
)
||
isPc
(
clientEnv
)
||
isMiniProgram
(
clientEnv
))
{
// android,ios,pc,小程序用token
String
token
=
request
.
getHeader
(
RedisKeyConstant
.
TAMP_TOKEN
);
userId
=
redisHelper
.
get
(
RedisKeyConstant
.
REDIS_PREFIX_TOKEN
+
token
);
}
else
{
// 用cookie
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
cookies
!=
null
)
{
Optional
<
Cookie
>
first
=
Arrays
.
stream
(
request
.
getCookies
())
.
filter
(
cookie
->
StringUtils
.
equalsIgnoreCase
(
RedisKeyConstant
.
SESSION_COOKIE_NAME
,
cookie
.
getName
()))
.
findFirst
();
if
(
first
.
isPresent
())
{
userId
=
first
.
get
().
getValue
();
}
}
}
return
userId
;
}
public
static
boolean
isAndroid
(
String
clientEnv
)
{
return
"android"
.
equalsIgnoreCase
(
clientEnv
);
}
public
static
boolean
isIOS
(
String
clientEnv
)
{
return
"ios"
.
equalsIgnoreCase
(
clientEnv
);
}
public
static
boolean
isPc
(
String
clientEnv
)
{
return
"pc"
.
equalsIgnoreCase
(
clientEnv
);
}
public
static
boolean
isMiniProgram
(
String
clientEnv
)
{
return
"xcx"
.
equalsIgnoreCase
(
clientEnv
);
}
}
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