mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-09-10 22:19:07 +00:00
文档和代码更新
This commit is contained in:
@@ -359,9 +359,11 @@ bin/startup.sh
|
||||
|
||||
- dbswitch-admin的WEB端会根据用户的配置调用dbswitch-data模块执行数据迁移同步;
|
||||
|
||||
- dbswitch离线同步工具提供各种数据库间表结构转换RESTful类型的API接口:
|
||||
- dbswitch-admin服务启动时会基于flyway自动建库建表,需要保证配置的mysql连接账号具有建库建表等权限;
|
||||
|
||||
> swagger在线接口文档:```htttp://127.0.0.1:9088/swagger-ui.html```
|
||||
- dbswitch离线同步工具提供各种数据库间表结构转换RESTful类型的在线API接口如下:(详见[接口文档](/INTERFACE.md))
|
||||
|
||||
> Swagger在线接口地址: http://127.0.0.1:9088/swagger-ui/
|
||||
|
||||
- WEB系统的访问如下:
|
||||
|
||||
@@ -371,6 +373,8 @@ bin/startup.sh
|
||||
|
||||
> 建立源端数据库的连接 -> 建立目的断数据库的连接 -> 配置任务 -> 发布任务 -> 手动/系统调度执行任务 -> 查看调度记录
|
||||
|
||||
- WEB系统的部分截图:
|
||||
|
||||

|
||||
|
||||

