From 6e69cf7c1bc83a8a84a51ee9a76273a9697913d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Fri, 27 Oct 2023 13:32:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CsdnController.java | 35 +++++++++---- .../CsdnTripletDayInfoController.java | 16 ++---- .../controller/CsdnUserController.java | 30 +++-------- .../entity/CsdnTripletDayInfo.java | 25 ++++------ .../springbootkwan/entity/CsdnUserInfo.java | 50 ++++++------------- .../entity/dto/CsdnTripletDayInfoDTO.java | 20 ++++---- .../entity/dto/CsdnUserInfoDTO.java | 49 ++++++------------ .../entity/query/CsdnTripletDayInfoQuery.java | 11 ++-- .../entity/query/CsdnUserInfoQuery.java | 41 +++++---------- .../springbootkwan/schedule/CsdnSchedule.java | 4 +- .../service/CsdnUserInfoService.java | 8 ++- .../service/impl/CsdnCollectServiceImpl.java | 4 -- .../service/impl/CsdnCommentServiceImpl.java | 5 -- .../service/impl/CsdnUserInfoServiceImpl.java | 45 +++++++++-------- 14 files changed, 145 insertions(+), 198 deletions(-) diff --git a/src/main/java/com/kwan/springbootkwan/controller/CsdnController.java b/src/main/java/com/kwan/springbootkwan/controller/CsdnController.java index 979f42c..7c0f1f0 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/CsdnController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/CsdnController.java @@ -6,6 +6,8 @@ import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.service.CsdnAutoReplyService; 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.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,7 @@ import java.util.Objects; @Slf4j @RestController +@Api(tags = "csdn三连用户管理") @RequestMapping("/csdn") public class CsdnController { @@ -27,6 +30,7 @@ public class CsdnController { @Autowired private CsdnUserInfoService csdnUserInfoService; + @ApiOperation(value = "单人三连", nickname = "单人三连") @GetMapping("/singleTriplet") public Result singleTriplet(@Param("username") String username) { QueryWrapper wrapper = new QueryWrapper<>(); @@ -39,33 +43,44 @@ public class CsdnController { return Result.ok("单人三连完成"); } + @ApiOperation(value = "多人三连", nickname = "多人三连") @GetMapping("/multiTriplet") public Result multiTriplet() { csdnService.multiTriplet(); return Result.ok("多人三连完成"); } + @ApiOperation(value = "自动回复", nickname = "自动回复") @GetMapping("/autoReply") public Result autoReply() { csdnAutoReplyService.commentSelf(); return Result.ok("自动回复完成"); } - @GetMapping("/resetCurrentStatus") - public Result resetCurrentStatus() { - csdnUserInfoService.resetCurrentStatus(); - return Result.ok("重置新博客状态完成"); + @ApiOperation(value = "重置全员新博客状态", nickname = "重置全员新博客状态") + @GetMapping("/resetAllCurrentStatus") + public Result resetAllCurrentStatus() { + csdnUserInfoService.resetAllCurrentStatus(); + return Result.ok("重置全员新博客状态完成"); } + @ApiOperation(value = "重置指定人员新博客状态", nickname = "重置指定人员新博客状态") + @GetMapping("/resetCsdnUserInfo") + public Result resetCsdnUserInfo(@Param("username") String username) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("is_delete", 0); + wrapper.eq("user_name", username).last("limit 1"); + final CsdnUserInfo csdnUserInfo = csdnUserInfoService.getOne(wrapper); + if (Objects.nonNull(csdnUserInfo)) { + csdnUserInfoService.resetCsdnUserInfo(csdnUserInfo); + } + return Result.ok("重置指定人员新博客状态完成"); + } + + @ApiOperation(value = "重置新一天用户状态", nickname = "重置新一天用户状态") @GetMapping("/resetUserDayStatus") public Result resetUserDayStatus() { csdnUserInfoService.resetUserDayStatus(); return Result.ok("重置新一天用户状态完成"); } - - @GetMapping("/resetDayStatus") - public Result resetDayStatus() { - csdnUserInfoService.resetUserDayStatus(); - return Result.ok("重置新一天状态完成"); - } } diff --git a/src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java b/src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java index c0d588c..a9d3350 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/CsdnTripletDayInfoController.java @@ -8,6 +8,8 @@ import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.entity.dto.CsdnTripletDayInfoDTO; import com.kwan.springbootkwan.entity.query.CsdnTripletDayInfoQuery; import com.kwan.springbootkwan.service.CsdnTripletDayInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -19,12 +21,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Objects; -/** - * 每日三连监控(CsdnTripletDayInfo)表控制层 - * - * @author makejava - * @since 2023-10-26 20:55:30 - */ + +@Api(tags = "csdn每日三连监控") @RestController @RequestMapping("/dayInfo") public class CsdnTripletDayInfoController { @@ -36,11 +34,7 @@ public class CsdnTripletDayInfoController { return Result.ok(csdnTripletDayInfoService.todayInfo()); } - /** - * 分页查询所有数据 - * - * @return 所有数据 - */ + @ApiOperation(value = "分页查询所有数据", nickname = "分页查询所有数据") @PostMapping("/page") public Result selectAll(@RequestBody CsdnTripletDayInfoQuery query) { final Date startDate = query.getStartDate(); diff --git a/src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java b/src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java index 64a68ba..ecc4edb 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java @@ -7,6 +7,8 @@ import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.entity.dto.CsdnUserInfoDTO; import com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery; 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; @@ -21,17 +23,15 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Objects; @Slf4j +@Api(tags = "csdn每日三连监控") @RestController @RequestMapping("/csdn/user") public class CsdnUserController { + @Autowired private CsdnUserInfoService csdnUserInfoService; - /** - * 分页查询所有数据 - * - * @return 所有数据 - */ + @ApiOperation(value = "分页查询所有数据", nickname = "分页查询所有数据") @PostMapping("/page") public Result selectAll(@RequestBody CsdnUserInfoQuery query) { final Integer userWeight = query.getUserWeight(); @@ -71,11 +71,7 @@ public class CsdnUserController { return Result.ok(CsdnUserInfoDTO.Converter.INSTANCE.from(this.csdnUserInfoService.page(pageParm, wrapper))); } - /** - * 新增用户 - * - * @return 所有数据 - */ + @ApiOperation(value = "新增用户", nickname = "新增用户") @PostMapping("/add") public Result add(@RequestBody CsdnUserInfoQuery addInfo) { final String userName = addInfo.getUserName(); @@ -119,12 +115,7 @@ public class CsdnUserController { return Result.ok(); } - /** - * 更新用户 - * - * @param query - * @return - */ + @ApiOperation(value = "更新用户", nickname = "更新用户") @PostMapping("/update") public Result update(@RequestBody CsdnUserInfoQuery query) { CsdnUserInfo csdnUserInfo = new CsdnUserInfo(); @@ -135,12 +126,7 @@ public class CsdnUserController { return Result.ok(this.csdnUserInfoService.updateById(csdnUserInfo)); } - /** - * 删除用户 - * - * @param id - * @return - */ + @ApiOperation(value = "删除用户", nickname = "删除用户") @GetMapping("/delete") public Result delete(@RequestParam("id") Integer id) { CsdnUserInfo csdnUserInfo = new CsdnUserInfo(); diff --git a/src/main/java/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java b/src/main/java/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java index 40aa5fa..4b66fad 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java +++ b/src/main/java/com/kwan/springbootkwan/entity/CsdnTripletDayInfo.java @@ -3,34 +3,31 @@ package com.kwan.springbootkwan.entity; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; -/** - * 每日三连监控(CsdnTripletDayInfo)表实体类 - * - * @author makejava - * @since 2023-10-26 20:55:31 - */ @Data +@ApiModel("csdn每日三连监控类") @TableName("csdn_triplet_day_info") public class CsdnTripletDayInfo extends Model { - //主键id + @ApiModelProperty("主键id") private Integer id; - //三连日期 + @ApiModelProperty("三连日期") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date tripletDate; - //点赞数量 + @ApiModelProperty("点赞数量") private Integer likeNum; - //收藏数量 + @ApiModelProperty("收藏数量") private Integer collectNum; - //评论数量 + @ApiModelProperty("评论数量") private Integer commentNum; - //创建时间 + @ApiModelProperty("创建时间") private Date createTime; - //更新时间 + @ApiModelProperty("更新时间") private Date updateTime; - //逻辑删除,0未删除,1已删除 + @ApiModelProperty("逻辑删除,0未删除,1已删除") private Integer isDelete; } \ No newline at end of file diff --git a/src/main/java/com/kwan/springbootkwan/entity/CsdnUserInfo.java b/src/main/java/com/kwan/springbootkwan/entity/CsdnUserInfo.java index ee35249..707cd83 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/CsdnUserInfo.java +++ b/src/main/java/com/kwan/springbootkwan/entity/CsdnUserInfo.java @@ -2,55 +2,37 @@ package com.kwan.springbootkwan.entity; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; import java.util.Date; @Data +@ApiModel("csdn用户类") @TableName("csdn_user_info") -public class CsdnUserInfo extends Model { - /** - * 主键id - */ +public class CsdnUserInfo extends Model implements Serializable { + @ApiModelProperty("主键id") private Integer id; - /** - * 用户code - */ + @ApiModelProperty("用户code") private String userName; - /** - * CSDN用户名称 - */ + @ApiModelProperty("CSDN用户名称") private String nickName; - /** - * 点赞状态 - */ + @ApiModelProperty("点赞状态") private Integer likeStatus; - /** - * 收藏状态 - */ + @ApiModelProperty("收藏状态") private Integer collectStatus; - /** - * 评论状态 - */ + @ApiModelProperty("评论状态") private Integer commentStatus; - /** - * 用户权重 - */ + @ApiModelProperty("用户权重") private Integer userWeight; - /** - * 文章类型 - */ + @ApiModelProperty("文章类型") private String articleType; - /** - * 创建时间 - */ + @ApiModelProperty("创建时间") private Date createTime; - /** - * 更新时间 - */ + @ApiModelProperty("更新时间") private Date updateTime; - /** - * 逻辑删除,0未删除,1已删除 - */ + @ApiModelProperty("逻辑删除,0未删除,1已删除") private Integer isDelete; } \ No newline at end of file diff --git a/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnTripletDayInfoDTO.java b/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnTripletDayInfoDTO.java index 263ce62..4801099 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnTripletDayInfoDTO.java +++ b/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnTripletDayInfoDTO.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.activerecord.Model; import com.fasterxml.jackson.annotation.JsonFormat; import com.kwan.springbootkwan.entity.CsdnTripletDayInfo; import com.kwan.springbootkwan.mapstruct.FromConverter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; @@ -11,25 +13,25 @@ import org.mapstruct.factory.Mappers; import java.util.Date; - @Data +@ApiModel("csdn三连监控DTO") public class CsdnTripletDayInfoDTO extends Model { - //主键id + @ApiModelProperty("主键id") private Integer id; - //三连日期 + @ApiModelProperty("三连日期") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date tripletDate; - //点赞数量 + @ApiModelProperty("点赞数量") private Integer likeNum; - //收藏数量 + @ApiModelProperty("收藏数量") private Integer collectNum; - //评论数量 + @ApiModelProperty("评论数量") private Integer commentNum; - //创建时间 + @ApiModelProperty("创建时间") private Date createTime; - //更新时间 + @ApiModelProperty("更新时间") private Date updateTime; - //逻辑删除,0未删除,1已删除 + @ApiModelProperty("逻辑删除,0未删除,1已删除") private Integer isDelete; @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) diff --git a/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java b/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java index dd9bd4c..6fbf091 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java +++ b/src/main/java/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java @@ -3,6 +3,8 @@ package com.kwan.springbootkwan.entity.dto; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.kwan.springbootkwan.entity.CsdnUserInfo; import com.kwan.springbootkwan.mapstruct.FromConverter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; @@ -10,52 +12,31 @@ import org.mapstruct.factory.Mappers; import java.util.Date; - @Data +@ApiModel("csdn三连用户DTO") public class CsdnUserInfoDTO extends Model { - /** - * 主键id - */ + + @ApiModelProperty("主键id") private Integer id; - /** - * 用户code - */ + @ApiModelProperty("用户code") private String userName; - /** - * CSDN用户名称 - */ + @ApiModelProperty("CSDN用户名称") private String nickName; - /** - * 点赞状态 - */ + @ApiModelProperty("点赞状态") private Integer likeStatus; - /** - * 收藏状态 - */ + @ApiModelProperty("收藏状态") private Integer collectStatus; - /** - * 评论状态 - */ + @ApiModelProperty("评论状态") private Integer commentStatus; - /** - * 用户权重 - */ + @ApiModelProperty("用户权重") private Integer userWeight; - /** - * 文章类型 - */ + @ApiModelProperty("文章类型") private String articleType; - /** - * 创建时间 - */ + @ApiModelProperty("创建时间") private Date createTime; - /** - * 更新时间 - */ + @ApiModelProperty("更新时间") private Date updateTime; - /** - * 逻辑删除,0未删除,1已删除 - */ + @ApiModelProperty("逻辑删除,0未删除,1已删除") private Integer isDelete; @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) diff --git a/src/main/java/com/kwan/springbootkwan/entity/query/CsdnTripletDayInfoQuery.java b/src/main/java/com/kwan/springbootkwan/entity/query/CsdnTripletDayInfoQuery.java index 444ff91..1369e4f 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/query/CsdnTripletDayInfoQuery.java +++ b/src/main/java/com/kwan/springbootkwan/entity/query/CsdnTripletDayInfoQuery.java @@ -2,18 +2,21 @@ package com.kwan.springbootkwan.entity.query; import com.fasterxml.jackson.annotation.JsonFormat; import com.kwan.springbootkwan.entity.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; @Data +@ApiModel("csdn三连监控查询参数类") public class CsdnTripletDayInfoQuery extends BasePage { - //主键id + @ApiModelProperty("主键id") private Integer id; - //开始日期 + @ApiModelProperty("开始日期") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date startDate; - //结束日期 + @ApiModelProperty("结束日期") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date endDate; -} +} \ No newline at end of file diff --git a/src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java b/src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java index 0dd9ba3..f484ea8 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java +++ b/src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java @@ -1,44 +1,29 @@ package com.kwan.springbootkwan.entity.query; import com.kwan.springbootkwan.entity.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data +@ApiModel("csdn三连用户查询参数类") public class CsdnUserInfoQuery extends BasePage { - /** - * 主键id - */ + @ApiModelProperty("主键id") private Integer id; - /** - * 用户code - */ + @ApiModelProperty("用户code") private String userName; - /** - * CSDN用户名称 - */ + @ApiModelProperty("CSDN用户名称") private String nickName; - /** - * 点赞状态 - */ + @ApiModelProperty("点赞状态") private Integer likeStatus = 0; - /** - * 收藏状态 - */ + @ApiModelProperty("收藏状态") private Integer collectStatus = 0; - /** - * 评论状态 - */ + @ApiModelProperty("评论状态") private Integer commentStatus = 0; - /** - * 用户权重 - */ + @ApiModelProperty("用户权重") private Integer userWeight; - /** - * 文章类型 - */ + @ApiModelProperty("文章类型") private String articleType; - /** - * 添加类型 - */ + @ApiModelProperty("添加类型") private Integer addType; -} +} \ No newline at end of file diff --git a/src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java b/src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java index 070988e..c2c0d1b 100644 --- a/src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java +++ b/src/main/java/com/kwan/springbootkwan/schedule/CsdnSchedule.java @@ -37,9 +37,9 @@ public class CsdnSchedule { } @Scheduled(cron = "0 0/30 * * * ?") - public void resetCurrentStatus() { + public void resetAllCurrentStatus() { log.info("executeInit task is running ... ..."); - csdnUserInfoService.resetCurrentStatus(); + csdnUserInfoService.resetAllCurrentStatus(); log.info("executeInit task is finish ... ..."); } diff --git a/src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java b/src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java index d0c2fde..0a2a766 100644 --- a/src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java +++ b/src/main/java/com/kwan/springbootkwan/service/CsdnUserInfoService.java @@ -13,12 +13,18 @@ public interface CsdnUserInfoService extends IService { /** * 重置新文章的状态 */ - void resetCurrentStatus(); + void resetAllCurrentStatus(); /** * 重置新一天的状态 */ void resetUserDayStatus(); + /** + * 重置某个人某一天的状态 + * + * @param csdnUserInfo + */ + void resetCsdnUserInfo(CsdnUserInfo csdnUserInfo); } diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCollectServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCollectServiceImpl.java index 24bd6c5..57d5727 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCollectServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCollectServiceImpl.java @@ -36,10 +36,6 @@ public class CsdnCollectServiceImpl implements CsdnCollectService { @Override public Boolean isCollect(String articleId, CsdnUserInfo csdnUserInfo) { - final Integer collectStatus = csdnUserInfo.getCollectStatus(); - if (CollectStatus.HAVE_ALREADY_COLLECT.getCode().equals(collectStatus) || CollectStatus.COLLECT_IS_FULL.getCode().equals(collectStatus)) { - return true; - } HttpResponse response = HttpUtil.createGet(isCollectUrl) .header("Cookie", csdnCookie) .form("articleId", articleId) diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCommentServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCommentServiceImpl.java index 7bc7f09..916e8e7 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCommentServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/CsdnCommentServiceImpl.java @@ -104,11 +104,6 @@ public class CsdnCommentServiceImpl implements CsdnCommentService { } else if (code == 400 && StringUtils.equals(message, "您评论太快了,请休息一下!")) { log.info("您评论太快了,请休息一下!"); csdnUserInfo.setCommentStatus(CommentStatus.COMMENT_TOO_FAST.getCode()); - try { - Thread.sleep(20000); - } catch (InterruptedException e) { - e.printStackTrace(); - } } else { log.info("其他错误"); csdnUserInfo.setCommentStatus(CommentStatus.OTHER_ERRORS.getCode()); diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java index 3898746..9416425 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/CsdnUserInfoServiceImpl.java @@ -34,31 +34,36 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq("is_delete", 0); final List list = this.list(wrapper); if (CollectionUtil.isNotEmpty(list)) { for (CsdnUserInfo csdnUserInfo : list) { - final String userName = csdnUserInfo.getUserName(); - final Integer commentStatus = csdnUserInfo.getCommentStatus(); - final String articleType = csdnUserInfo.getArticleType(); - final List articles = csdnArticleService.getArticles(userName); - if (CollectionUtil.isNotEmpty(articles)) { - final BusinessInfoResponse.ArticleData.Article article = articles.get(0); - final String type = article.getType(); - if (StringUtils.equals(type, "blog")) { - final String urlInfo = article.getUrl(); - String articleId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1); - final Boolean collect = csdnCollectService.isCollect(articleId, csdnUserInfo); - if (!collect || CommentStatus.COMMENT_TOO_FAST.getCode().equals(commentStatus) || !StringUtils.equals(articleType, type)) { - csdnUserInfo.setLikeStatus(LikeStatus.UN_PROCESSED.getCode()); - csdnUserInfo.setCollectStatus(CollectStatus.UN_PROCESSED.getCode()); - csdnUserInfo.setCommentStatus(CommentStatus.UN_PROCESSED.getCode()); - csdnUserInfo.setArticleType(type); - this.updateById(csdnUserInfo); - } - } + this.resetCsdnUserInfo(csdnUserInfo); + } + } + } + + @Override + public void resetCsdnUserInfo(CsdnUserInfo csdnUserInfo) { + final String userName = csdnUserInfo.getUserName(); + final Integer commentStatus = csdnUserInfo.getCommentStatus(); + final String articleType = csdnUserInfo.getArticleType(); + final List articles = csdnArticleService.getArticles(userName); + if (CollectionUtil.isNotEmpty(articles)) { + final BusinessInfoResponse.ArticleData.Article article = articles.get(0); + final String type = article.getType(); + if (StringUtils.equals(type, "blog")) { + final String urlInfo = article.getUrl(); + String articleId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1); + final Boolean collect = csdnCollectService.isCollect(articleId, csdnUserInfo); + if (!collect || CommentStatus.COMMENT_TOO_FAST.getCode().equals(commentStatus) || !StringUtils.equals(articleType, type)) { + csdnUserInfo.setLikeStatus(LikeStatus.UN_PROCESSED.getCode()); + csdnUserInfo.setCollectStatus(CollectStatus.UN_PROCESSED.getCode()); + csdnUserInfo.setCommentStatus(CommentStatus.UN_PROCESSED.getCode()); + csdnUserInfo.setArticleType(type); + this.updateById(csdnUserInfo); } } } -- GitLab