修改 定时任务 2021年11月12日12:02:06
parent
09f4d9be0c
commit
17f9e600b1
|
|
@ -228,7 +228,6 @@ public class UrlRequestController extends BaseController {
|
|||
return this.jumpPage("admin/permission/add");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/permission/edit")
|
||||
public ModelAndView permission_edit(Model model, String permissionId) {
|
||||
if (CommonUtil.isNotNull(permissionId)) {
|
||||
|
|
@ -239,7 +238,6 @@ public class UrlRequestController extends BaseController {
|
|||
return this.jumpPage("admin/permission/edit");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/article/index")
|
||||
public ModelAndView article_index(Model model,Long categoryId) {
|
||||
List<Category> categoryList = this.categoryFeign.findAll();
|
||||
|
|
@ -248,7 +246,6 @@ public class UrlRequestController extends BaseController {
|
|||
return this.jumpPage("admin/article/list");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/article/add")
|
||||
public ModelAndView article_add(Model model) {
|
||||
//查询分类
|
||||
|
|
@ -257,7 +254,6 @@ public class UrlRequestController extends BaseController {
|
|||
return this.jumpPage("admin/article/add");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/article/edit")
|
||||
public ModelAndView article_edit(Model model,String articleId) {
|
||||
if (CommonUtil.isNotNull(articleId)){
|
||||
|
|
@ -310,13 +306,11 @@ public class UrlRequestController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/quartz/index")
|
||||
public ModelAndView quartz_index(){
|
||||
return this.jumpPage("admin/job/job-list");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/quartz/add")
|
||||
public ModelAndView quartz_add(Model model){
|
||||
Set<String> names = this.quartzFeign.spring_bean_list();
|
||||
|
|
@ -324,7 +318,6 @@ public class UrlRequestController extends BaseController {
|
|||
return this.jumpPage("admin/job/job-add");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping("/quartz/edit")
|
||||
public ModelAndView quartz_edit(Model model,String jobId){
|
||||
Set<String> names = this.quartzFeign.spring_bean_list();
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@ var user_oauth_url = "mystyle-cloud-oauth";
|
|||
var blog_url = "mystyle-cloud-blog";
|
||||
//文件微服务
|
||||
var file_url = "mystyle-cloud-file";
|
||||
//定时任务微服务
|
||||
var quartz_url = "mystyle-cloud-quartz";
|
||||
//验证码
|
||||
var v_code = gate_way_url + "/" + admin_manager_url + "/verificationCode/generate";
|
||||
var access_token = localStorage.getItem("access_token");
|
||||
var access_token_url = "?access_token=" + access_token;
|
||||
var Authorization = "bearer " + access_token;
|
||||
//获取当前用户
|
||||
var current_user_url = gate_way_url + "/" + admin_manager_url + "/user/current" + access_token_url;
|
||||
//登录地址
|
||||
|
|
@ -79,7 +82,7 @@ var article_batchRemove_url = gate_way_url + "/" + blog_url + "/article/batchRem
|
|||
//文件上传
|
||||
var file_upload_url = gate_way_url + "/" + file_url + "/upload/file";
|
||||
//文件列表
|
||||
var file_list_url = gate_way_url + "/" + file_url + "/file/list" ;
|
||||
var file_list_url = gate_way_url + "/" + file_url + "/file/list";
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
//分类列表
|
||||
var category_list_url = gate_way_url + "/" + blog_url + "/category/list";
|
||||
|
|
@ -93,7 +96,21 @@ var category_delete_url = gate_way_url + "/" + blog_url + "/category/delete";
|
|||
var category_batchRemove_url = gate_way_url + "/" + blog_url + "/category/batchRemove";
|
||||
//分类保存
|
||||
var category_save_url = gate_way_url + "/" + blog_url + "/category/save";
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------
|
||||
//定时任务
|
||||
var quartz_list_url = gate_way_url + "/" + quartz_url + "/quartz/list";
|
||||
//新增定时任务
|
||||
var quartz_add_url = gate_way_url + "/" + admin_manager_url + "/quartz/add" + access_token_url;
|
||||
//保存定时任务
|
||||
var quartz_save_url = gate_way_url + "/" + quartz_url + "/quartz/save";
|
||||
//编辑定时任务
|
||||
var quartz_edit_url = gate_way_url + "/" + admin_manager_url + "/quartz/edit" + access_token_url;
|
||||
//校验cron 表达式
|
||||
var checkCron_url = gate_way_url + "/" + quartz_url + "/quartz/cron" + access_token_url;
|
||||
//定时任务删除
|
||||
var quartz_delete_url = gate_way_url + "/" + quartz_url + "/quartz/delete" ;
|
||||
//定时任务批量删除
|
||||
var quartz_batchRemove_url = gate_way_url + "/" + quartz_url + "/quartz/batchRemove" ;
|
||||
|
||||
//页面跳转
|
||||
function postToPage(url, token) {
|
||||
|
|
|
|||
|
|
@ -26,3 +26,7 @@
|
|||
@import url("module/card.css");
|
||||
@import url("module/tab.css");
|
||||
@import url("module/tag.css");
|
||||
|
||||
.layui-table-header, .layui-table-header th {
|
||||
background-color: #e2e2e2 !important;
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>定时任务添加</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css" />
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -61,9 +61,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/js/jquery.min.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/js/jquery.min.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['form','jquery'],function(){
|
||||
let form = layui.form;
|
||||
|
|
@ -71,10 +72,10 @@
|
|||
|
||||
form.on('submit(job-save)', function(data){
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
obj['access_token'] = access_token;
|
||||
// 请求后台
|
||||
$.ajax({
|
||||
url: "/job/save",
|
||||
url: quartz_save_url,
|
||||
type: "post",
|
||||
data: obj,
|
||||
success: function (response) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>定时任务修改</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css"/>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form" action="">
|
||||
|
|
@ -73,9 +73,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/js/jquery.min.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/js/jquery.min.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function () {
|
||||
let form = layui.form;
|
||||
|
|
@ -83,20 +84,20 @@
|
|||
|
||||
form.on('submit(job-save)', function (data) {
|
||||
var obj = data.field;
|
||||
obj['token'] = localStorage.getItem("token");
|
||||
obj['access_token'] = access_token;
|
||||
// 请求后台
|
||||
$.ajax({
|
||||
url: "/job/save",
|
||||
url: quartz_save_url,
|
||||
type: "post",
|
||||
data: obj,
|
||||
success: function (response) {
|
||||
success: function (result) {
|
||||
if (result.flag) {
|
||||
layer.msg(result.message, {icon: 1, time: 1000}, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
|
||||
parent.layui.table.reload("user-table");
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2, time: 1000});
|
||||
layer.msg(result.message, {icon: 2, time: 1000});
|
||||
}
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
|
|
@ -115,7 +116,7 @@
|
|||
if (cron != "") {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/job/cron?cron=' + cron + "&token=" + localStorage.getItem("token"),
|
||||
url: checkCron_url + "&cron=" + cron,
|
||||
success: function (data) {
|
||||
var msg = "正确";
|
||||
if (!data) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>定时任务列表</title>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/system/component/pear/css/pear.css"/>
|
||||
<link rel="stylesheet" href="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/css/pear.css"/>
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
<div class="layui-card">
|
||||
|
|
@ -82,8 +82,9 @@
|
|||
{{layui.util.toDateString(d.addTime, 'yyyy-MM-dd HH:mm:ss')}}
|
||||
</script>
|
||||
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/layui/layui.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/component/pear/pear.js"></script>
|
||||
<script src="${springMacroRequestContext.contextPath}/mystyle-cloud-admin-manager/system/admin/js/mystyle-admin.js"></script>
|
||||
<script>
|
||||
layui.use(['table', 'form', 'jquery', 'common', 'laydate'], function () {
|
||||
let table = layui.table;
|
||||
|
|
@ -91,7 +92,6 @@
|
|||
let $ = layui.jquery;
|
||||
let common = layui.common;
|
||||
var laydate = layui.laydate;
|
||||
let token = localStorage.getItem("token");
|
||||
let cols = [
|
||||
[{
|
||||
type: 'checkbox'
|
||||
|
|
@ -145,11 +145,13 @@
|
|||
|
||||
table.render({
|
||||
elem: '#job-table',
|
||||
url: '/job/list',
|
||||
headers: {token: localStorage.getItem("token")},
|
||||
url: quartz_list_url,
|
||||
headers: {
|
||||
access_token : access_token
|
||||
},
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: 'line',
|
||||
skin: 'rows',
|
||||
toolbar: '#job-toolbar',
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
|
|
@ -212,7 +214,7 @@
|
|||
title: '添加定时任务',
|
||||
shade: 0.1,
|
||||
area: [common.isModile() ? '100%' : '900px', common.isModile() ? '100%' : '600px'],
|
||||
content: '/job/add?token=' + token
|
||||
content: quartz_add_url
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -222,7 +224,7 @@
|
|||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['900px', '600px'],
|
||||
content: '/job/edit?jobId=' + obj.data.id + '&token=' + localStorage.getItem("token")
|
||||
content: quartz_edit_url + '&jobId=' + obj.data.id
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -235,10 +237,10 @@
|
|||
let loading = layer.load();
|
||||
|
||||
$.ajax({
|
||||
url: "/job/delete",
|
||||
url: quartz_delete_url,
|
||||
data: {
|
||||
jobId: obj.data['id'],
|
||||
token: token
|
||||
access_token: access_token
|
||||
},
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
|
|
@ -277,11 +279,11 @@
|
|||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: "/job/batchRemove",
|
||||
url:quartz_batchRemove_url,
|
||||
type: 'post',
|
||||
data: {
|
||||
ids: checkIds,
|
||||
token:token
|
||||
access_token:access_token
|
||||
},
|
||||
success: function (result) {
|
||||
layer.close(loading);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public interface QuartzControllerApi {
|
|||
public Result update(@RequestBody QuartzJob job);
|
||||
|
||||
@ApiOperation("根据id获取定时任务")
|
||||
public QuartzJob getById(@PathVariable Long id);
|
||||
public QuartzJob findById(@PathVariable Long id);
|
||||
|
||||
@ApiOperation("删除定时任务")
|
||||
public Result delete( @RequestParam("jobId") Long jobId);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
package com.zhangmeng.quartz.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 转身的背影在心底里沉沦
|
||||
* @date 2021年9月14日16:45:29
|
||||
* @version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)// 激活方法上的PreAuthorize注解
|
||||
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||
|
||||
// 公钥
|
||||
private static final String PUBLIC_KEY = "public.key";
|
||||
|
||||
@Autowired
|
||||
private SecurityProperty securityProperty;
|
||||
|
||||
/***
|
||||
* 定义JwtTokenStore
|
||||
* @param jwtAccessTokenConverter
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
|
||||
return new JwtTokenStore(jwtAccessTokenConverter);
|
||||
}
|
||||
|
||||
/***
|
||||
* 定义JJwtAccessTokenConverter
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public JwtAccessTokenConverter jwtAccessTokenConverter() {
|
||||
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
||||
converter.setVerifierKey(getPubKey()); //秘钥的一部分
|
||||
return converter;
|
||||
}
|
||||
/**
|
||||
* 获取非对称加密公钥 Key
|
||||
* @return 公钥 Key
|
||||
*/
|
||||
private String getPubKey() {
|
||||
Resource resource = new ClassPathResource(PUBLIC_KEY);
|
||||
try {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
|
||||
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||
return br.lines().collect(Collectors.joining("\n"));
|
||||
} catch (IOException ioe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* SpringSecurity
|
||||
* Http安全配置,对每个到达系统的http请求链接进行校验
|
||||
* @param http
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http.headers().frameOptions().disable();
|
||||
|
||||
// 所有请求必须认证通过
|
||||
http.authorizeRequests()
|
||||
// 跨域预检请求
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
.anyRequest().
|
||||
authenticated(); // 其他地址需要认证授权
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.zhangmeng.quartz.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author 转身的背影在心底里沉沦
|
||||
* @date 2021年9月14日16:50:47
|
||||
* @version 1.0
|
||||
* */
|
||||
@Configuration
|
||||
@ConfigurationProperties("mystyle.security")
|
||||
public class SecurityProperty {
|
||||
|
||||
/**
|
||||
* 超级管理员不认证
|
||||
* */
|
||||
private boolean superAuthOpen;
|
||||
|
||||
/**
|
||||
* 不验证权限用户名
|
||||
* */
|
||||
private String superAdmin;
|
||||
|
||||
/**
|
||||
* 记住密码标识
|
||||
* */
|
||||
private String rememberKey;
|
||||
|
||||
/**
|
||||
* 开放接口列表
|
||||
* */
|
||||
private String[] openApi;
|
||||
|
||||
/**
|
||||
* 是否允许多账号在线
|
||||
* */
|
||||
private Integer maximum = 1;
|
||||
|
||||
public boolean isSuperAuthOpen() {
|
||||
return superAuthOpen;
|
||||
}
|
||||
|
||||
public void setSuperAuthOpen(boolean superAuthOpen) {
|
||||
this.superAuthOpen = superAuthOpen;
|
||||
}
|
||||
|
||||
public String getSuperAdmin() {
|
||||
return superAdmin;
|
||||
}
|
||||
|
||||
public void setSuperAdmin(String superAdmin) {
|
||||
this.superAdmin = superAdmin;
|
||||
}
|
||||
|
||||
public String getRememberKey() {
|
||||
return rememberKey;
|
||||
}
|
||||
|
||||
public void setRememberKey(String rememberKey) {
|
||||
this.rememberKey = rememberKey;
|
||||
}
|
||||
|
||||
public String[] getOpenApi() {
|
||||
return openApi;
|
||||
}
|
||||
|
||||
public void setOpenApi(String[] openApi) {
|
||||
this.openApi = openApi;
|
||||
}
|
||||
|
||||
public Integer getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
public void setMaximum(Integer maximum) {
|
||||
this.maximum = maximum;
|
||||
}
|
||||
}
|
||||
|
|
@ -97,9 +97,9 @@ public class QuartzController extends BaseController implements QuartzController
|
|||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/{id}")
|
||||
public QuartzJob getById(@PathVariable Long id) {
|
||||
return this.quartzJobService.findById(id);
|
||||
@GetMapping("/findById")
|
||||
public QuartzJob findById(@RequestParam("jobId") Long jobId){
|
||||
return this.quartzJobService.findById(jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class QuartzJobServiceImpl extends AbstractBaseServiceImpl<QuartzJob> imp
|
|||
} else {
|
||||
scheduler.scheduleJob(jobDetail, cronTrigger);
|
||||
}
|
||||
Condition condition = new Condition(Job.class);
|
||||
Condition condition = new Condition(QuartzJob.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
criteria.andEqualTo("jobName",name);
|
||||
List<QuartzJob> jobs = this.findByCondition(condition);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,28 @@ spring:
|
|||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
quartz:
|
||||
properties:
|
||||
org:
|
||||
quartz:
|
||||
scheduler:
|
||||
instanceName: DefaultQuartzScheduler
|
||||
instanceId: AUTO
|
||||
jobStore:
|
||||
class: org.quartz.impl.jdbcjobstore.JobStoreTX
|
||||
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||
tablePrefix: QRTZ_
|
||||
isClustered: false
|
||||
clusterCheckinInterval: 10000
|
||||
useProperties: false
|
||||
threadPool:
|
||||
class: org.quartz.simpl.SimpleThreadPool
|
||||
threadCount: 10
|
||||
threadPriority: 5
|
||||
threadsInheritContextClassLoaderOfInitializingThread: true
|
||||
job-store-type: jdbc
|
||||
jdbc:
|
||||
initialize-schema: always
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
|
|
|||
Loading…
Reference in New Issue