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
;
package
com.kwan.springbootkwan.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.CsdnArticleInfoDTO
;
import
com.kwan.springbootkwan.entity.dto.CsdnArticleInfoDTO
;
import
com.kwan.springbootkwan.entity.query.CsdnArticleInfoQuery
;
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.CsdnArticleInfoService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
@@ -20,19 +24,26 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -20,19 +24,26 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
@Slf4j
@Api
(
tags
=
"csdn文章管理"
)
@Api
(
tags
=
"csdn文章管理"
)
@RestController
@RestController
@RequestMapping
(
"/csdnArticleInfo"
)
@RequestMapping
(
"/csdnArticleInfo"
)
public
class
CsdnArticleInfoController
{
public
class
CsdnArticleInfoController
{
@Resource
private
CsdnService
csdnService
;
@Resource
private
CsdnUserInfoService
csdnUserInfoService
;
@Resource
@Resource
private
CsdnArticleInfoService
csdnArticleInfoService
;
private
CsdnArticleInfoService
csdnArticleInfoService
;
@ApiOperation
(
value
=
"分页查询所有数据"
,
nickname
=
"分页查询所有数据"
)
@ApiOperation
(
value
=
"分页查询所有数据"
,
nickname
=
"分页查询所有数据"
)
@PostMapping
(
"/page"
)
@PostMapping
(
"/page"
)
public
Result
selectAll
(
@RequestBody
CsdnArticleInfoQuery
query
)
{
public
Result
selectAll
(
@RequestBody
CsdnArticleInfoQuery
query
)
{
final
String
articleId
=
query
.
getArticleId
();
final
String
nickName
=
query
.
getNickName
();
final
String
nickName
=
query
.
getNickName
();
final
String
userName
=
query
.
getUserName
();
final
String
userName
=
query
.
getUserName
();
final
Integer
likeStatus
=
query
.
getLikeStatus
();
final
Integer
likeStatus
=
query
.
getLikeStatus
();
...
@@ -43,6 +54,9 @@ public class CsdnArticleInfoController {
...
@@ -43,6 +54,9 @@ public class CsdnArticleInfoController {
pageParm
.
setSize
(
query
.
getPageSize
());
pageParm
.
setSize
(
query
.
getPageSize
());
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"is_delete"
,
0
);
if
(
StringUtils
.
isNotEmpty
(
articleId
))
{
wrapper
.
eq
(
"article_id"
,
articleId
);
}
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
wrapper
.
eq
(
"user_name"
,
userName
);
wrapper
.
eq
(
"user_name"
,
userName
);
}
}
...
@@ -62,46 +76,35 @@ public class CsdnArticleInfoController {
...
@@ -62,46 +76,35 @@ public class CsdnArticleInfoController {
return
Result
.
ok
(
CsdnArticleInfoDTO
.
Converter
.
INSTANCE
.
from
(
this
.
csdnArticleInfoService
.
page
(
pageParm
,
wrapper
)));
return
Result
.
ok
(
CsdnArticleInfoDTO
.
Converter
.
INSTANCE
.
from
(
this
.
csdnArticleInfoService
.
page
(
pageParm
,
wrapper
)));
}
}
@ApiOperation
(
value
=
"新增文章"
,
nickname
=
"新增文章"
)
@ApiOperation
(
value
=
"新增用户"
,
nickname
=
"新增用户"
)
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
CsdnArticleInfoQuery
addInfo
)
{
public
Result
add
(
@RequestBody
CsdnArticleInfoQuery
addInfo
)
{
final
String
userName
=
addInfo
.
getUserName
();
final
String
userName
=
addInfo
.
getUserName
();
final
Integer
addType
=
addInfo
.
getAddType
();
final
String
articleId
=
addInfo
.
getArticleId
();
final
String
articleId
=
addInfo
.
getArticleId
();
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
if
(
StringUtils
.
isNotEmpty
(
userName
)
&&
StringUtils
.
isNotEmpty
(
articleId
))
{
//批量添加
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
articles
=
this
.
csdnArticleInfoService
.
getBlogs
(
userName
);
if
(
addType
==
1
)
{
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
articles
)
{
final
String
[]
split
=
articleId
.
split
(
"\n"
);
if
(
articleId
.
equals
(
article
.
getArticleId
().
toString
()))
{
for
(
String
str
:
split
)
{
//首先查询用户
str
=
str
.
trim
();
CsdnUserInfoQuery
addUserInfo
=
new
CsdnUserInfoQuery
();
if
(
StringUtils
.
isNotEmpty
(
str
))
{
addUserInfo
.
setUserName
(
userName
);
addUserInfo
.
setAddType
(
0
);
csdnUserInfoService
.
add
(
addUserInfo
);
CsdnArticleInfo
csdnArticleInfo
=
new
CsdnArticleInfo
();
CsdnArticleInfo
csdnArticleInfo
=
new
CsdnArticleInfo
();
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"article_id"
,
str
);
wrapper
.
eq
(
"article_id"
,
articleId
);
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnArticleInfo
one
=
this
.
csdnArticleInfoService
.
getOne
(
wrapper
);
final
CsdnArticleInfo
one
=
this
.
csdnArticleInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnArticleInfo
);
csdnArticleInfo
.
setArticleId
(
articleId
);
csdnArticleInfo
.
setArticleId
(
str
);
csdnArticleInfo
.
setUserName
(
userName
);
csdnArticleInfo
.
setArticleUrl
(
"https://blog.csdn.net/"
+
userName
+
"/article/details/"
+
articleId
);
csdnArticleInfo
.
setArticleTitle
(
article
.
getTitle
());
csdnArticleInfo
.
setArticleDescription
(
article
.
getDescription
());
csdnArticleInfo
.
setArticleUrl
(
article
.
getUrl
());
csdnArticleInfo
.
setNickName
(
addUserInfo
.
getNickName
());
this
.
csdnArticleInfoService
.
save
(
csdnArticleInfo
);
this
.
csdnArticleInfoService
.
save
(
csdnArticleInfo
);
}
}
}
break
;
}
}
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
(
"该用户已存在"
);
}
}
}
}
}
}
...
@@ -115,6 +118,8 @@ public class CsdnArticleInfoController {
...
@@ -115,6 +118,8 @@ public class CsdnArticleInfoController {
csdnUserInfo
.
setId
(
query
.
getId
());
csdnUserInfo
.
setId
(
query
.
getId
());
csdnUserInfo
.
setUserName
(
query
.
getUserName
());
csdnUserInfo
.
setUserName
(
query
.
getUserName
());
csdnUserInfo
.
setNickName
(
query
.
getNickName
());
csdnUserInfo
.
setNickName
(
query
.
getNickName
());
csdnUserInfo
.
setArticleUrl
(
query
.
getArticleUrl
());
csdnUserInfo
.
setArticleId
(
query
.
getArticleId
());
return
Result
.
ok
(
this
.
csdnArticleInfoService
.
updateById
(
csdnUserInfo
));
return
Result
.
ok
(
this
.
csdnArticleInfoService
.
updateById
(
csdnUserInfo
));
}
}
...
@@ -127,5 +132,26 @@ public class CsdnArticleInfoController {
...
@@ -127,5 +132,26 @@ public class CsdnArticleInfoController {
wrapper
.
eq
(
"id"
,
id
);
wrapper
.
eq
(
"id"
,
id
);
return
Result
.
ok
(
this
.
csdnArticleInfoService
.
update
(
csdnArticleInfo
,
wrapper
));
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;
...
@@ -11,7 +11,6 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
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.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
@@ -74,45 +73,7 @@ public class CsdnUserController {
...
@@ -74,45 +73,7 @@ public class CsdnUserController {
@ApiOperation
(
value
=
"新增用户"
,
nickname
=
"新增用户"
)
@ApiOperation
(
value
=
"新增用户"
,
nickname
=
"新增用户"
)
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
CsdnUserInfoQuery
addInfo
)
{
public
Result
add
(
@RequestBody
CsdnUserInfoQuery
addInfo
)
{
final
String
userName
=
addInfo
.
getUserName
();
csdnUserInfoService
.
add
(
addInfo
);
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
(
"该用户已存在"
);
}
}
return
Result
.
ok
();
return
Result
.
ok
();
}
}
...
@@ -124,6 +85,7 @@ public class CsdnUserController {
...
@@ -124,6 +85,7 @@ public class CsdnUserController {
csdnUserInfo
.
setUserName
(
query
.
getUserName
());
csdnUserInfo
.
setUserName
(
query
.
getUserName
());
csdnUserInfo
.
setNickName
(
query
.
getNickName
());
csdnUserInfo
.
setNickName
(
query
.
getNickName
());
csdnUserInfo
.
setUserWeight
(
query
.
getUserWeight
());
csdnUserInfo
.
setUserWeight
(
query
.
getUserWeight
());
csdnUserInfo
.
setUserHomeUrl
(
query
.
getUserHomeUrl
());
return
Result
.
ok
(
this
.
csdnUserInfoService
.
updateById
(
csdnUserInfo
));
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> {
...
@@ -18,6 +18,10 @@ public class CsdnArticleInfo extends Model<CsdnArticleInfo> {
private
String
articleId
;
private
String
articleId
;
@ApiModelProperty
(
"文章URL"
)
@ApiModelProperty
(
"文章URL"
)
private
String
articleUrl
;
private
String
articleUrl
;
@ApiModelProperty
(
"文章标题"
)
private
String
articleTitle
;
@ApiModelProperty
(
"文章描述"
)
private
String
articleDescription
;
@ApiModelProperty
(
"用户名称"
)
@ApiModelProperty
(
"用户名称"
)
private
String
userName
;
private
String
userName
;
@ApiModelProperty
(
"用户昵称"
)
@ApiModelProperty
(
"用户昵称"
)
...
...
src/main/java/com/kwan/springbootkwan/entity/dto/CsdnArticleInfoDTO.java
浏览文件 @
9b2611a5
...
@@ -22,6 +22,10 @@ public class CsdnArticleInfoDTO extends Model<CsdnArticleInfoDTO> {
...
@@ -22,6 +22,10 @@ public class CsdnArticleInfoDTO extends Model<CsdnArticleInfoDTO> {
private
String
articleId
;
private
String
articleId
;
@ApiModelProperty
(
"文章URL"
)
@ApiModelProperty
(
"文章URL"
)
private
String
articleUrl
;
private
String
articleUrl
;
@ApiModelProperty
(
"文章标题"
)
private
String
articleTitle
;
@ApiModelProperty
(
"文章描述"
)
private
String
articleDescription
;
@ApiModelProperty
(
"用户名称"
)
@ApiModelProperty
(
"用户名称"
)
private
String
userName
;
private
String
userName
;
@ApiModelProperty
(
"用户昵称"
)
@ApiModelProperty
(
"用户昵称"
)
...
...
src/main/java/com/kwan/springbootkwan/entity/query/CsdnArticleInfoQuery.java
浏览文件 @
9b2611a5
...
@@ -16,6 +16,8 @@ public class CsdnArticleInfoQuery extends BasePage {
...
@@ -16,6 +16,8 @@ public class CsdnArticleInfoQuery extends BasePage {
private
String
nickName
;
private
String
nickName
;
@ApiModelProperty
(
"CSDN文章id"
)
@ApiModelProperty
(
"CSDN文章id"
)
private
String
articleId
;
private
String
articleId
;
@ApiModelProperty
(
"CSDN文章URL"
)
private
String
articleUrl
;
@ApiModelProperty
(
"点赞状态"
)
@ApiModelProperty
(
"点赞状态"
)
private
Integer
likeStatus
=
0
;
private
Integer
likeStatus
=
0
;
@ApiModelProperty
(
"收藏状态"
)
@ApiModelProperty
(
"收藏状态"
)
...
...
src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
浏览文件 @
9b2611a5
...
@@ -24,6 +24,8 @@ public class CsdnUserInfoQuery extends BasePage {
...
@@ -24,6 +24,8 @@ public class CsdnUserInfoQuery extends BasePage {
private
Integer
userWeight
;
private
Integer
userWeight
;
@ApiModelProperty
(
"文章类型"
)
@ApiModelProperty
(
"文章类型"
)
private
String
articleType
;
private
String
articleType
;
@ApiModelProperty
(
"用户主页"
)
private
String
userHomeUrl
;
@ApiModelProperty
(
"添加类型"
)
@ApiModelProperty
(
"添加类型"
)
private
Integer
addType
;
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 {
...
@@ -43,9 +43,11 @@ public class BusinessInfoResponse {
public
Object
fileType
;
public
Object
fileType
;
public
Object
content
;
public
Object
content
;
public
Object
status
;
public
Object
status
;
// public Integer articleId;
public
Object
articleId
;
// public Object top;
public
Object
top
;
// public Object forcePlan;
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.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* csdn文章信息(CsdnArticleInfo)表数据库访问层
*
@Mapper
* @author makejava
public
interface
CsdnArticleInfoMapper
extends
BaseMapper
<
CsdnArticleInfo
>
{
* @since 2023-10-28 01:58:46
*/
public
interface
CsdnArticleInfoDao
extends
BaseMapper
<
CsdnArticleInfo
>
{
}
}
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
浏览文件 @
9b2611a5
...
@@ -26,14 +26,8 @@ public class CsdnSchedule {
...
@@ -26,14 +26,8 @@ public class CsdnSchedule {
public
void
execute
()
{
public
void
execute
()
{
log
.
info
(
"execute task is running ... ..."
);
log
.
info
(
"execute task is running ... ..."
);
csdnService
.
multiTriplet
();
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
();
csdnAutoReplyService
.
commentSelf
();
log
.
info
(
"execute
Reply
task is finish ... ..."
);
log
.
info
(
"execute task is finish ... ..."
);
}
}
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
@Scheduled
(
cron
=
"0 0/30 * * * ?"
)
...
@@ -43,17 +37,11 @@ public class CsdnSchedule {
...
@@ -43,17 +37,11 @@ public class CsdnSchedule {
log
.
info
(
"executeInit task is finish ... ..."
);
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 * * ?"
)
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
resetTripletDayInfo
()
{
public
void
resetTripletDayInfo
()
{
log
.
info
(
"resetTripletDayInfo task is running ... ..."
);
log
.
info
(
"resetTripletDayInfo task is running ... ..."
);
//新增当前天的新的一条数据
//新增当前天的新的一条数据
csdnUserInfoService
.
resetUserDayStatus
();
csdnTripletDayInfoService
.
todayInfo
();
csdnTripletDayInfoService
.
todayInfo
();
log
.
info
(
"resetTripletDayInfo task is finish ... ..."
);
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;
...
@@ -2,7 +2,6 @@ package com.kwan.springbootkwan.schedule;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -17,9 +16,25 @@ import org.springframework.stereotype.Component;
...
@@ -17,9 +16,25 @@ import org.springframework.stereotype.Component;
@Slf4j
@Slf4j
public
class
ScheduleTest
{
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 * * * * ?")
// @Scheduled(cron = "0/10 * * * * ?")
public
void
execute
()
{
public
void
execute2
()
{
log
.
info
(
"Scheduled task is running ... ..."
);
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;
...
@@ -2,6 +2,9 @@ package com.kwan.springbootkwan.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
java.util.List
;
/**
/**
* csdn文章信息(CsdnArticleInfo)表服务接口
* csdn文章信息(CsdnArticleInfo)表服务接口
...
@@ -11,5 +14,20 @@ import com.kwan.springbootkwan.entity.CsdnArticleInfo;
...
@@ -11,5 +14,20 @@ import com.kwan.springbootkwan.entity.CsdnArticleInfo;
*/
*/
public
interface
CsdnArticleInfoService
extends
IService
<
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
;
package
com.kwan.springbootkwan.service
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
/**
/**
* csdn博客自动化
* csdn博客自动化
...
@@ -22,4 +24,12 @@ public interface CsdnService {
...
@@ -22,4 +24,12 @@ public interface CsdnService {
* 多人三连
* 多人三连
*/
*/
void
multiTriplet
();
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;
...
@@ -2,6 +2,7 @@ package com.kwan.springbootkwan.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery
;
/**
/**
* csdn用户信息(CsdnUserInfo)表服务接口
* csdn用户信息(CsdnUserInfo)表服务接口
...
@@ -26,5 +27,11 @@ public interface CsdnUserInfoService extends IService<CsdnUserInfo> {
...
@@ -26,5 +27,11 @@ public interface CsdnUserInfoService extends IService<CsdnUserInfo> {
*/
*/
void
resetCsdnUserInfo
(
CsdnUserInfo
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
;
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.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.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.mapper.CsdnArticleInfoMapper
;
import
com.kwan.springbootkwan.service.CsdnArticleInfoService
;
import
com.kwan.springbootkwan.service.CsdnArticleInfoService
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
/**
* csdn文章信息(CsdnArticleInfo)表服务实现类
* csdn文章信息(CsdnArticleInfo)表服务实现类
*
*
...
@@ -13,7 +22,68 @@ import org.springframework.stereotype.Service;
...
@@ -13,7 +22,68 @@ import org.springframework.stereotype.Service;
* @since 2023-10-28 01:58:46
* @since 2023-10-28 01:58:46
*/
*/
@Service
(
"csdnArticleInfoService"
)
@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;
...
@@ -10,7 +10,7 @@ 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.service.CsdnArticleService
;
import
com.kwan.springbootkwan.service.CsdnArticle
Info
Service
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnCommentService
;
import
com.kwan.springbootkwan.service.CsdnService
;
import
com.kwan.springbootkwan.service.CsdnService
;
...
@@ -38,7 +38,7 @@ public class CsdnAutoReplyServiceImpl implements CsdnAutoReplyService {
...
@@ -38,7 +38,7 @@ public class CsdnAutoReplyServiceImpl implements CsdnAutoReplyService {
@Autowired
@Autowired
private
CsdnService
csdnService
;
private
CsdnService
csdnService
;
@Autowired
@Autowired
private
CsdnArticle
Service
csdnArticle
Service
;
private
CsdnArticle
InfoService
csdnArticleInfo
Service
;
@Autowired
@Autowired
private
CsdnCommentService
csdnCommentService
;
private
CsdnCommentService
csdnCommentService
;
@Autowired
@Autowired
...
@@ -46,7 +46,7 @@ public class CsdnAutoReplyServiceImpl implements CsdnAutoReplyService {
...
@@ -46,7 +46,7 @@ public class CsdnAutoReplyServiceImpl implements CsdnAutoReplyService {
@Override
@Override
public
void
commentSelf
()
{
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
))
{
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
list
)
{
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
list
)
{
final
String
type
=
article
.
getType
();
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;
...
@@ -2,11 +2,12 @@ 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.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnTripletDayInfo
;
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
;
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.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
;
...
@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
...
@@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
@Slf4j
@Slf4j
...
@@ -34,7 +36,7 @@ public class CsdnServiceImpl implements CsdnService {
...
@@ -34,7 +36,7 @@ public class CsdnServiceImpl implements CsdnService {
@Autowired
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
private
CsdnUserInfoService
csdnUserInfoService
;
@Autowired
@Autowired
private
CsdnArticle
Service
csdnArticle
Service
;
private
CsdnArticle
InfoService
csdnArticleInfo
Service
;
@Autowired
@Autowired
private
CsdnCollectService
csdnCollectService
;
private
CsdnCollectService
csdnCollectService
;
@Autowired
@Autowired
...
@@ -45,7 +47,7 @@ public class CsdnServiceImpl implements CsdnService {
...
@@ -45,7 +47,7 @@ public class CsdnServiceImpl implements CsdnService {
@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
=
csdnArticle
Info
Service
.
getArticles
(
username
);
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
final
int
size
=
list
.
size
();
final
int
size
=
list
.
size
();
numOfArticlesPerPerson
=
size
<
numOfArticlesPerPerson
?
size
:
numOfArticlesPerPerson
;
numOfArticlesPerPerson
=
size
<
numOfArticlesPerPerson
?
size
:
numOfArticlesPerPerson
;
...
@@ -58,6 +60,41 @@ public class CsdnServiceImpl implements CsdnService {
...
@@ -58,6 +60,41 @@ public class CsdnServiceImpl implements CsdnService {
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
continue
;
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
CsdnTripletDayInfo
csdnTripletDayInfo
=
csdnTripletDayInfoService
.
todayInfo
();
final
String
urlInfo
=
article
.
getUrl
();
final
String
urlInfo
=
article
.
getUrl
();
...
@@ -82,14 +119,19 @@ public class CsdnServiceImpl implements CsdnService {
...
@@ -82,14 +119,19 @@ public class CsdnServiceImpl implements CsdnService {
if
(!
collect
)
{
if
(!
collect
)
{
csdnCollectService
.
collect
(
article
,
csdnUserInfo
,
csdnTripletDayInfo
);
csdnCollectService
.
collect
(
article
,
csdnUserInfo
,
csdnTripletDayInfo
);
}
}
csdnTripletDayInfo
.
setUpdateTime
(
new
Date
());
csdnTripletDayInfo
.
setUpdateTime
(
new
Date
());
csdnTripletDayInfoService
.
updateById
(
csdnTripletDayInfo
);
csdnTripletDayInfoService
.
updateById
(
csdnTripletDayInfo
);
csdnUserInfo
.
setUpdateTime
(
new
Date
());
csdnUserInfo
.
setUpdateTime
(
new
Date
());
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
csdnUserInfoService
.
updateById
(
csdnUserInfo
);
}
}
}
csdnArticleInfo
.
setUpdateTime
(
new
Date
());
csdnArticleInfo
.
setLikeStatus
(
csdnUserInfo
.
getLikeStatus
());
csdnArticleInfo
.
setCollectStatus
(
csdnUserInfo
.
getCollectStatus
());
csdnArticleInfo
.
setCommentStatus
(
csdnUserInfo
.
getCommentStatus
());
csdnArticleInfoService
.
updateById
(
csdnArticleInfo
);
}
@Override
@Override
public
void
multiTriplet
()
{
public
void
multiTriplet
()
{
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
浏览文件 @
9b2611a5
...
@@ -4,15 +4,17 @@ import cn.hutool.core.collection.CollectionUtil;
...
@@ -4,15 +4,17 @@ import cn.hutool.core.collection.CollectionUtil;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
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.query.CsdnUserInfoQuery
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
import
com.kwan.springbootkwan.enums.CollectStatus
;
import
com.kwan.springbootkwan.enums.CollectStatus
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.CommentStatus
;
import
com.kwan.springbootkwan.enums.LikeStatus
;
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.CsdnArticle
Info
Service
;
import
com.kwan.springbootkwan.service.CsdnCollectService
;
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.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -31,7 +33,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
...
@@ -31,7 +33,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
@Autowired
@Autowired
private
CsdnCollectService
csdnCollectService
;
private
CsdnCollectService
csdnCollectService
;
@Autowired
@Autowired
private
CsdnArticle
Service
csdnArticle
Service
;
private
CsdnArticle
InfoService
csdnArticleInfo
Service
;
@Override
@Override
public
void
resetAllCurrentStatus
()
{
public
void
resetAllCurrentStatus
()
{
...
@@ -50,7 +52,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
...
@@ -50,7 +52,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
String
userName
=
csdnUserInfo
.
getUserName
();
final
Integer
commentStatus
=
csdnUserInfo
.
getCommentStatus
();
final
Integer
commentStatus
=
csdnUserInfo
.
getCommentStatus
();
final
String
articleType
=
csdnUserInfo
.
getArticleType
();
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
))
{
if
(
CollectionUtil
.
isNotEmpty
(
articles
))
{
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
String
type
=
article
.
getType
();
final
String
type
=
article
.
getType
();
...
@@ -75,6 +77,48 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
...
@@ -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
@Override
public
void
resetUserDayStatus
()
{
public
void
resetUserDayStatus
()
{
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
...
@@ -83,7 +127,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
...
@@ -83,7 +127,7 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
if
(
CollectionUtil
.
isNotEmpty
(
list
))
{
for
(
CsdnUserInfo
csdnUserInfo
:
list
)
{
for
(
CsdnUserInfo
csdnUserInfo
:
list
)
{
final
String
userName
=
csdnUserInfo
.
getUserName
();
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
))
{
if
(
CollectionUtil
.
isNotEmpty
(
articles
))
{
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
String
type
=
article
.
getType
();
final
String
type
=
article
.
getType
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录