Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
9b2611a5
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看板
提交
9b2611a5
编写于
10月 28, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:最近的文章
上级
83a7f5a1
变更
19
显示空白变更内容
内联
并排
Showing
19 changed file
with
345 addition
and
214 deletion
+345
-214
src/main/java/com/kwan/springbootkwan/controller/CsdnArticleInfoController.java
.../springbootkwan/controller/CsdnArticleInfoController.java
+64
-38
src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java
...om/kwan/springbootkwan/controller/CsdnUserController.java
+2
-40
src/main/java/com/kwan/springbootkwan/entity/CsdnArticleInfo.java
.../java/com/kwan/springbootkwan/entity/CsdnArticleInfo.java
+4
-0
src/main/java/com/kwan/springbootkwan/entity/dto/CsdnArticleInfoDTO.java
...om/kwan/springbootkwan/entity/dto/CsdnArticleInfoDTO.java
+4
-0
src/main/java/com/kwan/springbootkwan/entity/query/CsdnArticleInfoQuery.java
...wan/springbootkwan/entity/query/CsdnArticleInfoQuery.java
+2
-0
src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
...m/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
+2
-0
src/main/java/com/kwan/springbootkwan/entity/resp/BusinessInfoResponse.java
...kwan/springbootkwan/entity/resp/BusinessInfoResponse.java
+5
-3
src/main/java/com/kwan/springbootkwan/mapper/CsdnArticleInfoMapper.java
...com/kwan/springbootkwan/mapper/CsdnArticleInfoMapper.java
+13
-0
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
...n/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
+2
-14
src/main/java/com/kwan/springbootkwan/schedule/ScheduleTest.java
...n/java/com/kwan/springbootkwan/schedule/ScheduleTest.java
+18
-3
src/main/java/com/kwan/springbootkwan/service/CsdnArticleInfoService.java
...m/kwan/springbootkwan/service/CsdnArticleInfoService.java
+18
-0
src/main/java/com/kwan/springbootkwan/service/CsdnArticleService.java
...a/com/kwan/springbootkwan/service/CsdnArticleService.java
+0
-24
src/main/java/com/kwan/springbootkwan/service/CsdnService.java
...ain/java/com/kwan/springbootkwan/service/CsdnService.java
+10
-0
src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java
.../com/kwan/springbootkwan/service/CsdnUserInfoService.java
+7
-0
src/main/java/com/kwan/springbootkwan/service/impl/CsdnArticleInfoServiceImpl.java
...ringbootkwan/service/impl/CsdnArticleInfoServiceImpl.java
+72
-2
src/main/java/com/kwan/springbootkwan/service/impl/CsdnArticleServiceImpl.java
...n/springbootkwan/service/impl/CsdnArticleServiceImpl.java
+0
-54
src/main/java/com/kwan/springbootkwan/service/impl/CsdnAutoReplyServiceImpl.java
...springbootkwan/service/impl/CsdnAutoReplyServiceImpl.java
+3
-3
src/main/java/com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
...com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
+71
-29
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
.../springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
+48
-4
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/CsdnArticleInfoController.java
浏览文件 @
9b2611a5
package
com.kwan.springbootkwan.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.CsdnArticleInfoDTO
;
import
com.kwan.springbootkwan.entity.query.CsdnArticleInfoQuery
;
import
com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.service.CsdnArticleInfoService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -20,19 +24,26 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Objects
;
@Slf4j
@Api
(
tags
=
"csdn文章管理"
)
@RestController
@RequestMapping
(
"/csdnArticleInfo"
)
public
class
CsdnArticleInfoController
{
@Resource
private
CsdnService
csdnService
;
@Resource
private
CsdnUserInfoService
csdnUserInfoService
;
@Resource
private
CsdnArticleInfoService
csdnArticleInfoService
;
@ApiOperation
(
value
=
"分页查询所有数据"
,
nickname
=
"分页查询所有数据"
)
@PostMapping
(
"/page"
)
public
Result
selectAll
(
@RequestBody
CsdnArticleInfoQuery
query
)
{
final
String
articleId
=
query
.
getArticleId
();
final
String
nickName
=
query
.
getNickName
();
final
String
userName
=
query
.
getUserName
();
final
Integer
likeStatus
=
query
.
getLikeStatus
();
...
...
@@ -43,6 +54,9 @@ public class CsdnArticleInfoController {
pageParm
.
setSize
(
query
.
getPageSize
());
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
if
(
StringUtils
.
isNotEmpty
(
articleId
))
{
wrapper
.
eq
(
"article_id"
,
articleId
);
}
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
wrapper
.
eq
(
"user_name"
,
userName
);
}
...
...
@@ -62,46 +76,35 @@ public class CsdnArticleInfoController {
return
Result
.
ok
(
CsdnArticleInfoDTO
.
Converter
.
INSTANCE
.
from
(
this
.
csdnArticleInfoService
.
page
(
pageParm
,
wrapper
)));
}
@ApiOperation
(
value
=
"新增用户"
,
nickname
=
"新增用户"
)
@ApiOperation
(
value
=
"新增文章"
,
nickname
=
"新增文章"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
CsdnArticleInfoQuery
addInfo
)
{
final
String
userName
=
addInfo
.
getUserName
();
final
Integer
addType
=
addInfo
.
getAddType
();
final
String
articleId
=
addInfo
.
getArticleId
();
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
articleId
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
();
if
(
StringUtils
.
isNotEmpty
(
str
))
{
if
(
StringUtils
.
isNotEmpty
(
userName
)
&&
StringUtils
.
isNotEmpty
(
articleId
))
{
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
this
.
csdnArticleInfoService
.
getBlogs
(
userName
);
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
articles
)
{
if
(
articleId
.
equals
(
article
.
getArticleId
().
toString
()))
{
//首先查询用户
CsdnUserInfoQuery
addUserInfo
=
new
CsdnUserInfoQuery
();
addUserInfo
.
setUserName
(
userName
);
addUserInfo
.
setAddType
(
0
);
csdnUserInfoService
.
add
(
addUserInfo
);
CsdnArticleInfo
csdnArticleInfo
=
new
CsdnArticleInfo
();
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"article_id"
,
str
);
wrapper
.
eq
(
"article_id"
,
articleId
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnArticleInfo
one
=
this
.
csdnArticleInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnArticleInfo
);
csdnArticleInfo
.
setArticleId
(
str
);
csdnArticleInfo
.
setArticleUrl
(
"https://blog.csdn.net/"
+
userName
+
"/article/details/"
+
articleId
);
csdnArticleInfo
.
setArticleId
(
articleId
);
csdnArticleInfo
.
setUserName
(
userName
);
csdnArticleInfo
.
setArticleTitle
(
article
.
getTitle
());
csdnArticleInfo
.
setArticleDescription
(
article
.
getDescription
());
csdnArticleInfo
.
setArticleUrl
(
article
.
getUrl
());
csdnArticleInfo
.
setNickName
(
addUserInfo
.
getNickName
());
this
.
csdnArticleInfoService
.
save
(
csdnArticleInfo
);
}
}
}
}
else
{
CsdnArticleInfo
csdnArticleInfo
=
new
CsdnArticleInfo
();
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
userName
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnArticleInfo
one
=
this
.
csdnArticleInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnArticleInfo
);
csdnArticleInfo
.
setArticleUrl
(
"https://blog.csdn.net/"
+
userName
+
"/article/details/"
+
articleId
);
this
.
csdnArticleInfoService
.
save
(
csdnArticleInfo
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
(
"该用户已存在"
);
break
;
}
}
}
...
...
@@ -115,6 +118,8 @@ public class CsdnArticleInfoController {
csdnUserInfo
.
setId
(
query
.
getId
());
csdnUserInfo
.
setUserName
(
query
.
getUserName
());
csdnUserInfo
.
setNickName
(
query
.
getNickName
());
csdnUserInfo
.
setArticleUrl
(
query
.
getArticleUrl
());
csdnUserInfo
.
setArticleId
(
query
.
getArticleId
());
return
Result
.
ok
(
this
.
csdnArticleInfoService
.
updateById
(
csdnUserInfo
));
}
...
...
@@ -127,5 +132,26 @@ public class CsdnArticleInfoController {
wrapper
.
eq
(
"id"
,
id
);
return
Result
.
ok
(
this
.
csdnArticleInfoService
.
update
(
csdnArticleInfo
,
wrapper
));
}
}
@ApiOperation
(
value
=
"单篇文章三连"
,
nickname
=
"单篇文章三连"
)
@GetMapping
(
"/triplet"
)
public
Result
triplet
(
@RequestParam
(
"articleId"
)
Integer
articleId
)
{
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"article_id"
,
articleId
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnArticleInfo
one
=
this
.
csdnArticleInfoService
.
getOne
(
wrapper
);
if
(
one
!=
null
)
{
final
String
userName
=
one
.
getUserName
();
QueryWrapper
<
CsdnUserInfo
>
wrapperUser
=
new
QueryWrapper
<>();
wrapperUser
.
eq
(
"user_name"
,
userName
);
wrapperUser
.
eq
(
"is_delete"
,
0
);
final
CsdnUserInfo
userInfo
=
this
.
csdnUserInfoService
.
getOne
(
wrapperUser
);
BusinessInfoResponse
.
ArticleData
.
Article
article
=
new
BusinessInfoResponse
.
ArticleData
.
Article
();
article
.
setDescription
(
one
.
getArticleDescription
());
article
.
setTitle
(
one
.
getArticleTitle
());
article
.
setUrl
(
one
.
getArticleUrl
());
csdnService
.
tripletByArticle
(
userInfo
,
article
,
one
);
}
return
Result
.
ok
(
"单篇文章三连完成"
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java
浏览文件 @
9b2611a5
...
...
@@ -11,7 +11,6 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -74,45 +73,7 @@ public class CsdnUserController {
@ApiOperation
(
value
=
"新增用户"
,
nickname
=
"新增用户"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
CsdnUserInfoQuery
addInfo
)
{
final
String
userName
=
addInfo
.
getUserName
();
final
Integer
addType
=
addInfo
.
getAddType
();
if
(
StringUtils
.
isEmpty
(
userName
))
{
return
Result
.
error
(
"名字不能为空"
);
}
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
userName
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
();
if
(
StringUtils
.
isNotEmpty
(
str
))
{
CsdnUserInfo
csdnUserInfo
=
new
CsdnUserInfo
();
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
str
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnUserInfo
one
=
this
.
csdnUserInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnUserInfo
);
csdnUserInfo
.
setUserName
(
str
);
csdnUserInfo
.
setUserHomeUrl
(
"https://blog.csdn.net/"
+
str
);
this
.
csdnUserInfoService
.
save
(
csdnUserInfo
);
}
}
}
}
else
{
CsdnUserInfo
csdnUserInfo
=
new
CsdnUserInfo
();
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
userName
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnUserInfo
one
=
this
.
csdnUserInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnUserInfo
);
csdnUserInfo
.
setUserHomeUrl
(
"https://blog.csdn.net/"
+
userName
);
this
.
csdnUserInfoService
.
save
(
csdnUserInfo
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
(
"该用户已存在"
);
}
}
csdnUserInfoService
.
add
(
addInfo
);
return
Result
.
ok
();
}
...
...
@@ -124,6 +85,7 @@ public class CsdnUserController {
csdnUserInfo
.
setUserName
(
query
.
getUserName
());
csdnUserInfo
.
setNickName
(
query
.
getNickName
());
csdnUserInfo
.
setUserWeight
(
query
.
getUserWeight
());
csdnUserInfo
.
setUserHomeUrl
(
query
.
getUserHomeUrl
());
return
Result
.
ok
(
this
.
csdnUserInfoService
.
updateById
(
csdnUserInfo
));
}
...
...
src/main/java/com/kwan/springbootkwan/entity/CsdnArticleInfo.java
浏览文件 @
9b2611a5
...
...
@@ -18,6 +18,10 @@ public class CsdnArticleInfo extends Model<CsdnArticleInfo> {
private
String
articleId
;
@ApiModelProperty
(
"文章URL"
)
private
String
articleUrl
;
@ApiModelProperty
(
"文章标题"
)
private
String
articleTitle
;
@ApiModelProperty
(
"文章描述"
)
private
String
articleDescription
;
@ApiModelProperty
(
"用户名称"
)
private
String
userName
;
@ApiModelProperty
(
"用户昵称"
)
...
...
src/main/java/com/kwan/springbootkwan/entity/dto/CsdnArticleInfoDTO.java
浏览文件 @
9b2611a5
...
...
@@ -22,6 +22,10 @@ public class CsdnArticleInfoDTO extends Model<CsdnArticleInfoDTO> {
private
String
articleId
;
@ApiModelProperty
(
"文章URL"
)
private
String
articleUrl
;
@ApiModelProperty
(
"文章标题"
)
private
String
articleTitle
;
@ApiModelProperty
(
"文章描述"
)
private
String
articleDescription
;
@ApiModelProperty
(
"用户名称"
)
private
String
userName
;
@ApiModelProperty
(
"用户昵称"
)
...
...
src/main/java/com/kwan/springbootkwan/entity/query/CsdnArticleInfoQuery.java
浏览文件 @
9b2611a5
...
...
@@ -16,6 +16,8 @@ public class CsdnArticleInfoQuery extends BasePage {
private
String
nickName
;
@ApiModelProperty
(
"CSDN文章id"
)
private
String
articleId
;
@ApiModelProperty
(
"CSDN文章URL"
)
private
String
articleUrl
;
@ApiModelProperty
(
"点赞状态"
)
private
Integer
likeStatus
=
0
;
@ApiModelProperty
(
"收藏状态"
)
...
...
src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
浏览文件 @
9b2611a5
...
...
@@ -24,6 +24,8 @@ public class CsdnUserInfoQuery extends BasePage {
private
Integer
userWeight
;
@ApiModelProperty
(
"文章类型"
)
private
String
articleType
;
@ApiModelProperty
(
"用户主页"
)
private
String
userHomeUrl
;
@ApiModelProperty
(
"添加类型"
)
private
Integer
addType
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/resp/BusinessInfoResponse.java
浏览文件 @
9b2611a5
...
...
@@ -43,9 +43,11 @@ public class BusinessInfoResponse {
public
Object
fileType
;
public
Object
content
;
public
Object
status
;
// public Integer articleId;
// public Object top;
// public Object forcePlan;
public
Object
articleId
;
public
Object
top
;
public
Object
forcePlan
;
public
Object
solve
;
public
Object
answersCount
;
}
}
...
...
src/main/java/com/kwan/springbootkwan/
dao/CsdnArticleInfoDao
.java
→
src/main/java/com/kwan/springbootkwan/
mapper/CsdnArticleInfoMapper
.java
浏览文件 @
9b2611a5
package
com.kwan.springbootkwan.
dao
;
package
com.kwan.springbootkwan.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* csdn文章信息(CsdnArticleInfo)表数据库访问层
*
* @author makejava
* @since 2023-10-28 01:58:46
*/
public
interface
CsdnArticleInfoDao
extends
BaseMapper
<
CsdnArticleInfo
>
{
@Mapper
public
interface
CsdnArticleInfoMapper
extends
BaseMapper
<
CsdnArticleInfo
>
{
}
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
浏览文件 @
9b2611a5
...
...
@@ -26,14 +26,8 @@ public class CsdnSchedule {
public
void
execute
()
{
log
.
info
(
"execute task is running ... ..."
);
csdnService
.
multiTriplet
();
log
.
info
(
"execute task is finish ... ..."
);
}
@Scheduled
(
cron
=
"0 0/50 0 * * ?"
)
public
void
executeReply
()
{
log
.
info
(
"executeReply task is running ... ..."
);
csdnAutoReplyService
.
commentSelf
();
log
.
info
(
"execute
Reply
task is finish ... ..."
);
log
.
info
(
"execute task is finish ... ..."
);
}
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
...
...
@@ -43,17 +37,11 @@ public class CsdnSchedule {
log
.
info
(
"executeInit task is finish ... ..."
);
}
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
public
void
resetUserDayStatus
()
{
log
.
info
(
"executeInit task is running ... ..."
);
csdnUserInfoService
.
resetUserDayStatus
();
log
.
info
(
"executeInit task is finish ... ..."
);
}
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
resetTripletDayInfo
()
{
log
.
info
(
"resetTripletDayInfo task is running ... ..."
);
//新增当前天的新的一条数据
csdnUserInfoService
.
resetUserDayStatus
();
csdnTripletDayInfoService
.
todayInfo
();
log
.
info
(
"resetTripletDayInfo task is finish ... ..."
);
}
...
...
src/main/java/com/kwan/springbootkwan/schedule/ScheduleTest.java
浏览文件 @
9b2611a5
...
...
@@ -2,7 +2,6 @@ package com.kwan.springbootkwan.schedule;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -17,9 +16,25 @@ import org.springframework.stereotype.Component;
@Slf4j
public
class
ScheduleTest
{
// @Scheduled(cron = "0/6 * * * * ?")
public
void
execute1
()
{
log
.
info
(
"Scheduled execute1 is running ... ..."
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
// @Scheduled(cron = "0/10 * * * * ?")
public
void
execute
()
{
log
.
info
(
"Scheduled task is running ... ..."
);
public
void
execute2
()
{
log
.
info
(
"Scheduled execute2 is running ... ..."
);
try
{
Thread
.
sleep
(
30000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/com/kwan/springbootkwan/service/CsdnArticleInfoService.java
浏览文件 @
9b2611a5
...
...
@@ -2,6 +2,9 @@ package com.kwan.springbootkwan.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
java.util.List
;
/**
* csdn文章信息(CsdnArticleInfo)表服务接口
...
...
@@ -11,5 +14,20 @@ import com.kwan.springbootkwan.entity.CsdnArticleInfo;
*/
public
interface
CsdnArticleInfoService
extends
IService
<
CsdnArticleInfo
>
{
/**
* 获取最新的10篇文章
*
* @param username
* @return
*/
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
getArticles
(
String
username
);
/**
* 获取最新的10篇博客(只能是blog类型)
*
* @param username
* @return
*/
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
getBlogs
(
String
username
);
}
src/main/java/com/kwan/springbootkwan/service/CsdnArticleService.java
已删除
100644 → 0
浏览文件 @
83a7f5a1
package
com.kwan.springbootkwan.service
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
java.util.List
;
/**
* 获取最新的文章
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/10/25 18:44
*/
public
interface
CsdnArticleService
{
/**
* 获取最新的5篇文章
*
* @param username
* @return
*/
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
getArticles
(
String
username
);
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnService.java
浏览文件 @
9b2611a5
package
com.kwan.springbootkwan.service
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
/**
* csdn博客自动化
...
...
@@ -22,4 +24,12 @@ public interface CsdnService {
* 多人三连
*/
void
multiTriplet
();
/**
* 根据文章三连
*
* @param csdnUserInfo
* @param article
*/
void
tripletByArticle
(
CsdnUserInfo
csdnUserInfo
,
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnArticleInfo
csdnArticleInfo
);
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java
浏览文件 @
9b2611a5
...
...
@@ -2,6 +2,7 @@ package com.kwan.springbootkwan.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery
;
/**
* csdn用户信息(CsdnUserInfo)表服务接口
...
...
@@ -26,5 +27,11 @@ public interface CsdnUserInfoService extends IService<CsdnUserInfo> {
*/
void
resetCsdnUserInfo
(
CsdnUserInfo
csdnUserInfo
);
/**
* 新增用户
* @param addInfo
*/
void
add
(
CsdnUserInfoQuery
addInfo
);
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnArticleInfoServiceImpl.java
浏览文件 @
9b2611a5
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.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.dao.CsdnArticleInfoDao
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.mapper.CsdnArticleInfoMapper
;
import
com.kwan.springbootkwan.service.CsdnArticleInfoService
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* csdn文章信息(CsdnArticleInfo)表服务实现类
*
...
...
@@ -13,7 +22,68 @@ import org.springframework.stereotype.Service;
* @since 2023-10-28 01:58:46
*/
@Service
(
"csdnArticleInfoService"
)
public
class
CsdnArticleInfoServiceImpl
extends
ServiceImpl
<
CsdnArticleInfoDao
,
CsdnArticleInfo
>
implements
CsdnArticleInfoService
{
public
class
CsdnArticleInfoServiceImpl
extends
ServiceImpl
<
CsdnArticleInfoMapper
,
CsdnArticleInfo
>
implements
CsdnArticleInfoService
{
@Value
(
"${csdn.cookie}"
)
private
String
csdnCookie
;
@Value
(
"${csdn.url.user_article_url}"
)
private
String
url
;
@Override
public
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
getArticles
(
String
username
)
{
HttpResponse
response
=
HttpUtil
.
createGet
(
url
)
.
header
(
"Cookie"
,
csdnCookie
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
10
)
// .form("businessType", "blog")
// .form("blogType", "ViewCount")
.
form
(
"businessType"
,
"lately"
)
.
form
(
"noMore"
,
false
)
.
form
(
"username"
,
username
)
.
execute
();
final
String
body
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
BusinessInfoResponse
businessInfoResponse
;
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
null
;
try
{
businessInfoResponse
=
objectMapper
.
readValue
(
body
,
BusinessInfoResponse
.
class
);
final
BusinessInfoResponse
.
ArticleData
data
=
businessInfoResponse
.
getData
();
list
=
data
.
getList
();
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
if
(
CollectionUtil
.
isEmpty
(
list
))
{
return
null
;
}
return
list
;
}
@Override
public
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
getBlogs
(
String
username
)
{
HttpResponse
response
=
HttpUtil
.
createGet
(
url
)
.
header
(
"Cookie"
,
csdnCookie
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
10
)
.
form
(
"businessType"
,
"blog"
)
// .form("blogType", "ViewCount")
.
form
(
"noMore"
,
false
)
.
form
(
"username"
,
username
)
.
execute
();
final
String
body
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
BusinessInfoResponse
businessInfoResponse
;
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
null
;
try
{
businessInfoResponse
=
objectMapper
.
readValue
(
body
,
BusinessInfoResponse
.
class
);
final
BusinessInfoResponse
.
ArticleData
data
=
businessInfoResponse
.
getData
();
list
=
data
.
getList
();
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
if
(
CollectionUtil
.
isEmpty
(
list
))
{
return
null
;
}
return
list
;
}
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnArticleServiceImpl.java
已删除
100644 → 0
浏览文件 @
83a7f5a1
package
com.kwan.springbootkwan.service.impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.service.CsdnArticleService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Slf4j
@Service
public
class
CsdnArticleServiceImpl
implements
CsdnArticleService
{
@Value
(
"${csdn.cookie}"
)
private
String
csdnCookie
;
@Value
(
"${csdn.url.user_article_url}"
)
private
String
url
;
@Override
public
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
getArticles
(
String
username
)
{
HttpResponse
response
=
HttpUtil
.
createGet
(
url
)
.
header
(
"Cookie"
,
csdnCookie
)
.
form
(
"page"
,
1
)
.
form
(
"size"
,
5
)
// .form("businessType", "blog")
// .form("blogType", "ViewCount")
.
form
(
"businessType"
,
"lately"
)
.
form
(
"noMore"
,
false
)
.
form
(
"username"
,
username
)
.
execute
();
final
String
body
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
BusinessInfoResponse
businessInfoResponse
;
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
null
;
try
{
businessInfoResponse
=
objectMapper
.
readValue
(
body
,
BusinessInfoResponse
.
class
);
final
BusinessInfoResponse
.
ArticleData
data
=
businessInfoResponse
.
getData
();
list
=
data
.
getList
();
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
if
(
CollectionUtil
.
isEmpty
(
list
))
{
return
null
;
}
return
list
;
}
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnAutoReplyServiceImpl.java
浏览文件 @
9b2611a5
...
...
@@ -10,7 +10,7 @@ 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.CsdnArticle
Info
Service
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnService
;
...
...
@@ -38,7 +38,7 @@ public class CsdnAutoReplyServiceImpl implements CsdnAutoReplyService {
@Autowired
private
CsdnService
csdnService
;
@Autowired
private
CsdnArticle
Service
csdnArticle
Service
;
private
CsdnArticle
InfoService
csdnArticleInfo
Service
;
@Autowired
private
CsdnCommentService
csdnCommentService
;
@Autowired
...
...
@@ -46,7 +46,7 @@ public class CsdnAutoReplyServiceImpl implements CsdnAutoReplyService {
@Override
public
void
commentSelf
()
{
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticleService
.
getArticles
(
selfUserName
);
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticle
Info
Service
.
getArticles
(
selfUserName
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
list
)
{
final
String
type
=
article
.
getType
();
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
浏览文件 @
9b2611a5
...
...
@@ -2,11 +2,12 @@ package com.kwan.springbootkwan.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.service.CsdnArticleService
;
import
com.kwan.springbootkwan.service.CsdnArticle
Info
Service
;
import
com.kwan.springbootkwan.service.CsdnCollectService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnLikeService
;
...
...
@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
@Slf4j
...
...
@@ -34,7 +36,7 @@ public class CsdnServiceImpl implements CsdnService {
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
@Autowired
private
CsdnArticle
Service
csdnArticle
Service
;
private
CsdnArticle
InfoService
csdnArticleInfo
Service
;
@Autowired
private
CsdnCollectService
csdnCollectService
;
@Autowired
...
...
@@ -45,7 +47,7 @@ public class CsdnServiceImpl implements CsdnService {
@Override
public
void
singleArticle
(
CsdnUserInfo
csdnUserInfo
)
{
final
String
username
=
csdnUserInfo
.
getUserName
();
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticleService
.
getArticles
(
username
);
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
list
=
csdnArticle
Info
Service
.
getArticles
(
username
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
final
int
size
=
list
.
size
();
numOfArticlesPerPerson
=
size
<
numOfArticlesPerPerson
?
size
:
numOfArticlesPerPerson
;
...
...
@@ -58,6 +60,41 @@ public class CsdnServiceImpl implements CsdnService {
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
continue
;
}
//先去查询文章,没有查到的话就插入文章
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
final
String
articleUrl
=
article
.
getUrl
();
String
articleIdFormUrl
=
articleUrl
.
substring
(
articleUrl
.
lastIndexOf
(
"/"
)
+
1
);
final
Object
articleId
=
article
.
getArticleId
();
if
(
Objects
.
isNull
(
articleId
))
{
article
.
setArticleId
(
articleIdFormUrl
);
}
wrapper
.
eq
(
"article_id"
,
article
.
getArticleId
().
toString
());
wrapper
.
eq
(
"is_delete"
,
0
);
CsdnArticleInfo
csdnArticleInfo
=
this
.
csdnArticleInfoService
.
getOne
(
wrapper
);
if
(
csdnArticleInfo
==
null
)
{
csdnArticleInfo
=
new
CsdnArticleInfo
();
csdnArticleInfo
.
setArticleId
(
article
.
getArticleId
().
toString
());
csdnArticleInfo
.
setArticleUrl
(
articleUrl
);
csdnArticleInfo
.
setArticleTitle
(
article
.
getTitle
());
csdnArticleInfo
.
setArticleDescription
(
article
.
getDescription
());
csdnArticleInfo
.
setUserName
(
username
);
csdnArticleInfo
.
setNickName
(
csdnUserInfo
.
getNickName
());
this
.
csdnArticleInfoService
.
save
(
csdnArticleInfo
);
}
this
.
tripletByArticle
(
csdnUserInfo
,
article
,
csdnArticleInfo
);
}
}
}
/**
* 根据文章三连
*
* @param csdnUserInfo
* @param article
*/
@Override
public
void
tripletByArticle
(
CsdnUserInfo
csdnUserInfo
,
BusinessInfoResponse
.
ArticleData
.
Article
article
,
CsdnArticleInfo
csdnArticleInfo
)
{
//获取每日三连总信息
final
CsdnTripletDayInfo
csdnTripletDayInfo
=
csdnTripletDayInfoService
.
todayInfo
();
final
String
urlInfo
=
article
.
getUrl
();
...
...
@@ -82,14 +119,19 @@ public class CsdnServiceImpl implements CsdnService {
if
(!
collect
)
{
csdnCollectService
.
collect
(
article
,
csdnUserInfo
,
csdnTripletDayInfo
);
}
csdnTripletDayInfo
.
setUpdateTime
(
new
Date
());
csdnTripletDayInfoService
.
updateById
(
csdnTripletDayInfo
);
csdnUserInfo
.
setUpdateTime
(
new
Date
());
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
}
}
}
csdnArticleInfo
.
setUpdateTime
(
new
Date
());
csdnArticleInfo
.
setLikeStatus
(
csdnUserInfo
.
getLikeStatus
());
csdnArticleInfo
.
setCollectStatus
(
csdnUserInfo
.
getCollectStatus
());
csdnArticleInfo
.
setCommentStatus
(
csdnUserInfo
.
getCommentStatus
());
csdnArticleInfoService
.
updateById
(
csdnArticleInfo
);
}
@Override
public
void
multiTriplet
()
{
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
浏览文件 @
9b2611a5
...
...
@@ -4,15 +4,17 @@ import cn.hutool.core.collection.CollectionUtil;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery
;
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.service.CsdnArticleService
;
import
com.kwan.springbootkwan.service.CsdnArticle
Info
Service
;
import
com.kwan.springbootkwan.service.CsdnCollectService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -31,7 +33,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
@Autowired
private
CsdnCollectService
csdnCollectService
;
@Autowired
private
CsdnArticle
Service
csdnArticle
Service
;
private
CsdnArticle
InfoService
csdnArticleInfo
Service
;
@Override
public
void
resetAllCurrentStatus
()
{
...
...
@@ -50,7 +52,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
Integer
commentStatus
=
csdnUserInfo
.
getCommentStatus
();
final
String
articleType
=
csdnUserInfo
.
getArticleType
();
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
csdnArticleService
.
getArticles
(
userName
);
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
csdnArticle
Info
Service
.
getArticles
(
userName
);
if
(
CollectionUtil
.
isNotEmpty
(
articles
))
{
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
String
type
=
article
.
getType
();
...
...
@@ -75,6 +77,48 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
}
}
@Override
public
void
add
(
CsdnUserInfoQuery
addInfo
)
{
final
String
userName
=
addInfo
.
getUserName
();
final
Integer
addType
=
addInfo
.
getAddType
();
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
userName
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
();
if
(
StringUtils
.
isNotEmpty
(
str
))
{
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
str
);
wrapper
.
eq
(
"is_delete"
,
0
);
CsdnUserInfo
one
=
this
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
one
=
new
CsdnUserInfo
();
BeanUtils
.
copyProperties
(
addInfo
,
one
);
one
.
setUserName
(
str
);
one
.
setUserHomeUrl
(
"https://blog.csdn.net/"
+
str
);
this
.
save
(
one
);
}
addInfo
.
setNickName
(
one
.
getNickName
());
}
}
}
else
{
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
userName
);
wrapper
.
eq
(
"is_delete"
,
0
);
CsdnUserInfo
one
=
this
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
one
=
new
CsdnUserInfo
();
BeanUtils
.
copyProperties
(
addInfo
,
one
);
one
.
setUserHomeUrl
(
"https://blog.csdn.net/"
+
userName
);
this
.
save
(
one
);
}
addInfo
.
setNickName
(
one
.
getNickName
());
}
}
}
@Override
public
void
resetUserDayStatus
()
{
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
...
...
@@ -83,7 +127,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
CsdnUserInfo
csdnUserInfo
:
list
)
{
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
csdnArticleService
.
getArticles
(
userName
);
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
csdnArticle
Info
Service
.
getArticles
(
userName
);
if
(
CollectionUtil
.
isNotEmpty
(
articles
))
{
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
String
type
=
article
.
getType
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录