From c39e67927b3205c3ea2bcdd8bf6f741e19789eac Mon Sep 17 00:00:00 2001 From: wujing <297115770@qq.com> Date: Wed, 16 Dec 2020 14:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nacos_config.zip | Bin 3740 -> 4363 bytes .../education/ServerGatewayApplication.java | 41 +++-- .../gateway/common/FilterPre.java | 148 +++++++++--------- .../gateway/controller/HandlerController.java | 39 +++++ .../gateway/controller/IndexController.java | 10 +- .../gateway/controller/HandlerController.java | 37 ----- .../src/main/resources/bootstrap.properties | 6 +- .../src/main/resources/templates/index.ftl | 14 +- .../education/app/job/MsgSendCrontab.java | 48 ++++++ .../education/app/job/OrderCrontab.java | 46 ++++++ .../education/app/job/VideoCrontab.java | 68 ++++++++ .../education/server/job/MsgSendCrontab.java | 50 ------ .../education/server/job/OrderCrontab.java | 47 ------ .../education/server/job/VideoCrontab.java | 69 -------- .../sba/ServerSbaApplication.java | 11 +- .../app/sba/config/SecuritySecureConfig.java | 28 ++++ .../sba/config/SecuritySecureConfig.java | 29 ---- .../src/main/resources/logback-roncoo.xml | 29 ++-- 18 files changed, 359 insertions(+), 361 deletions(-) rename roncoo-education-app-gateway/src/main/java/com/roncoo/education/{server => app}/gateway/common/FilterPre.java (93%) create mode 100644 roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/HandlerController.java rename roncoo-education-app-gateway/src/main/java/com/roncoo/education/{server => app}/gateway/controller/IndexController.java (63%) delete mode 100644 roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/HandlerController.java create mode 100644 roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/MsgSendCrontab.java create mode 100644 roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/OrderCrontab.java create mode 100644 roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/VideoCrontab.java delete mode 100644 roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/MsgSendCrontab.java delete mode 100644 roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/OrderCrontab.java delete mode 100644 roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/VideoCrontab.java rename roncoo-education-app-sba/src/main/java/com/roncoo/education/{server => app}/sba/ServerSbaApplication.java (74%) create mode 100644 roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/config/SecuritySecureConfig.java delete mode 100644 roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/config/SecuritySecureConfig.java diff --git a/nacos_config.zip b/nacos_config.zip index ab8ab2b3d00d94cbea530ff6307ad70ea3ae7ae7..ae9a6be0b0775d5036f2744e73d8e7c00c23c8bb 100644 GIT binary patch literal 4363 zcmbuC2|QG97stn%>_lW4qsUSd$w;WwAlcVa_T5-!EMq6Tk!fs&B4pqG$P!VOu`kIs zw4lfmk-hA^Bd_;0{r&sA_1^i+oVoXN?{mJ-bAIV{-MEJ zxUnh1$_6WsBP(}BTS?3Cnue;j+J7FT06fS0NG6si79a)yfMfu` z*BY!p>!sNhJ(4HZhl@w>!rk`XoF?Rp$>ry>K@1M`3P@GwtL;Vlw=u0 zqkQ6>swz1&8v7=rD?R!ur@beyUpkMV$(%Wb^_Z=N#9ZeSs8HUlZBW%0|9PdHru15E z7JgZ+#TMIPT*DZn`L)Tc$<>wf7C*70ti2laYL3##=$8VJo4 zxDweYECsI3jIW>i9B$>@HlVMZ>HRTxI1cEJVj_}UyZsSupyW<%TS*a2X_k5|Ba>-Z zcc5+rJ<3-jC$#0xo$c*vRS%a0HG3LOj7UmTX}WZxZ+$yfdL*g6hVR%jaKB^1m(6s& zs%Y26uU}2)CCc)8q%3tp^#XD(mTURyD(bEzmMJbmf`fgnnB=igZh9Gac~NGLXN+b% zFTURHrZ#6Zk)ScD)dH`BAJ;VdjykJ_ca<%Rh-QQt4M`cjj1!>A=C(o;LD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9b|L-u;7uD;YzE6 zY_AYW-`1$_Jk5ACUhmy|{M%3Z`qxW@1N-(r?=11F*m~R1`*mGh08AX88LPcOb8yTqP!66}qU5yl73J2f z^KRs&)iAd2j{hPZfS>JqA# zWuqG_r03M2{%7VxTS|niv`H$G<}9%|Qpc7-xUqu57eO~iAmmzWDrz%{-6~4liH=Hp zMq?wGiD1)?7vf5(XY40ej2{DTsEZOO0ccQ4+(=_~&%{a!oqYx>>l zy`#}TBZ=-`yZ_r={%e)pO0c&|De#Z0{I(Z getParamMap(HttpServletRequest request) { + TreeMap paramMap = new TreeMap<>(); + Map map = request.getParameterMap(); + for (String key : map.keySet()) { + paramMap.put(key, map.get(key)[0]); + } + if (paramMap.isEmpty()) { + DataInputStream in = null; + try { + in = new DataInputStream(request.getInputStream()); + byte[] buf = new byte[request.getContentLength()]; + in.readFully(buf); + String t = new String(buf, "UTF-8"); + if (StringUtils.hasText(t)) { + return new TreeMap<>(JSONUtil.parseObject(t, TreeMap.class)); + } + } catch (Exception e) { + logger.error("获取不到任何参数"); + } finally { + if (null != in) + try { + in.close();// 关闭数据流 + } catch (IOException e) { + logger.error("关闭数据流异常"); + } + } + } + return paramMap; + } + + // 校验用户是否有权限 + private static Boolean checkUri(String uri, String tk) { + List menuVOList1 = JSONUtil.parseArray(tk, String.class); + if (StringUtils.hasText(uri) && uri.endsWith("/")) { + uri = uri.substring(0, uri.length() - 1); + } + for (String s : menuVOList1) { + if (s.contains(uri)) { + return true; + } + } + return false; + } + @Override public String filterType() { return FilterConstants.PRE_TYPE; @@ -138,11 +180,16 @@ public class FilterPre extends ZuulFilter { } // 单点登录处理,注意,登录的时候必须要放入缓存 - /* - * if (!stringRedisTemplate.hasKey(userNo.toString())) { // 不存在,则登录异常,有效期为1小时 throw new BaseException(ResultEnum.TOKEN_PAST); } - * - * // 存在,判断是否token相同 String tk = stringRedisTemplate.opsForValue().get(userNo.toString()); if (!token.equals(tk)) { // 不同则为不同的用户登录,这时候提示异地登录 throw new BaseException(ResultEnum.REMOTE_ERROR); } - */ +// if (!stringRedisTemplate.hasKey(userNo.toString())) { +// // 不存在,则登录异常,有效期为1小时 +// throw new BaseException(ResultEnum.TOKEN_PAST); +// } +// // 存在,判断是否token相同 +// String tk = stringRedisTemplate.opsForValue().get(userNo.toString()); +// if (!token.equals(tk)) { +// // 不同则为不同的用户登录,这时候提示异地登录 +// throw new BaseException(ResultEnum.REMOTE_ERROR); +// } // 更新时间,使token不过期 stringRedisTemplate.opsForValue().set(userNo.toString(), token, 1, TimeUnit.HOURS); @@ -178,49 +225,4 @@ public class FilterPre extends ZuulFilter { } }; } - - @SuppressWarnings("unchecked") - private static TreeMap getParamMap(HttpServletRequest request) { - TreeMap paramMap = new TreeMap<>(); - Map map = request.getParameterMap(); - for (String key : map.keySet()) { - paramMap.put(key, map.get(key)[0]); - } - if (paramMap.isEmpty()) { - DataInputStream in = null; - try { - in = new DataInputStream(request.getInputStream()); - byte[] buf = new byte[request.getContentLength()]; - in.readFully(buf); - String t = new String(buf, "UTF-8"); - if (StringUtils.hasText(t)) { - return new TreeMap<>(JSONUtil.parseObject(t, TreeMap.class)); - } - } catch (Exception e) { - logger.error("获取不到任何参数"); - } finally { - if (null != in) - try { - in.close();// 关闭数据流 - } catch (IOException e) { - logger.error("关闭数据流异常"); - } - } - } - return paramMap; - } - - // 校验用户是否有权限 - private static Boolean checkUri(String uri, String tk) { - List menuVOList1 = JSONUtil.parseArray(tk, String.class); - if (StringUtils.hasText(uri) && uri.endsWith("/")) { - uri = uri.substring(0, uri.length() - 1); - } - for (String s : menuVOList1) { - if (s.contains(uri)) { - return true; - } - } - return false; - } } diff --git a/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/HandlerController.java b/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/HandlerController.java new file mode 100644 index 00000000..cb93927f --- /dev/null +++ b/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/HandlerController.java @@ -0,0 +1,39 @@ +package com.roncoo.education.app.gateway.controller; + +import com.netflix.zuul.context.RequestContext; +import com.netflix.zuul.exception.ZuulException; +import com.roncoo.education.util.base.Result; +import com.roncoo.education.util.enums.ResultEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController +public class HandlerController implements ErrorController { + + /** + * 出异常后进入该方法,交由下面的方法处理 + */ + @Override + public String getErrorPath() { + return "/error"; + } + + @RequestMapping("/error") + @ResponseStatus(HttpStatus.OK) + public Result error() { + RequestContext ctx = RequestContext.getCurrentContext(); + Throwable throwable = ctx.getThrowable(); + log.error("系统异常", throwable); + if (null != throwable && throwable instanceof ZuulException) { + ZuulException e = (ZuulException) ctx.getThrowable(); + return Result.error(e.nStatusCode, e.errorCause); + } + return Result.error(ResultEnum.ERROR); + } + +} diff --git a/roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/IndexController.java b/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/IndexController.java similarity index 63% rename from roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/IndexController.java rename to roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/IndexController.java index 2cdce935..54b817d5 100644 --- a/roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/IndexController.java +++ b/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/controller/IndexController.java @@ -1,7 +1,7 @@ /** * Copyright 2015-现在 广州市领课网络科技有限公司 */ -package com.roncoo.education.server.gateway.controller; +package com.roncoo.education.app.gateway.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -10,9 +10,9 @@ import org.springframework.web.bind.annotation.RequestMethod; @Controller public class IndexController { - @RequestMapping(value = "/", method = RequestMethod.GET) - public String index() { - return "index"; - } + @RequestMapping(value = "/", method = RequestMethod.GET) + public String index() { + return "index"; + } } diff --git a/roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/HandlerController.java b/roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/HandlerController.java deleted file mode 100644 index 4fc8dd9d..00000000 --- a/roncoo-education-app-gateway/src/main/java/com/roncoo/education/server/gateway/controller/HandlerController.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.roncoo.education.server.gateway.controller; - -import com.roncoo.education.util.base.Result; -import com.roncoo.education.util.enums.ResultEnum; -import org.springframework.boot.web.servlet.error.ErrorController; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -import com.netflix.zuul.context.RequestContext; -import com.netflix.zuul.exception.ZuulException; - -@RestController -public class HandlerController implements ErrorController { - - /** - * 出异常后进入该方法,交由下面的方法处理 - */ - @Override - public String getErrorPath() { - return "/error"; - } - - @RequestMapping("/error") - @ResponseStatus(HttpStatus.OK) - public Result error() { - RequestContext ctx = RequestContext.getCurrentContext(); - Throwable throwable = ctx.getThrowable(); - if(null != throwable && throwable instanceof ZuulException ){ - ZuulException e = (ZuulException) ctx.getThrowable(); - return Result.error(e.nStatusCode, e.errorCause); - } - return Result.error(ResultEnum.ERROR); - } - -} diff --git a/roncoo-education-app-gateway/src/main/resources/bootstrap.properties b/roncoo-education-app-gateway/src/main/resources/bootstrap.properties index 31840108..40d0c8af 100644 --- a/roncoo-education-app-gateway/src/main/resources/bootstrap.properties +++ b/roncoo-education-app-gateway/src/main/resources/bootstrap.properties @@ -1,13 +1,13 @@ # application spring.application.name=roncoo-education-app-gateway # profile -spring.profiles.active=dev +spring.profiles.active=demo # server server.port=5840 # nacos spring.cloud.nacos.username=nacos -spring.cloud.nacos.password=nacos -spring.cloud.nacos.server-addr=localhost:8848 +spring.cloud.nacos.password=RonCoo.123 +spring.cloud.nacos.server-addr=10.65.3.98:8848 spring.cloud.nacos.namespace=${spring.profiles.active} spring.cloud.nacos.discovery.namespace=${spring.cloud.nacos.namespace} spring.cloud.nacos.config.namespace=${spring.cloud.nacos.namespace} diff --git a/roncoo-education-app-gateway/src/main/resources/templates/index.ftl b/roncoo-education-app-gateway/src/main/resources/templates/index.ftl index e5fedaf1..3679548e 100644 --- a/roncoo-education-app-gateway/src/main/resources/templates/index.ftl +++ b/roncoo-education-app-gateway/src/main/resources/templates/index.ftl @@ -1,19 +1,19 @@ - - 接口文档 + + 接口文档 - diff --git a/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/MsgSendCrontab.java b/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/MsgSendCrontab.java new file mode 100644 index 00000000..7b8d641b --- /dev/null +++ b/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/MsgSendCrontab.java @@ -0,0 +1,48 @@ +package com.roncoo.education.app.job; + +import com.roncoo.education.system.feign.interfaces.IFeignMsg; +import com.roncoo.education.util.base.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +/** + * 站内信-定时发送 + * + * @author wuyun + */ +@Component +public class MsgSendCrontab extends BaseController { + + private static final Object KEY = new Object(); + private static boolean taskFlag = false; + + @Autowired + private IFeignMsg bossMsg; + + /** + * 定时任务,一小时启动一次 + * + * @author wuyun + */ + @Scheduled(fixedRate = 60000) + public void pushCancel() { + synchronized (KEY) { + if (MsgSendCrontab.taskFlag) { + logger.warn("站内信-定时发送已经启动"); + return; + } + MsgSendCrontab.taskFlag = true; + } + + try { + bossMsg.push(); + } catch (Exception e) { + logger.error("站内信-定时发送-执行出错", e); + } + + MsgSendCrontab.taskFlag = false; + + logger.warn("站内信-定时发送-任务完成"); + } +} diff --git a/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/OrderCrontab.java b/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/OrderCrontab.java new file mode 100644 index 00000000..eeabd0ac --- /dev/null +++ b/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/OrderCrontab.java @@ -0,0 +1,46 @@ +package com.roncoo.education.app.job; + +import com.roncoo.education.course.feign.interfaces.IFeignOrderInfo; +import com.roncoo.education.util.base.BaseController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +/** + * 定时任务-订单处理 + * + * @author wuyun + */ +@Component +public class OrderCrontab extends BaseController { + + private static final Object KEY = new Object(); + + private static boolean taskFlag = false; + + @Autowired + private IFeignOrderInfo feignOrderInfo; + + /** + * 定时任务每分钟执行一次 + */ + @Scheduled(fixedRate = 60000) + public void orderCancel() { + synchronized (KEY) { + if (OrderCrontab.taskFlag) { + logger.warn("订单处理-任务已经启动"); + return; + } + OrderCrontab.taskFlag = true; + } + logger.warn("订单处理-定时任务开始"); + + try { + feignOrderInfo.handleScheduledTasks(); + } catch (Exception e) { + logger.error("定时任务-订单处理-执行出错", e); + } + OrderCrontab.taskFlag = false; + } + +} diff --git a/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/VideoCrontab.java b/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/VideoCrontab.java new file mode 100644 index 00000000..5f8c2de9 --- /dev/null +++ b/roncoo-education-app-job/src/main/java/com/roncoo/education/app/job/VideoCrontab.java @@ -0,0 +1,68 @@ +package com.roncoo.education.app.job; + +import com.roncoo.education.course.feign.interfaces.IFeignCourseVideo; +import com.roncoo.education.util.base.BaseController; +import com.roncoo.education.util.config.SystemUtil; +import com.xiaoleilu.hutool.io.FileUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.io.File; + +/** + * 定时任务-视频处理 + * + * @author wuyun + */ +@Component +public class VideoCrontab extends BaseController { + + private static final Object KEY = new Object(); + private static boolean taskFlag = false; + + @Autowired + private IFeignCourseVideo feignCourseVideo; + + /** + * 定时任务每分钟执行一次
+ * 注意:每个course服务都必须要对应有一个定时任务,针对服务器 + */ + @Scheduled(fixedRate = 60000) + public void orderCancel() { + synchronized (KEY) { + if (VideoCrontab.taskFlag) { + logger.warn("视频处理-任务已经启动"); + return; + } + VideoCrontab.taskFlag = true; + } + + int videoSum = 0; + + File file = new File(SystemUtil.PERIOD_VIDEO_PATH); + if (file.isDirectory()) {// isDirectory是否文件夹 + File[] files = file.listFiles();// listFiles是获取该目录下所有文件和目录的绝对路径 + for (File targetFile : files) { + + if (targetFile.isFile() && targetFile.exists()) { + if (FileUtil.newerThan(targetFile, (System.currentTimeMillis() - 7200000))) {// 上传两个小时内 + + try { + feignCourseVideo.handleScheduledTasks(targetFile); + videoSum = videoSum + 1; + } catch (Exception e) { + logger.error("视频定时任务处理失败", e); + } + + } + } + } + } + + VideoCrontab.taskFlag = false; + + logger.warn("视频处理-定时任务完成,处理视频数={}", videoSum); + } + +} diff --git a/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/MsgSendCrontab.java b/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/MsgSendCrontab.java deleted file mode 100644 index 63a4db99..00000000 --- a/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/MsgSendCrontab.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.roncoo.education.server.job; - -import com.roncoo.education.system.feign.interfaces.IFeignMsg; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import com.roncoo.education.util.base.BaseController; - -/** - * 站内信-定时发送 - * - * @author wuyun - * - */ -@Component -public class MsgSendCrontab extends BaseController { - - private static final Object KEY = new Object(); - private static boolean taskFlag = false; - - @Autowired - private IFeignMsg bossMsg; - - /** - * 定时任务,一小时启动一次 - * - * @author wuyun - */ - @Scheduled(fixedRate = 60000) - public void pushCancel() { - synchronized (KEY) { - if (MsgSendCrontab.taskFlag) { - logger.warn("站内信-定时发送已经启动"); - return; - } - MsgSendCrontab.taskFlag = true; - } - - try { - bossMsg.push(); - } catch (Exception e) { - logger.error("站内信-定时发送-执行出错", e); - } - - MsgSendCrontab.taskFlag = false; - - logger.warn("站内信-定时发送-任务完成"); - } -} diff --git a/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/OrderCrontab.java b/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/OrderCrontab.java deleted file mode 100644 index 256eaf39..00000000 --- a/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/OrderCrontab.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.roncoo.education.server.job; - -import com.roncoo.education.course.feign.interfaces.IFeignOrderInfo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import com.roncoo.education.util.base.BaseController; - -/** - * 定时任务-订单处理 - * - * @author wuyun - */ -@Component -public class OrderCrontab extends BaseController { - - private static final Object KEY = new Object(); - - private static boolean taskFlag = false; - - @Autowired - private IFeignOrderInfo feignOrderInfo; - - /** - * 定时任务每分钟执行一次 - */ - @Scheduled(fixedRate = 60000) - public void orderCancel() { - synchronized (KEY) { - if (OrderCrontab.taskFlag) { - logger.warn("订单处理-任务已经启动"); - return; - } - OrderCrontab.taskFlag = true; - } - logger.warn("订单处理-定时任务开始"); - - try { - feignOrderInfo.handleScheduledTasks(); - } catch (Exception e) { - logger.error("定时任务-订单处理-执行出错", e); - } - OrderCrontab.taskFlag = false; - } - -} diff --git a/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/VideoCrontab.java b/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/VideoCrontab.java deleted file mode 100644 index 01154148..00000000 --- a/roncoo-education-app-job/src/main/java/com/roncoo/education/server/job/VideoCrontab.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.roncoo.education.server.job; - -import java.io.File; - -import com.roncoo.education.course.feign.interfaces.IFeignCourseVideo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import com.roncoo.education.util.base.BaseController; -import com.roncoo.education.util.config.SystemUtil; -import com.xiaoleilu.hutool.io.FileUtil; - -/** - * 定时任务-视频处理 - * - * @author wuyun - */ -@Component -public class VideoCrontab extends BaseController { - - private static final Object KEY = new Object(); - private static boolean taskFlag = false; - - @Autowired - private IFeignCourseVideo feignCourseVideo; - - /** - * 定时任务每分钟执行一次
- * 注意:每个course服务都必须要对应有一个定时任务,针对服务器 - */ - @Scheduled(fixedRate = 60000) - public void orderCancel() { - synchronized (KEY) { - if (VideoCrontab.taskFlag) { - logger.warn("视频处理-任务已经启动"); - return; - } - VideoCrontab.taskFlag = true; - } - - int videoSum = 0; - - File file = new File(SystemUtil.PERIOD_VIDEO_PATH); - if (file.isDirectory()) {// isDirectory是否文件夹 - File[] files = file.listFiles();// listFiles是获取该目录下所有文件和目录的绝对路径 - for (File targetFile : files) { - - if (targetFile.isFile() && targetFile.exists()) { - if (FileUtil.newerThan(targetFile, (System.currentTimeMillis() - 7200000))) {// 上传两个小时内 - - try { - feignCourseVideo.handleScheduledTasks(targetFile); - videoSum = videoSum + 1; - } catch (Exception e) { - logger.error("视频定时任务处理失败", e); - } - - } - } - } - } - - VideoCrontab.taskFlag = false; - - logger.warn("视频处理-定时任务完成,处理视频数={}", videoSum); - } - -} diff --git a/roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/ServerSbaApplication.java b/roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/ServerSbaApplication.java similarity index 74% rename from roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/ServerSbaApplication.java rename to roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/ServerSbaApplication.java index adb51c01..e70e681a 100644 --- a/roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/ServerSbaApplication.java +++ b/roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/ServerSbaApplication.java @@ -1,21 +1,20 @@ /** * Copyright 2015-现在 广州市领课网络科技有限公司 */ -package com.roncoo.education.server.sba; +package com.roncoo.education.app.sba; +import de.codecentric.boot.admin.server.config.EnableAdminServer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import de.codecentric.boot.admin.server.config.EnableAdminServer; - @EnableAdminServer @EnableDiscoveryClient @SpringBootApplication public class ServerSbaApplication { - public static void main(String[] args) { - SpringApplication.run(ServerSbaApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(ServerSbaApplication.class, args); + } } diff --git a/roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/config/SecuritySecureConfig.java b/roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/config/SecuritySecureConfig.java new file mode 100644 index 00000000..b34cd9fe --- /dev/null +++ b/roncoo-education-app-sba/src/main/java/com/roncoo/education/app/sba/config/SecuritySecureConfig.java @@ -0,0 +1,28 @@ +package com.roncoo.education.app.sba.config; + +import de.codecentric.boot.admin.server.config.AdminServerProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; +import org.springframework.security.web.csrf.CookieCsrfTokenRepository; + +@Configuration +public class SecuritySecureConfig extends WebSecurityConfigurerAdapter { + private final String adminContextPath; + + public SecuritySecureConfig(AdminServerProperties adminServerProperties) { + this.adminContextPath = adminServerProperties.getContextPath(); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter:off + SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); + successHandler.setTargetUrlParameter("redirectTo"); + successHandler.setDefaultTargetUrl(adminContextPath + "/"); + + http.authorizeRequests().antMatchers(adminContextPath + "/assets/**").permitAll().antMatchers(adminContextPath + "/login").permitAll().anyRequest().authenticated().and().formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and().logout().logoutUrl(adminContextPath + "/logout").and().httpBasic().and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).ignoringAntMatchers(adminContextPath + "/instances", adminContextPath + "/actuator/**"); + // @formatter:on + } +} diff --git a/roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/config/SecuritySecureConfig.java b/roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/config/SecuritySecureConfig.java deleted file mode 100644 index 4f4a0573..00000000 --- a/roncoo-education-app-sba/src/main/java/com/roncoo/education/server/sba/config/SecuritySecureConfig.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.roncoo.education.server.sba.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; -import org.springframework.security.web.csrf.CookieCsrfTokenRepository; - -import de.codecentric.boot.admin.server.config.AdminServerProperties; - -@Configuration -public class SecuritySecureConfig extends WebSecurityConfigurerAdapter { - private final String adminContextPath; - - public SecuritySecureConfig(AdminServerProperties adminServerProperties) { - this.adminContextPath = adminServerProperties.getContextPath(); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); - successHandler.setTargetUrlParameter("redirectTo"); - successHandler.setDefaultTargetUrl(adminContextPath + "/"); - - http.authorizeRequests().antMatchers(adminContextPath + "/assets/**").permitAll().antMatchers(adminContextPath + "/login").permitAll().anyRequest().authenticated().and().formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and().logout().logoutUrl(adminContextPath + "/logout").and().httpBasic().and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).ignoringAntMatchers(adminContextPath + "/instances", adminContextPath + "/actuator/**"); - // @formatter:on - } -} \ No newline at end of file diff --git a/roncoo-education-util/src/main/resources/logback-roncoo.xml b/roncoo-education-util/src/main/resources/logback-roncoo.xml index a5d290da..8c965431 100644 --- a/roncoo-education-util/src/main/resources/logback-roncoo.xml +++ b/roncoo-education-util/src/main/resources/logback-roncoo.xml @@ -1,9 +1,10 @@ - + - + @@ -14,16 +15,16 @@ ${PATTERN} - - - + + + - + - + ${PATTERN} @@ -44,13 +45,13 @@ - - - + + + - - + + @@ -98,10 +99,10 @@ - + - + -- GitLab