mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 11:48:50 +00:00
备份
This commit is contained in:
parent
5281af66f3
commit
d853ab365a
@ -2,10 +2,16 @@
|
|||||||
e5续订
|
e5续订
|
||||||
用到技术
|
用到技术
|
||||||
spring boot
|
spring boot
|
||||||
|
<br>
|
||||||
rabbitMq
|
rabbitMq
|
||||||
|
<br>
|
||||||
Redis
|
Redis
|
||||||
|
<br>
|
||||||
Mysql
|
Mysql
|
||||||
|
<br>
|
||||||
Mybatis Plus
|
Mybatis Plus
|
||||||
|
<br>
|
||||||
Security
|
Security
|
||||||
|
<br>
|
||||||
log4j2
|
log4j2
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class AutoGenerator_ {
|
|||||||
gc.setAuthor("落叶");
|
gc.setAuthor("落叶");
|
||||||
gc.setOpen(false);
|
gc.setOpen(false);
|
||||||
// 是否覆盖
|
// 是否覆盖
|
||||||
gc.setFileOverride(true);
|
gc.setFileOverride(false);
|
||||||
// gc.setSwagger2(true); 实体属性 Swagger2 注解
|
// gc.setSwagger2(true); 实体属性 Swagger2 注解
|
||||||
mpg.setGlobalConfig(gc);
|
mpg.setGlobalConfig(gc);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class UsernamePasswordAuthenticationProvider implements AuthenticationPro
|
|||||||
QueryWrapper<Github> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Github> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("github_id", userInfo.getGithub_id());
|
queryWrapper.eq("github_id", userInfo.getGithub_id());
|
||||||
Github github = githubMapper.selectOne(queryWrapper);
|
Github github = githubMapper.selectOne(queryWrapper);
|
||||||
// 未注册就进行注册
|
// 未注册就进行注册
|
||||||
if (github == null) {
|
if (github == null) {
|
||||||
github = new Github();
|
github = new Github();
|
||||||
github.setAccessToken(accessToken)
|
github.setAccessToken(accessToken)
|
||||||
|
@ -21,15 +21,16 @@ import java.util.UUID;
|
|||||||
public class TestController {
|
public class TestController {
|
||||||
@Autowired
|
@Autowired
|
||||||
RabbitTemplate rabbitTemplate;
|
RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
@GetMapping("/send")
|
@GetMapping("/send")
|
||||||
public void aaa(){
|
public void aaa() {
|
||||||
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
|
CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
|
||||||
|
|
||||||
|
|
||||||
rabbitTemplate.convertAndSend("delay", "delay", "ttt", message -> {
|
rabbitTemplate.convertAndSend("delay", "delay", "ttt", message -> {
|
||||||
MessageProperties messageProperties = message.getMessageProperties();
|
MessageProperties messageProperties = message.getMessageProperties();
|
||||||
// 设置这条消息的过期时间
|
// 设置这条消息的过期时间
|
||||||
messageProperties.setExpiration("10000");
|
messageProperties.setExpiration("5000");
|
||||||
return message;
|
return message;
|
||||||
}, correlationData);
|
}, correlationData);
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
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.RequestMapping;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@ -48,9 +46,15 @@ public class WebController {
|
|||||||
if (one != null) {
|
if (one != null) {
|
||||||
model.addAttribute("client_id", one.getClientId());
|
model.addAttribute("client_id", one.getClientId());
|
||||||
model.addAttribute("client_secret", one.getClientSecret());
|
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 {
|
} else {
|
||||||
model.addAttribute("client_id", "");
|
model.addAttribute("client_id", "");
|
||||||
model.addAttribute("client_secret", "");
|
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");
|
model.addAttribute("welcome", "hello fishpro");
|
||||||
|
@ -3,7 +3,6 @@ package io.qyi.e5.outlook.controller;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
||||||
import io.qyi.e5.outlook.entity.Outlook;
|
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.service.IOutlookService;
|
||||||
import io.qyi.e5.util.EncryptUtil;
|
import io.qyi.e5.util.EncryptUtil;
|
||||||
import io.qyi.e5.util.redis.RedisUtil;
|
import io.qyi.e5.util.redis.RedisUtil;
|
||||||
@ -30,9 +29,6 @@ public class AuthController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
RedisUtil redisUtil;
|
RedisUtil redisUtil;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
OutlookMapper outlookMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IOutlookService outlookService;
|
IOutlookService outlookService;
|
||||||
|
|
||||||
@ -52,7 +48,7 @@ public class AuthController {
|
|||||||
// 这里不应该查询,在进行授权时因该把基础数据丢到redis
|
// 这里不应该查询,在进行授权时因该把基础数据丢到redis
|
||||||
QueryWrapper<Outlook> outlookQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<Outlook> outlookQueryWrapper = new QueryWrapper<>();
|
||||||
outlookQueryWrapper.eq("github_id", redisUtil.get(states + state));
|
outlookQueryWrapper.eq("github_id", redisUtil.get(states + state));
|
||||||
Outlook outlook = outlookMapper.selectOne(outlookQueryWrapper);
|
Outlook outlook = outlookService.getOne(outlookQueryWrapper);
|
||||||
// 删除redis中的此键
|
// 删除redis中的此键
|
||||||
redisUtil.del(states + state);
|
redisUtil.del(states + state);
|
||||||
if (outlook == null) {
|
if (outlook == null) {
|
||||||
@ -77,7 +73,7 @@ public class AuthController {
|
|||||||
QueryWrapper<Outlook> outlookQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<Outlook> outlookQueryWrapper = new QueryWrapper<>();
|
||||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||||
outlookQueryWrapper.eq("github_id", authentication.getGithub_id());
|
outlookQueryWrapper.eq("github_id", authentication.getGithub_id());
|
||||||
Outlook outlook = outlookMapper.selectOne(outlookQueryWrapper);
|
Outlook outlook = outlookService.getOne(outlookQueryWrapper);
|
||||||
|
|
||||||
if (outlook != null) {
|
if (outlook != null) {
|
||||||
// 生成随机uuid标识用户
|
// 生成随机uuid标识用户
|
||||||
|
@ -34,4 +34,13 @@ public class OutlookController {
|
|||||||
}
|
}
|
||||||
return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);
|
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>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 落叶
|
* @author 落叶
|
||||||
* @since 2020-02-24
|
* @since 2020-03-22
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@ -43,5 +43,20 @@ public class Outlook implements Serializable {
|
|||||||
|
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新时间间隔
|
||||||
|
*/
|
||||||
|
private Integer cronTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机时间开始
|
||||||
|
*/
|
||||||
|
private Integer cronTimeRandomStart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机时间结束
|
||||||
|
*/
|
||||||
|
private Integer cronTimeRandomEnd;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.qyi.e5.outlook.mapper;
|
package io.qyi.e5.outlook.mapper;
|
||||||
|
|
||||||
import io.qyi.e5.outlook.entity.Outlook;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import io.qyi.e5.outlook.entity.Outlook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.qyi.e5.outlook.service;
|
package io.qyi.e5.outlook.service;
|
||||||
|
|
||||||
import io.qyi.e5.outlook.entity.Outlook;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import io.qyi.e5.outlook.entity.Outlook;
|
||||||
|
|
||||||
import java.util.List;
|
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 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);
|
boolean getMailList(Outlook outlook);
|
||||||
|
|
||||||
List<Outlook> findAll();
|
List<Outlook> findAll();
|
||||||
|
@ -2,18 +2,15 @@ package io.qyi.e5.outlook.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.entity.Outlook;
|
||||||
import io.qyi.e5.outlook.mapper.OutlookMapper;
|
import io.qyi.e5.outlook.mapper.OutlookMapper;
|
||||||
import io.qyi.e5.outlook.service.IOutlookService;
|
import io.qyi.e5.outlook.service.IOutlookService;
|
||||||
import io.qyi.e5.outlook_log.service.IOutlookLogService;
|
import io.qyi.e5.outlook_log.service.IOutlookLogService;
|
||||||
import io.qyi.e5.util.netRequest.OkHttpClientUtil;
|
import io.qyi.e5.util.netRequest.OkHttpClientUtil;
|
||||||
import io.qyi.e5.util.netRequest.OkHttpRequestUtils;
|
import io.qyi.e5.util.netRequest.OkHttpRequestUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -110,6 +107,12 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
|||||||
return false;
|
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
|
@Override
|
||||||
public List<Outlook> findAll() {
|
public List<Outlook> findAll() {
|
||||||
return baseMapper.selectList(null);
|
return baseMapper.selectList(null);
|
||||||
@ -160,6 +163,7 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 刷新令牌,同时更新数据库中的令牌
|
// 刷新令牌,同时更新数据库中的令牌
|
||||||
public String refresh_token(Outlook outlook) {
|
public String refresh_token(Outlook outlook) {
|
||||||
Map<String, Object> head = new HashMap<>();
|
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.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.config.security.UsernamePasswordAuthenticationToken;
|
||||||
import io.qyi.e5.outlook.entity.Outlook;
|
import io.qyi.e5.outlook.entity.Outlook;
|
||||||
import io.qyi.e5.outlook.service.IOutlookService;
|
import io.qyi.e5.outlook.service.IOutlookService;
|
||||||
import io.qyi.e5.outlook_log.entity.OutlookLog;
|
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 io.qyi.e5.outlook_log.service.IOutlookLogService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -3,11 +3,13 @@ package io.qyi.e5.service.rabbitMQ.impl;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.rabbitmq.client.Channel;
|
import com.rabbitmq.client.Channel;
|
||||||
|
import io.qyi.e5.outlook.service.IOutlookService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -22,20 +24,13 @@ import java.io.IOException;
|
|||||||
public class ListenerImpl {
|
public class ListenerImpl {
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IOutlookService outlookService;
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
@RabbitListener(queues = "delay_queue2", containerFactory = "rabbitListenerContainerFactory")
|
@RabbitListener(queues = "delay_queue2", containerFactory = "rabbitListenerContainerFactory")
|
||||||
public void listen(Message message, Channel channel) throws IOException {
|
public void listen(Message message, Channel channel) throws IOException {
|
||||||
try {
|
logger.info("消费者1开始处理消息: {},时间戳:{}" ,new String(message.getBody()),System.currentTimeMillis());
|
||||||
logger.info("消费者开始处理消息: {}" ,new String(message.getBody()));
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,25 @@
|
|||||||
<button id="findLog" class="mdui-btn mdui-color-theme-accent mdui-ripple">查询日志</button>
|
<button id="findLog" class="mdui-btn mdui-color-theme-accent mdui-ripple">查询日志</button>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
<script src="//www.mdui.org/source/dist/js/mdui.min.js"></script>
|
<script src="//www.mdui.org/source/dist/js/mdui.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -51,7 +70,7 @@
|
|||||||
//日志查询
|
//日志查询
|
||||||
$("#findLog").click(function () {
|
$("#findLog").click(function () {
|
||||||
var url = "/outlookLog/findLog"
|
var url = "/outlookLog/findLog"
|
||||||
window.open(url,'_blank')
|
window.open(url, '_blank')
|
||||||
})
|
})
|
||||||
// 授权
|
// 授权
|
||||||
$("#authorization").click(function () {
|
$("#authorization").click(function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user