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
719dbbee
Commit
719dbbee
authored
Aug 24, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!12
parents
486792be
3f77bf3e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
1779 additions
and
130 deletions
+1779
-130
CommunityConstant.java
.../main/java/com/tanpu/community/api/CommunityConstant.java
+5
-0
NotificationQo.java
...java/com/tanpu/community/api/beans/qo/NotificationQo.java
+25
-0
ThemeNotifyQo.java
.../java/com/tanpu/community/api/beans/qo/ThemeNotifyQo.java
+85
-0
UserBriefInfoQO.java
...ava/com/tanpu/community/api/beans/qo/UserBriefInfoQO.java
+22
-0
OSSCheckExtras.java
...ava/com/tanpu/community/api/beans/req/OSSCheckExtras.java
+17
-0
OSSCheckReq.java
...n/java/com/tanpu/community/api/beans/req/OSSCheckReq.java
+22
-0
OSSCheckResult.java
...ava/com/tanpu/community/api/beans/req/OSSCheckResult.java
+18
-0
OSSCheckScanResult.java
...com/tanpu/community/api/beans/req/OSSCheckScanResult.java
+22
-0
NotifyQueryReq.java
.../community/api/beans/req/notification/NotifyQueryReq.java
+25
-0
Pageable.java
...java/com/tanpu/community/api/beans/req/page/Pageable.java
+2
-8
ThemeFullSearchResp.java
...m/tanpu/community/api/beans/resp/ThemeFullSearchResp.java
+5
-0
UserInfoNewChief.java
...ommunity/api/beans/vo/feign/fatools/UserInfoNewChief.java
+1
-3
RedisKeyConstant.java
...a/com/tanpu/community/api/constants/RedisKeyConstant.java
+8
-0
FileChechStatusEnum.java
...va/com/tanpu/community/api/enums/FileChechStatusEnum.java
+41
-0
NotificationTypeEnum.java
...a/com/tanpu/community/api/enums/NotificationTypeEnum.java
+52
-0
pom.xml
community-service/pom.xml
+22
-0
RedisCache.java
...e/src/main/java/com/tanpu/community/cache/RedisCache.java
+19
-0
CacheConfig.java
...src/main/java/com/tanpu/community/config/CacheConfig.java
+18
-2
SwaggerConfig.java
...c/main/java/com/tanpu/community/config/SwaggerConfig.java
+1
-1
CallBackController.java
...va/com/tanpu/community/controller/CallBackController.java
+91
-0
CommentController.java
...ava/com/tanpu/community/controller/CommentController.java
+5
-6
NotificationController.java
...om/tanpu/community/controller/NotificationController.java
+70
-0
CodeAutoGenerator.java
.../main/java/com/tanpu/community/dao/CodeAutoGenerator.java
+1
-1
NotificationForwardDO.java
...com/tanpu/community/dao/entity/NotificationForwardDO.java
+20
-0
NotificationLikeDO.java
...va/com/tanpu/community/dao/entity/NotificationLikeDO.java
+27
-0
FileRecordEntity.java
...anpu/community/dao/entity/community/FileRecordEntity.java
+30
-8
NotificationEntity.java
...pu/community/dao/entity/community/NotificationEntity.java
+155
-0
FileRecordMapper.java
...anpu/community/dao/mapper/community/FileRecordMapper.java
+1
-1
NotificationMapper.java
...pu/community/dao/mapper/community/NotificationMapper.java
+16
-0
CommentManager.java
...main/java/com/tanpu/community/manager/CommentManager.java
+51
-15
FileManager.java
...rc/main/java/com/tanpu/community/manager/FileManager.java
+84
-1
HomePageManager.java
...ain/java/com/tanpu/community/manager/HomePageManager.java
+32
-4
NotificationManager.java
...java/com/tanpu/community/manager/NotificationManager.java
+238
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+20
-4
BatchFeignCallService.java
...va/com/tanpu/community/service/BatchFeignCallService.java
+34
-15
CollectionService.java
...n/java/com/tanpu/community/service/CollectionService.java
+14
-4
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+9
-0
FollowRelService.java
...in/java/com/tanpu/community/service/FollowRelService.java
+9
-1
NotificationService.java
...java/com/tanpu/community/service/NotificationService.java
+277
-0
OSSFileService.java
...main/java/com/tanpu/community/service/OSSFileService.java
+31
-7
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+5
-7
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+7
-0
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+7
-34
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+78
-8
TimeUtils.java
...ice/src/main/java/com/tanpu/community/util/TimeUtils.java
+12
-0
application-dev.yml
community-service/src/main/resources/application-dev.yml
+5
-0
FileRecordEntityMapper.xml
...ain/resources/mapper/community/FileRecordEntityMapper.xml
+2
-0
NotificationEntityMapper.xml
...n/resources/mapper/community/NotificationEntityMapper.xml
+19
-0
v2.sql
docs/v2.sql
+19
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/CommunityConstant.java
View file @
719dbbee
...
...
@@ -23,6 +23,11 @@ public final class CommunityConstant {
//图片压缩比例:50%
public
static
final
String
OSS_RESIZE_RATIO
=
"?x-oss-process=image/resize,p_50"
;
// 图片审核不通过的替换默认图片
public
static
final
String
OSS_CHECK_FAIL_DEFAULT
=
"https://tamp-sit.oss-cn-shanghai.aliyuncs.com/community/pic/default/check_fail.png"
;
public
static
final
Integer
OSS_CHECK_FAIL_DEFAULT_WIDTH
=
1035
;
public
static
final
Integer
OSS_CHECK_FAIL_DEFAULT_HEIGHT
=
1115
;
public
static
final
String
THEME_PREFIX
=
"NEW_THEME_"
;
public
static
final
String
OLD_FILE_UPLOAD_URL
=
"http://tp-fatools-svc/fatools/h5/rest/common/uploadSingleFile"
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/qo/NotificationQo.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
NotificationQo
{
@ApiModelProperty
(
value
=
"未读条数"
)
private
Integer
updateCount
;
@ApiModelProperty
(
value
=
"最新消息"
)
private
String
message
;
@ApiModelProperty
(
value
=
"更新时间"
)
private
String
updateTime
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/ThemeNotifyQo.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
ThemeNotifyQo
{
@ApiModelProperty
(
value
=
"通知主键Id"
)
private
String
notificationId
;
@ApiModelProperty
(
value
=
"被通知的用户id"
)
private
String
notifiedUserId
;
@ApiModelProperty
(
value
=
"1:转发 2:点赞 3:评论 4:关注"
)
private
Integer
messageType
;
@ApiModelProperty
(
value
=
"操作用户id"
)
public
String
authorId
;
@ApiModelProperty
(
value
=
"操作用户头像"
)
public
String
userImg
;
@ApiModelProperty
(
value
=
"操作用户昵称"
)
public
String
nickName
;
@ApiModelProperty
(
value
=
"操作用户简介"
)
private
String
userIntroduction
;
@ApiModelProperty
(
value
=
"当前用户是否关注该操作用户"
)
public
boolean
follow
;
@ApiModelProperty
(
value
=
"认证机构"
)
private
String
authOrg
;
@ApiModelProperty
(
value
=
"发表时间-距今"
)
public
String
upToNowTime
;
@ApiModelProperty
(
value
=
"发表时间-标准格式化"
)
public
String
formatTime
;
// 内容、话题
@ApiModelProperty
(
value
=
"所属的话题"
)
public
String
topicId
;
@ApiModelProperty
(
value
=
"话题名称"
)
public
String
topicTitle
;
@ApiModelProperty
(
value
=
"评论/转发内容"
)
private
String
content
;
@ApiModelProperty
(
value
=
"转发类型-主题id"
)
private
String
forwardThemeId
;
@ApiModelProperty
(
value
=
"引用的主题id"
)
public
String
formerThemeId
;
@ApiModelProperty
(
value
=
"引用的主题内容"
)
public
String
formerContent
;
@ApiModelProperty
(
value
=
"引用的主题用户昵称"
)
public
String
formerUserName
;
@ApiModelProperty
(
value
=
"引用的主题的话题id"
)
public
String
formerTopicId
;
@ApiModelProperty
(
value
=
"引用的主题的话题名称"
)
public
String
formerTopicTitle
;
// 点赞聚合
@ApiModelProperty
(
value
=
"用户id"
)
public
List
<
UserBriefInfoQO
>
likeUsers
;
@ApiModelProperty
(
value
=
"点赞人数"
)
public
Integer
likeUserCount
;
// 认证标签相关
@ApiModelProperty
(
"认证标签用-用户等级体系 0 游客 1注册用户 10投资人 20 探普理顾 30 探普专家理顾 40 交易理财师 50 首席投顾"
)
private
Integer
levelGrade
;
@ApiModelProperty
(
"认证标签用-当levelGrade=10有值 1投资萌新 2投资达人"
)
private
Integer
userInvestorType
;
@ApiModelProperty
(
"认证标签用-用户类型 1普通账号 2机构账号 3机构人员"
)
private
Integer
userType
;
@ApiModelProperty
(
"认证标签用-所属机构id"
)
private
String
belongUserOrgId
;
@ApiModelProperty
(
"认证标签用-所属机构名"
)
private
String
belongUserOrgName
;
}
community-api/src/main/java/com/tanpu/community/api/beans/qo/UserBriefInfoQO.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
UserBriefInfoQO
{
@ApiModelProperty
(
"用户id"
)
private
String
userId
;
//用户id
@ApiModelProperty
(
"昵称"
)
private
String
nickName
;
//昵称
@ApiModelProperty
(
"头像"
)
private
String
headImageUrl
;
//头像
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckExtras.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckExtras
{
private
String
sexRate
;
private
String
normRate
;
private
String
pornRate
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckReq.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
com.google.gson.JsonObject
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckReq
{
private
String
bucket
;
private
String
object
;
private
boolean
stock
;
private
String
region
;
private
String
freezed
;
private
JsonObject
scanResult
;
private
JsonObject
auditResult
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckResult.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckResult
{
private
String
label
;
private
double
rate
;
private
String
scene
;
private
String
suggestion
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/OSSCheckScanResult.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
req
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
OSSCheckScanResult
{
private
String
code
;
private
String
dataId
;
private
OSSCheckExtras
extras
;
private
String
msg
;
private
List
<
OSSCheckResult
>
results
;
private
String
taskId
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/notification/NotifyQueryReq.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
req
.
notification
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
NotifyQueryReq
{
@ApiModelProperty
(
value
=
"1:转发 2:点赞 3:评论 4:关注 0:全部"
)
private
Integer
type
;
@ApiModelProperty
(
value
=
"最后一条通知"
)
private
String
lastId
;
@ApiModelProperty
(
value
=
"页幅"
)
public
Integer
pageSize
=
20
;
}
community-api/src/main/java/com/tanpu/community/api/beans/req/page/Pageable.java
View file @
719dbbee
...
...
@@ -4,23 +4,17 @@ import io.swagger.annotations.ApiModel;
import
lombok.Builder
;
import
lombok.Data
;
import
javax.validation.constraints.NotEmpty
;
@Data
@Builder
@ApiModel
(
value
=
"分页"
)
public
class
Pageable
{
public
static
final
Integer
DEFAULT_PAGE_SIZE
=
10
;
public
static
final
Integer
MAX_PAGE_SIZE
=
9999
;
public
static
final
Integer
DEFAULT_PAGE_SIZE
=
20
;
public
static
final
Integer
DEFAULT_PAGE_NUMBER
=
0
;
public
static
final
Integer
DEFAULT_PAGE_NUMBER
=
1
;
@NotEmpty
(
message
=
"分页Number不能为空"
)
public
Integer
pageNumber
=
DEFAULT_PAGE_NUMBER
;
@NotEmpty
(
message
=
"分页pageSize不能为空"
)
public
Integer
pageSize
=
DEFAULT_PAGE_SIZE
;
public
Pageable
()
{
...
...
community-api/src/main/java/com/tanpu/community/api/beans/resp/ThemeFullSearchResp.java
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
beans
.
resp
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
io.swagger.annotations.ApiModel
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
@ApiModel
(
value
=
"主题搜索"
)
public
class
ThemeFullSearchResp
{
public
List
<
ThemeQo
>
themes
;
...
...
community-api/src/main/java/com/tanpu/community/api/beans/vo/feign/fatools/UserInfoNewChief.java
View file @
719dbbee
...
...
@@ -7,8 +7,6 @@ import lombok.Builder;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @description: 用户信息 圈子使用
* @author: zejia zj wu
...
...
@@ -18,7 +16,7 @@ import java.io.Serializable;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
description
=
"用户信息 首席投顾专用信息"
)
@ApiModel
(
value
=
"用户信息 首席投顾专用信息"
)
public
class
UserInfoNewChief
{
...
...
community-api/src/main/java/com/tanpu/community/api/constants/RedisKeyConstant.java
View file @
719dbbee
...
...
@@ -23,4 +23,12 @@ public class RedisKeyConstant {
// 关注的人,上次浏览的最新主题last id
public
static
final
String
CACHE_IDOL_THEME_LAST_ID
=
"CACHE_IDOL_THEME_LAST_ID_"
;
// 消息通知
public
static
final
String
MESSAGE_NOTIFY_COUNT
=
"MESSAGE_NOTIFY_COUNT_"
;
public
static
final
String
MESSAGE_NOTIFY_LAST_MSG
=
"MESSAGE_NOTIFY_LAST_MSG_"
;
public
static
final
String
MESSAGE_NOTIFY_LAST_TIME
=
"MESSAGE_NOTIFY_LAST_TIME_"
;
// 消息通知-
public
static
final
String
MESSAGE_NOTIFY_QUERY_TIME
=
"MESSAGE_NOTIFY_QUERY_TIME_"
;
}
community-api/src/main/java/com/tanpu/community/api/enums/FileChechStatusEnum.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
enums
;
import
org.apache.commons.collections4.SetUtils
;
import
java.util.HashSet
;
public
enum
FileChechStatusEnum
{
INIT
(
0
,
"初始化"
),
PASS
(
1
,
"审核通过"
),
BLOCK
(
2
,
"审核不通过"
),
REVIEW
(
3
,
"建议人工审核"
);
public
static
final
HashSet
<
String
>
ossTypeSet
=
SetUtils
.
hashSet
(
"jpg"
,
"jpeg"
,
"png"
,
"txt"
);
private
Integer
code
;
private
String
type
;
FileChechStatusEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
community-api/src/main/java/com/tanpu/community/api/enums/NotificationTypeEnum.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
api
.
enums
;
import
java.util.EnumSet
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 通用操作类型枚举,包括点赞/取消点赞,收藏/取消收藏,关注/取消关注
*/
public
enum
NotificationTypeEnum
{
FORWARD
(
1
,
"转发"
),
LIKE
(
2
,
"点赞"
),
COMMENT
(
3
,
"评论"
),
FOLLOW
(
4
,
"关注"
),
ALL
(
0
,
"全部"
);
private
Integer
code
;
private
String
type
;
public
Integer
getCode
()
{
return
code
;
}
public
void
setCode
(
Integer
code
)
{
this
.
code
=
code
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
NotificationTypeEnum
(
Integer
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
private
static
final
Map
<
Integer
,
String
>
lookup
=
new
HashMap
<
Integer
,
String
>();
static
{
for
(
NotificationTypeEnum
s
:
EnumSet
.
allOf
(
NotificationTypeEnum
.
class
))
{
lookup
.
put
(
s
.
getCode
(),
s
.
getType
());
}
}
public
static
String
lookup
(
Integer
code
){
return
lookup
.
get
(
code
);
}
}
community-service/pom.xml
View file @
719dbbee
...
...
@@ -189,6 +189,28 @@
<version>
4.0.11
</version>
</dependency>
<!-- 阿里云内容检测-->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
4.1.1
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-green
</artifactId>
<version>
3.6.5
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.51
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.8.3
</version>
</dependency>
</dependencies>
<build>
...
...
community-service/src/main/java/com/tanpu/community/cache/RedisCache.java
View file @
719dbbee
...
...
@@ -51,6 +51,16 @@ public class RedisCache {
return
redisHelper
.
get
(
key
);
}
public
void
incr
(
String
key
)
{
key
=
cacheName
+
":"
+
key
;
redisHelper
.
incr
(
key
);
}
public
void
decr
(
String
key
)
{
key
=
cacheName
+
":"
+
key
;
redisHelper
.
decr
(
key
);
}
public
void
put
(
String
key
,
Object
obj
,
Integer
expireSeconds
)
{
key
=
cacheName
+
":"
+
key
;
String
value
=
JsonUtil
.
toJson
(
obj
);
...
...
@@ -61,6 +71,15 @@ public class RedisCache {
}
}
public
void
set
(
String
key
,
String
value
,
Integer
expireSeconds
)
{
key
=
cacheName
+
":"
+
key
;
if
(
expireSeconds
==
0
)
{
redisHelper
.
set
(
key
,
value
);
}
else
{
redisHelper
.
set
(
key
,
value
,
Duration
.
ofSeconds
(
expireSeconds
));
}
}
private
void
delete
(
String
key
)
{
redisHelper
.
delete
(
key
);
}
...
...
community-service/src/main/java/com/tanpu/community/config/CacheConfig.java
View file @
719dbbee
...
...
@@ -2,16 +2,26 @@ package com.tanpu.community.config;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.util.SpringUtils
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.cache.caffeine.CaffeineCacheManager
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
@Configuration
@Slf4j
@Data
@Component
@ConfigurationProperties
(
prefix
=
"cache"
)
public
class
CacheConfig
{
private
String
caffeineSpec
;
@Autowired
private
SpringUtils
springUtils
;
...
...
@@ -22,10 +32,16 @@ public class CacheConfig {
@Bean
public
CaffeineCacheManager
caffeineCacheManager
()
{
log
.
info
(
"initialize local cache with caffeineSpec:{}"
,
caffeineSpec
);
if
(
StringUtils
.
isBlank
(
caffeineSpec
))
{
caffeineSpec
=
"maximumSize=10000,expireAfterWrite=300s"
;
}
CaffeineCacheManager
cacheManager
=
new
CaffeineCacheManager
();
cacheManager
.
setCacheNames
(
Arrays
.
asList
(
"local"
));
// todo 配置化
cacheManager
.
setCacheSpecification
(
"maximumSize=1000,expireAfterWrite=30s"
);
cacheManager
.
setCacheSpecification
(
caffeineSpec
);
return
cacheManager
;
}
}
community-service/src/main/java/com/tanpu/community/config/SwaggerConfig.java
View file @
719dbbee
...
...
@@ -29,7 +29,7 @@ public class SwaggerConfig {
Docket
docket
=
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
CommunityConstant
.
PACKAGE_BASE
))
.
apis
(
RequestHandlerSelectors
.
basePackage
(
CommunityConstant
.
PACKAGE_BASE
+
".controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
...
...
community-service/src/main/java/com/tanpu/community/controller/CallBackController.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
controller
;
import
com.alibaba.fastjson.JSONArray
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.enums.FileChechStatusEnum
;
import
com.tanpu.community.manager.FileManager
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
@RestController
@Slf4j
@RequestMapping
(
value
=
"/api"
)
public
class
CallBackController
{
@Autowired
private
FileManager
fileManager
;
/**
* 阿里云图片审核回调接口
* 回调时间:6秒以内
* 文档地址:https://help.aliyun.com/document_detail/129946.html?spm=a2c4g.11186623.6.562.19a05f3aNkd2Oo#table-s9e-grd-408
* https://help.aliyun.com/document_detail/70292.htm?spm=a2c4g.11186623.2.12.26573ac7EEunMN#reference-fzy-ztm-v2b
* 屏蔽内容:
* 图片智能鉴黄(porn)结果分类:normal:正常 sexy:性感 porn:色情
* 图片不良场景(live)结果分类:normal:正常 meaningless:图片中无内容(例如,黑屏、白屏) PIP:画中画 smoking:吸烟 drivelive:车内直播
* @param checksum
* @param content
* @return
*/
@ApiOperation
(
"oss图片审核回调"
)
@PostMapping
(
value
=
"/picCheck/callback"
)
public
String
picCheck
(
String
checksum
,
String
content
)
{
Map
<
String
,
Object
>
response
=
JsonUtil
.
toMap
(
content
);
String
fileKey
=
(
String
)
response
.
get
(
"object"
);
boolean
freezed
=
(
boolean
)
response
.
get
(
"freezed"
);
FileChechStatusEnum
type
=
freezed
?
FileChechStatusEnum
.
BLOCK
:
FileChechStatusEnum
.
PASS
;
HashMap
<
String
,
Object
>
scanResult
=
(
HashMap
<
String
,
Object
>)
response
.
get
(
"scanResult"
);
String
taskId
=
(
String
)
scanResult
.
get
(
"taskId"
);
List
<
HashMap
<
String
,
Object
>>
scenes
=
(
List
<
HashMap
<
String
,
Object
>>)
scanResult
.
get
(
"results"
);
for
(
HashMap
<
String
,
Object
>
scene
:
scenes
)
{
// pass:结果正常,无需进行其余操作。
// review:结果不确定,需要进行人工审核。
// block:结果违规,建议直接删除或者限制公开。
if
(
"block"
.
equals
(
scene
.
get
(
"suggestion"
)))
{
type
=
FileChechStatusEnum
.
BLOCK
;
break
;
}
if
(
"review"
.
equals
(
scene
.
get
(
"suggestion"
)))
{
if
(
"porn"
.
equals
(
scene
.
get
(
"scene"
))){
type
=
FileChechStatusEnum
.
BLOCK
;
break
;
}
type
=
FileChechStatusEnum
.
REVIEW
;
}
}
fileManager
.
updateCheckResult
(
fileKey
,
type
,
JsonUtil
.
toJson
(
scanResult
));
return
"success"
;
}
@ApiOperation
(
"oss图片审核结果查询"
)
@PostMapping
(
value
=
"/picCheck/queryTask"
)
public
CommonResp
<
JSONArray
>
queryTask
(
@RequestParam
String
taskId
)
{
try
{
return
CommonResp
.
success
(
fileManager
.
queryTask
(
taskId
));
}
catch
(
Exception
e
)
{
throw
new
BizException
(
"queryTask请求失败"
);
}
}
public
static
void
main
(
String
[]
args
)
{
ConcurrentHashMap
<
String
,
Object
>
map
=
new
ConcurrentHashMap
<>();
map
.
put
(
"a"
,
1
);
}
}
community-service/src/main/java/com/tanpu/community/controller/CommentController.java
View file @
719dbbee
...
...
@@ -36,10 +36,9 @@ public class CommentController {
@AuthLogin
@PostMapping
(
value
=
"/publishComment"
)
@ResponseBody
public
CommonResp
<
Void
>
publishCommet
(
@Validated
@RequestBody
CreateCommentReq
req
)
{
public
CommonResp
<
CommentQo
>
publishCommet
(
@Validated
@RequestBody
CreateCommentReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
comment
(
req
,
userId
);
return
CommonResp
.
success
();
return
CommonResp
.
success
(
commentManager
.
comment
(
req
,
userId
));
}
@ApiOperation
(
"评论列表"
)
...
...
@@ -68,7 +67,7 @@ public class CommentController {
@ResponseBody
public
CommonResp
<
Void
>
reportComment
(
@Validated
@RequestBody
ReportCommentReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
report
(
req
,
userId
);
commentManager
.
report
(
req
,
userId
);
return
CommonResp
.
success
();
}
...
...
@@ -76,9 +75,9 @@ public class CommentController {
@GetMapping
(
value
=
"/deleteComment"
)
@AuthLogin
@ResponseBody
public
CommonResp
<
Void
>
reportComment
(
@RequestParam
(
value
=
"commentId"
)
String
commentId
)
{
public
CommonResp
<
Void
>
reportComment
(
@RequestParam
(
value
=
"commentId"
)
String
commentId
)
{
String
userId
=
userHolder
.
getUserId
();
commentManager
.
delete
(
commentId
,
userId
);
commentManager
.
delete
(
commentId
,
userId
);
return
CommonResp
.
success
();
}
}
community-service/src/main/java/com/tanpu/community/controller/NotificationController.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.auth.AuthLogin
;
import
com.tanpu.common.auth.UserHolder
;
import
com.tanpu.community.api.beans.qo.NotificationQo
;
import
com.tanpu.community.api.beans.qo.ThemeNotifyQo
;
import
com.tanpu.community.api.beans.req.notification.NotifyQueryReq
;
import
com.tanpu.community.manager.NotificationManager
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
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.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* 消息通知
*/
@Slf4j
@RestController
@RequestMapping
(
"/api/notification"
)
@Api
(
value
=
"圈子消息通知"
)
public
class
NotificationController
{
@Autowired
private
UserHolder
userHolder
;
@Autowired
private
NotificationManager
notificationManager
;
@AuthLogin
@PostMapping
(
"/query"
)
@ResponseBody
@ApiOperation
(
value
=
"查找用戶的消息通知列表"
)
public
CommonResp
<
List
<
ThemeNotifyQo
>>
query
(
@RequestBody
NotifyQueryReq
req
){
List
<
ThemeNotifyQo
>
query
=
notificationManager
.
queryList
(
req
,
userHolder
.
getUserId
());
return
CommonResp
.
success
(
query
);
}
@AuthLogin
@GetMapping
(
"/updateCount"
)
@ResponseBody
@ApiOperation
(
value
=
"更新推送"
)
public
CommonResp
<
NotificationQo
>
query
(){
NotificationQo
notificationQO
=
notificationManager
.
queryBriefInfo
(
userHolder
.
getUserId
());
return
CommonResp
.
success
(
notificationQO
);
}
@AuthLogin
@GetMapping
(
"/init"
)
@ResponseBody
@ApiOperation
(
value
=
"初始化数据"
)
public
CommonResp
<
Void
>
initData
(){
if
(!
"admin"
.
equals
(
userHolder
.
getUserId
())){
return
CommonResp
.
failed
(
"权限不足"
);
}
notificationManager
.
initAllData
();
return
CommonResp
.
success
();
}
}
community-service/src/main/java/com/tanpu/community/dao/CodeAutoGenerator.java
View file @
719dbbee
...
...
@@ -23,7 +23,7 @@ public class CodeAutoGenerator {
String
mysqlPassword
=
"@imeng123"
;
String
jdbcUrl
=
"jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community"
;
// String[] tables = new String[]{"theme"};
String
[]
tables
=
new
String
[]{
"
visit_log
"
};
String
[]
tables
=
new
String
[]{
"
file_record
"
};
String
basePackage
=
"com.tanpu.community"
;
String
mapperPackage
=
"dao.mapper.community"
;
String
entityPackage
=
"dao.entity.community"
;
...
...
community-service/src/main/java/com/tanpu/community/dao/entity/NotificationForwardDO.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
dao
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
NotificationForwardDO
{
private
String
content
;
private
String
topicId
;
private
String
themeId
;
}
community-service/src/main/java/com/tanpu/community/dao/entity/NotificationLikeDO.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
dao
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.TreeSet
;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
NotificationLikeDO
{
private
Integer
count
=
0
;
private
TreeSet
<
String
>
set
=
new
TreeSet
<>();
public
void
addItem
(
String
item
)
{
if
(
this
.
set
.
size
()
>=
3
)
{
set
.
pollFirst
();
}
set
.
add
(
item
);
count
++;
}
}
community-service/src/main/java/com/tanpu/community/dao/entity/community/FileRecordEntity.java
View file @
719dbbee
...
...
@@ -18,7 +18,7 @@ import java.time.LocalDateTime;
* </p>
*
* @author xudong
* @since 2021-0
7-12
* @since 2021-0
8-18
*/
@TableName
(
"file_record"
)
@Builder
...
...
@@ -31,9 +31,9 @@ public class FileRecordEntity implements Serializable {
@ApiModelProperty
(
value
=
"id"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
Long
id
;
@ApiModelProperty
(
value
=
"文件Id"
)
@ApiModelProperty
(
value
=
"文件
主键
Id"
)
private
String
fileId
;
@ApiModelProperty
(
value
=
"类型:1:图片"
)
...
...
@@ -45,7 +45,7 @@ public class FileRecordEntity implements Serializable {
@ApiModelProperty
(
value
=
"阿里云key"
)
private
String
fileOssKey
;
@ApiModelProperty
(
value
=
"预览url"
)
@ApiModelProperty
(
value
=
"预
签名预
览url"
)
private
String
previewUrl
;
private
LocalDateTime
createTime
;
...
...
@@ -56,16 +56,20 @@ public class FileRecordEntity implements Serializable {
private
String
extInfo
;
@ApiModelProperty
(
value
=
"审核状态 0:初试化 1:通过 2:不通过 3:需要人工再审"
)
private
Integer
checkStatus
;
@ApiModelProperty
(
value
=
"审核结果记录"
)
private
String
checkResultLog
;
public
String
getUrl
(){
return
getPreviewUrl
().
substring
(
0
,
getPreviewUrl
().
indexOf
(
"?"
));
}
public
Integer
getId
()
{
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
...
...
@@ -141,6 +145,22 @@ public class FileRecordEntity implements Serializable {
this
.
extInfo
=
extInfo
;
}
public
Integer
getCheckStatus
()
{
return
checkStatus
;
}
public
void
setCheckStatus
(
Integer
checkStatus
)
{
this
.
checkStatus
=
checkStatus
;
}
public
String
getCheckResultLog
()
{
return
checkResultLog
;
}
public
void
setCheckResultLog
(
String
checkResultLog
)
{
this
.
checkResultLog
=
checkResultLog
;
}
@Override
public
String
toString
()
{
return
"FileRecordEntity{"
+
...
...
@@ -154,6 +174,8 @@ public class FileRecordEntity implements Serializable {
", updateTime="
+
updateTime
+
", deleteTag="
+
deleteTag
+
", extInfo="
+
extInfo
+
", checkStatus="
+
checkStatus
+
", checkResultLog="
+
checkResultLog
+
"}"
;
}
}
community-service/src/main/java/com/tanpu/community/dao/entity/community/NotificationEntity.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
dao
.
entity
.
community
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* <p>
* 消息通知记录
* </p>
*
* @author xudong
* @since 2021-08-13
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName
(
"notification"
)
@ApiModel
(
value
=
"NotificationEntity对象"
,
description
=
"消息通知记录"
)
public
class
NotificationEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"id"
)
private
Long
id
;
@ApiModelProperty
(
value
=
"通知主键Id"
)
private
String
notificationId
;
@ApiModelProperty
(
value
=
"被通知的用户id"
)
private
String
notifiedUserId
;
@ApiModelProperty
(
value
=
"1:转发 2:点赞 3:评论 4:关注"
)
private
Integer
messageType
;
@ApiModelProperty
(
value
=
"目标id,类型是转发、点赞、评论时为themeId,关注则为user_id"
)
private
String
targetId
;
@ApiModelProperty
(
value
=
"评论:评论内容 转发:topicId+内容 点赞:人数+最近3个用户"
)
private
String
content
;
@ApiModelProperty
(
value
=
"操作者id"
)
private
String
operatorId
;
private
LocalDateTime
createTime
;
private
LocalDateTime
updateTime
;
private
Integer
deleteTag
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getNotificationId
()
{
return
notificationId
;
}
public
void
setNotificationId
(
String
notificationId
)
{
this
.
notificationId
=
notificationId
;
}
public
String
getNotifiedUserId
()
{
return
notifiedUserId
;
}
public
void
setNotifiedUserId
(
String
notifiedUserId
)
{
this
.
notifiedUserId
=
notifiedUserId
;
}
public
Integer
getMessageType
()
{
return
messageType
;
}
public
void
setMessageType
(
Integer
messageType
)
{
this
.
messageType
=
messageType
;
}
public
String
getTargetId
()
{
return
targetId
;
}
public
void
setTargetId
(
String
targetId
)
{
this
.
targetId
=
targetId
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getOperatorId
()
{
return
operatorId
;
}
public
void
setOperatorId
(
String
operatorId
)
{
this
.
operatorId
=
operatorId
;
}
public
LocalDateTime
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
LocalDateTime
createTime
)
{
this
.
createTime
=
createTime
;
}
public
LocalDateTime
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
LocalDateTime
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Integer
getDeleteTag
()
{
return
deleteTag
;
}
public
void
setDeleteTag
(
Integer
deleteTag
)
{
this
.
deleteTag
=
deleteTag
;
}
@Override
public
String
toString
()
{
return
"NotificationEntity{"
+
"id="
+
id
+
", notificationId="
+
notificationId
+
", notifiedUserId="
+
notifiedUserId
+
", messageType="
+
messageType
+
", targetId="
+
targetId
+
", content="
+
content
+
", operatorId="
+
operatorId
+
", createTime="
+
createTime
+
", updateTime="
+
updateTime
+
", deleteTag="
+
deleteTag
+
"}"
;
}
}
community-service/src/main/java/com/tanpu/community/dao/mapper/community/FileRecordMapper.java
View file @
719dbbee
...
...
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
*
* @author xudong
* @since 2021-0
7-07
* @since 2021-0
8-18
*/
public
interface
FileRecordMapper
extends
BaseMapper
<
FileRecordEntity
>
{
...
...
community-service/src/main/java/com/tanpu/community/dao/mapper/community/NotificationMapper.java
0 → 100644
View file @
719dbbee
package
com
.
tanpu
.
community
.
dao
.
mapper
.
community
;
import
com.tanpu.community.dao.entity.community.NotificationEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* 消息通知记录 Mapper 接口
* </p>
*
* @author xudong
* @since 2021-08-13
*/
public
interface
NotificationMapper
extends
BaseMapper
<
NotificationEntity
>
{
}
community-service/src/main/java/com/tanpu/community/manager/CommentManager.java
View file @
719dbbee
...
...
@@ -10,13 +10,17 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import
com.tanpu.community.api.beans.req.comment.LikeCommentReq
;
import
com.tanpu.community.api.beans.req.comment.ReportCommentReq
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.service.CollectionService
;
import
com.tanpu.community.service.CommentService
;
import
com.tanpu.community.service.NotificationService
;
import
com.tanpu.community.service.ReportLogService
;
import
com.tanpu.community.service.ThemeService
;
import
com.tanpu.community.util.ConvertUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -24,6 +28,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -49,9 +54,15 @@ public class CommentManager {
@Autowired
private
RedisCache
redisCache
;
@Autowired
private
NotificationService
notificationService
;
@Autowired
private
ThemeService
themeService
;
// 评论(对主题)
// 发表评论(对主题)
public
void
comment
(
CreateCommentReq
req
,
String
userId
)
{
public
CommentQo
comment
(
CreateCommentReq
req
,
String
userId
)
{
if
(
StringUtils
.
isEmpty
(
req
.
getComment
()))
{
throw
new
IllegalArgumentException
(
"评论内容不能为空"
);
...
...
@@ -60,6 +71,7 @@ public class CommentManager {
throw
new
IllegalArgumentException
(
"评论内容不能超过500字"
);
}
LocalDateTime
now
=
LocalDateTime
.
now
();
CommentEntity
commentEntity
=
CommentEntity
.
builder
()
.
themeId
(
req
.
getThemeId
())
.
parentId
(
req
.
getParentId
())
...
...
@@ -67,9 +79,19 @@ public class CommentManager {
.
authorId
(
userId
)
.
content
(
req
.
getComment
())
.
commentType
(
CommentTypeEnum
.
THEME
.
getCode
())
.
createTime
(
now
)
.
updateTime
(
now
)
.
build
();
commentService
.
insertComment
(
commentEntity
);
CommentQo
commentQo
=
ConvertUtil
.
commentEntity2Qo
(
commentEntity
);
buildUserInfo
(
commentQo
);
// 消息通知
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
notificationService
.
insert
(
userId
,
themeEntity
.
getAuthorId
(),
NotificationTypeEnum
.
COMMENT
,
commentEntity
.
getCommentId
(),
req
.
getComment
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
COMMENT
);
return
commentQo
;
}
// 查询评论
...
...
@@ -81,20 +103,9 @@ public class CommentManager {
Set
<
String
>
likeCommentList
=
collectionService
.
getSetByUser
(
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
for
(
CommentQo
commentQo
:
commentQos
)
{
//查询用户信息
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoResp
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FEIGN_USER_INFO
,
authorId
),
60
,
()
->
this
.
getUserInfo
(
authorId
)
,
UserInfoResp
.
class
);
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getHeadImageUrl
());
commentQo
.
setNickName
(
userInfo
.
getNickName
());
commentQo
.
setUserType
(
userInfo
.
getUserType
());
commentQo
.
setLevelGrade
(
userInfo
.
getLevelGrade
());
commentQo
.
setUserInvestorType
(
userInfo
.
getUserInvestorType
());
commentQo
.
setBelongUserOrgId
(
userInfo
.
getBelongUserOrgId
());
commentQo
.
setBelongUserOrgName
(
userInfo
.
getBelongUserOrgName
());
}
//是否点赞及点赞数
// 封装用户信息
buildUserInfo
(
commentQo
);
// 是否点赞及点赞数
String
commentId
=
commentQo
.
getCommentId
();
commentQo
.
setHasLiked
(
likeCommentList
.
contains
(
commentId
));
Integer
countByTypeAndId
=
collectionService
.
getCountByTypeAndId
(
commentId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
...
...
@@ -107,6 +118,24 @@ public class CommentManager {
.
collect
(
Collectors
.
toList
());
}
private
void
buildUserInfo
(
CommentQo
commentQo
)
{
String
authorId
=
commentQo
.
getAuthorId
();
UserInfoResp
userInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FEIGN_USER_INFO
,
authorId
),
60
,
()
->
this
.
getUserInfo
(
authorId
)
,
UserInfoResp
.
class
);
if
(
userInfo
!=
null
)
{
commentQo
.
setUserImg
(
userInfo
.
getHeadImageUrl
());
commentQo
.
setNickName
(
userInfo
.
getNickName
());
commentQo
.
setUserType
(
userInfo
.
getUserType
());
commentQo
.
setLevelGrade
(
userInfo
.
getLevelGrade
());
commentQo
.
setUserInvestorType
(
userInfo
.
getUserInvestorType
());
commentQo
.
setBelongUserOrgId
(
userInfo
.
getBelongUserOrgId
());
commentQo
.
setBelongUserOrgName
(
userInfo
.
getBelongUserOrgName
());
}
commentQo
.
setHasLiked
(
false
);
commentQo
.
setLikeCount
(
0
);
}
private
UserInfoResp
getUserInfo
(
String
authorId
){
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
...
...
@@ -119,6 +148,7 @@ public class CommentManager {
public
void
likeComment
(
LikeCommentReq
req
,
String
userId
)
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
collectionService
.
saveOrUpdate
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
collectionService
.
delete
(
req
.
getCommentId
(),
userId
,
CollectionTypeEnum
.
LIKE_COMMENT
);
}
...
...
@@ -139,5 +169,11 @@ public class CommentManager {
//删除评论
public
void
delete
(
String
commentId
,
String
userId
)
{
commentService
.
delete
(
commentId
,
userId
);
CommentEntity
commentEntity
=
commentService
.
queryByIdIncludeDelete
(
commentId
);
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
commentEntity
.
getThemeId
());
notificationService
.
deleteCommentNotify
(
themeEntity
.
getAuthorId
(),
userId
,
commentId
,
commentEntity
.
getCreateTime
());
}
}
community-service/src/main/java/com/tanpu/community/manager/FileManager.java
View file @
719dbbee
package
com
.
tanpu
.
community
.
manager
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.green.model.v20180509.ImageAsyncScanResultsRequest
;
import
com.aliyuncs.http.FormatType
;
import
com.aliyuncs.http.HttpResponse
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.http.ProtocolType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.resp.FileUploadResp
;
import
com.tanpu.community.api.enums.FileChechStatusEnum
;
import
com.tanpu.community.api.enums.OssDirEnum
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.service.OSSFileService
;
...
...
@@ -10,11 +23,11 @@ import com.tanpu.community.util.ConvertUtil;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -61,4 +74,74 @@ public class FileManager {
.
collect
(
Collectors
.
toMap
(
FileRecordEntity:
:
getFileId
,
FileRecordEntity:
:
getUrl
));
}
public
void
updateCheckResult
(
String
fileKey
,
FileChechStatusEnum
type
,
String
resultLog
)
{
FileRecordEntity
fileRecordEntity
=
ossFileService
.
queryByOssKey
(
fileKey
);
if
(
fileRecordEntity
==
null
)
{
throw
new
BizException
(
"图片未找到:"
+
fileKey
);
}
fileRecordEntity
.
setCheckStatus
(
type
.
getCode
());
fileRecordEntity
.
setCheckResultLog
(
resultLog
);
ossFileService
.
update
(
fileRecordEntity
);
}
// 同步查询,使用taskId,且1/24小时内才能查询
public
JSONArray
queryTask
(
String
taskId
)
throws
Exception
{
// 帐号没有权限,会导致查询结果为空
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-shanghai"
,
ossFileService
.
accessId
,
ossFileService
.
accessSK
);
DefaultProfile
.
addEndpoint
(
"cn-shanghai"
,
"cn-shanghai"
,
"Green"
,
"green.cn-shanghai.aliyuncs.com"
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
ImageAsyncScanResultsRequest
imageAsyncScanResultsRequest
=
new
ImageAsyncScanResultsRequest
();
// 指定API返回格式。
imageAsyncScanResultsRequest
.
setAcceptFormat
(
FormatType
.
JSON
);
// 指定请求方法。
imageAsyncScanResultsRequest
.
setMethod
(
MethodType
.
POST
);
imageAsyncScanResultsRequest
.
setEncoding
(
"utf-8"
);
// 支持HTTP和HTTPS。
imageAsyncScanResultsRequest
.
setProtocol
(
ProtocolType
.
HTTP
);
List
<
String
>
taskIds
=
new
ArrayList
<
String
>();
taskIds
.
add
(
taskId
);
imageAsyncScanResultsRequest
.
setHttpContent
(
JSON
.
toJSONString
(
taskIds
).
getBytes
(
"UTF-8"
),
"UTF-8"
,
FormatType
.
JSON
);
/**
* 请务必设置超时时间。
*/
imageAsyncScanResultsRequest
.
setConnectTimeout
(
3000
);
imageAsyncScanResultsRequest
.
setReadTimeout
(
6000
);
HttpResponse
httpResponse
=
client
.
doAction
(
imageAsyncScanResultsRequest
);
if
(
httpResponse
.
isSuccess
())
{
JSONObject
scrResponse
=
JSON
.
parseObject
(
new
String
(
httpResponse
.
getHttpContent
(),
"UTF-8"
));
System
.
out
.
println
(
JSON
.
toJSONString
(
scrResponse
,
true
));
if
(
200
==
scrResponse
.
getInteger
(
"code"
))
{
JSONArray
taskResults
=
scrResponse
.
getJSONArray
(
"data"
);
for
(
Object
taskResult
:
taskResults
)
{
if
(
200
==
((
JSONObject
)
taskResult
).
getInteger
(
"code"
))
{
JSONArray
sceneResults
=
((
JSONObject
)
taskResult
).
getJSONArray
(
"results"
);
for
(
Object
sceneResult
:
sceneResults
)
{
String
scene
=
((
JSONObject
)
sceneResult
).
getString
(
"scene"
);
String
suggestion
=
((
JSONObject
)
sceneResult
).
getString
(
"suggestion"
);
// 根据scene和suggestion做相关的处理。
// 根据不同的suggestion结果做业务上的不同处理。例如,将违规数据删除等。
}
return
sceneResults
;
}
else
{
throw
new
BizException
(
"task process fail:"
+
((
JSONObject
)
taskResult
).
getInteger
(
"code"
));
}
}
}
else
{
throw
new
BizException
(
"detect not success. code:"
+
scrResponse
.
getInteger
(
"code"
));
}
}
else
{
throw
new
BizException
(
"response not success. status:"
+
httpResponse
.
getStatus
());
}
return
null
;
}
}
community-service/src/main/java/com/tanpu/community/manager/HomePageManager.java
View file @
719dbbee
...
...
@@ -17,7 +17,12 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoNewChief;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoOrg
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO
;
import
com.tanpu.community.api.enums.*
;
import
com.tanpu.community.api.enums.FundCompanyTypeEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.PersonalCenterTypeEnum
;
import
com.tanpu.community.api.enums.QueryFollowTypeEnum
;
import
com.tanpu.community.api.enums.ShowFollowStatusEnum
;
import
com.tanpu.community.cache.RedisCache
;
import
com.tanpu.community.dao.entity.community.FollowRelEntity
;
import
com.tanpu.community.dao.mapper.community.FollowRelMapper
;
...
...
@@ -27,15 +32,24 @@ import com.tanpu.community.feign.fatools.FeignClientForFatools;
import
com.tanpu.community.feign.product.FeignForFund
;
import
com.tanpu.community.feign.product.FeignForPublicFund
;
import
com.tanpu.community.service.FollowRelService
;
import
com.tanpu.community.service.NotificationService
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.PageUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -61,6 +75,9 @@ public class HomePageManager {
@Resource
private
RedisCache
redisCache
;
@Autowired
private
NotificationService
notificationService
;
//查询 个人中心 相关信息
public
UserInfoResp
queryUsersInfo
(
String
userIdMyself
,
String
userId
)
{
CommonResp
<
UserInfoResp
>
queryUsersListNew
=
feignClientForFatools
.
queryUserInfoNew
(
StringUtils
.
isNotBlank
(
userId
)
?
userId
:
userIdMyself
);
...
...
@@ -209,7 +226,7 @@ public class HomePageManager {
List
<
FollowQo
>
collect
=
userInfoNews
.
stream
().
map
(
ConvertUtil:
:
userInfoNew2FollowQo
).
collect
(
Collectors
.
toList
());
followQos
=
judgeFollowed
(
collect
,
userId
);
}
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
return
PageUtils
.
page
(
userIdsPage
,
followQos
);
}
...
...
@@ -227,11 +244,22 @@ public class HomePageManager {
public
void
addFollowRel
(
FollowRelReq
req
,
String
followerId
)
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
);
// 第一次关注才有消息通知
if
(
followRelService
.
addFollowRel
(
req
.
getFollowUserId
(),
followerId
))
{
notificationService
.
insert
(
followerId
,
req
.
getFollowUserId
(),
NotificationTypeEnum
.
FOLLOW
,
req
.
getFollowUserId
(),
null
);
notificationService
.
putNotifyCacheFollow
(
req
.
getFollowUserId
(),
followerId
);
}
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
followRelService
.
deleteFollowRel
(
req
.
getFollowUserId
(),
followerId
);
}
}
private
UserInfoResp
getUserInfo
(
String
authorId
)
{
CommonResp
<
UserInfoResp
>
userInfoNewCommonResp
=
feignClientForFatools
.
queryUserInfoNew
(
authorId
);
if
(
userInfoNewCommonResp
.
isNotSuccess
())
{
throw
new
BizException
(
"内部接口调用失败"
);
}
return
userInfoNewCommonResp
.
getData
();
}
}
community-service/src/main/java/com/tanpu/community/manager/NotificationManager.java
0 → 100644
View file @
719dbbee
This diff is collapsed.
Click to expand it.
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
719dbbee
...
...
@@ -34,6 +34,7 @@ import com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedResReq;
import
com.tanpu.community.api.beans.vo.feign.newsfeed.NewsFeedSave4NewCommReq
;
import
com.tanpu.community.api.enums.BlockTypeEnum
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.api.enums.OperationTypeEnum
;
import
com.tanpu.community.api.enums.ThemeListTypeEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
...
...
@@ -51,6 +52,7 @@ import com.tanpu.community.util.BizUtils;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.RankUtils
;
import
com.tanpu.community.util.TencentcloudUtils
;
import
com.tanpu.community.util.TimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
...
...
@@ -134,6 +136,9 @@ public class ThemeManager {
@Resource
private
RestTemplate
restTemplate
;
@Autowired
private
NotificationService
notificationService
;
@PostConstruct
public
void
init
()
throws
IOException
{
File
f
=
new
File
(
tmpDir
);
...
...
@@ -384,10 +389,10 @@ public class ThemeManager {
if
(
content
.
getProductType
()
==
null
)
{
throw
new
BizException
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"附件产品FUND缺少类型"
);
}
if
(
content
.
getProductType
()
==
ProductTypeEnum
.
CUSTOMER_IMPORT
.
type
)
{
if
(
content
.
getProductType
()
==
ProductTypeEnum
.
CUSTOMER_IMPORT
.
type
)
{
throw
new
BizException
(
ErrorCodeConstant
.
LIMIT_CONTENT
.
getCode
(),
"圈子暂不支持私有基金"
);
}
if
(
content
.
getProductType
()
==
ProductTypeEnum
.
NOT_NET_PRODUCT
.
type
)
{
if
(
content
.
getProductType
()
==
ProductTypeEnum
.
NOT_NET_PRODUCT
.
type
)
{
throw
new
BizException
(
ErrorCodeConstant
.
LIMIT_CONTENT
.
getCode
(),
"圈子暂不支持无净值私有基金"
);
}
}
...
...
@@ -407,6 +412,11 @@ public class ThemeManager {
if
(
StringUtils
.
isBlank
(
req
.
getEditThemeId
())
||
req
.
getEditThemeId
().
equals
(
req
.
getFormerThemeId
()))
{
// 新建
themeService
.
insertTheme
(
themeEntity
);
// 消息通知
ThemeEntity
formerTheme
=
themeService
.
queryByThemeId
(
req
.
getFormerThemeId
());
notificationService
.
insertForward
(
userId
,
formerTheme
.
getAuthorId
(),
formerTheme
.
getThemeId
(),
req
.
getTopicId
(),
req
.
getContent
().
get
(
0
).
getValue
(),
themeEntity
.
getThemeId
());
notificationService
.
putNotifyCache
(
formerTheme
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
FORWARD
);
}
else
{
// 修改
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
...
...
@@ -657,7 +667,13 @@ public class ThemeManager {
// 点赞/取消点赞
public
void
like
(
LikeThemeReq
req
,
String
userId
)
{
if
(
OperationTypeEnum
.
CONFIRM
.
getCode
().
equals
(
req
.
getType
()))
{
collectionService
.
saveOrUpdate
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
if
(
collectionService
.
saveOrUpdate
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
))
{
ThemeEntity
themeEntity
=
themeService
.
queryByThemeId
(
req
.
getThemeId
());
// 消息通知
notificationService
.
insertLike
(
userId
,
themeEntity
.
getAuthorId
(),
req
.
getThemeId
());
notificationService
.
putNotifyCache
(
themeEntity
.
getAuthorId
(),
userId
,
NotificationTypeEnum
.
LIKE
);
}
}
else
if
(
OperationTypeEnum
.
CANCEL
.
getCode
().
equals
(
req
.
getType
()))
{
collectionService
.
delete
(
req
.
getThemeId
(),
userId
,
CollectionTypeEnum
.
LIKE_THEME
);
}
...
...
@@ -866,6 +882,7 @@ public class ThemeManager {
.
commentId
(
commentEntity
.
getCommentId
())
.
themeType
(
ThemeTypeEnum
.
RES_COMMENT
.
getCode
())
.
follow
(
followRelService
.
checkFollow
(
userId
,
userId
))
.
upToNowTime
(
TimeUtils
.
calUpToNowTime
(
commentEntity
.
getCreateTime
()))
.
build
();
//原主题包装到formerThemeQo中
...
...
@@ -909,5 +926,4 @@ public class ThemeManager {
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
CACHE_THEME_ID
,
themeId
));
}
}
community-service/src/main/java/com/tanpu/community/service/BatchFeignCallService.java
View file @
719dbbee
...
...
@@ -18,6 +18,7 @@ import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import
com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp
;
import
com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp
;
import
com.tanpu.community.api.enums.FileChechStatusEnum
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.feign.course.FeignClientForCourse
;
...
...
@@ -75,7 +76,6 @@ public class BatchFeignCallService {
private
TopicService
topicService
;
public
void
getAttachDetail
(
ThemeQo
themeQo
)
{
ArrayList
<
ThemeQo
>
themeQos
=
new
ArrayList
<>();
themeQos
.
add
(
themeQo
);
...
...
@@ -181,7 +181,10 @@ public class BatchFeignCallService {
curriculumIds
.
add
(
c
.
getValue
());
}
else
if
(
c
.
getType
().
equals
(
RelTypeEnum
.
SINGLE_IMG
.
type
))
{
imageIds
.
add
(
c
.
getValue
());
}
else
if
(
c
.
getType
().
equals
(
RelTypeEnum
.
NEW_COURSE_SECTION_AUDIO
.
type
)
||
}
else
if
(
c
.
getType
().
equals
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
))
{
c
.
getImgList
().
forEach
(
img
->
imageIds
.
add
(
img
.
getRelId
()));
}
else
if
(
c
.
getType
().
equals
(
RelTypeEnum
.
NEW_COURSE_SECTION_AUDIO
.
type
)
||
c
.
getType
().
equals
(
RelTypeEnum
.
NEW_COURSE_SECTION_VIDEO
.
type
))
{
courseIds
.
add
(
c
.
getValue
());
}
...
...
@@ -192,7 +195,7 @@ public class BatchFeignCallService {
if
(!
CollectionUtils
.
isEmpty
(
shortVideoIds
))
{
// 短视频列表
List
<
ShortVideoBaseInfoResp
>
list
=
feignService
.
batchGetShortVideoBaseInfo
(
setToList
(
shortVideoIds
));
shortVideoMap
.
putAll
(
list
.
stream
().
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getSourceId
,
item
->
item
,
(
oldValue
,
newValue
)->
oldValue
)));
shortVideoMap
.
putAll
(
list
.
stream
().
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getSourceId
,
item
->
item
,
(
oldValue
,
newValue
)
->
oldValue
)));
}
if
(!
CollectionUtils
.
isEmpty
(
curriculumIds
))
{
// 课程列表
...
...
@@ -200,19 +203,19 @@ public class BatchFeignCallService {
feignClientForFatools
.
getCurriculumByColumnRelId
(
setToList
(
curriculumIds
));
if
(
commonResp
!=
null
&&
!
CollectionUtils
.
isEmpty
(
commonResp
))
{
curriculumMap
.
putAll
(
commonResp
.
stream
()
.
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getColumnRelId
,
item
->
item
,
(
oldValue
,
newValue
)->
oldValue
)));
.
collect
(
Collectors
.
toMap
(
ShortVideoBaseInfoResp:
:
getColumnRelId
,
item
->
item
,
(
oldValue
,
newValue
)
->
oldValue
)));
}
}
if
(!
CollectionUtils
.
isEmpty
(
courseIds
))
{
// 新版课程列表
List
<
CourseSimpleResp
>
list
=
feignService
.
getCourseSimpleList
(
setToList
(
courseIds
));
courseMap
.
putAll
(
list
.
stream
().
collect
(
Collectors
.
toMap
(
CourseSimpleResp:
:
getCourseId
,
item
->
item
,
(
oldValue
,
newValue
)->
oldValue
)));
courseMap
.
putAll
(
list
.
stream
().
collect
(
Collectors
.
toMap
(
CourseSimpleResp:
:
getCourseId
,
item
->
item
,
(
oldValue
,
newValue
)
->
oldValue
)));
}
if
(!
CollectionUtils
.
isEmpty
(
zhiboIds
))
{
// 直播列表
List
<
ZhiboListResp
>
list
=
feignService
.
getZhiboSimpleList
(
setToList
(
zhiboIds
));
feignClientForZhibo
.
simpleList
(
setToList
(
zhiboIds
));
zhiboMap
.
putAll
(
list
.
stream
().
collect
(
Collectors
.
toMap
(
ZhiboListResp:
:
getId
,
item
->
item
,
(
oldValue
,
newValue
)->
oldValue
)));
feignClientForZhibo
.
simpleList
(
setToList
(
zhiboIds
));
zhiboMap
.
putAll
(
list
.
stream
().
collect
(
Collectors
.
toMap
(
ZhiboListResp:
:
getId
,
item
->
item
,
(
oldValue
,
newValue
)
->
oldValue
)));
}
if
(!
CollectionUtils
.
isEmpty
(
imageIds
))
{
// 查询图片
...
...
@@ -428,7 +431,7 @@ public class BatchFeignCallService {
//单图封装到imglist列表中
if
(
imgUrlMap
.
containsKey
(
themeContent
.
getValue
()))
{
FileRecordEntity
imgEntity
=
imgUrlMap
.
get
(
themeContent
.
getValue
());
if
(
imgEntity
!=
null
&&
!
StringUtils
.
isEmpty
(
imgEntity
.
getExtInfo
()))
{
if
(
imgEntity
!=
null
&&
!
StringUtils
.
isEmpty
(
imgEntity
.
getExtInfo
()))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
imgEntity
.
getExtInfo
());
ImagesDTO
imagesDTO
=
ImagesDTO
.
builder
().
imgHeight
((
Integer
)
extMap
.
get
(
"height"
))
.
imgWidth
((
Integer
)
extMap
.
get
(
"width"
))
...
...
@@ -437,6 +440,13 @@ public class BatchFeignCallService {
//压缩图片
.
resizeUrl
(
imgEntity
.
getUrl
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
)
.
build
();
// 图片审核屏蔽
if
(
FileChechStatusEnum
.
BLOCK
.
getCode
().
equals
(
imgEntity
.
getCheckStatus
())){
imagesDTO
.
setRemark
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT
);
imagesDTO
.
setResizeUrl
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
imagesDTO
.
setImgWidth
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT_WIDTH
);
imagesDTO
.
setImgHeight
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT_HEIGHT
);
}
themeContent
.
setImgList
(
Collections
.
singletonList
(
imagesDTO
));
}
}
...
...
@@ -444,15 +454,24 @@ public class BatchFeignCallService {
//多图写入图片宽高,压缩图片url
List
<
ImagesDTO
>
imgList
=
themeContent
.
getImgList
();
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
//压缩图片地址
imagesDTO
.
setResizeUrl
(
imagesDTO
.
getRemark
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
if
(
imgUrlMap
.
containsKey
(
imagesDTO
.
getRelId
()))
{
FileRecordEntity
imgEntity
=
imgUrlMap
.
get
(
imagesDTO
.
getRelId
());
String
extInfo
=
imgEntity
.
getExtInfo
();
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
imagesDTO
.
setImgHeight
((
Integer
)
extMap
.
get
(
"height"
));
imagesDTO
.
setImgWidth
((
Integer
)
extMap
.
get
(
"width"
));
// 图片审核不通过,替换为默认图片 todo 配置移除
if
(
FileChechStatusEnum
.
BLOCK
.
getCode
().
equals
(
imgEntity
.
getCheckStatus
())){
imagesDTO
.
setRemark
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT
);
imagesDTO
.
setResizeUrl
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
imagesDTO
.
setImgWidth
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT_WIDTH
);
imagesDTO
.
setImgHeight
(
CommunityConstant
.
OSS_CHECK_FAIL_DEFAULT_HEIGHT
);
}
else
{
imagesDTO
.
setRemark
(
imgEntity
.
getUrl
());
imagesDTO
.
setResizeUrl
(
imgEntity
.
getUrl
()
+
CommunityConstant
.
OSS_RESIZE_RATIO
);
String
extInfo
=
imgEntity
.
getExtInfo
();
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
imagesDTO
.
setImgHeight
((
Integer
)
extMap
.
get
(
"height"
));
imagesDTO
.
setImgWidth
((
Integer
)
extMap
.
get
(
"width"
));
}
}
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/CollectionService.java
View file @
719dbbee
...
...
@@ -29,7 +29,7 @@ public class CollectionService {
// 若不存在则新增,若存在则修改deleteTag
@Transactional
public
void
saveOrUpdate
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
)
{
public
boolean
saveOrUpdate
(
String
themeId
,
String
userId
,
CollectionTypeEnum
type
)
{
// 判断记录是否存在,无论是否删除
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
...
...
@@ -40,6 +40,7 @@ public class CollectionService {
queryCollection
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
queryCollection
.
setCollectionTime
(
LocalDateTime
.
now
());
collectionMapper
.
updateById
(
queryCollection
);
return
false
;
}
else
{
CollectionEntity
entity
=
CollectionEntity
.
builder
()
.
collectionType
(
type
.
getCode
())
...
...
@@ -49,6 +50,7 @@ public class CollectionService {
.
build
();
collectionMapper
.
insert
(
entity
);
return
true
;
}
}
...
...
@@ -74,7 +76,7 @@ public class CollectionService {
//根据用户、主题、类型查询未删除对象
public
Set
<
String
>
getTargets
(
List
<
String
>
targetIds
,
String
userId
,
CollectionTypeEnum
type
)
{
if
(
CollectionUtils
.
isEmpty
(
targetIds
)){
if
(
CollectionUtils
.
isEmpty
(
targetIds
))
{
return
new
HashSet
<>();
}
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
...
...
@@ -107,7 +109,7 @@ public class CollectionService {
}
// 根据用户id和行为type获取target_id列表
public
List
<
String
>
getListByUser
(
String
userId
,
CollectionTypeEnum
type
,
String
lastId
,
Integer
pageSize
)
{
public
List
<
String
>
getListByUser
(
String
userId
,
CollectionTypeEnum
type
,
String
lastId
,
Integer
pageSize
)
{
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getUserId
,
userId
)
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
...
...
@@ -143,7 +145,7 @@ public class CollectionService {
}
LambdaQueryWrapper
<
CollectionEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
type
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
in
(
CollectionEntity:
:
getTargetId
,
targetIds
).
groupBy
(
CollectionEntity:
:
getTargetId
);
return
collectionMapper
.
selectCountByTargetIds
(
queryWrapper
).
stream
()
.
collect
(
Collectors
.
toMap
(
TimesCountEntity:
:
getId
,
TimesCountEntity:
:
getTimes
));
...
...
@@ -171,4 +173,12 @@ public class CollectionService {
return
;
}
}
public
List
<
CollectionEntity
>
queryALlLikeTheme
()
{
return
collectionMapper
.
selectList
(
new
LambdaQueryWrapper
<
CollectionEntity
>()
.
eq
(
CollectionEntity:
:
getCollectionType
,
CollectionTypeEnum
.
LIKE_THEME
.
getCode
())
.
eq
(
CollectionEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
CollectionEntity:
:
getCreateTime
));
}
}
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
719dbbee
...
...
@@ -154,4 +154,13 @@ public class CommentService {
redisCache
.
evict
(
StringUtils
.
joinWith
(
"_"
,
THEME_COMMENT_COUNT
,
themeId
));
}
public
List
<
CommentEntity
>
queryAll
()
{
return
commentMapper
.
selectList
(
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
CommentEntity:
:
getCreateTime
));
}
public
CommentEntity
queryByCommentId
(
String
commentId
)
{
return
commentMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CommentEntity
>().
eq
(
CommentEntity:
:
getCommentId
,
commentId
));
}
}
community-service/src/main/java/com/tanpu/community/service/FollowRelService.java
View file @
719dbbee
...
...
@@ -77,7 +77,7 @@ public class FollowRelService {
}
@Transactional
public
void
addFollowRel
(
String
idolId
,
String
followerId
)
{
public
boolean
addFollowRel
(
String
idolId
,
String
followerId
)
{
FollowRelEntity
searchResult
=
queryRecord
(
idolId
,
followerId
);
if
(
searchResult
==
null
)
{
FollowRelEntity
entity
=
FollowRelEntity
.
builder
()
...
...
@@ -87,10 +87,12 @@ public class FollowRelService {
.
build
();
followRelMapper
.
insert
(
entity
);
return
true
;
}
else
{
searchResult
.
setFollowTime
(
LocalDateTime
.
now
());
searchResult
.
setDeleteTag
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
());
followRelMapper
.
updateById
(
searchResult
);
return
false
;
}
}
...
...
@@ -127,4 +129,10 @@ public class FollowRelService {
}
public
List
<
FollowRelEntity
>
queryAll
()
{
// todo 会丢失关注后 取消关注的情况,怎么选择?
return
followRelMapper
.
selectList
(
new
LambdaQueryWrapper
<
FollowRelEntity
>()
.
eq
(
FollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
FollowRelEntity:
:
getUpdateTime
));
}
}
community-service/src/main/java/com/tanpu/community/service/NotificationService.java
0 → 100644
View file @
719dbbee
This diff is collapsed.
Click to expand it.
community-service/src/main/java/com/tanpu/community/service/OSSFileService.java
View file @
719dbbee
...
...
@@ -2,7 +2,6 @@ package com.tanpu.community.service;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.common.constant.BizStatus
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.AliyunOSSHelper
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.uuid.UuidGenHelper
;
...
...
@@ -22,6 +21,7 @@ import javax.annotation.Resource;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -80,7 +80,8 @@ public class OSSFileService {
record
.
setFileId
(
id
);
record
.
setPreviewUrl
(
ossHelper
.
getPreSignedUrl
(
bucketName
,
key
));
record
.
setFileType
(
FileTypeEnum
.
IMAGE
.
getCode
());
HashMap
<
String
,
Integer
>
attr
=
getStringIntegerHashMap
(
data
);
// todo 上传非文件类型
HashMap
<
String
,
Integer
>
attr
=
getStringIntegerHashMap
(
data
,
"webp"
.
equals
(
suffix
));
record
.
setExtInfo
(
JsonUtil
.
toJson
(
attr
));
fileRecordMapper
.
insert
(
record
);
...
...
@@ -96,7 +97,9 @@ public class OSSFileService {
ossHelper
.
writeFile
(
bucketName
,
key
,
data
,
fileSuffix
);
}
private
HashMap
<
String
,
Integer
>
getStringIntegerHashMap
(
byte
[]
data
)
{
private
HashMap
<
String
,
Integer
>
getStringIntegerHashMap
(
byte
[]
data
,
boolean
isWebp
)
{
ByteArrayInputStream
bins
=
new
ByteArrayInputStream
(
data
);
BufferedImage
bi
=
null
;
try
{
...
...
@@ -105,18 +108,39 @@ public class OSSFileService {
e
.
printStackTrace
();
}
HashMap
<
String
,
Integer
>
attr
=
new
HashMap
<>();
attr
.
put
(
"width"
,
bi
.
getWidth
());
attr
.
put
(
"height"
,
bi
.
getHeight
());
if
(
bi
!=
null
)
{
attr
.
put
(
"width"
,
bi
.
getWidth
());
attr
.
put
(
"height"
,
bi
.
getHeight
());
}
if
(
isWebp
)
{
// webp格式图片读取宽高
byte
[]
bytes
=
Arrays
.
copyOf
(
data
,
30
);
int
width
=
((
int
)
bytes
[
27
]
&
0xff
)
<<
8
|
((
int
)
bytes
[
26
]
&
0xff
);
int
height
=
((
int
)
bytes
[
29
]
&
0xff
)
<<
8
|
((
int
)
bytes
[
28
]
&
0xff
);
attr
.
put
(
"width"
,
width
);
attr
.
put
(
"height"
,
height
);
}
return
attr
;
}
public
FileRecordEntity
queryById
(
String
fileId
)
{
return
fileRecordMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FileRecordEntity
>()
.
eq
(
FileRecordEntity:
:
getFileId
,
fileId
));
.
eq
(
FileRecordEntity:
:
getFileId
,
fileId
));
}
public
List
<
FileRecordEntity
>
queryByIds
(
List
<
String
>
fileIds
)
{
return
fileRecordMapper
.
selectList
(
new
LambdaQueryWrapper
<
FileRecordEntity
>()
.
in
(
FileRecordEntity:
:
getFileId
,
fileIds
));
.
in
(
FileRecordEntity:
:
getFileId
,
fileIds
));
}
public
FileRecordEntity
queryByOssKey
(
String
fileKey
)
{
return
fileRecordMapper
.
selectOne
(
new
LambdaQueryWrapper
<
FileRecordEntity
>().
eq
(
FileRecordEntity:
:
getFileOssKey
,
fileKey
));
}
public
void
update
(
FileRecordEntity
fileRecordEntity
)
{
fileRecordMapper
.
updateById
(
fileRecordEntity
);
}
}
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
719dbbee
...
...
@@ -37,8 +37,8 @@ public class RankService {
public
Double
forwardRate
;
@Value
(
"${rank.theme.commentRate:2}"
)
public
Double
commentRate
;
@Value
(
"${rank.theme.likeRate
n
:3}"
)
public
Double
likeRate
n
;
@Value
(
"${rank.theme.likeRate:3}"
)
public
Double
likeRate
;
@Value
(
"${rank.theme.collectRate:3}"
)
public
Double
collectRate
;
//用户质量权重
...
...
@@ -187,8 +187,6 @@ public class RankService {
}
// 排序
List
<
TopicRankQo
>
rankList
=
topicRankQos
.
stream
()
.
sorted
(
Comparator
.
comparing
(
TopicRankQo:
:
getScore
).
reversed
())
...
...
@@ -200,10 +198,10 @@ public class RankService {
this
.
rankTopicList
=
rankList
;
// 首页推荐话题
// 记录排序前
最新的2个话题
//
最新的2个话题
List
<
TopicRankQo
>
newest2Topic
=
topicRankQos
.
stream
().
filter
(
TopicRankQo:
:
judgeNewTopic
)
.
sorted
(
Comparator
.
comparing
(
TopicRankQo:
:
getMinutesTillNow
)).
limit
(
2
).
collect
(
Collectors
.
toList
());
// 最熱的2个话题
List
<
TopicRankQo
>
top4Topic
=
rankList
.
stream
()
.
limit
(
6
)
.
filter
(
o
->
!
newest2Topic
.
contains
(
o
))
...
...
@@ -280,7 +278,7 @@ public class RankService {
double
w
=
theme
.
getViewCount
()
*
viewRate
+
theme
.
getForwardCount
()
*
forwardRate
+
theme
.
getCommentCount
()
*
commentRate
+
theme
.
getLikeCount
()
*
likeRate
n
+
theme
.
getLikeCount
()
*
likeRate
+
theme
.
getCollectCount
()
*
collectRate
+
Math
.
pow
(
theme
.
getUserWeight
(),
userWeightRate
);
double
score
=
(
w
+
initialWeight
)
/
Math
.
pow
(
theme
.
getMinutesTillNow
()
+
1
,
timeRate
);
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
719dbbee
...
...
@@ -7,6 +7,7 @@ import com.tanpu.common.exception.BizException;
import
com.tanpu.common.redis.RedisHelper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.ThemeTypeEnum
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TimesCountEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
...
...
@@ -268,4 +269,10 @@ public class ThemeService {
.
collect
(
Collectors
.
toMap
(
TimesCountEntity:
:
getId
,
TimesCountEntity:
:
getTimes
));
}
public
List
<
ThemeEntity
>
queryAllForward
()
{
return
themeMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getThemeType
,
ThemeTypeEnum
.
FORWARD
.
getCode
())
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
orderByAsc
(
ThemeEntity:
:
getCreateTime
));
}
}
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
719dbbee
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.tanpu.common.uuid.UuidGenHelper
;
import
com.tanpu.community.api.enums.StatusEnum
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
...
...
@@ -44,36 +43,6 @@ public class TopicService {
public
void
updateTopicToTop
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsTop
(
StatusEnum
.
TRUE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
void
updateTopicNotTop
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsTop
(
StatusEnum
.
FALSE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
void
updateTopicToConceal
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsConceal
(
StatusEnum
.
TRUE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
void
updateTopicNotConceal
(
String
topicId
)
{
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setIsConceal
(
StatusEnum
.
FALSE
.
getCode
());
topicMapper
.
update
(
topicEntity
,
new
LambdaUpdateWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getId
,
topicId
));
}
public
TopicEntity
queryById
(
String
topicId
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getTopicId
,
topicId
)
...
...
@@ -81,6 +50,13 @@ public class TopicService {
.
eq
(
TopicEntity:
:
getDeleteTag
,
StatusEnum
.
FALSE
));
}
// 根据话题id查询title,(包括已删除)
public
String
queryTitleById
(
String
topicId
)
{
TopicEntity
topicEntity
=
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getTopicId
,
topicId
));
return
topicEntity
!=
null
?
topicEntity
.
getTopicTitle
():
null
;
}
public
List
<
TopicEntity
>
queryByIds
(
List
<
String
>
topicIds
)
{
if
(
CollectionUtils
.
isEmpty
(
topicIds
))
{
return
Collections
.
emptyList
();
...
...
@@ -88,7 +64,4 @@ public class TopicService {
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>().
in
(
TopicEntity:
:
getTopicId
,
topicIds
));
}
public
TopicEntity
queryByTitile
(
String
topicTitle
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>().
eq
(
TopicEntity:
:
getTopicTitle
,
topicTitle
));
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
719dbbee
...
...
@@ -3,15 +3,9 @@ package com.tanpu.community.util;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.tanpu.biz.common.enums.RelTypeEnum
;
import
com.tanpu.biz.common.enums.community.TopicStatusEnum
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.beans.qo.CommentQo
;
import
com.tanpu.community.api.beans.qo.ESThemeQo
;
import
com.tanpu.community.api.beans.qo.FollowQo
;
import
com.tanpu.community.api.beans.qo.FormerThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeAnalysDO
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.qo.TopicRankQo
;
import
com.tanpu.community.api.beans.qo.*
;
import
com.tanpu.community.api.beans.req.theme.CreateThemeReq
;
import
com.tanpu.community.api.beans.req.theme.ThemeContentReq
;
import
com.tanpu.community.api.beans.resp.FileUploadResp
;
...
...
@@ -19,8 +13,12 @@ import com.tanpu.community.api.beans.vo.ImagesDTO;
import
com.tanpu.community.api.beans.vo.KafkaDurationUptMsg
;
import
com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.api.enums.NotificationTypeEnum
;
import
com.tanpu.community.dao.entity.NotificationLikeDO
;
import
com.tanpu.community.dao.entity.NotificationForwardDO
;
import
com.tanpu.community.dao.entity.community.CommentEntity
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.dao.entity.community.NotificationEntity
;
import
com.tanpu.community.dao.entity.community.ThemeAttachmentEntity
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
...
...
@@ -34,6 +32,7 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeSet
;
import
java.util.stream.Collectors
;
public
class
ConvertUtil
{
...
...
@@ -237,5 +236,76 @@ public class ConvertUtil {
return
resp
;
}
public
static
ThemeNotifyQo
notificationEntitiy2ThemeQo
(
NotificationEntity
entity
)
{
ThemeNotifyQo
themeNotifyQo
=
new
ThemeNotifyQo
();
BeanUtils
.
copyProperties
(
entity
,
themeNotifyQo
);
// 操作者
themeNotifyQo
.
setAuthorId
(
entity
.
getOperatorId
());
themeNotifyQo
.
setUpToNowTime
(
TimeUtils
.
calUpToNowTime
(
entity
.
getUpdateTime
()));
themeNotifyQo
.
setFormatTime
(
TimeUtils
.
format
(
entity
.
getUpdateTime
()));
// 转、评、赞 有原贴
if
(
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
FORWARD
.
getCode
())
||
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
LIKE
.
getCode
())
||
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
COMMENT
.
getCode
())
)
{
themeNotifyQo
.
setFormerThemeId
(
entity
.
getTargetId
());
}
// 转发有话题信息
if
(
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
FORWARD
.
getCode
()))
{
themeNotifyQo
.
setFormerThemeId
(
entity
.
getTargetId
());
themeNotifyQo
.
setFormerUserName
(
entity
.
getNotifiedUserId
());
if
(!
StringUtils
.
isEmpty
(
entity
.
getContent
()))
{
try
{
NotificationForwardDO
forwardDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationForwardDO
.
class
);
themeNotifyQo
.
setContent
(
forwardDO
.
getContent
());
themeNotifyQo
.
setTopicId
(
forwardDO
.
getTopicId
());
themeNotifyQo
.
setForwardThemeId
(
forwardDO
.
getThemeId
());
}
catch
(
Exception
e
){
throw
new
BizException
(
"消息通知-转发类型-反序列化异常:"
+
entity
.
getContent
());
}
}
}
// 点赞需要聚合头像和人数
if
(
entity
.
getMessageType
().
equals
(
NotificationTypeEnum
.
LIKE
.
getCode
()))
{
if
(!
StringUtils
.
isEmpty
(
entity
.
getContent
()))
{
try
{
NotificationLikeDO
notificationLikeDO
=
JsonUtil
.
toBean
(
entity
.
getContent
(),
NotificationLikeDO
.
class
);
themeNotifyQo
.
setLikeUserCount
(
notificationLikeDO
.
getCount
());
ArrayList
<
UserBriefInfoQO
>
likeUsers
=
new
ArrayList
<>();
notificationLikeDO
.
getSet
().
stream
().
forEach
(
o
->
likeUsers
.
add
(
UserBriefInfoQO
.
builder
().
userId
(
o
).
build
()));
themeNotifyQo
.
setLikeUsers
(
likeUsers
);
}
catch
(
Exception
e
){
throw
new
BizException
(
"消息通知-点赞类型-反序列化异常:"
+
entity
.
getContent
());
}
}
}
return
themeNotifyQo
;
}
public
static
List
<
ThemeNotifyQo
>
notificationEntitiy2ThemeQos
(
List
<
NotificationEntity
>
entities
)
{
return
entities
.
stream
().
map
(
ConvertUtil:
:
notificationEntitiy2ThemeQo
).
collect
(
Collectors
.
toList
());
}
public
static
void
main
(
String
[]
args
)
{
NotificationLikeDO
notificationLikeDO
=
new
NotificationLikeDO
();
notificationLikeDO
.
setCount
(
1
);
TreeSet
<
String
>
set
=
new
TreeSet
<>();
set
.
add
(
"aaa"
);
set
.
add
(
"bbb"
);
set
.
add
(
"ccc"
);
set
.
pollFirst
();
set
.
add
(
"ddd"
);
notificationLikeDO
.
setSet
(
set
);
String
x
=
JsonUtil
.
toJson
(
notificationLikeDO
);
System
.
out
.
println
(
x
);
NotificationLikeDO
notificationLikeDO1
=
JsonUtil
.
toBean
(
x
,
NotificationLikeDO
.
class
);
System
.
out
.
println
(
notificationLikeDO1
);
}
}
community-service/src/main/java/com/tanpu/community/util/TimeUtils.java
View file @
719dbbee
...
...
@@ -42,6 +42,11 @@ public class TimeUtils {
return
start
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
}
public
static
LocalDateTime
reFormat
(
String
time
)
{
return
LocalDateTime
.
parse
(
time
,
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm"
));
}
//计算迄今分钟
public
static
long
calMinuteTillNow
(
LocalDateTime
start
)
{
if
(
start
==
null
){
...
...
@@ -93,4 +98,11 @@ public class TimeUtils {
System
.
out
.
println
(
calUpToNowTime
(
LocalDateTime
.
now
().
minusSeconds
(
12
)));
}
public
static
boolean
lessThan
(
String
cacheTime
,
LocalDateTime
updateTime
)
{
return
calMillisTillNow
(
reFormat
(
cacheTime
))
>
calMillisTillNow
(
updateTime
);
}
public
static
boolean
lessThan
(
LocalDateTime
before
,
LocalDateTime
after
)
{
return
calMillisTillNow
(
before
)
>
calMillisTillNow
(
after
);
}
}
community-service/src/main/resources/application-dev.yml
View file @
719dbbee
apollo.bootstrap.enabled
:
false
#app.id: tanpu-community
springfox
:
documentation
:
swagger
:
v2
:
path
:
/api-docs
#apollo:
# meta: http://dev-apollo.tamp-innner.com:8080
# cacheDir: ./apollocache/
...
...
community-service/src/main/resources/mapper/community/FileRecordEntityMapper.xml
View file @
719dbbee
...
...
@@ -14,6 +14,8 @@
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"delete_tag"
property=
"deleteTag"
/>
<result
column=
"ext_info"
property=
"extInfo"
/>
<result
column=
"check_status"
property=
"checkStatus"
/>
<result
column=
"check_result_log"
property=
"checkResultLog"
/>
</resultMap>
</mapper>
community-service/src/main/resources/mapper/community/NotificationEntityMapper.xml
0 → 100644
View file @
719dbbee
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.tanpu.community.dao.mapper.community.NotificationMapper"
>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"com.tanpu.community.dao.entity.community.NotificationEntity"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"notification_id"
property=
"notificationId"
/>
<result
column=
"notified_user_id"
property=
"notifiedUserId"
/>
<result
column=
"message_type"
property=
"messageType"
/>
<result
column=
"target_id"
property=
"targetId"
/>
<result
column=
"content"
property=
"content"
/>
<result
column=
"operator_id"
property=
"operatorId"
/>
<result
column=
"create_time"
property=
"createTime"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"delete_tag"
property=
"deleteTag"
/>
</resultMap>
</mapper>
docs/v2.sql
0 → 100644
View file @
719dbbee
use
tamp_community
;
ALTER
TABLE
tamp_community
.
file_record
ADD
`check_status`
int
(
3
)
NOT
NULL
DEFAULT
'0'
COMMENT
'审核状态 0:初试化 1:通过 2:不通过 3:需要人工再审'
;
ALTER
TABLE
tamp_community
.
file_record
ADD
`check_result_log`
varchar
(
500
)
NOT
NULL
DEFAULT
''
COMMENT
'审核结果记录'
;
CREATE
TABLE
`notification`
(
`id`
bigint
(
32
)
NOT
NULL
COMMENT
'id'
,
`notification_id`
varchar
(
64
)
NOT
NULL
DEFAULT
''
COMMENT
'通知主键Id'
,
`notified_user_id`
varchar
(
64
)
NOT
NULL
DEFAULT
''
COMMENT
'被通知的用户id'
,
`message_type`
varchar
(
64
)
NOT
NULL
DEFAULT
''
COMMENT
'1:转发 2:点赞 3:评论 4:关注'
,
`target_id`
varchar
(
64
)
NOT
NULL
DEFAULT
''
COMMENT
'目标id,类型是转发、点赞、评论时为themeId,关注则为user_id'
,
`content`
varchar
(
600
)
NOT
NULL
DEFAULT
''
COMMENT
'评论:评论内容 转发:topicId+内容 点赞:人数+最近3个用户'
,
`operator_id`
varchar
(
64
)
NOT
NULL
DEFAULT
''
COMMENT
'操作者id'
,
`create_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`update_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`delete_tag`
int
(
3
)
NOT
NULL
DEFAULT
'0'
,
PRIMARY
KEY
(
`id`
),
KEY
`idx_user_type_time`
(
`notified_user_id`
,
`update_time`
,
`message_type`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COMMENT
=
'消息通知记录'
\ No newline at end of file
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