提交 4464a49a 编写于 作者: sq3536's avatar sq3536

sample

上级 e7b38937
...@@ -141,7 +141,16 @@ public class JobsServiceImpl implements IJobsService { ...@@ -141,7 +141,16 @@ public class JobsServiceImpl implements IJobsService {
if(et == null) if(et == null)
return null; return null;
JobsInfo jobsInfo = new JobsInfo(); JobsInfo jobsInfo = new JobsInfo();
CachedBeanCopier.copy(et,jobsInfo); jobsInfo.setApp(et.getApp());
jobsInfo.setAuthor(et.getAuthor());
jobsInfo.setCron(et.getCron());
jobsInfo.setFailRetryCount(et.getFailRetryCount());
jobsInfo.setHandler(et.getHandler());
jobsInfo.setParam(et.getParam());
jobsInfo.setRemark(et.getRemark());
jobsInfo.setStatus(et.getStatus());
jobsInfo.setTenantId(et.getTenantId());
jobsInfo.setTimeout(et.getTimeout());
if(et.getId()!=null) if(et.getId()!=null)
jobsInfo.setId(et.getId().longValue()); jobsInfo.setId(et.getId().longValue());
if(et.getLastTime()!=null) if(et.getLastTime()!=null)
...@@ -160,7 +169,16 @@ public class JobsServiceImpl implements IJobsService { ...@@ -160,7 +169,16 @@ public class JobsServiceImpl implements IJobsService {
if(et == null) if(et == null)
return null; return null;
cn.ibizlab.core.task.domain.JobsInfo jobsInfo = new cn.ibizlab.core.task.domain.JobsInfo(); cn.ibizlab.core.task.domain.JobsInfo jobsInfo = new cn.ibizlab.core.task.domain.JobsInfo();
CachedBeanCopier.copy(et,jobsInfo); jobsInfo.setApp(et.getApp());
jobsInfo.setAuthor(et.getAuthor());
jobsInfo.setCron(et.getCron());
jobsInfo.setFailRetryCount(et.getFailRetryCount());
jobsInfo.setHandler(et.getHandler());
jobsInfo.setParam(et.getParam());
jobsInfo.setRemark(et.getRemark());
jobsInfo.setStatus(et.getStatus());
jobsInfo.setTenantId(et.getTenantId());
jobsInfo.setTimeout(et.getTimeout());
if(et.getId()!=null) if(et.getId()!=null)
jobsInfo.setId(BigInteger.valueOf(et.getId())); jobsInfo.setId(BigInteger.valueOf(et.getId()));
if(et.getLastTime()!=null) if(et.getLastTime()!=null)
...@@ -180,7 +198,13 @@ public class JobsServiceImpl implements IJobsService { ...@@ -180,7 +198,13 @@ public class JobsServiceImpl implements IJobsService {
if(et == null) if(et == null)
return null; return null;
cn.ibizlab.core.task.domain.JobsLog jobsLog = new cn.ibizlab.core.task.domain.JobsLog(); cn.ibizlab.core.task.domain.JobsLog jobsLog = new cn.ibizlab.core.task.domain.JobsLog();
CachedBeanCopier.copy(et,jobsLog); jobsLog.setAddress(et.getAddress());
jobsLog.setFailRetryCount(et.getFailRetryCount());
jobsLog.setHandler(et.getHandler());
jobsLog.setParam(et.getParam());
jobsLog.setTriggerCode(et.getTriggerCode());
jobsLog.setTriggerMsg(et.getTriggerMsg());
jobsLog.setTriggerType(et.getTriggerType());
if(et.getId()!=null) if(et.getId()!=null)
jobsLog.setId(BigInteger.valueOf(et.getId())); jobsLog.setId(BigInteger.valueOf(et.getId()));
if(et.getCreateTime()!=null) if(et.getCreateTime()!=null)
......
...@@ -119,6 +119,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -119,6 +119,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/"+downloadpath+"/**").permitAll() .antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll() .antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**").permitAll() .antMatchers("/"+previewpath+"/**").permitAll()
.antMatchers("/jobs-api").permitAll()
// 所有请求都需要认证 // 所有请求都需要认证
.anyRequest().authenticated() .anyRequest().authenticated()
// 防止iframe 造成跨域 // 防止iframe 造成跨域
......
package cn.ibizlab.api.rest;
import com.baomidou.jobs.JobsConstant;
import com.baomidou.jobs.starter.JobsScheduler;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Jobs Api
*
* @author jobob
* @since 2019-07-13
*/
@RestController
public class JobsApiResource implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
// to do nothing
}
@RequestMapping(JobsConstant.JOBS_API)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
JobsScheduler.invokeAdminService(request, response);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
</parent>
<artifactId>ibztask-sample</artifactId>
<name>Ibztask Sample</name>
<description> Sample</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>jobs-spring-boot-starter</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>ibztask</finalName>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<mainClass>com.baomidou.jobs.sample.JobsSampleApplication</mainClass>
<outputDirectory>../</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.baomidou.jobs.sample;
import com.baomidou.jobs.starter.EnableJobs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Spring boot jobs sample
*
* @author jobob
* @since 2019-06-25
*/
@EnableJobs
@SpringBootApplication
public class JobsSampleApplication {
public static void main(String[] args) {
SpringApplication.run(JobsSampleApplication.class, args);
}
}
\ No newline at end of file
package com.baomidou.jobs.sample.handler;
import com.baomidou.jobs.api.JobsResponse;
import com.baomidou.jobs.exception.JobsException;
import com.baomidou.jobs.handler.IJobsHandler;
import org.springframework.stereotype.Component;
/**
* 处理器 DEMO
*
* @author jobob
* @since 2019-07-16
*/
@Component("demojobhandler")
public class DemoJobHandler implements IJobsHandler {
@Override
public JobsResponse execute(String tenantId, String param) throws JobsException {
System.out.println("执行 DemoJobHandler tenantId=" + tenantId
+ ",param=" + param);
return JobsResponse.ok();
}
}
# web port
server:
port: 8081
### jobs
jobs:
admin-address: http://127.0.0.1:40005
app-name: jobs-executor-sample
app-port: 9999
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册