-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
19,168 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/com/light/hexo/business/admin/task/PostTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.light.hexo.business.admin.task; | ||
|
||
import com.light.hexo.business.admin.constant.ConfigEnum; | ||
import com.light.hexo.business.admin.constant.StateEnum; | ||
import com.light.hexo.business.admin.model.Backup; | ||
import com.light.hexo.business.admin.model.Post; | ||
import com.light.hexo.business.admin.service.PostService; | ||
import com.light.hexo.common.util.MarkdownUtil; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
/** | ||
* @Author MoonlightL | ||
* @ClassName: PostTask | ||
* @ProjectName hexo-boot | ||
* @Description: 文章定时器 | ||
* @DateTime 2021/4/27 17:03 | ||
*/ | ||
@Component | ||
@Slf4j | ||
public class PostTask { | ||
|
||
@Autowired | ||
private PostService postService; | ||
|
||
private ExecutorService executorService = Executors.newFixedThreadPool(2); | ||
|
||
/** | ||
* 扫描 contentHtml 内容为空的文章(兼容老版本) | ||
*/ | ||
@Scheduled(cron = "0 0/1 * * * ?") | ||
public void checkContentHtml() { | ||
List<Post> postList = this.postService.listEmptyHtml(); | ||
if (CollectionUtils.isEmpty(postList)) { | ||
return; | ||
} | ||
|
||
for (Post post : postList) { | ||
this.executorService.submit(() -> { | ||
Post tmp = new Post(); | ||
tmp.setId(post.getId()); | ||
tmp.setContentHtml(MarkdownUtil.md2html(post.getContent())).setUpdateTime(LocalDateTime.now()); | ||
this.postService.updateModel(tmp); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.