|
||||
|
@@ -19,3 +19,7 @@ npm run build
|
||||
# build for production and view the bundle analyzer report
|
||||
npm run build --report
|
||||
```
|
||||
|
||||
## 三、部署
|
||||
|
||||
执行`npm run build`命令后,将dbswitch-admin-ui\dist目录生成的所有文件拷贝(或替换)到dbswitch-admin\src\main\resources目录下。然后直接使用mvn对整个dbswitch项目打包即可。
|
@@ -39,6 +39,9 @@ module.exports = {
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
options:{
|
||||
plugins:['syntax-dynamic-import']
|
||||
},
|
||||
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
|
||||
},
|
||||
{
|
||||
|
26500
dbswitch-admin-ui/package-lock.json
generated
Normal file
26500
dbswitch-admin-ui/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
"babel-core": "^6.22.1",
|
||||
"babel-helper-vue-jsx-merge-props": "^2.0.3",
|
||||
"babel-loader": "^7.1.1",
|
||||
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
||||
"babel-plugin-syntax-jsx": "^6.18.0",
|
||||
"babel-plugin-transform-runtime": "^6.22.0",
|
||||
"babel-plugin-transform-vue-jsx": "^3.5.0",
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
|
||||
Vue.use(Router)
|
||||
Vue.use(Router);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 路由配置
|
||||
|
@@ -85,12 +85,17 @@
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -82,12 +82,13 @@ public class ShiroConfig {
|
||||
// anno匿名访问 auth验证
|
||||
filterMap.put("/static/**", "anon");
|
||||
filterMap.put("/index.html", "anon");
|
||||
filterMap.put("/favicon.ico", "anon");
|
||||
filterMap.put("/favicon.ico*", "anon");
|
||||
filterMap.put("/webjars/**", "anon");
|
||||
filterMap.put(SwaggerConfig.API_V1 + "/authentication/login", "anon");
|
||||
filterMap.put("/swagger/**", "anon");
|
||||
filterMap.put("/v2/api-docs", "anon");
|
||||
filterMap.put("/swagger-ui.html", "anon");
|
||||
filterMap.put("/swagger-ui/**", "anon");
|
||||
filterMap.put("/v2/api-docs*", "anon");
|
||||
filterMap.put("/swagger-ui.html*", "anon");
|
||||
filterMap.put("/swagger-resources/**", "anon");
|
||||
// 除了以上路径,其他都需要权限验证
|
||||
filterMap.put("/**", "auth");
|
||||
|
@@ -9,6 +9,8 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
package com.gitee.dbswitch.admin.config.shiro;
|
||||
|
||||
import com.gitee.dbswitch.admin.common.excption.DbswitchException;
|
||||
import com.gitee.dbswitch.admin.common.response.ResultCode;
|
||||
import com.gitee.dbswitch.admin.dao.SystemUserDAO;
|
||||
import com.gitee.dbswitch.admin.entity.SystemUserEntity;
|
||||
import com.gitee.dbswitch.admin.util.CacheUtil;
|
||||
@@ -91,7 +93,7 @@ public class SystemUserRealm extends AuthorizingRealm {
|
||||
//根据缓存将token转换成User实体对象
|
||||
Object cache = CacheUtil.get(accessToken);
|
||||
if (null == cache) {
|
||||
throw new RuntimeException("token不存在或已经失效,请重新登录!");
|
||||
throw new DbswitchException(ResultCode.ERROR_ACCESS_FORBIDDEN, "token不存在或已经失效,请重新登录!");
|
||||
}
|
||||
|
||||
//判断数据库中的User实体对象的有效性
|
||||
|
@@ -46,14 +46,14 @@ public class AssignmentController {
|
||||
@PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Result<AssignmentInfoResponse> createAssignment(
|
||||
@RequestBody AssigmentCreateRequest request) {
|
||||
return Result.success(assignmentService.create(request));
|
||||
return Result.success(assignmentService.createAssignment(request));
|
||||
}
|
||||
|
||||
@OperateLog(name = "修改任务", description = "'修改任务的名称为:'+#request.name")
|
||||
@ApiOperation(value = "修改")
|
||||
@PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Result updateAssignment(@RequestBody AssigmentUpdateRequest request) {
|
||||
assignmentService.update(request);
|
||||
assignmentService.updateAssignment(request);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AssignmentController {
|
||||
@ApiOperation(value = "删除")
|
||||
@DeleteMapping(value = "/delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Result deleteAssignment(@PathVariable("id") Long id) {
|
||||
assignmentService.delete(id);
|
||||
assignmentService.deleteAssignment(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@@ -81,24 +81,24 @@ public class AssignmentController {
|
||||
@OperateLog(name = "发布任务", description = "'发布任务的ID为:'+#ids")
|
||||
@ApiOperation(value = "发布")
|
||||
@PostMapping(value = "/deploy", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Result deployAssignment(@RequestParam(value = "ids") List<Long> ids) {
|
||||
assignmentService.deploy(ids);
|
||||
public Result deployAssignments(@RequestParam(value = "ids") List<Long> ids) {
|
||||
assignmentService.deployAssignments(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@OperateLog(name = "手动执行任务", description = "'手动执行任务的ID为:'+#ids")
|
||||
@ApiOperation(value = "手动执行")
|
||||
@RequestMapping(value = "/run", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
|
||||
public Result runAssignment(@RequestBody List<Long> ids) {
|
||||
assignmentService.run(ids);
|
||||
public Result runAssignments(@RequestBody List<Long> ids) {
|
||||
assignmentService.runAssignments(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@OperateLog(name = "下线任务", description = "'下线任务的ID为:'+#ids")
|
||||
@ApiOperation(value = "下线")
|
||||
@PostMapping(value = "/retire", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Result retireAssignment(@RequestParam(value = "ids") List<Long> ids) {
|
||||
assignmentService.retire(ids);
|
||||
public Result retireAssignments(@RequestParam(value = "ids") List<Long> ids) {
|
||||
assignmentService.retireAssignments(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
@@ -24,14 +24,17 @@ public class ExceptionController {
|
||||
@ResponseBody
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public Result errorHandler(Exception ex) {
|
||||
if (ex instanceof DbswitchException) {
|
||||
DbswitchException learnException = (DbswitchException) ex;
|
||||
return Result.failed(learnException.getCode(), learnException.getMessage());
|
||||
}
|
||||
|
||||
log.error("ERROR:", ex);
|
||||
if (ex instanceof NullPointerException) {
|
||||
return Result.failed(ResultCode.ERROR_INTERNAL_ERROR, "Null Pointer Expression");
|
||||
} else if (ex instanceof DbswitchException) {
|
||||
DbswitchException learnException = (DbswitchException) ex;
|
||||
return Result.failed(learnException.getCode(), learnException.getMessage());
|
||||
} else {
|
||||
return Result.failed(ResultCode.ERROR_INTERNAL_ERROR, ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,8 @@ public class AssignmentJobDAO {
|
||||
@Resource
|
||||
private AssignmentJobMapper assignmentJobMapper;
|
||||
|
||||
public AssignmentJobEntity newAssignmentJob(Long assignmentId, Integer scheduleMode , String jobKey) {
|
||||
public AssignmentJobEntity newAssignmentJob(Long assignmentId, Integer scheduleMode,
|
||||
String jobKey) {
|
||||
AssignmentJobEntity assignmentJobEntity = new AssignmentJobEntity();
|
||||
assignmentJobEntity.setAssignmentId(assignmentId);
|
||||
assignmentJobEntity.setJobKey(jobKey);
|
||||
@@ -46,8 +47,12 @@ public class AssignmentJobDAO {
|
||||
|
||||
public List<AssignmentJobEntity> getByAssignmentId(Long assignmentId) {
|
||||
Objects.requireNonNull(assignmentId, "assignmentId不能为null");
|
||||
|
||||
AssignmentJobEntity condition = new AssignmentJobEntity();
|
||||
condition.setAssignmentId(assignmentId);
|
||||
|
||||
Example example = new Example(AssignmentJobEntity.class);
|
||||
example.createCriteria().andEqualTo("assignmentId", assignmentId);
|
||||
example.createCriteria().andEqualTo(condition);
|
||||
example.orderBy("createTime").desc();
|
||||
return assignmentJobMapper.selectByExample(example);
|
||||
}
|
||||
@@ -58,8 +63,11 @@ public class AssignmentJobDAO {
|
||||
}
|
||||
|
||||
public int getCountByStatus(JobStatusEnum status) {
|
||||
AssignmentJobEntity condition = new AssignmentJobEntity();
|
||||
condition.setStatus(status.getValue());
|
||||
|
||||
Example example = new Example(AssignmentJobEntity.class);
|
||||
example.createCriteria().andEqualTo("status", status.getValue());
|
||||
example.createCriteria().andEqualTo(condition);
|
||||
return assignmentJobMapper.selectCountByExample(example);
|
||||
}
|
||||
|
||||
|
@@ -59,8 +59,11 @@ public class AssignmentTaskDAO {
|
||||
}
|
||||
|
||||
public int getPublishedCount() {
|
||||
AssignmentTaskEntity condition = new AssignmentTaskEntity();
|
||||
condition.setPublished(Boolean.TRUE);
|
||||
|
||||
Example example = new Example(AssignmentTaskEntity.class);
|
||||
example.createCriteria().andEqualTo("published", 1);
|
||||
example.createCriteria().andEqualTo(condition);
|
||||
return assignmentTaskMapper.selectCountByExample(example);
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,11 @@ public class SystemLogDAO {
|
||||
public List<SystemLogEntity> listAll(LogTypeEnum logType) {
|
||||
Example example = new Example(SystemLogEntity.class);
|
||||
Criteria criteria = example.createCriteria();
|
||||
criteria.andEqualTo("type", logType.getValue());
|
||||
|
||||
SystemLogEntity condition=new SystemLogEntity();
|
||||
condition.setType(logType.getValue());
|
||||
|
||||
criteria.andEqualTo(condition);
|
||||
example.orderBy("createTime").desc();
|
||||
return systemLogMapper.selectByExample(example);
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ public class AssignmentService {
|
||||
private DatabaseConnectionDAO databaseConnectionDAO;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AssignmentInfoResponse create(AssigmentCreateRequest request) {
|
||||
public AssignmentInfoResponse createAssignment(AssigmentCreateRequest request) {
|
||||
AssignmentTaskEntity assignment = request.toAssignmentTask();
|
||||
assignmentTaskDAO.insert(assignment);
|
||||
|
||||
@@ -70,12 +70,12 @@ public class AssignmentService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
public void deleteAssignment(Long id) {
|
||||
assignmentTaskDAO.deleteById(id);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(AssigmentUpdateRequest request) {
|
||||
public void updateAssignment(AssigmentUpdateRequest request) {
|
||||
AssignmentTaskEntity assignmentTaskEntity = assignmentTaskDAO.getById(request.getId());
|
||||
if (Objects.isNull(assignmentTaskEntity)) {
|
||||
throw new DbswitchException(ResultCode.ERROR_RESOURCE_NOT_EXISTS, "ID=" + request.getId());
|
||||
@@ -93,10 +93,9 @@ public class AssignmentService {
|
||||
}
|
||||
|
||||
public PageResult<AssignmentInfoResponse> listAll(String searchText, Integer page, Integer size) {
|
||||
Supplier<List<AssignmentInfoResponse>> method = () -> {
|
||||
List<AssignmentTaskEntity> assignments = assignmentTaskDAO.listAll(searchText);
|
||||
return ConverterFactory.getConverter(AssignmentInfoConverter.class).convert(assignments);
|
||||
};
|
||||
Supplier<List<AssignmentInfoResponse>> method = () ->
|
||||
ConverterFactory.getConverter(AssignmentInfoConverter.class)
|
||||
.convert(assignmentTaskDAO.listAll(searchText));
|
||||
|
||||
return PageUtil.getPage(method, page, size);
|
||||
}
|
||||
@@ -113,7 +112,7 @@ public class AssignmentService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deploy(List<Long> ids) {
|
||||
public void deployAssignments(List<Long> ids) {
|
||||
checkAssignmentAllExist(ids);
|
||||
|
||||
//检查是否有已经发布过
|
||||
@@ -147,7 +146,7 @@ public class AssignmentService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void run(List<Long> ids) {
|
||||
public void runAssignments(List<Long> ids) {
|
||||
checkAssignmentAllExist(ids);
|
||||
|
||||
//检查是否有已经都发布了
|
||||
@@ -168,12 +167,12 @@ public class AssignmentService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void retire(List<Long> ids) {
|
||||
public void retireAssignments(List<Long> ids) {
|
||||
checkAssignmentAllExist(ids);
|
||||
for (Long id : ids) {
|
||||
AssignmentTaskEntity assignmentTaskEntity = assignmentTaskDAO.getById(id);
|
||||
if (Objects.nonNull(assignmentTaskEntity.getPublished()) && assignmentTaskEntity
|
||||
.getPublished()) {
|
||||
if (Objects.nonNull(assignmentTaskEntity.getPublished()) &&
|
||||
assignmentTaskEntity.getPublished()) {
|
||||
scheduleService.cancelJobByTaskId(id);
|
||||
assignmentTaskEntity.setPublished(Boolean.FALSE);
|
||||
assignmentTaskEntity.setContent("{}");
|
||||
|
@@ -62,21 +62,21 @@ public class ScheduleService {
|
||||
|
||||
}
|
||||
|
||||
public Trigger getQuartzJobDetail(String jobKey) {
|
||||
Scheduler scheduler = schedulerFactoryBean.getScheduler();
|
||||
|
||||
String triggerName = jobKey;
|
||||
String triggerGroup = JobExecutorService.GROUP;
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroup);
|
||||
try {
|
||||
Trigger trigger = scheduler.getTrigger(triggerKey);
|
||||
return trigger;
|
||||
} catch (SchedulerException e) {
|
||||
log.error("Query job trigger detail failed:", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
// public Trigger getQuartzJobDetail(String jobKey) {
|
||||
// Scheduler scheduler = schedulerFactoryBean.getScheduler();
|
||||
//
|
||||
// String triggerName = jobKey;
|
||||
// String triggerGroup = JobExecutorService.GROUP;
|
||||
// TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroup);
|
||||
// try {
|
||||
// Trigger trigger = scheduler.getTrigger(triggerKey);
|
||||
// return trigger;
|
||||
// } catch (SchedulerException e) {
|
||||
// log.error("Query job trigger detail failed:", e);
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public void scheduleTask(Long taskId, ScheduleModeEnum scheduleMode) {
|
||||
/** 准备JobDetail */
|
||||
@@ -84,12 +84,10 @@ public class ScheduleService {
|
||||
String jobGroup = JobExecutorService.GROUP;
|
||||
JobKey jobKey = JobKey.jobKey(jobName, jobGroup);
|
||||
|
||||
JobDetail jobDetail = JobBuilder.newJob(JobExecutorService.class)
|
||||
JobBuilder jobBuilder = JobBuilder.newJob(JobExecutorService.class)
|
||||
.withIdentity(jobKey)
|
||||
.usingJobData(JobExecutorService.TASK_ID, taskId.toString())
|
||||
.usingJobData(JobExecutorService.SCHEDULE, scheduleMode.getValue().toString())
|
||||
.storeDurably()
|
||||
.build();
|
||||
.usingJobData(JobExecutorService.SCHEDULE, scheduleMode.getValue().toString());
|
||||
|
||||
/** 准备TriggerKey,注意这里的triggerName与jobName配置相同 */
|
||||
String triggerName = jobName;
|
||||
@@ -100,9 +98,9 @@ public class ScheduleService {
|
||||
|
||||
AssignmentTaskEntity task = assignmentTaskDAO.getById(taskId);
|
||||
if (ScheduleModeEnum.MANUAL == scheduleMode) {
|
||||
scheduleOnce(jobDetail, triggerKey);
|
||||
scheduleOnce(jobBuilder.storeDurably(false).build(), triggerKey);
|
||||
} else {
|
||||
scheduleCron(jobDetail, triggerKey, task.getCronExpression());
|
||||
scheduleCron(jobBuilder.storeDurably(true).build(), triggerKey, task.getCronExpression());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -132,9 +130,7 @@ public class ScheduleService {
|
||||
try {
|
||||
scheduler.interrupt(jobKey);
|
||||
scheduler.pauseTrigger(triggerKey);
|
||||
scheduler.unscheduleJob(triggerKey);
|
||||
scheduler.deleteJob(jobKey);
|
||||
return true;
|
||||
return scheduler.unscheduleJob(triggerKey) && scheduler.deleteJob(jobKey);
|
||||
} catch (SchedulerException e) {
|
||||
log.error("Quartz stop task job failed. JobKey: {}", jobKey);
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@ package com.gitee.dbswitch.admin.util;
|
||||
import com.gitee.dbswitch.admin.common.response.PageResult;
|
||||
import com.gitee.dbswitch.admin.common.response.PageResult.Pagination;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -20,10 +19,8 @@ public class PageUtil {
|
||||
|
||||
public static <E> PageResult<E> getPage(Supplier<List<E>> method, int pageNum, int pageSize) {
|
||||
com.github.pagehelper.Page<E> originPage = PageHelper.startPage(pageNum, pageSize);
|
||||
List<E> result = method.get();
|
||||
|
||||
PageResult<E> resultPage = new PageResult<>();
|
||||
resultPage.setData(result);
|
||||
resultPage.setData(method.get());
|
||||
|
||||
Pagination pagination = new Pagination();
|
||||
pagination.setTotal((int) originPage.getTotal());
|
||||
@@ -35,52 +32,8 @@ public class PageUtil {
|
||||
pagination.setSize(originPage.getPageSize());
|
||||
}
|
||||
resultPage.setPagination(pagination);
|
||||
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
public static <E> PageResult<E> getPage(List<E> pagingList, int pageNum, int pageSize) {
|
||||
Pagination pagination = new Pagination();
|
||||
PageResult<E> page = new PageResult<>();
|
||||
if (pageNum <= 0 || pageSize <= 0) {
|
||||
pagination.setTotal(pagingList.size());
|
||||
pagination.setPage(0);
|
||||
pagination.setSize(0);
|
||||
page.setPagination(pagination);
|
||||
page.setData(pagingList);
|
||||
} else {
|
||||
pagination.setTotal(pagingList.size());
|
||||
pagination.setPage(pageNum);
|
||||
pagination.setSize(pageSize);
|
||||
|
||||
page.setPagination(pagination);
|
||||
page.setData(subList(pagingList, pageNum, pageSize));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public static <E> PageResult<E> pacPage(List<E> pagingList, int pageNum, int pageSize, int total) {
|
||||
Pagination pagination = new Pagination();
|
||||
PageResult<E> page = new PageResult<>();
|
||||
pagination.setTotal(total);
|
||||
pagination.setPage(pageNum);
|
||||
pagination.setSize(pageSize);
|
||||
page.setPagination(pagination);
|
||||
page.setData(pagingList);
|
||||
return page;
|
||||
}
|
||||
|
||||
private static <E> List<E> subList(List<E> list, int pageNum, int pageSize) {
|
||||
int size = list.size();
|
||||
List<E> result = new ArrayList<>();
|
||||
int idx = (pageNum - 1) * pageSize;
|
||||
int end = idx + pageSize;
|
||||
while (idx < size && idx < end) {
|
||||
result.add(list.get(idx));
|
||||
idx++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,20 +28,8 @@ public class SpringUtil implements ApplicationContextAware {
|
||||
return SpringUtil.applicationContext;
|
||||
}
|
||||
|
||||
public static Object getBean(String name) {
|
||||
return SpringUtil.applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return SpringUtil.applicationContext.getBean(clazz);
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> clazz, Object... objects) {
|
||||
return SpringUtil.applicationContext.getBean(clazz, objects);
|
||||
}
|
||||
|
||||
public static <T> T getBean(String name, Class<T> clazz) {
|
||||
return SpringUtil.applicationContext.getBean(name, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ mybatis:
|
||||
lazy-loading-enabled: true
|
||||
aggressive-lazy-loading: false
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
mapper:
|
||||
wrap-keyword: "`{0}`"
|
||||
|
@@ -4,7 +4,6 @@
|
||||
-- STDJDBCDELEGATE说明支持集群,所有的任务信息都会保存到数据库中,可以控制事物,还有就是如果应用服务器关闭或者重启,任务信息都不会丢失,并且可以恢复因服务器关闭或者重启而导致执行失败的任务
|
||||
-- THIS IS THE SCRIPT FROM QUARTZ TO CREATE THE TABLES IN A MYSQL DATABASE, MODIFIED TO USE INNODB INSTEAD OF MYISAM
|
||||
|
||||
-- 存储每一个已配置的JOB的详细信息
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_JOB_DETAILS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -18,9 +17,8 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_JOB_DETAILS
|
||||
REQUESTS_RECOVERY VARCHAR(1) NOT NULL,
|
||||
JOB_DATA BLOB NULL,
|
||||
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储每一个已配置的JOB的详细信息';
|
||||
|
||||
-- 存储已配置的TRIGGER的信息
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_TRIGGERS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -42,9 +40,8 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_TRIGGERS
|
||||
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
|
||||
REFERENCES DBSWITCH_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储已配置的TRIGGER的信息';
|
||||
|
||||
-- 存储已配置的SIMPLE TRIGGER的信息
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_SIMPLE_TRIGGERS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -56,9 +53,8 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_SIMPLE_TRIGGERS
|
||||
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES DBSWITCH_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储已配置的SIMPLE类型的触发器(包括重复次数,间隔,及已触的次数)';
|
||||
|
||||
-- 存储CRON TRIGGER,包括CRON表达式和时区信息
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_CRON_TRIGGERS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -69,9 +65,8 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_CRON_TRIGGERS
|
||||
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES DBSWITCH_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储CRON类型的触发器(包括Cron表达式和时区信息)';
|
||||
|
||||
-- 存储简单的Trigger,包括重复次数,间隔,以及已触的次数
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_SIMPROP_TRIGGERS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -91,9 +86,8 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_SIMPROP_TRIGGERS
|
||||
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES DBSWITCH_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
)ENGINE=INNODB;
|
||||
)ENGINE=INNODB COMMENT = '存储CalendarIntervalTrigger和DailyTimeIntervalTrigger两种类型的触发器';
|
||||
|
||||
-- TRIGGER作为BLOB类型存储(用于QUARTZ用户用JDBC创建他们自己定制的TRIGGER类型,JOBSTORE并不知道如何存储实例的时候)
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_BLOB_TRIGGERS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -104,26 +98,23 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_BLOB_TRIGGERS
|
||||
INDEX (SCHED_NAME,TRIGGER_NAME, TRIGGER_GROUP),
|
||||
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES DBSWITCH_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
)ENGINE=INNODB;
|
||||
)ENGINE=INNODB COMMENT = 'TRIGGER作为BLOB类型存储(用于QUARTZ用户用JDBC创建他们自己定制的TRIGGER类型,JOBSTORE并不知道如何存储实例的时候)';
|
||||
|
||||
-- 以BLOB类型存储QUARTZ的CALENDAR日历信息,QUARTZ可配置一个日历来指定一个时间范围
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_CALENDARS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
CALENDAR_NAME VARCHAR(200) NOT NULL,
|
||||
CALENDAR BLOB NOT NULL,
|
||||
PRIMARY KEY (SCHED_NAME,CALENDAR_NAME)
|
||||
)ENGINE=INNODB;
|
||||
)ENGINE=INNODB COMMENT = '以BLOB类型存储QUARTZ的CALENDAR日历信息,QUARTZ可配置一个日历来指定一个时间范围';
|
||||
|
||||
-- 存储已暂停的TRIGGER组的信息
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_PAUSED_TRIGGER_GRPS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储已暂停的TRIGGER组的信息';
|
||||
|
||||
-- 存储与已触发的TRIGGER相关的状态信息,以及相联JOB的执行信息
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_FIRED_TRIGGERS
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -140,9 +131,8 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_FIRED_TRIGGERS
|
||||
IS_NONCONCURRENT VARCHAR(1) NULL,
|
||||
REQUESTS_RECOVERY VARCHAR(1) NULL,
|
||||
PRIMARY KEY (SCHED_NAME,ENTRY_ID)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储与已触发的TRIGGER相关的状态信息,以及相联JOB的执行信息';
|
||||
|
||||
-- 存储少量的有关 SCHEDULER的状态信息,和别的 SCHEDULER 实例(假如是用于一个集群中)
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_SCHEDULER_STATE
|
||||
(
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
@@ -150,7 +140,7 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_SCHEDULER_STATE
|
||||
LAST_CHECKIN_TIME BIGINT(13) NOT NULL,
|
||||
CHECKIN_INTERVAL BIGINT(13) NOT NULL,
|
||||
PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储少量的有关 SCHEDULER的状态信息,和别的 SCHEDULER 实例(假如是用于一个集群中)';
|
||||
|
||||
-- 存储程序的非观锁的信息(假如使用了悲观锁)
|
||||
CREATE TABLE IF NOT EXISTS DBSWITCH_LOCKS
|
||||
@@ -158,7 +148,7 @@ CREATE TABLE IF NOT EXISTS DBSWITCH_LOCKS
|
||||
SCHED_NAME VARCHAR(120) NOT NULL,
|
||||
LOCK_NAME VARCHAR(40) NOT NULL,
|
||||
PRIMARY KEY (SCHED_NAME,LOCK_NAME)
|
||||
) ENGINE=INNODB;
|
||||
) ENGINE=INNODB COMMENT = '存储程序的非观锁的信息(假如使用了悲观锁)';
|
||||
|
||||
-- 创建索引
|
||||
CREATE INDEX IDX_DBSWITCH_J_REQ_RECOVERY ON DBSWITCH_JOB_DETAILS(SCHED_NAME,REQUESTS_RECOVERY);
|
||||
|
@@ -81,9 +81,10 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<groupId>net.minidev</groupId>
|
||||
<artifactId>json-smart</artifactId>
|
||||
<version>2.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
Reference in New Issue
Block a user