From 23d8501ee48142e2f3fee2fc181fcb09bcc2c0bc Mon Sep 17 00:00:00 2001 From: APLS Date: Sun, 13 Dec 2020 01:59:23 +0800 Subject: [PATCH] ~ --- .../java/io/qyi/e5/outlook/bean/OutlookVo.java | 2 ++ .../io/qyi/e5/outlook/bean/bo/SaveRandomBo.java | 1 + .../e5/outlook/controller/OutlookController.java | 5 ++++- .../java/io/qyi/e5/outlook/entity/Outlook.java | 8 +++++++- .../qyi/e5/outlook/service/IOutlookService.java | 6 +++--- .../outlook/service/impl/OutlookServiceImpl.java | 16 ++++++++++++---- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/qyi/e5/outlook/bean/OutlookVo.java b/src/main/java/io/qyi/e5/outlook/bean/OutlookVo.java index 97727cf..04d0bbd 100644 --- a/src/main/java/io/qyi/e5/outlook/bean/OutlookVo.java +++ b/src/main/java/io/qyi/e5/outlook/bean/OutlookVo.java @@ -15,4 +15,6 @@ public class OutlookVo { private String clientSecret; private Integer cronTimeRandomStart; private Integer cronTimeRandomEnd; + private Integer step; + private Integer status; } diff --git a/src/main/java/io/qyi/e5/outlook/bean/bo/SaveRandomBo.java b/src/main/java/io/qyi/e5/outlook/bean/bo/SaveRandomBo.java index c5f91ff..b1134cd 100644 --- a/src/main/java/io/qyi/e5/outlook/bean/bo/SaveRandomBo.java +++ b/src/main/java/io/qyi/e5/outlook/bean/bo/SaveRandomBo.java @@ -10,6 +10,7 @@ import lombok.Data; **/ @Data public class SaveRandomBo { + private int outlookId; private int cronTime; private String crondomTime; } diff --git a/src/main/java/io/qyi/e5/outlook/controller/OutlookController.java b/src/main/java/io/qyi/e5/outlook/controller/OutlookController.java index 59d8c7e..7df704d 100644 --- a/src/main/java/io/qyi/e5/outlook/controller/OutlookController.java +++ b/src/main/java/io/qyi/e5/outlook/controller/OutlookController.java @@ -14,6 +14,7 @@ import io.qyi.e5.outlook.bean.bo.insertOneBO; import io.qyi.e5.outlook.entity.Outlook; import io.qyi.e5.outlook.service.IOutlookService; import io.qyi.e5.util.ResultUtil; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; @@ -34,6 +35,7 @@ import java.util.List; */ @RestController @RequestMapping("/outlook/outlook") +@Slf4j public class OutlookController { @Autowired @@ -96,7 +98,7 @@ public class OutlookController { return ResultUtil.error(-1, "最大间隔时间为 6 小时"); } UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); - if (outlookService.saveRandomTime(authentication.getGithub_id(), bo.getCronTime(), cron_time_random_start, cron_time_random_end)) { + if (outlookService.saveRandomTime(authentication.getGithub_id(), bo.getCronTime(), bo.getOutlookId(), cron_time_random_start, cron_time_random_end)) { return ResultUtil.success(); } return ResultUtil.error(ResultEnum.UNKNOWN_ERROR); @@ -126,6 +128,7 @@ public class OutlookController { List vo = new ArrayList<>(); outlooklist.forEach(outlook -> { OutlookListVo v = new OutlookListVo(); + log.info(outlook.toString()); BeanUtils.copyProperties(outlook, v); vo.add(v); }); diff --git a/src/main/java/io/qyi/e5/outlook/entity/Outlook.java b/src/main/java/io/qyi/e5/outlook/entity/Outlook.java index bc22a80..11e2a90 100644 --- a/src/main/java/io/qyi/e5/outlook/entity/Outlook.java +++ b/src/main/java/io/qyi/e5/outlook/entity/Outlook.java @@ -65,6 +65,12 @@ public class Outlook implements Serializable { /*描述*/ private String describes; - + /*步骤*/ + private Integer step; + /** + * 随机时间结束 + * 状态: 1、等待配置 2、暂停 3、运行中 4、封禁 5、已停止(由于调用错误导致的停止) + */ + private Integer status; } diff --git a/src/main/java/io/qyi/e5/outlook/service/IOutlookService.java b/src/main/java/io/qyi/e5/outlook/service/IOutlookService.java index 1c42561..9e7e49e 100644 --- a/src/main/java/io/qyi/e5/outlook/service/IOutlookService.java +++ b/src/main/java/io/qyi/e5/outlook/service/IOutlookService.java @@ -7,7 +7,7 @@ import java.util.List; /** *

- * 服务类 + * 服务类 *

* * @author 落叶 @@ -15,13 +15,13 @@ import java.util.List; */ public interface IOutlookService extends IService { - boolean getTokenAndSave(String code,String client_id,String client_secret,String redirect_uri,String grant_type) throws Exception; + boolean getTokenAndSave(String code, String client_id, String client_secret, String redirect_uri, String grant_type) throws Exception; Outlook insertOne(String name, String describe, int github_id); boolean save(String client_id, String client_secret, int outlook_id, int github_id); - boolean saveRandomTime(int github_id, int cron_time, int cron_time_random_start, int cron_time_random_end); + boolean saveRandomTime(int github_id, int cron_time, int outlook_id, int cron_time_random_start, int cron_time_random_end); int getMailList(Outlook outlook) throws Exception; diff --git a/src/main/java/io/qyi/e5/outlook/service/impl/OutlookServiceImpl.java b/src/main/java/io/qyi/e5/outlook/service/impl/OutlookServiceImpl.java index 8840b06..72a8dfc 100644 --- a/src/main/java/io/qyi/e5/outlook/service/impl/OutlookServiceImpl.java +++ b/src/main/java/io/qyi/e5/outlook/service/impl/OutlookServiceImpl.java @@ -116,6 +116,8 @@ public class OutlookServiceImpl extends ServiceImpl impl } outlook1.setClientId(client_id); outlook1.setClientSecret(client_secret); + outlook1.setStep(1) + .setStatus(8);; if (baseMapper.update(outlook1, queryWrapper) != 1) { throw new APIException("更新记录失败!"); } @@ -123,14 +125,20 @@ public class OutlookServiceImpl extends ServiceImpl impl } @Override - public boolean saveRandomTime(int github_id, int cron_time, int cron_time_random_start, int cron_time_random_end) { - if (github_id == 0) { - return false; + public boolean saveRandomTime(int github_id, int cron_time, int outlook_id ,int cron_time_random_start, int cron_time_random_end) { + if (github_id == 0 || outlook_id == 0) { + throw new APIException("缺少参数!"); } UpdateWrapper Wrapper = new UpdateWrapper<>(); Wrapper.eq("github_id", github_id); + Wrapper.eq("id", outlook_id); Outlook outlook = new Outlook(); - outlook.setCronTime(cron_time).setCronTimeRandomStart(cron_time_random_start).setCronTimeRandomEnd(cron_time_random_end); + outlook.setCronTime(cron_time) + .setCronTimeRandomStart(cron_time_random_start) + .setCronTimeRandomEnd(cron_time_random_end) + .setStep(2) + .setStatus(6); + int update = baseMapper.update(outlook, Wrapper); // 有数据 if (update > 0) {