fix:调整

上级 f1d7791c
......@@ -4,6 +4,9 @@ import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kwan.springbootkwan.entity.CsdnUserInfo;
import com.kwan.springbootkwan.entity.Result;
import com.kwan.springbootkwan.enums.CollectStatus;
import com.kwan.springbootkwan.enums.CommentStatus;
import com.kwan.springbootkwan.enums.LikeStatus;
import com.kwan.springbootkwan.service.CsdnCommentService;
import com.kwan.springbootkwan.service.CsdnService;
import com.kwan.springbootkwan.service.CsdnUserInfoService;
......@@ -15,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
@Slf4j
@RestController
......@@ -32,10 +36,9 @@ public class CsdnController {
public Result singleTriplet(@Param("username") String username) {
QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
wrapper.eq("is_delete", 0);
wrapper.eq("user_name", username);
final List<CsdnUserInfo> list = csdnUserInfoService.list(wrapper);
if (CollectionUtil.isNotEmpty(list)) {
final CsdnUserInfo csdnUserInfo = list.get(0);
wrapper.eq("user_name", username).last("limit 1");
final CsdnUserInfo csdnUserInfo = csdnUserInfoService.getOne(wrapper);
if (Objects.nonNull(csdnUserInfo)) {
csdnService.singleArticle(csdnUserInfo);
}
return Result.ok("单人三连完成");
......@@ -52,4 +55,20 @@ public class CsdnController {
csdnCommentService.commentSelf();
return Result.ok("自动回复完成");
}
@GetMapping("/resetCurrentStatus")
public Result resetCurrentStatus() {
QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
wrapper.eq("is_delete", 0);
final List<CsdnUserInfo> list = csdnUserInfoService.list(wrapper);
if (CollectionUtil.isNotEmpty(list)) {
for (CsdnUserInfo csdnUserInfo : list) {
csdnUserInfo.setLikeStatus(LikeStatus.UN_PROCESSED.getCode());
csdnUserInfo.setCollectStatus(CollectStatus.UN_PROCESSED.getCode());
csdnUserInfo.setCommentStatus(CommentStatus.RESTRICTED_COMMENTS.getCode());
csdnUserInfoService.updateById(csdnUserInfo);
}
}
return Result.ok("重置当天状态完成");
}
}
......@@ -36,12 +36,14 @@ public class CsdnSchedule {
log.info("execute task is finish ... ...");
}
@Scheduled(cron = "0 0 3 * * ?")
/**
* 当天可能有新的发布
*/
@Scheduled(cron = "0 0/30 * * * ?")
public void executeInit() {
log.info("executeInit task is running ... ...");
QueryWrapper<CsdnUserInfo> wrapper = new QueryWrapper<>();
wrapper.eq("is_delete", 0);
wrapper.orderByAsc("rand()");
final List<CsdnUserInfo> list = csdnUserInfoService.list(wrapper);
if (CollectionUtil.isNotEmpty(list)) {
for (CsdnUserInfo csdnUserInfo : list) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册