mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
备份
This commit is contained in:
parent
5281af66f3
commit
d853ab365a
@ -2,10 +2,16 @@
|
||||
e5续订
|
||||
用到技术
|
||||
spring boot
|
||||
<br>
|
||||
rabbitMq
|
||||
<br>
|
||||
Redis
|
||||
<br>
|
||||
Mysql
|
||||
<br>
|
||||
Mybatis Plus
|
||||
<br>
|
||||
Security
|
||||
<br>
|
||||
log4j2
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -21,6 +21,7 @@ import java.util.UUID;
|
||||
public class TestController {
|
||||
@Autowired
|
||||
RabbitTemplate rabbitTemplate;
|
||||
|
||||
@GetMapping("/send")
|
||||
public void aaa() {
|
||||
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
|
||||
@ -29,7 +30,7 @@ public class TestController {
|
||||
rabbitTemplate.convertAndSend("delay", "delay", "ttt", message -> {
|
||||
MessageProperties messageProperties = message.getMessageProperties();
|
||||
// 设置这条消息的过期时间
|
||||
messageProperties.setExpiration("10000");
|
||||
messageProperties.setExpiration("5000");
|
||||
return message;
|
||||
}, correlationData);
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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<Outlook> 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<Outlook> 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标识用户
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
|
||||
* </p>
|
||||
*
|
||||
* @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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -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<Outlook> {
|
||||
|
||||
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<Outlook> findAll();
|
||||
|
@ -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<OutlookMapper, Outlook> 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<Outlook> findAll() {
|
||||
return baseMapper.selectList(null);
|
||||
@ -160,6 +163,7 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 刷新令牌,同时更新数据库中的令牌
|
||||
public String refresh_token(Outlook outlook) {
|
||||
Map<String, Object> head = new HashMap<>();
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -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");
|
||||
|
||||
logger.info("消费者1开始处理消息: {},时间戳:{}" ,new String(message.getBody()),System.currentTimeMillis());
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
||||
logger.info("处理完成!");
|
||||
} catch (IOException e) {
|
||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(),false,true);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,25 @@
|
||||
<button id="findLog" class="mdui-btn mdui-color-theme-accent mdui-ripple">查询日志</button>
|
||||
</div>
|
||||
|
||||
<#--时间设置-->
|
||||
<div class="mdui-table-fluid table-container floats">
|
||||
<div class="mdui-textfield">
|
||||
<label class="mdui-textfield-label" style="font-weight: 500;">调用时间间隔</label>
|
||||
<input id="client_secret" class="mdui-textfield-input" type="text" value="${cron_time!}"/>
|
||||
</div>
|
||||
<div class="mdui-textfield">
|
||||
<label class="mdui-textfield-label" style="font-weight: 500;">随机时间范围</label>
|
||||
<input id="client_secret" class="mdui-textfield-input" type="text"
|
||||
value="${cron_time_random_start!}-${cron_time_random_end!}"/>
|
||||
</div>
|
||||
<ol>
|
||||
<li>调用时间间隔,单位 秒。</li>
|
||||
<li>随机时间范围格式,“10-30”,指的是 调用时间间隔+取范围中的一个值,进行调用。</li>
|
||||
<li>调用时间间隔不得大于12小时,也就是43200秒</li>
|
||||
</ol>
|
||||
<button id="save_random_time" class="mdui-btn mdui-color-theme-accent mdui-ripple">保存</button>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script src="//www.mdui.org/source/dist/js/mdui.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
Loading…
Reference in New Issue
Block a user