diff --git a/README.md b/README.md
index f611f5b..cdb5caa 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,16 @@
e5续订
用到技术
spring boot
+
rabbitMq
+
Redis
+
Mysql
+
Mybatis Plus
+
Security
+
log4j2
diff --git a/src/main/java/io/qyi/e5/AutoGenerator_.java b/src/main/java/io/qyi/e5/AutoGenerator_.java
index 0f82e18..0d5ec4c 100644
--- a/src/main/java/io/qyi/e5/AutoGenerator_.java
+++ b/src/main/java/io/qyi/e5/AutoGenerator_.java
@@ -52,7 +52,7 @@ public class AutoGenerator_ {
gc.setAuthor("落叶");
gc.setOpen(false);
// 是否覆盖
- gc.setFileOverride(true);
+ gc.setFileOverride(false);
// gc.setSwagger2(true); 实体属性 Swagger2 注解
mpg.setGlobalConfig(gc);
diff --git a/src/main/java/io/qyi/e5/config/security/UsernamePasswordAuthenticationProvider.java b/src/main/java/io/qyi/e5/config/security/UsernamePasswordAuthenticationProvider.java
index 8061475..4ff6cb4 100644
--- a/src/main/java/io/qyi/e5/config/security/UsernamePasswordAuthenticationProvider.java
+++ b/src/main/java/io/qyi/e5/config/security/UsernamePasswordAuthenticationProvider.java
@@ -79,7 +79,7 @@ public class UsernamePasswordAuthenticationProvider implements AuthenticationPro
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("github_id", userInfo.getGithub_id());
Github github = githubMapper.selectOne(queryWrapper);
-// 未注册就进行注册
+// 未注册就进行注册
if (github == null) {
github = new Github();
github.setAccessToken(accessToken)
diff --git a/src/main/java/io/qyi/e5/controller/TestController.java b/src/main/java/io/qyi/e5/controller/TestController.java
index 0654255..9dd7839 100644
--- a/src/main/java/io/qyi/e5/controller/TestController.java
+++ b/src/main/java/io/qyi/e5/controller/TestController.java
@@ -21,15 +21,16 @@ import java.util.UUID;
public class TestController {
@Autowired
RabbitTemplate rabbitTemplate;
+
@GetMapping("/send")
- public void aaa(){
+ public void aaa() {
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend("delay", "delay", "ttt", message -> {
MessageProperties messageProperties = message.getMessageProperties();
// 设置这条消息的过期时间
- messageProperties.setExpiration("10000");
+ messageProperties.setExpiration("5000");
return message;
}, correlationData);
}
diff --git a/src/main/java/io/qyi/e5/controller/web/WebController.java b/src/main/java/io/qyi/e5/controller/web/WebController.java
index 7bf5ced..b97ea22 100644
--- a/src/main/java/io/qyi/e5/controller/web/WebController.java
+++ b/src/main/java/io/qyi/e5/controller/web/WebController.java
@@ -8,9 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
@@ -48,9 +46,15 @@ public class WebController {
if (one != null) {
model.addAttribute("client_id", one.getClientId());
model.addAttribute("client_secret", one.getClientSecret());
+ model.addAttribute("cron_time", one.getCronTime());
+ model.addAttribute("cron_time_random_start", one.getCronTimeRandomStart());
+ model.addAttribute("cron_time_random_end", one.getCronTimeRandomEnd());
} else {
model.addAttribute("client_id", "");
model.addAttribute("client_secret", "");
+ model.addAttribute("cron_time", 0);
+ model.addAttribute("cron_time_random_start", 0);
+ model.addAttribute("cron_time_random_end", 0);
}
model.addAttribute("welcome", "hello fishpro");
diff --git a/src/main/java/io/qyi/e5/outlook/controller/AuthController.java b/src/main/java/io/qyi/e5/outlook/controller/AuthController.java
index cf11dd9..0d7f5c3 100644
--- a/src/main/java/io/qyi/e5/outlook/controller/AuthController.java
+++ b/src/main/java/io/qyi/e5/outlook/controller/AuthController.java
@@ -3,7 +3,6 @@ package io.qyi.e5.outlook.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
import io.qyi.e5.outlook.entity.Outlook;
-import io.qyi.e5.outlook.mapper.OutlookMapper;
import io.qyi.e5.outlook.service.IOutlookService;
import io.qyi.e5.util.EncryptUtil;
import io.qyi.e5.util.redis.RedisUtil;
@@ -30,9 +29,6 @@ public class AuthController {
@Autowired
RedisUtil redisUtil;
- @Autowired
- OutlookMapper outlookMapper;
-
@Autowired
IOutlookService outlookService;
@@ -52,7 +48,7 @@ public class AuthController {
// 这里不应该查询,在进行授权时因该把基础数据丢到redis
QueryWrapper outlookQueryWrapper = new QueryWrapper<>();
outlookQueryWrapper.eq("github_id", redisUtil.get(states + state));
- Outlook outlook = outlookMapper.selectOne(outlookQueryWrapper);
+ Outlook outlook = outlookService.getOne(outlookQueryWrapper);
// 删除redis中的此键
redisUtil.del(states + state);
if (outlook == null) {
@@ -77,7 +73,7 @@ public class AuthController {
QueryWrapper outlookQueryWrapper = new QueryWrapper<>();
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
outlookQueryWrapper.eq("github_id", authentication.getGithub_id());
- Outlook outlook = outlookMapper.selectOne(outlookQueryWrapper);
+ Outlook outlook = outlookService.getOne(outlookQueryWrapper);
if (outlook != null) {
// 生成随机uuid标识用户
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 b7c420c..f945f99 100644
--- a/src/main/java/io/qyi/e5/outlook/controller/OutlookController.java
+++ b/src/main/java/io/qyi/e5/outlook/controller/OutlookController.java
@@ -34,4 +34,13 @@ public class OutlookController {
}
return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);
}
+
+ @PostMapping("/saveRandomTime")
+ public Result saveRandomTime(@RequestParam int cronTime,@RequestParam int crondomTime) {
+ UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
+ if (outlookService.saveRandomTime(cronTime,0,0)) {
+ return ResultUtil.success();
+ }
+ return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);
+ }
}
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 792bf40..20231da 100644
--- a/src/main/java/io/qyi/e5/outlook/entity/Outlook.java
+++ b/src/main/java/io/qyi/e5/outlook/entity/Outlook.java
@@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
*
*
* @author 落叶
- * @since 2020-02-24
+ * @since 2020-03-22
*/
@Data
@EqualsAndHashCode(callSuper = false)
@@ -43,5 +43,20 @@ public class Outlook implements Serializable {
private String accessToken;
+ /**
+ * 刷新时间间隔
+ */
+ private Integer cronTime;
+
+ /**
+ * 随机时间开始
+ */
+ private Integer cronTimeRandomStart;
+
+ /**
+ * 随机时间结束
+ */
+ private Integer cronTimeRandomEnd;
+
}
diff --git a/src/main/java/io/qyi/e5/outlook/mapper/OutlookMapper.java b/src/main/java/io/qyi/e5/outlook/mapper/OutlookMapper.java
index dce1ca9..78fbf11 100644
--- a/src/main/java/io/qyi/e5/outlook/mapper/OutlookMapper.java
+++ b/src/main/java/io/qyi/e5/outlook/mapper/OutlookMapper.java
@@ -1,7 +1,7 @@
package io.qyi.e5.outlook.mapper;
-import io.qyi.e5.outlook.entity.Outlook;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.qyi.e5.outlook.entity.Outlook;
/**
*
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 a52f2f0..68b51b5 100644
--- a/src/main/java/io/qyi/e5/outlook/service/IOutlookService.java
+++ b/src/main/java/io/qyi/e5/outlook/service/IOutlookService.java
@@ -1,7 +1,7 @@
package io.qyi.e5.outlook.service;
-import io.qyi.e5.outlook.entity.Outlook;
import com.baomidou.mybatisplus.extension.service.IService;
+import io.qyi.e5.outlook.entity.Outlook;
import java.util.List;
@@ -19,6 +19,8 @@ public interface IOutlookService extends IService {
boolean save(String client_id,String client_secret,int github_id);
+ boolean saveRandomTime(int github_id,int cron_time,int cron_time_random_start,int cron_time_random_end);
+
boolean getMailList(Outlook outlook);
List findAll();
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 1578df8..ff6e556 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
@@ -2,18 +2,15 @@ package io.qyi.e5.outlook.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import io.qyi.e5.github.entity.Github;
import io.qyi.e5.outlook.entity.Outlook;
import io.qyi.e5.outlook.mapper.OutlookMapper;
import io.qyi.e5.outlook.service.IOutlookService;
import io.qyi.e5.outlook_log.service.IOutlookLogService;
import io.qyi.e5.util.netRequest.OkHttpClientUtil;
import io.qyi.e5.util.netRequest.OkHttpRequestUtils;
-import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -110,6 +107,12 @@ public class OutlookServiceImpl extends ServiceImpl impl
return false;
}
+ @Override
+ public boolean saveRandomTime(int github_id, int cron_time, int cron_time_random_start, int cron_time_random_end) {
+
+ return false;
+ }
+
@Override
public List findAll() {
return baseMapper.selectList(null);
@@ -160,6 +163,7 @@ public class OutlookServiceImpl extends ServiceImpl impl
}
+
// 刷新令牌,同时更新数据库中的令牌
public String refresh_token(Outlook outlook) {
Map head = new HashMap<>();
diff --git a/src/main/java/io/qyi/e5/outlook_log/controller/OutlookLogController.java b/src/main/java/io/qyi/e5/outlook_log/controller/OutlookLogController.java
index 9467d21..bb23a65 100644
--- a/src/main/java/io/qyi/e5/outlook_log/controller/OutlookLogController.java
+++ b/src/main/java/io/qyi/e5/outlook_log/controller/OutlookLogController.java
@@ -2,13 +2,10 @@ package io.qyi.e5.outlook_log.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
import io.qyi.e5.outlook.entity.Outlook;
import io.qyi.e5.outlook.service.IOutlookService;
import io.qyi.e5.outlook_log.entity.OutlookLog;
-import io.qyi.e5.outlook_log.mapper.OutlookLogMapper;
import io.qyi.e5.outlook_log.service.IOutlookLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,10 +17,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
import java.util.List;
-import java.util.Map;
/**
*
diff --git a/src/main/java/io/qyi/e5/service/rabbitMQ/impl/ListenerImpl.java b/src/main/java/io/qyi/e5/service/rabbitMQ/impl/ListenerImpl.java
index 8535324..3f6722b 100644
--- a/src/main/java/io/qyi/e5/service/rabbitMQ/impl/ListenerImpl.java
+++ b/src/main/java/io/qyi/e5/service/rabbitMQ/impl/ListenerImpl.java
@@ -3,11 +3,13 @@ package io.qyi.e5.service.rabbitMQ.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
+import io.qyi.e5.outlook.service.IOutlookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -22,20 +24,13 @@ import java.io.IOException;
public class ListenerImpl {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ @Autowired
+ IOutlookService outlookService;
@RabbitHandler
@RabbitListener(queues = "delay_queue2", containerFactory = "rabbitListenerContainerFactory")
public void listen(Message message, Channel channel) throws IOException {
- try {
- logger.info("消费者开始处理消息: {}" ,new String(message.getBody()));
-// JSONObject data = JSON.parseObject(new String(message.getBody()));
-// String token = data.getString("token");
-
- channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
- logger.info("处理完成!");
- } catch (IOException e) {
- channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
- e.printStackTrace();
- }
+ logger.info("消费者1开始处理消息: {},时间戳:{}" ,new String(message.getBody()),System.currentTimeMillis());
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
}
}
diff --git a/src/main/resources/templates/user/home.ftl b/src/main/resources/templates/user/home.ftl
index 1064358..de1a732 100644
--- a/src/main/resources/templates/user/home.ftl
+++ b/src/main/resources/templates/user/home.ftl
@@ -44,6 +44,25 @@
+<#--时间设置-->
+
+
+
+
+
+
+
+
+
+
+ - 调用时间间隔,单位 秒。
+ - 随机时间范围格式,“10-30”,指的是 调用时间间隔+取范围中的一个值,进行调用。
+ - 调用时间间隔不得大于12小时,也就是43200秒
+
+
+
+