This commit is contained in:
APLS 2020-12-13 01:59:23 +08:00
parent bd48b33078
commit 3f7505c16d
6 changed files with 29 additions and 9 deletions

View File

@ -15,4 +15,6 @@ public class OutlookVo {
private String clientSecret;
private Integer cronTimeRandomStart;
private Integer cronTimeRandomEnd;
private Integer step;
private Integer status;
}

View File

@ -10,6 +10,7 @@ import lombok.Data;
**/
@Data
public class SaveRandomBo {
private int outlookId;
private int cronTime;
private String crondomTime;
}

View File

@ -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<OutlookListVo> vo = new ArrayList<>();
outlooklist.forEach(outlook -> {
OutlookListVo v = new OutlookListVo();
log.info(outlook.toString());
BeanUtils.copyProperties(outlook, v);
vo.add(v);
});

View File

@ -65,6 +65,12 @@ public class Outlook implements Serializable {
/*描述*/
private String describes;
/*步骤*/
private Integer step;
/**
* 随机时间结束
* 状态: 1等待配置 2暂停 3运行中 4封禁 5已停止(由于调用错误导致的停止)
*/
private Integer status;
}

View File

@ -7,7 +7,7 @@ import java.util.List;
/**
* <p>
* 服务类
* 服务类
* </p>
*
* @author 落叶
@ -15,13 +15,13 @@ import java.util.List;
*/
public interface IOutlookService extends IService<Outlook> {
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;

View File

@ -116,6 +116,8 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> 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<OutlookMapper, Outlook> 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<Outlook> 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) {