Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
bd6db650
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看板
提交
bd6db650
编写于
10月 29, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
{query}
上级
fcafd617
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
140 addition
and
41 deletion
+140
-41
src/main/java/com/kwan/springbootkwan/controller/CsdnArticleInfoController.java
.../springbootkwan/controller/CsdnArticleInfoController.java
+24
-18
src/main/java/com/kwan/springbootkwan/controller/CsdnController.java
...va/com/kwan/springbootkwan/controller/CsdnController.java
+37
-3
src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java
...ringbootkwan/controller/CsdnTripletDayInfoController.java
+1
-0
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
...n/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
+1
-1
src/main/java/com/kwan/springbootkwan/service/CsdnArticleInfoService.java
...m/kwan/springbootkwan/service/CsdnArticleInfoService.java
+14
-0
src/main/java/com/kwan/springbootkwan/service/CsdnService.java
...ain/java/com/kwan/springbootkwan/service/CsdnService.java
+1
-1
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
+27
-3
src/main/java/com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
...com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
+4
-8
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
.../springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
+24
-7
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/CsdnArticleInfoController.java
浏览文件 @
bd6db650
package
com.kwan.springbootkwan.controller
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
...
...
@@ -90,19 +91,16 @@ public class CsdnArticleInfoController {
addUserInfo
.
setUserName
(
userName
);
addUserInfo
.
setAddType
(
0
);
csdnUserInfoService
.
add
(
addUserInfo
);
CsdnArticleInfo
csdnArticleInfo
=
new
CsdnArticleInfo
();
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
)
{
CsdnArticleInfo
csdnArticleInfo
=
this
.
csdnArticleInfoService
.
getArticleByArticleId
(
articleId
);
if
(
csdnArticleInfo
==
null
)
{
csdnArticleInfo
=
new
CsdnArticleInfo
();
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
);
this
.
csdnArticleInfoService
.
save
Article
(
csdnArticleInfo
);
}
break
;
}
...
...
@@ -136,19 +134,27 @@ public class CsdnArticleInfoController {
@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
();
CsdnUserInfo
csdnUserInfo
=
csdnUserInfoService
.
getUserByUserName
(
userName
);
final
CsdnArticleInfo
csdnArticleInfo
=
this
.
csdnArticleInfoService
.
getArticleByArticleId
(
articleId
.
toString
());
if
(
csdnArticleInfo
!=
null
)
{
final
String
userName
=
csdnArticleInfo
.
getUserName
();
CsdnUserInfo
csdnUserInfo
=
csdnUserInfoService
.
getUserByUserName
(
userName
);
BusinessInfoResponse
.
ArticleData
.
Article
article
=
new
BusinessInfoResponse
.
ArticleData
.
Article
();
article
.
setDescription
(
one
.
getArticleDescription
());
article
.
setTitle
(
one
.
getArticleTitle
());
article
.
setUrl
(
one
.
getArticleUrl
());
csdnService
.
tripletByArticle
(
csdnUserInfo
,
article
,
one
);
article
.
setDescription
(
csdnArticleInfo
.
getArticleDescription
());
article
.
setTitle
(
csdnArticleInfo
.
getArticleTitle
());
article
.
setUrl
(
csdnArticleInfo
.
getArticleUrl
());
csdnService
.
tripletByArticle
(
csdnUserInfo
,
article
,
csdnArticleInfo
);
}
return
Result
.
ok
(
"单篇文章三连完成"
);
}
@ApiOperation
(
value
=
"多条blog三连"
,
nickname
=
"多条blog三连"
)
@PostMapping
(
"/multiTriplet"
)
public
Result
multiTriplet
(
@RequestBody
List
<
String
>
articleIds
)
{
if
(
CollectionUtil
.
isNotEmpty
(
articleIds
))
{
for
(
String
articleId
:
articleIds
)
{
triplet
(
Integer
.
valueOf
(
articleId
));
}
}
return
Result
.
ok
(
"重置多个人员新博客状态完成"
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/controller/CsdnController.java
浏览文件 @
bd6db650
package
com.kwan.springbootkwan.controller
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.service.CsdnAutoReplyService
;
...
...
@@ -11,9 +12,12 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Objects
;
@Slf4j
...
...
@@ -40,12 +44,23 @@ public class CsdnController {
}
@ApiOperation
(
value
=
"多人三连"
,
nickname
=
"多人三连"
)
@GetMapping
(
"/multiTriplet"
)
public
Result
multiTriplet
()
{
csdnService
.
multiTriplet
();
@PostMapping
(
"/multiTriplet"
)
public
Result
multiTriplet
(
@RequestBody
List
<
String
>
userNames
)
{
if
(
CollectionUtil
.
isNotEmpty
(
userNames
))
{
for
(
String
userName
:
userNames
)
{
singleTriplet
(
userName
);
}
}
return
Result
.
ok
(
"多人三连完成"
);
}
@ApiOperation
(
value
=
"全员三连"
,
nickname
=
"全员三连"
)
@GetMapping
(
"/allTriplet"
)
public
Result
allTriplet
()
{
csdnService
.
allTriplet
();
return
Result
.
ok
(
"全员三连完成"
);
}
@ApiOperation
(
value
=
"自动回复"
,
nickname
=
"自动回复"
)
@GetMapping
(
"/autoReply"
)
public
Result
autoReply
()
{
...
...
@@ -70,10 +85,29 @@ public class CsdnController {
return
Result
.
ok
(
"重置指定人员新博客状态完成"
);
}
@ApiOperation
(
value
=
"重置多个人员新博客"
,
nickname
=
"重置多个人员新博客"
)
@PostMapping
(
"/resetCsdnUserInfo"
)
public
Result
resetCsdnUserInfo
(
@RequestBody
List
<
String
>
userNames
)
{
if
(
CollectionUtil
.
isNotEmpty
(
userNames
))
{
for
(
String
userName
:
userNames
)
{
resetCsdnUserInfo
(
userName
);
}
}
return
Result
.
ok
(
"重置多个人员新博客状态完成"
);
}
@ApiOperation
(
value
=
"重置新一天用户状态"
,
nickname
=
"重置新一天用户状态"
)
@GetMapping
(
"/resetUserDayStatus"
)
public
Result
resetUserDayStatus
()
{
csdnUserInfoService
.
resetUserDayStatus
();
return
Result
.
ok
(
"重置新一天用户状态完成"
);
}
@ApiOperation
(
value
=
"给指定人员添加10篇博客"
,
nickname
=
"给指定人员添加10篇博客"
)
@GetMapping
(
"/add10Blog"
)
public
Result
add10Blog
(
@Param
(
"username"
)
String
username
)
{
csdnUserInfoService
.
add10Blog
(
username
);
return
Result
.
ok
(
"给指定人员添加10篇博客完成"
);
}
}
src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java
浏览文件 @
bd6db650
...
...
@@ -26,6 +26,7 @@ import java.util.Objects;
@RestController
@RequestMapping
(
"/dayInfo"
)
public
class
CsdnTripletDayInfoController
{
@Autowired
private
CsdnTripletDayInfoService
csdnTripletDayInfoService
;
...
...
src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java
浏览文件 @
bd6db650
...
...
@@ -25,7 +25,7 @@ public class CsdnSchedule {
@Scheduled
(
cron
=
"0 0 8,10,12,14,16,18,20 * * ?"
)
public
void
execute
()
{
log
.
info
(
"execute task is running ... ..."
);
csdnService
.
multi
Triplet
();
csdnService
.
all
Triplet
();
csdnAutoReplyService
.
commentSelf
();
log
.
info
(
"execute task is finish ... ..."
);
}
...
...
src/main/java/com/kwan/springbootkwan/service/CsdnArticleInfoService.java
浏览文件 @
bd6db650
...
...
@@ -13,6 +13,20 @@ import java.util.List;
* @since 2023-10-28 01:58:46
*/
public
interface
CsdnArticleInfoService
extends
IService
<
CsdnArticleInfo
>
{
/**
* 通过文章id获取文章信息
*
* @return
*/
CsdnArticleInfo
getArticleByArticleId
(
String
articleId
);
/**
* 保存文章Blog
*
* @return
*/
void
saveArticle
(
CsdnArticleInfo
csdnArticleInfo
);
/**
* 获取最新的10篇文章
...
...
src/main/java/com/kwan/springbootkwan/service/CsdnService.java
浏览文件 @
bd6db650
...
...
@@ -23,7 +23,7 @@ public interface CsdnService {
/**
* 多人三连
*/
void
multi
Triplet
();
void
all
Triplet
();
/**
* 根据文章三连
...
...
src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java
浏览文件 @
bd6db650
...
...
@@ -54,5 +54,12 @@ public interface CsdnUserInfoService extends IService<CsdnUserInfo> {
*/
void
add
(
CsdnUserInfoQuery
addInfo
);
/**
* 给指定人员添加10篇博客
*
* @param username
*/
void
add10Blog
(
String
username
);
}
src/main/java/com/kwan/springbootkwan/service/impl/CsdnArticleInfoServiceImpl.java
浏览文件 @
bd6db650
...
...
@@ -3,6 +3,7 @@ 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Objects
;
/**
* csdn文章信息(CsdnArticleInfo)表服务实现类
...
...
@@ -29,14 +31,37 @@ public class CsdnArticleInfoServiceImpl extends ServiceImpl<CsdnArticleInfoMappe
@Value
(
"${csdn.url.user_article_url}"
)
private
String
url
;
@Override
public
CsdnArticleInfo
getArticleByArticleId
(
String
articleId
)
{
QueryWrapper
<
CsdnArticleInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"article_id"
,
articleId
)
.
last
(
"limit 1"
);
return
this
.
getOne
(
wrapper
);
}
@Override
public
void
saveArticle
(
CsdnArticleInfo
add
)
{
final
String
articleId
=
add
.
getArticleId
();
CsdnArticleInfo
csdnArticleInfo
=
this
.
getArticleByArticleId
(
articleId
);
if
(
Objects
.
isNull
(
csdnArticleInfo
))
{
csdnArticleInfo
=
new
CsdnArticleInfo
();
csdnArticleInfo
.
setArticleId
(
articleId
);
csdnArticleInfo
.
setUserName
(
add
.
getUserName
());
csdnArticleInfo
.
setArticleTitle
(
add
.
getArticleTitle
());
csdnArticleInfo
.
setArticleDescription
(
add
.
getArticleDescription
());
csdnArticleInfo
.
setArticleUrl
(
add
.
getArticleUrl
());
csdnArticleInfo
.
setNickName
(
add
.
getNickName
());
this
.
save
(
csdnArticleInfo
);
}
}
@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
)
...
...
@@ -65,7 +90,6 @@ public class CsdnArticleInfoServiceImpl extends ServiceImpl<CsdnArticleInfoMappe
.
form
(
"page"
,
1
)
.
form
(
"size"
,
10
)
.
form
(
"businessType"
,
"blog"
)
// .form("blogType", "ViewCount")
.
form
(
"noMore"
,
false
)
.
form
(
"username"
,
username
)
.
execute
();
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnServiceImpl.java
浏览文件 @
bd6db650
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
;
...
...
@@ -61,17 +60,14 @@ public class CsdnServiceImpl implements CsdnService {
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
csdnArticleInfo
=
this
.
csdnArticleInfoService
.
getArticleByArticleId
(
article
.
getArticleId
().
toString
());
if
(
Objects
.
isNull
(
csdnArticleInfo
))
{
csdnArticleInfo
=
new
CsdnArticleInfo
();
csdnArticleInfo
.
setArticleId
(
article
.
getArticleId
().
toString
());
csdnArticleInfo
.
setArticleUrl
(
articleUrl
);
...
...
@@ -79,7 +75,7 @@ public class CsdnServiceImpl implements CsdnService {
csdnArticleInfo
.
setArticleDescription
(
article
.
getDescription
());
csdnArticleInfo
.
setUserName
(
username
);
csdnArticleInfo
.
setNickName
(
csdnUserInfo
.
getNickName
());
this
.
csdnArticleInfoService
.
save
(
csdnArticleInfo
);
this
.
csdnArticleInfoService
.
save
Article
(
csdnArticleInfo
);
}
this
.
tripletByArticle
(
csdnUserInfo
,
article
,
csdnArticleInfo
);
}
...
...
@@ -134,7 +130,7 @@ public class CsdnServiceImpl implements CsdnService {
}
@Override
public
void
multi
Triplet
()
{
public
void
all
Triplet
()
{
final
List
<
CsdnUserInfo
>
allUser
=
csdnUserInfoService
.
getAllUser
();
if
(
CollectionUtil
.
isNotEmpty
(
allUser
))
{
for
(
CsdnUserInfo
csdnUserInfo
:
allUser
)
{
...
...
src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java
浏览文件 @
bd6db650
...
...
@@ -4,6 +4,7 @@ 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.constant.CsdnConstant
;
import
com.kwan.springbootkwan.entity.CsdnArticleInfo
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery
;
import
com.kwan.springbootkwan.entity.resp.BusinessInfoResponse
;
...
...
@@ -20,15 +21,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Objects
;
/**
* csdn用户信息(CsdnUserInfo)表服务实现类
*
* @author makejava
* @since 2023-10-23 16:03:14
*/
@Service
(
"csdnUserInfoService"
)
public
class
CsdnUserInfoServiceImpl
extends
ServiceImpl
<
CsdnUserInfoMapper
,
CsdnUserInfo
>
implements
CsdnUserInfoService
{
@Autowired
private
CsdnCollectService
csdnCollectService
;
@Autowired
...
...
@@ -71,7 +68,8 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
final
BusinessInfoResponse
.
ArticleData
.
Article
article
=
articles
.
get
(
0
);
final
String
type
=
article
.
getType
();
if
(
StringUtils
.
equals
(
type
,
CsdnConstant
.
ARTICLE_TYPE
))
{
final
String
articleId
=
article
.
getArticleId
().
toString
();
final
String
articleUrl
=
article
.
getUrl
();
String
articleId
=
articleUrl
.
substring
(
articleUrl
.
lastIndexOf
(
"/"
)
+
1
);
final
Boolean
collect
=
csdnCollectService
.
isCollect
(
articleId
,
csdnUserInfo
);
if
(!
collect
||
CommentStatus
.
COMMENT_TOO_FAST
.
getCode
().
equals
(
commentStatus
)
||
!
StringUtils
.
equals
(
articleType
,
type
))
{
csdnUserInfo
.
setLikeStatus
(
LikeStatus
.
UN_PROCESSED
.
getCode
());
...
...
@@ -125,6 +123,25 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
}
}
@Override
public
void
add10Blog
(
String
username
)
{
final
CsdnUserInfo
csdnUserInfo
=
this
.
getUserByUserName
(
username
);
final
List
<
BusinessInfoResponse
.
ArticleData
.
Article
>
blogs
=
csdnArticleInfoService
.
getBlogs
(
username
);
for
(
BusinessInfoResponse
.
ArticleData
.
Article
article
:
blogs
)
{
CsdnArticleInfo
csdnArticleInfo
=
this
.
csdnArticleInfoService
.
getArticleByArticleId
(
article
.
getArticleId
().
toString
());
if
(
Objects
.
isNull
(
csdnArticleInfo
))
{
csdnArticleInfo
=
new
CsdnArticleInfo
();
csdnArticleInfo
.
setArticleId
(
article
.
getArticleId
().
toString
());
csdnArticleInfo
.
setArticleUrl
(
article
.
getUrl
());
csdnArticleInfo
.
setArticleTitle
(
article
.
getTitle
());
csdnArticleInfo
.
setArticleDescription
(
article
.
getDescription
());
csdnArticleInfo
.
setUserName
(
username
);
csdnArticleInfo
.
setNickName
(
csdnUserInfo
.
getNickName
());
this
.
csdnArticleInfoService
.
saveArticle
(
csdnArticleInfo
);
}
}
}
@Override
public
void
resetUserDayStatus
()
{
final
List
<
CsdnUserInfo
>
allUser
=
this
.
getAllUser
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录