mirror of
https://github.com/luoye663/e5.git
synced 2024-12-26 03:38:53 +00:00
~
This commit is contained in:
parent
35d17d9148
commit
e3efe64926
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,3 +3,5 @@
|
||||
/target/
|
||||
/src/main/resources/application-online.properties.bak
|
||||
/src/main/resources/application.properties
|
||||
/src/main/resources/application-online.properties.bak
|
||||
/src/main/resources/application.properties
|
||||
|
@ -73,6 +73,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
/*验证token*/
|
||||
http.addFilterBefore(new LinkTokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
|
||||
http.csrf().disable().apply(githubAuth2AuthenticationConfig);
|
||||
// http.addFilterAt(githubAuth2AuthenticationConfig, UsernamePasswordAuthenticationFilter.class);
|
||||
/*添加自定义权限管理器*/
|
||||
http.authorizeRequests().anyRequest().authenticated().withObjectPostProcessor(filterSecurityInterceptorObjectPostProcessor());
|
||||
/*关闭创建session*/
|
||||
|
@ -41,6 +41,7 @@ public class GithubLoginAuthenticationFilter extends AbstractAuthenticationProce
|
||||
|
||||
public GithubLoginAuthenticationFilter() {
|
||||
super(new AntPathRequestMatcher("/auth2/receive", "GET"));
|
||||
|
||||
log.info("注册 LoginAuthenticationFilter");
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,9 @@ import io.qyi.e5.github.entity.UserInfo;
|
||||
import io.qyi.e5.github.mapper.GithubMapper;
|
||||
import io.qyi.e5.github.service.IGithubService;
|
||||
import io.qyi.e5.util.StringUtil;
|
||||
import io.qyi.e5.util.netRequest.OkHttpClientUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import io.qyi.e5.util.netRequest.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
15
src/main/java/io/qyi/e5/outlook/bean/bo/SaveRandomBo.java
Normal file
15
src/main/java/io/qyi/e5/outlook/bean/bo/SaveRandomBo.java
Normal file
@ -0,0 +1,15 @@
|
||||
package io.qyi.e5.outlook.bean.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @program: e5
|
||||
* @description:
|
||||
* @author: 落叶随风
|
||||
* @create: 2020-12-10 22:46
|
||||
**/
|
||||
@Data
|
||||
public class SaveRandomBo {
|
||||
private int cronTime;
|
||||
private String crondomTime;
|
||||
}
|
16
src/main/java/io/qyi/e5/outlook/bean/bo/UpdateBo.java
Normal file
16
src/main/java/io/qyi/e5/outlook/bean/bo/UpdateBo.java
Normal file
@ -0,0 +1,16 @@
|
||||
package io.qyi.e5.outlook.bean.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @program: e5
|
||||
* @description:
|
||||
* @author: 落叶随风
|
||||
* @create: 2020-12-10 22:36
|
||||
**/
|
||||
@Data
|
||||
public class UpdateBo {
|
||||
private String client_id;
|
||||
private String client_secret;
|
||||
private int outlook_id;
|
||||
}
|
@ -8,6 +8,8 @@ import io.qyi.e5.config.ResultVO;
|
||||
import io.qyi.e5.config.security.UsernamePasswordAuthenticationToken;
|
||||
import io.qyi.e5.outlook.bean.OutlookListVo;
|
||||
import io.qyi.e5.outlook.bean.OutlookVo;
|
||||
import io.qyi.e5.outlook.bean.bo.SaveRandomBo;
|
||||
import io.qyi.e5.outlook.bean.bo.UpdateBo;
|
||||
import io.qyi.e5.outlook.bean.bo.insertOneBO;
|
||||
import io.qyi.e5.outlook.entity.Outlook;
|
||||
import io.qyi.e5.outlook.service.IOutlookService;
|
||||
@ -47,18 +49,28 @@ public class OutlookController {
|
||||
}
|
||||
|
||||
@PostMapping("/save")
|
||||
public ResultVO save(@RequestParam String client_id, @RequestParam String client_secret,@RequestParam int outlook_id) {
|
||||
public ResultVO save(@RequestBody UpdateBo bo) {
|
||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
if (outlookService.save(client_id, client_secret, outlook_id, authentication.getGithub_id())) {
|
||||
if (outlookService.save(bo.getClient_id(), bo.getClient_secret(), bo.getOutlook_id(), authentication.getGithub_id())) {
|
||||
return new ResultVO<>();
|
||||
}
|
||||
return new ResultVO<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存调用时间
|
||||
* @title saveRandomTime
|
||||
* @description
|
||||
* @author 落叶随风
|
||||
* @param: cronTime
|
||||
* @param: crondomTime
|
||||
* @updateTime 2020/12/10 21:49
|
||||
* @return: io.qyi.e5.bean.result.Result
|
||||
* @throws
|
||||
*/
|
||||
@PostMapping("/saveRandomTime")
|
||||
public Result saveRandomTime(@RequestParam int cronTime, @RequestParam String crondomTime) {
|
||||
String[] split = crondomTime.split("-");
|
||||
public Result saveRandomTime(@RequestBody SaveRandomBo bo) {
|
||||
String[] split = bo.getCrondomTime().split("-");
|
||||
if (split.length != 2) {
|
||||
return ResultUtil.error(ResultEnum.INVALID_format);
|
||||
}
|
||||
@ -84,18 +96,19 @@ public class OutlookController {
|
||||
return ResultUtil.error(-1, "最大间隔时间为 6 小时");
|
||||
}
|
||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
if (outlookService.saveRandomTime(authentication.getGithub_id(), cronTime, cron_time_random_start, cron_time_random_end)) {
|
||||
if (outlookService.saveRandomTime(authentication.getGithub_id(), bo.getCronTime(), cron_time_random_start, cron_time_random_end)) {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
return ResultUtil.error(ResultEnum.UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
@GetMapping("/getOutlookInfo")
|
||||
public Result getOutlookInfo() {
|
||||
public Result getOutlookInfo(@RequestParam int id) {
|
||||
UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
int github_id = authentication.getGithub_id();
|
||||
QueryWrapper<Outlook> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("github_id", github_id);
|
||||
queryWrapper.eq("id", id);
|
||||
Outlook one = outlookService.getOne(queryWrapper);
|
||||
OutlookVo vo = new OutlookVo();
|
||||
if (one != null) {
|
||||
|
@ -13,7 +13,7 @@ import io.qyi.e5.config.exception.APIException;
|
||||
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.netRequest.OkHttpClientUtil;
|
||||
import io.qyi.e5.util.netRequest.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -98,7 +98,7 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
if (github_id == 0) {
|
||||
throw new APIException(APiCode.OUTLOOK_NAME_NOT_NULL);
|
||||
}
|
||||
if (outlook_id == 0) {
|
||||
if (outlook_id == 0 || StringUtils.isBlank(client_id) || StringUtils.isBlank(client_secret)) {
|
||||
throw new APIException("缺少参数!");
|
||||
}
|
||||
QueryWrapper<Outlook> queryWrapper = new QueryWrapper<>();
|
||||
@ -110,7 +110,7 @@ public class OutlookServiceImpl extends ServiceImpl<OutlookMapper, Outlook> impl
|
||||
/*2020-12-10 mybatis plus问题导致会被截断*/
|
||||
// Outlook outlook1 = baseMapper.selectOne(queryWrapper);
|
||||
|
||||
Outlook outlook1 = baseMapper.selectOutlookOne(outlook_id,github_id );
|
||||
Outlook outlook1 = baseMapper.selectOutlookOne(outlook_id, github_id);
|
||||
if (outlook1 == null) {
|
||||
throw new APIException("未查询到此条记录!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user