Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
b611c2b4
S
SpringBoot-kwan
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
SpringBoot-kwan
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringBoot-kwan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b611c2b4
编写于
10月 26, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:整理
上级
a21c9d2b
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
424 addition
and
162 deletion
+424
-162
src/main/java/com/kwan/springbootkwan/controller/CsdnController.java
...va/com/kwan/springbootkwan/controller/CsdnController.java
+4
-19
src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java
...ringbootkwan/controller/CsdnTripletDayInfoController.java
+28
-0
src/main/java/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java
...va/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java
+36
-0
src/main/java/com/kwan/springbootkwan/enums/CommentStatus.java
...ain/java/com/kwan/springbootkwan/enums/CommentStatus.java
+1
-1
src/main/java/com/kwan/springbootkwan/mapper/CsdnTripletDayInfoMapper.java
.../kwan/springbootkwan/mapper/CsdnTripletDayInfoMapper.java
+15
-0
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
...n/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
+16
-23
src/main/java/com/kwan/springbootkwan/service/CsdnArticleService.java
...a/com/kwan/springbootkwan/service/CsdnArticleService.java
+1
-1
src/main/java/com/kwan/springbootkwan/service/CsdnAutoReplyService.java
...com/kwan/springbootkwan/service/CsdnAutoReplyService.java
+18
-0
src/main/java/com/kwan/springbootkwan/service/CsdnCollectService.java
...a/com/kwan/springbootkwan/service/CsdnCollectService.java
+2
-1
src/main/java/com/kwan/springbootkwan/service/CsdnCommentService.java
...a/com/kwan/springbootkwan/service/CsdnCommentService.java
+8
-4
src/main/java/com/kwan/springbootkwan/service/CsdnLikeService.java
...java/com/kwan/springbootkwan/service/CsdnLikeService.java
+2
-1
src/main/java/com/kwan/springbootkwan/service/CsdnTripletDayInfoService.java
...wan/springbootkwan/service/CsdnTripletDayInfoService.java
+21
-0
src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java
.../com/kwan/springbootkwan/service/CsdnUserInfoService.java
+3
-0
src/main/java/com/kwan/springbootkwan/service/impl/CsdnAutoReplyServiceImpl.java
...springbootkwan/service/impl/CsdnAutoReplyServiceImpl.java
+126
-0
src/main/java/com/kwan/springbootkwan/service/impl/CsdnCollectServiceImpl.java
...n/springbootkwan/service/impl/CsdnCollectServiceImpl.java
+3
-1
src/main/java/com/kwan/springbootkwan/service/impl/CsdnCommentServiceImpl.java
...n/springbootkwan/service/impl/CsdnCommentServiceImpl.java
+5
-69
src/main/java/com/kwan/springbootkwan/service/impl/CsdnLikeServiceImpl.java
...kwan/springbootkwan/service/impl/CsdnLikeServiceImpl.java
+3
-1
src/main/java/com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
...com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
+44
-41
src/main/java/com/kwan/springbootkwan/service/impl/CsdnTripletDayInfoServiceImpl.java
...gbootkwan/service/impl/CsdnTripletDayInfoServiceImpl.java
+43
-0
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
.../springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
+45
-0
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/CsdnController.java
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.controller
;
package
com.kwan.springbootkwan.controller
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.enums.CollectStatus
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.LikeStatus
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -17,7 +13,6 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -17,7 +13,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
@Slf4j
@Slf4j
...
@@ -28,7 +23,7 @@ public class CsdnController {
...
@@ -28,7 +23,7 @@ public class CsdnController {
@Autowired
@Autowired
private
CsdnService
csdnService
;
private
CsdnService
csdnService
;
@Autowired
@Autowired
private
Csdn
CommentService
csdnComment
Service
;
private
Csdn
AutoReplyService
csdnAutoReply
Service
;
@Autowired
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
private
CsdnUserInfoService
csdnUserInfoService
;
...
@@ -52,23 +47,13 @@ public class CsdnController {
...
@@ -52,23 +47,13 @@ public class CsdnController {
@GetMapping
(
"/autoReply"
)
@GetMapping
(
"/autoReply"
)
public
Result
autoReply
()
{
public
Result
autoReply
()
{
csdn
Comment
Service
.
commentSelf
();
csdn
AutoReply
Service
.
commentSelf
();
return
Result
.
ok
(
"自动回复完成"
);
return
Result
.
ok
(
"自动回复完成"
);
}
}
@GetMapping
(
"/resetCurrentStatus"
)
@GetMapping
(
"/resetCurrentStatus"
)
public
Result
resetCurrentStatus
()
{
public
Result
resetCurrentStatus
()
{
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
csdnUserInfoService
.
resetCurrentStatus
();
wrapper
.
eq
(
"is_delete"
,
0
);
final
List
<
CsdnUserInfo
>
list
=
csdnUserInfoService
.
list
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
CsdnUserInfo
csdnUserInfo
:
list
)
{
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
UN_PROCESSED
.
getCode
());
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
UN_PROCESSED
.
getCode
());
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
RESTRICTED_COMMENTS
.
getCode
());
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
}
}
return
Result
.
ok
(
"重置当天状态完成"
);
return
Result
.
ok
(
"重置当天状态完成"
);
}
}
}
}
src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.controller
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.service.CsdnTripletDayInfoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 每日三连监控(CsdnTripletDayInfo)表控制层
*
* @author makejava
* @since 2023-10-26 20:55:30
*/
@RestController
@RequestMapping
(
"/dayInfo"
)
public
class
CsdnTripletDayInfoController
{
@Autowired
private
CsdnTripletDayInfoService
csdnTripletDayInfoService
;
@GetMapping
(
"/add"
)
public
Result
autoReply
()
{
return
Result
.
ok
(
csdnTripletDayInfoService
.
todayInfo
());
}
}
src/main/java/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.entity
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 每日三连监控(CsdnTripletDayInfo)表实体类
*
* @author makejava
* @since 2023-10-26 20:55:31
*/
@Data
@TableName
(
"csdn_triplet_day_info"
)
public
class
CsdnTripletDayInfo
extends
Model
<
CsdnTripletDayInfo
>
{
//主键id
private
Integer
id
;
//三连日期
@JsonFormat
(
pattern
=
"yyyy-MM-dd"
,
timezone
=
"GMT+8"
)
private
Date
tripletDate
;
//点赞数量
private
Integer
likeNum
;
//收藏数量
private
Integer
collectNum
;
//评论数量
private
Integer
commentNum
;
//创建时间
private
Date
createTime
;
//更新时间
private
Date
updateTime
;
//逻辑删除,0未删除,1已删除
private
Integer
isDelete
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/enums/CommentStatus.java
浏览文件 @
b611c2b4
...
@@ -29,7 +29,7 @@ public enum CommentStatus {
...
@@ -29,7 +29,7 @@ public enum CommentStatus {
/**
/**
* 评论已经到了49条
* 评论已经到了49条
*/
*/
COMMENT_NUM_49
(
5
,
"评论已经到了49条"
),
COMMENT_NUM_49
(
5
,
"
当日
评论已经到了49条"
),
/**
/**
* 其他错误
* 其他错误
*/
*/
...
...
src/main/java/com/kwan/springbootkwan/mapper/CsdnTripletDayInfoMapper.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
/**
* 每日三连监控(CsdnTripletDayInfo)表数据库访问层
*
* @author makejava
* @since 2023-10-26 20:55:30
*/
public
interface
CsdnTripletDayInfoMapper
extends
BaseMapper
<
CsdnTripletDayInfo
>
{
}
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.schedule
;
package
com.kwan.springbootkwan.schedule
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.enums.CollectStatus
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.LikeStatus
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnTripletDayInfoService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Slf4j
@Slf4j
@Component
@Component
public
class
CsdnSchedule
{
public
class
CsdnSchedule
{
...
@@ -28,6 +20,10 @@ public class CsdnSchedule {
...
@@ -28,6 +20,10 @@ public class CsdnSchedule {
private
CsdnCommentService
csdnCommentService
;
private
CsdnCommentService
csdnCommentService
;
@Autowired
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
private
CsdnUserInfoService
csdnUserInfoService
;
@Autowired
private
CsdnAutoReplyService
csdnAutoReplyService
;
@Autowired
private
CsdnTripletDayInfoService
csdnTripletDayInfoService
;
@Scheduled
(
cron
=
"0 0 8,10,12,14,16,18,20 * * ?"
)
@Scheduled
(
cron
=
"0 0 8,10,12,14,16,18,20 * * ?"
)
public
void
execute
()
{
public
void
execute
()
{
...
@@ -39,25 +35,22 @@ public class CsdnSchedule {
...
@@ -39,25 +35,22 @@ public class CsdnSchedule {
@Scheduled
(
cron
=
"0 0/30 0 * * ?"
)
@Scheduled
(
cron
=
"0 0/30 0 * * ?"
)
public
void
executeReply
()
{
public
void
executeReply
()
{
log
.
info
(
"executeReply task is running ... ..."
);
log
.
info
(
"executeReply task is running ... ..."
);
csdn
Comment
Service
.
commentSelf
();
csdn
AutoReply
Service
.
commentSelf
();
log
.
info
(
"executeReply task is finish ... ..."
);
log
.
info
(
"executeReply task is finish ... ..."
);
}
}
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
public
void
executeInit
()
{
public
void
executeInit
()
{
log
.
info
(
"executeInit task is running ... ..."
);
log
.
info
(
"executeInit task is running ... ..."
);
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
csdnUserInfoService
.
resetCurrentStatus
();
wrapper
.
eq
(
"is_delete"
,
0
);
final
List
<
CsdnUserInfo
>
list
=
csdnUserInfoService
.
list
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
CsdnUserInfo
csdnUserInfo
:
list
)
{
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
UN_PROCESSED
.
getCode
());
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
UN_PROCESSED
.
getCode
());
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
RESTRICTED_COMMENTS
.
getCode
());
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
}
}
log
.
info
(
"executeInit task is finish ... ..."
);
log
.
info
(
"executeInit task is finish ... ..."
);
}
}
}
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
resetTripletDayInfo
()
{
log
.
info
(
"resetTripletDayInfo task is running ... ..."
);
//新增当前天的新的一条数据
csdnTripletDayInfoService
.
todayInfo
();
log
.
info
(
"resetTripletDayInfo task is finish ... ..."
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnArticleService.java
浏览文件 @
b611c2b4
...
@@ -15,7 +15,7 @@ import java.util.List;
...
@@ -15,7 +15,7 @@ import java.util.List;
public
interface
CsdnArticleService
{
public
interface
CsdnArticleService
{
/**
/**
* 获取最新的文章
* 获取最新的
5篇
文章
*
*
* @param username
* @param username
* @return
* @return
...
...
src/main/java/com/kwan/springbootkwan/service/CsdnAutoReplyService.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service
;
/**
* 自动回复
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/10/24 01:25
*/
public
interface
CsdnAutoReplyService
{
/**
* 评论自己的文章
*
* @return
*/
void
commentSelf
();
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnCollectService.java
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service
;
package
com.kwan.springbootkwan.service
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
...
@@ -25,5 +26,5 @@ public interface CsdnCollectService {
...
@@ -25,5 +26,5 @@ public interface CsdnCollectService {
*
*
* @return
* @return
*/
*/
Boolean
collect
(
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnUserInfo
csdnUserInfo
);
Boolean
collect
(
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnUserInfo
csdnUserInfo
,
CsdnTripletDayInfo
csdnTripletDayInfo
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnCommentService.java
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service
;
package
com.kwan.springbootkwan.service
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentResponse
;
/**
/**
* 评论
* 评论
...
@@ -24,13 +26,15 @@ public interface CsdnCommentService {
...
@@ -24,13 +26,15 @@ public interface CsdnCommentService {
*
*
* @return
* @return
*/
*/
Boolean
comment
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
);
Boolean
comment
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
,
CsdnTripletDayInfo
csdnTripletDayInfo
);
/**
/**
* 评论
自己的
文章
* 评论文章
*
*
* @param articleId
* @param commentInfo
* @param commentId
* @return
* @return
*/
*/
void
commentSelf
(
);
CommentResponse
dealComment
(
String
articleId
,
String
commentInfo
,
Integer
commentId
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnLikeService.java
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service
;
package
com.kwan.springbootkwan.service
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
/**
/**
...
@@ -24,5 +25,5 @@ public interface CsdnLikeService {
...
@@ -24,5 +25,5 @@ public interface CsdnLikeService {
*
*
* @return
* @return
*/
*/
Boolean
like
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
);
Boolean
like
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
,
CsdnTripletDayInfo
csdnTripletDayInfo
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnTripletDayInfoService.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
/**
* 每日三连监控(CsdnTripletDayInfo)表服务接口
*
* @author makejava
* @since 2023-10-26 20:55:31
*/
public
interface
CsdnTripletDayInfoService
extends
IService
<
CsdnTripletDayInfo
>
{
/**
* 重置每日三连监控
*/
CsdnTripletDayInfo
todayInfo
();
}
src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java
浏览文件 @
b611c2b4
...
@@ -11,5 +11,8 @@ import com.kwan.springbootkwan.entity.CsdnUserInfo;
...
@@ -11,5 +11,8 @@ import com.kwan.springbootkwan.entity.CsdnUserInfo;
*/
*/
public
interface
CsdnUserInfoService
extends
IService
<
CsdnUserInfo
>
{
public
interface
CsdnUserInfoService
extends
IService
<
CsdnUserInfo
>
{
void
resetCurrentStatus
();
}
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnAutoReplyServiceImpl.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service.impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentListResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentResponse
;
import
com.kwan.springbootkwan.service.CsdnArticleService
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Objects
;
@Slf4j
@Service
public
class
CsdnAutoReplyServiceImpl
implements
CsdnAutoReplyService
{
@Value
(
"${csdn.cookie}"
)
private
String
csdnCookie
;
@Value
(
"#{'${csdn.self_reply}'.split(';')}"
)
private
String
[]
selfReply
;
@Value
(
"${csdn.self_user_name}"
)
private
String
selfUserName
;
@Value
(
"${csdn.url.is_comment_list_url}"
)
private
String
commentListUrl
;
@Autowired
private
CsdnService
csdnService
;
@Autowired
private
CsdnArticleService
csdnArticleService
;
@Autowired
private
CsdnCommentService
csdnCommentService
;
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
@Override
public
void
commentSelf
()
{
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticleService
.
getArticles
(
selfUserName
);
if
(
list
==
null
)
{
return
;
}
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
list
)
{
final
String
type
=
article
.
getType
();
if
(
StringUtils
.
equals
(
"blog"
,
type
))
{
final
String
urlInfo
=
article
.
getUrl
();
String
articleId
=
urlInfo
.
substring
(
urlInfo
.
lastIndexOf
(
"/"
)
+
1
);
String
url
=
commentListUrl
+
articleId
;
HttpResponse
response
=
HttpUtil
.
createPost
(
url
)
.
header
(
"Cookie"
,
csdnCookie
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
200
)
//获取当前文章的200条评论
.
execute
();
final
String
body
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
CommentListResponse
articleInfo
;
try
{
articleInfo
=
objectMapper
.
readValue
(
body
,
CommentListResponse
.
class
);
final
CommentListResponse
.
DataInfo
data
=
articleInfo
.
getData
();
final
List
<
CommentListResponse
.
Comment
>
otherCommentList
=
data
.
getList
();
if
(
CollectionUtil
.
isNotEmpty
(
otherCommentList
))
{
for
(
CommentListResponse
.
Comment
oneComment
:
otherCommentList
)
{
final
CommentListResponse
.
Info
info
=
oneComment
.
getInfo
();
final
String
userName
=
info
.
getUserName
();
final
String
nickName
=
info
.
getNickName
();
final
Integer
commentId
=
info
.
getCommentId
();
if
(!
StringUtils
.
equals
(
userName
,
selfUserName
))
{
final
List
<
CommentListResponse
.
SubComment
>
sub
=
oneComment
.
getSub
();
boolean
flag
=
false
;
if
(
CollectionUtil
.
isNotEmpty
(
sub
))
{
for
(
CommentListResponse
.
SubComment
subComment
:
sub
)
{
//如果没有自己的评论,需要评论
final
String
subUserName
=
subComment
.
getUserName
();
if
(
StringUtils
.
equals
(
subUserName
,
selfUserName
))
{
flag
=
true
;
}
}
}
if
(
CollectionUtil
.
isEmpty
(
sub
)
||
!
flag
)
{
//需要评论
int
start
=
-
1
;
int
end
=
selfReply
.
length
;
int
temp_count
=
(
int
)
(
Math
.
floor
(
Math
.
random
()
*
(
start
-
end
+
1
))
+
end
);
CommentResponse
reply
=
csdnCommentService
.
dealComment
(
articleId
,
selfReply
[
temp_count
],
commentId
);
log
.
info
(
reply
.
toString
());
}
//三连此评论人
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"user_name"
,
userName
).
last
(
"limit 1"
);
CsdnUserInfo
csdnUserInfo
=
csdnUserInfoService
.
getOne
(
wrapper
);
if
(
Objects
.
isNull
(
csdnUserInfo
))
{
//新增用户
csdnUserInfo
=
new
CsdnUserInfo
();
csdnUserInfo
.
setUserName
(
userName
);
csdnUserInfo
.
setNickName
(
nickName
);
csdnUserInfo
.
setLikeStatus
(
0
);
csdnUserInfo
.
setCollectStatus
(
0
);
csdnUserInfo
.
setCommentStatus
(
0
);
csdnUserInfo
.
setUserWeight
(
7
);
csdnUserInfoService
.
save
(
csdnUserInfo
);
}
csdnService
.
singleArticle
(
csdnUserInfo
);
}
}
}
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnCollectServiceImpl.java
浏览文件 @
b611c2b4
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpResponse;
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.CollectInfoQuery
;
import
com.kwan.springbootkwan.entity.resp.CollectInfoQuery
;
...
@@ -66,7 +67,7 @@ public class CsdnCollectServiceImpl implements CsdnCollectService {
...
@@ -66,7 +67,7 @@ public class CsdnCollectServiceImpl implements CsdnCollectService {
}
}
@Override
@Override
public
Boolean
collect
(
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnUserInfo
csdnUserInfo
)
{
public
Boolean
collect
(
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnUserInfo
csdnUserInfo
,
CsdnTripletDayInfo
csdnTripletDayInfo
)
{
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
Integer
collectStatus
=
csdnUserInfo
.
getCollectStatus
();
final
Integer
collectStatus
=
csdnUserInfo
.
getCollectStatus
();
if
(
CollectStatus
.
HAVE_ALREADY_COLLECT
.
getCode
().
equals
(
collectStatus
)
||
CollectStatus
.
COLLECT_IS_FULL
.
getCode
().
equals
(
collectStatus
))
{
if
(
CollectStatus
.
HAVE_ALREADY_COLLECT
.
getCode
().
equals
(
collectStatus
)
||
CollectStatus
.
COLLECT_IS_FULL
.
getCode
().
equals
(
collectStatus
))
{
...
@@ -104,6 +105,7 @@ public class CsdnCollectServiceImpl implements CsdnCollectService {
...
@@ -104,6 +105,7 @@ public class CsdnCollectServiceImpl implements CsdnCollectService {
if
(
code
==
200
)
{
if
(
code
==
200
)
{
log
.
info
(
"文章{}收藏成功"
,
articleId
);
log
.
info
(
"文章{}收藏成功"
,
articleId
);
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
COLLECT_SUCCESSFUL
.
getCode
());
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
COLLECT_SUCCESSFUL
.
getCode
());
csdnTripletDayInfo
.
setCollectNum
(
csdnTripletDayInfo
.
getCollectNum
()
+
1
);
}
else
if
(
code
==
400000101
)
{
}
else
if
(
code
==
400000101
)
{
log
.
info
(
"收藏文章{}参数缺失"
,
articleId
);
log
.
info
(
"收藏文章{}参数缺失"
,
articleId
);
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
MISSING_PARAMETER
.
getCode
());
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
MISSING_PARAMETER
.
getCode
());
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnCommentServiceImpl.java
浏览文件 @
b611c2b4
...
@@ -5,16 +5,15 @@ import cn.hutool.http.HttpResponse;
...
@@ -5,16 +5,15 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentListResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentListResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentResponse
;
import
com.kwan.springbootkwan.entity.resp.CommentResponse
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.service.CsdnArticleService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -29,8 +28,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
...
@@ -29,8 +28,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
private
String
csdnCookie
;
private
String
csdnCookie
;
@Value
(
"#{'${csdn.self_comment}'.split(';')}"
)
@Value
(
"#{'${csdn.self_comment}'.split(';')}"
)
private
String
[]
selfComment
;
private
String
[]
selfComment
;
@Value
(
"#{'${csdn.self_reply}'.split(';')}"
)
private
String
[]
selfReply
;
@Value
(
"${csdn.self_user_name}"
)
@Value
(
"${csdn.self_user_name}"
)
private
String
selfUserName
;
private
String
selfUserName
;
@Value
(
"${csdn.url.is_comment_list_url}"
)
@Value
(
"${csdn.url.is_comment_list_url}"
)
...
@@ -38,8 +35,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
...
@@ -38,8 +35,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
@Value
(
"${csdn.url.comment_url}"
)
@Value
(
"${csdn.url.comment_url}"
)
private
String
commentUrl
;
private
String
commentUrl
;
@Autowired
private
CsdnArticleService
csdnArticleService
;
@Override
@Override
public
Boolean
isComment
(
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnUserInfo
csdnUserInfo
)
{
public
Boolean
isComment
(
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnUserInfo
csdnUserInfo
)
{
...
@@ -56,7 +51,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
...
@@ -56,7 +51,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
.
header
(
"Cookie"
,
csdnCookie
)
.
header
(
"Cookie"
,
csdnCookie
)
.
form
(
"page"
,
1
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
50
)
.
form
(
"size"
,
50
)
.
form
(
"fold"
,
"unfold"
)
.
execute
();
.
execute
();
final
String
body
=
response
.
body
();
final
String
body
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
...
@@ -83,7 +77,7 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
...
@@ -83,7 +77,7 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
}
}
@Override
@Override
public
Boolean
comment
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
)
{
public
Boolean
comment
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
,
CsdnTripletDayInfo
csdnTripletDayInfo
)
{
final
Integer
commentStatus
=
csdnUserInfo
.
getCommentStatus
();
final
Integer
commentStatus
=
csdnUserInfo
.
getCommentStatus
();
if
(
CommentStatus
.
HAVE_ALREADY_COMMENT
.
getCode
().
equals
(
commentStatus
)
if
(
CommentStatus
.
HAVE_ALREADY_COMMENT
.
getCode
().
equals
(
commentStatus
)
||
CommentStatus
.
COMMENT_IS_FULL
.
getCode
().
equals
(
commentStatus
)
||
CommentStatus
.
COMMENT_IS_FULL
.
getCode
().
equals
(
commentStatus
)
...
@@ -100,6 +94,7 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
...
@@ -100,6 +94,7 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
if
(
code
==
200
)
{
if
(
code
==
200
)
{
log
.
info
(
"文章{}评论成功"
,
articleId
);
log
.
info
(
"文章{}评论成功"
,
articleId
);
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
COMMENT_SUCCESSFUL
.
getCode
());
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
COMMENT_SUCCESSFUL
.
getCode
());
csdnTripletDayInfo
.
setCommentNum
(
csdnTripletDayInfo
.
getCommentNum
()
+
1
);
}
else
if
(
code
==
400
&&
StringUtils
.
equals
(
message
,
"您已达到当日发送上限,请明天尝试!"
))
{
}
else
if
(
code
==
400
&&
StringUtils
.
equals
(
message
,
"您已达到当日发送上限,请明天尝试!"
))
{
log
.
info
(
message
);
log
.
info
(
message
);
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
COMMENT_IS_FULL
.
getCode
());
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
COMMENT_IS_FULL
.
getCode
());
...
@@ -121,73 +116,14 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
...
@@ -121,73 +116,14 @@ public class CsdnCommentServiceImpl implements CsdnCommentService {
return
true
;
return
true
;
}
}
@Override
public
void
commentSelf
()
{
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticleService
.
getArticles
(
selfUserName
);
if
(
list
==
null
)
{
return
;
}
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
list
)
{
final
String
type
=
article
.
getType
();
if
(!
StringUtils
.
equals
(
"blog"
,
type
))
{
continue
;
}
final
String
urlInfo
=
article
.
getUrl
();
String
articleId
=
urlInfo
.
substring
(
urlInfo
.
lastIndexOf
(
"/"
)
+
1
);
String
url
=
commentListUrl
+
articleId
;
HttpResponse
response
=
HttpUtil
.
createPost
(
url
)
.
header
(
"Cookie"
,
csdnCookie
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
100
)
.
execute
();
final
String
body
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
CommentListResponse
articleInfo
;
try
{
articleInfo
=
objectMapper
.
readValue
(
body
,
CommentListResponse
.
class
);
final
CommentListResponse
.
DataInfo
data
=
articleInfo
.
getData
();
final
List
<
CommentListResponse
.
Comment
>
otherCommentList
=
data
.
getList
();
if
(
CollectionUtil
.
isNotEmpty
(
otherCommentList
))
{
for
(
CommentListResponse
.
Comment
oneComment
:
otherCommentList
)
{
final
CommentListResponse
.
Info
info
=
oneComment
.
getInfo
();
final
String
userName
=
info
.
getUserName
();
final
Integer
commentId
=
info
.
getCommentId
();
if
(!
StringUtils
.
equals
(
userName
,
selfUserName
))
{
final
List
<
CommentListResponse
.
SubComment
>
sub
=
oneComment
.
getSub
();
boolean
flag
=
false
;
if
(
CollectionUtil
.
isNotEmpty
(
sub
))
{
for
(
CommentListResponse
.
SubComment
subComment
:
sub
)
{
//如果没有自己的评论,需要评论
final
String
subUserName
=
subComment
.
getUserName
();
if
(
StringUtils
.
equals
(
subUserName
,
selfUserName
))
{
flag
=
true
;
}
}
}
if
(
CollectionUtil
.
isEmpty
(
sub
)
||
!
flag
)
{
//需要评论
int
start
=
-
1
;
int
end
=
selfReply
.
length
;
int
temp_count
=
(
int
)
(
Math
.
floor
(
Math
.
random
()
*
(
start
-
end
+
1
))
+
end
);
CommentResponse
reply
=
this
.
dealComment
(
articleId
,
selfReply
[
temp_count
],
commentId
);
log
.
info
(
reply
.
toString
());
}
}
}
}
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
}
}
/**
/**
* 评论文章
* 评论文章
*
*
* @param articleId
* @param articleId
* @return
* @return
*/
*/
private
CommentResponse
dealComment
(
String
articleId
,
String
commentInfo
,
Integer
commentId
)
{
@Override
public
CommentResponse
dealComment
(
String
articleId
,
String
commentInfo
,
Integer
commentId
)
{
HttpResponse
response
;
HttpResponse
response
;
if
(
Objects
.
nonNull
(
commentId
))
{
if
(
Objects
.
nonNull
(
commentId
))
{
response
=
HttpUtil
.
createPost
(
commentUrl
)
response
=
HttpUtil
.
createPost
(
commentUrl
)
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnLikeServiceImpl.java
浏览文件 @
b611c2b4
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpResponse;
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.LikeResponse
;
import
com.kwan.springbootkwan.entity.resp.LikeResponse
;
import
com.kwan.springbootkwan.enums.LikeStatus
;
import
com.kwan.springbootkwan.enums.LikeStatus
;
...
@@ -46,7 +47,7 @@ public class CsdnLikeServiceImpl implements CsdnLikeService {
...
@@ -46,7 +47,7 @@ public class CsdnLikeServiceImpl implements CsdnLikeService {
}
}
@Override
@Override
public
Boolean
like
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
)
{
public
Boolean
like
(
String
articleId
,
CsdnUserInfo
csdnUserInfo
,
CsdnTripletDayInfo
csdnTripletDayInfo
)
{
final
Integer
likeStatus
=
csdnUserInfo
.
getLikeStatus
();
final
Integer
likeStatus
=
csdnUserInfo
.
getLikeStatus
();
if
(
LikeStatus
.
HAVE_ALREADY_LIKED
.
getCode
().
equals
(
likeStatus
)
||
LikeStatus
.
LIKE_IS_FULL
.
getCode
().
equals
(
likeStatus
))
{
if
(
LikeStatus
.
HAVE_ALREADY_LIKED
.
getCode
().
equals
(
likeStatus
)
||
LikeStatus
.
LIKE_IS_FULL
.
getCode
().
equals
(
likeStatus
))
{
return
true
;
return
true
;
...
@@ -65,6 +66,7 @@ public class CsdnLikeServiceImpl implements CsdnLikeService {
...
@@ -65,6 +66,7 @@ public class CsdnLikeServiceImpl implements CsdnLikeService {
if
(
status
)
{
if
(
status
)
{
log
.
info
(
"文章{}点赞成功"
,
articleId
);
log
.
info
(
"文章{}点赞成功"
,
articleId
);
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
LIKE_SUCCESSFUL
.
getCode
());
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
LIKE_SUCCESSFUL
.
getCode
());
csdnTripletDayInfo
.
setLikeNum
(
csdnTripletDayInfo
.
getLikeNum
()
+
1
);
}
else
{
}
else
{
log
.
info
(
"文章{}点赞取消"
,
articleId
);
log
.
info
(
"文章{}点赞取消"
,
articleId
);
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
CANCEL_LIKES
.
getCode
());
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
CANCEL_LIKES
.
getCode
());
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
浏览文件 @
b611c2b4
...
@@ -2,6 +2,7 @@ package com.kwan.springbootkwan.service.impl;
...
@@ -2,6 +2,7 @@ package com.kwan.springbootkwan.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
...
@@ -10,6 +11,7 @@ import com.kwan.springbootkwan.service.CsdnCollectService;
...
@@ -10,6 +11,7 @@ import com.kwan.springbootkwan.service.CsdnCollectService;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnLikeService
;
import
com.kwan.springbootkwan.service.CsdnLikeService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnTripletDayInfoService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -27,7 +29,8 @@ public class CsdnServiceImpl implements CsdnService {
...
@@ -27,7 +29,8 @@ public class CsdnServiceImpl implements CsdnService {
@Value
(
"${csdn.num_of_articles_per_person}"
)
@Value
(
"${csdn.num_of_articles_per_person}"
)
private
Integer
numOfArticlesPerPerson
;
private
Integer
numOfArticlesPerPerson
;
@Autowired
private
CsdnLikeService
csdnLikeService
;
@Autowired
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
private
CsdnUserInfoService
csdnUserInfoService
;
@Autowired
@Autowired
...
@@ -37,54 +40,54 @@ public class CsdnServiceImpl implements CsdnService {
...
@@ -37,54 +40,54 @@ public class CsdnServiceImpl implements CsdnService {
@Autowired
@Autowired
private
CsdnCommentService
csdnCommentService
;
private
CsdnCommentService
csdnCommentService
;
@Autowired
@Autowired
private
Csdn
LikeService
csdnLike
Service
;
private
Csdn
TripletDayInfoService
csdnTripletDayInfo
Service
;
@Override
@Override
public
void
singleArticle
(
CsdnUserInfo
csdnUserInfo
)
{
public
void
singleArticle
(
CsdnUserInfo
csdnUserInfo
)
{
final
String
username
=
csdnUserInfo
.
getUserName
();
final
String
username
=
csdnUserInfo
.
getUserName
();
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticleService
.
getArticles
(
username
);
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticleService
.
getArticles
(
username
);
if
(
list
==
null
)
{
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
return
;
final
int
size
=
list
.
size
();
}
numOfArticlesPerPerson
=
size
<
numOfArticlesPerPerson
?
size
:
numOfArticlesPerPerson
;
final
int
size
=
list
.
size
();
for
(
int
i
=
0
;
i
<
numOfArticlesPerPerson
;
i
++)
{
numOfArticlesPerPerson
=
size
<
numOfArticlesPerPerson
?
size
:
numOfArticlesPerPerson
;
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
list
.
get
(
i
);
for
(
int
i
=
0
;
i
<
numOfArticlesPerPerson
;
i
++)
{
final
String
type
=
article
.
getType
();
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
list
.
get
(
i
);
if
(!
StringUtils
.
equals
(
"blog"
,
type
))
{
final
String
type
=
article
.
getType
();
csdnUserInfo
.
setArticleType
(
type
);
if
(!
StringUtils
.
equals
(
"blog"
,
type
))
{
csdnUserInfo
.
setUpdateTime
(
new
Date
());
csdnUserInfo
.
setArticleType
(
type
);
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
continue
;
continue
;
}
final
String
urlInfo
=
article
.
getUrl
();
String
articleId
=
urlInfo
.
substring
(
urlInfo
.
lastIndexOf
(
"/"
)
+
1
);
//点赞
final
Boolean
isLike
=
csdnLikeService
.
isLike
(
articleId
,
csdnUserInfo
);
if
(!
isLike
)
{
csdnLikeService
.
like
(
articleId
,
csdnUserInfo
);
}
//查看已经评论总数量
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"comment_status"
,
9
);
final
List
<
CsdnUserInfo
>
comments
=
csdnUserInfoService
.
list
(
wrapper
);
if
(
CollectionUtil
.
isEmpty
(
comments
)
||
comments
.
size
()
<
49
)
{
//评论
final
Boolean
comment
=
csdnCommentService
.
isComment
(
article
,
csdnUserInfo
);
if
(!
comment
)
{
csdnCommentService
.
comment
(
articleId
,
csdnUserInfo
);
}
}
}
//获取每日三连总信息
if
(
CollectionUtil
.
isNotEmpty
(
comments
)
&&
comments
.
size
()
>=
49
)
{
final
CsdnTripletDayInfo
csdnTripletDayInfo
=
csdnTripletDayInfoService
.
todayInfo
();
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
COMMENT_NUM_49
.
getCode
());
final
String
urlInfo
=
article
.
getUrl
();
}
String
articleId
=
urlInfo
.
substring
(
urlInfo
.
lastIndexOf
(
"/"
)
+
1
);
//收藏
//点赞
final
Boolean
collect
=
csdnCollectService
.
isCollect
(
articleId
,
csdnUserInfo
);
final
Boolean
isLike
=
csdnLikeService
.
isLike
(
articleId
,
csdnUserInfo
);
if
(!
collect
)
{
if
(!
isLike
)
{
csdnCollectService
.
collect
(
article
,
csdnUserInfo
);
csdnLikeService
.
like
(
articleId
,
csdnUserInfo
,
csdnTripletDayInfo
);
}
final
Integer
commentNum
=
csdnTripletDayInfo
.
getCommentNum
();
if
(
commentNum
<
49
)
{
//评论
final
Boolean
comment
=
csdnCommentService
.
isComment
(
article
,
csdnUserInfo
);
if
(!
comment
)
{
csdnCommentService
.
comment
(
articleId
,
csdnUserInfo
,
csdnTripletDayInfo
);
}
}
else
{
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
COMMENT_NUM_49
.
getCode
());
}
//收藏
final
Boolean
collect
=
csdnCollectService
.
isCollect
(
articleId
,
csdnUserInfo
);
if
(!
collect
)
{
csdnCollectService
.
collect
(
article
,
csdnUserInfo
,
csdnTripletDayInfo
);
}
csdnTripletDayInfo
.
setUpdateTime
(
new
Date
());
csdnTripletDayInfoService
.
updateById
(
csdnTripletDayInfo
);
csdnUserInfo
.
setUpdateTime
(
new
Date
());
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
}
}
}
}
csdnUserInfo
.
setUpdateTime
(
new
Date
());
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
}
}
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnTripletDayInfoServiceImpl.java
0 → 100644
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service.impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.mapper.CsdnTripletDayInfoMapper
;
import
com.kwan.springbootkwan.service.CsdnTripletDayInfoService
;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Objects
;
/**
* 每日三连监控(CsdnTripletDayInfo)表服务实现类
*
* @author makejava
* @since 2023-10-26 20:55:31
*/
@Service
(
"csdnTripletDayInfoService"
)
public
class
CsdnTripletDayInfoServiceImpl
extends
ServiceImpl
<
CsdnTripletDayInfoMapper
,
CsdnTripletDayInfo
>
implements
CsdnTripletDayInfoService
{
@Override
public
CsdnTripletDayInfo
todayInfo
()
{
Date
currentDate
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
formattedDate
=
sdf
.
format
(
currentDate
);
QueryWrapper
<
CsdnTripletDayInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"triplet_date"
,
formattedDate
);
final
CsdnTripletDayInfo
one
=
this
.
getOne
(
wrapper
);
if
(
Objects
.
isNull
(
one
))
{
CsdnTripletDayInfo
csdnTripletDayInfo
=
new
CsdnTripletDayInfo
();
csdnTripletDayInfo
.
setTripletDate
(
new
Date
());
csdnTripletDayInfo
.
setLikeNum
(
0
);
csdnTripletDayInfo
.
setCollectNum
(
0
);
csdnTripletDayInfo
.
setCommentNum
(
0
);
csdnTripletDayInfo
.
setUpdateTime
(
new
Date
());
this
.
save
(
csdnTripletDayInfo
);
}
return
one
;
}
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
浏览文件 @
b611c2b4
package
com.kwan.springbootkwan.service.impl
;
package
com.kwan.springbootkwan.service.impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.enums.CollectStatus
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.LikeStatus
;
import
com.kwan.springbootkwan.mapper.CsdnUserInfoMapper
;
import
com.kwan.springbootkwan.mapper.CsdnUserInfoMapper
;
import
com.kwan.springbootkwan.service.CsdnArticleService
;
import
com.kwan.springbootkwan.service.CsdnCollectService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
/**
* csdn用户信息(CsdnUserInfo)表服务实现类
* csdn用户信息(CsdnUserInfo)表服务实现类
*
*
...
@@ -15,5 +27,38 @@ import org.springframework.stereotype.Service;
...
@@ -15,5 +27,38 @@ import org.springframework.stereotype.Service;
@Service
(
"csdnUserInfoService"
)
@Service
(
"csdnUserInfoService"
)
public
class
CsdnUserInfoServiceImpl
extends
ServiceImpl
<
CsdnUserInfoMapper
,
CsdnUserInfo
>
implements
CsdnUserInfoService
{
public
class
CsdnUserInfoServiceImpl
extends
ServiceImpl
<
CsdnUserInfoMapper
,
CsdnUserInfo
>
implements
CsdnUserInfoService
{
@Autowired
private
CsdnCollectService
csdnCollectService
;
@Autowired
private
CsdnArticleService
csdnArticleService
;
@Override
public
void
resetCurrentStatus
()
{
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
final
List
<
CsdnUserInfo
>
list
=
this
.
list
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
CsdnUserInfo
csdnUserInfo
:
list
)
{
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
csdnArticleService
.
getArticles
(
userName
);
if
(
CollectionUtil
.
isNotEmpty
(
articles
))
{
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
String
type
=
article
.
getType
();
if
(
StringUtils
.
equals
(
type
,
"blog"
))
{
final
String
urlInfo
=
article
.
getUrl
();
String
articleId
=
urlInfo
.
substring
(
urlInfo
.
lastIndexOf
(
"/"
)
+
1
);
final
Boolean
collect
=
csdnCollectService
.
isCollect
(
articleId
,
csdnUserInfo
);
if
(!
collect
)
{
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
UN_PROCESSED
.
getCode
());
csdnUserInfo
.
setCollectStatus
(
CollectStatus
.
UN_PROCESSED
.
getCode
());
csdnUserInfo
.
setCommentStatus
(
CommentStatus
.
UN_PROCESSED
.
getCode
());
this
.
updateById
(
csdnUserInfo
);
}
}
}
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录