fix:添加新的调整

上级 339ee66f
......@@ -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<CsdnUserInfo> 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<CsdnUserInfo> 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("重置新一天状态完成");
}
}
......@@ -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();
......
......@@ -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();
......
......@@ -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<CsdnTripletDayInfo> {
//主键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
......@@ -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<CsdnUserInfo> {
/**
* 主键id
*/
public class CsdnUserInfo extends Model<CsdnUserInfo> 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
......@@ -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<CsdnTripletDayInfoDTO> {
//主键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)
......
......@@ -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<CsdnUserInfoDTO> {
/**
* 主键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)
......
......@@ -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
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
......@@ -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 ... ...");
}
......
......@@ -13,12 +13,18 @@ public interface CsdnUserInfoService extends IService<CsdnUserInfo> {
/**
* 重置新文章的状态
*/
void resetCurrentStatus();
void resetAllCurrentStatus();
/**
* 重置新一天的状态
*/
void resetUserDayStatus();
/**
* 重置某个人某一天的状态
*
* @param csdnUserInfo
*/
void resetCsdnUserInfo(CsdnUserInfo csdnUserInfo);
}
......@@ -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)
......
......@@ -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());
......
......@@ -34,31 +34,36 @@ public class CsdnUserInfoServiceImpl extends ServiceImpl<CsdnUserInfoMapper, Csd
private CsdnArticleService csdnArticleService;
@Override
public void resetCurrentStatus() {
public void resetAllCurrentStatus() {
QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
wrapper.eq("is_delete", 0);
final List<CsdnUserInfo> list = this.list(wrapper);
if (CollectionUtil.isNotEmpty(list)) {
for (CsdnUserInfo csdnUserInfo : list) {
final String userName = csdnUserInfo.getUserName();
final Integer commentStatus = csdnUserInfo.getCommentStatus();
final String articleType = csdnUserInfo.getArticleType();
final List<BusinessInfoResponse.ArticleData.Article> articles = csdnArticleService.getArticles(userName);
if (CollectionUtil.isNotEmpty(articles)) {
final BusinessInfoResponse.ArticleData.Article article = articles.get(0);
final String type = article.getType();
if (StringUtils.equals(type, "blog")) {
final String urlInfo = article.getUrl();
String articleId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1);
final Boolean collect = csdnCollectService.isCollect(articleId, csdnUserInfo);
if (!collect || 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<BusinessInfoResponse.ArticleData.Article> articles = csdnArticleService.getArticles(userName);
if (CollectionUtil.isNotEmpty(articles)) {
final BusinessInfoResponse.ArticleData.Article article = articles.get(0);
final String type = article.getType();
if (StringUtils.equals(type, "blog")) {
final String urlInfo = article.getUrl();
String articleId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1);
final Boolean collect = csdnCollectService.isCollect(articleId, csdnUserInfo);
if (!collect || 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);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册