CommentsJob.java
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.cnlive.shenhe.job;
import com.cnlive.shenhe.entity.ShyComments;
import com.cnlive.shenhe.service.CommentsService;
import com.cnlive.shenhe.utils.CommonConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author Administrator
*/
@Component
public class CommentsJob {
private static Logger logger = LoggerFactory.getLogger(CommentsJob.class);
@Autowired
CommentsService commentsService;
@Scheduled(fixedRate = 60 * 1000)
public void updateComments() {
//遍历免审的spid去更改状态值
ShyComments shyComments = new ShyComments();
// 审核类型为免审
shyComments.setShenhe_type(CommonConst.AUDIT_TYPE_FREE);
shyComments.setState(CommonConst.AUDIT_INTT);
List<ShyComments> commentsList = commentsService.findShyComments(shyComments);
if (commentsList.size() > 0) {
for (ShyComments comments : commentsList) {
commentsService.updateState(comments.getId().toString(), CommonConst.AUDIT_SUCCESS, "", "白名单", "白名单通过");
}
}
}
/**
* 自动退领
* 每天0点执行
*/
@Scheduled(cron = "0 0 0 * * ? ")
public void autoRetReceive() {
logger.info("评论自动退领的进入.....");
ShyComments shyComments = new ShyComments();
//审核状态:未审核
shyComments.setState(CommonConst.AUDIT_INTT);
//已领取
shyComments.setReceive(CommonConst.RECEIVE_AFTER);
List<ShyComments> commentsList = commentsService.findShyComments(shyComments);
if (commentsList.size() > 0) {
for (ShyComments comments : commentsList) {
logger.info("自动退领的comments_id:" + comments.getId());
//未领取
comments.setReceive(CommonConst.RECEIVE_BEFORE);
comments.setReceive_user_id(null);
commentsService.updateShyComments1(comments);
}
}
}
}