jpz最新

newone
jpz 2023-12-27 10:36:31 +08:00
parent 96f33c3358
commit b68b6af04c
11 changed files with 11 additions and 91 deletions

View File

@ -12,6 +12,7 @@
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>net.srt</groupId>
<artifactId>srt-cloud-api</artifactId>

View File

@ -172,7 +172,7 @@ public class QualityConfigServiceimpl extends BaseServiceImpl<QualityConfigDao,
*/
@Override
public void handRun(Long id) {
// quartzDataGovernanceQualityApi.handRun(id);
quartzDataGovernanceQualityApi.handRun(id);
System.out.println("===================================");
}

View File

@ -88,7 +88,7 @@ public class DataServiceApiConfigEntity extends BaseEntity {
/**
* 0- 1-
*/
private Integer previlege;
private Integer privates;
/**
* 0- 1-

View File

@ -87,7 +87,7 @@ public class MappingRequestHandler {
throw new ServerException(String.format("不支持的请求类型,请使用 【%s】方式请求", apiConfigEntity.getType()));
}
//如果是私有接口,鉴权
if (apiConfigEntity.getPrevilege() == 1) {
if (apiConfigEntity.getPrivates() == 1) {
if (StringUtil.isBlank(apiToken)) {
throw new ServerException("No Token!");
}

View File

@ -90,7 +90,7 @@ public class DataServiceApiConfigServiceImpl extends BaseServiceImpl<DataService
.eq(query.getStatus() != null, DataServiceApiConfigEntity::getStatus, query.getStatus())
.eq(query.getSqlDbType() != null, DataServiceApiConfigEntity::getSqlDbType, query.getSqlDbType())
.eq(query.getDatabaseId() != null, DataServiceApiConfigEntity::getDatabaseId, query.getDatabaseId())
.eq(query.getPrevilege() != null, DataServiceApiConfigEntity::getPrevilege, query.getPrevilege())
.eq(query.getPrevilege() != null, DataServiceApiConfigEntity::getPrivates, query.getPrevilege())
.eq(query.getOpenTrans() != null, DataServiceApiConfigEntity::getOpenTrans, query.getOpenTrans())
.orderByDesc(DataServiceApiConfigEntity::getCreateTime).orderByDesc(DataServiceApiConfigEntity::getId);
dataScopeWithoutOrgId(wrapper);
@ -228,8 +228,8 @@ public class DataServiceApiConfigServiceImpl extends BaseServiceImpl<DataService
.append("\n- 接口地址:/data-service/api/").append(api.getPath())
.append("\n- 请求方式:").append(api.getType())
.append("\n- Content-Type").append(api.getContentType())
.append("\n- 是否需要鉴权:").append(api.getPrevilege() == 1 ? "是" : "否");
if (api.getPrevilege() == 1) {
.append("\n- 是否需要鉴权:").append(api.getPrivates() == 1 ? "是" : "否");
if (api.getPrivates() == 1) {
docs.append("\n- 获取鉴权token").append("/data-service/api/token/generate?appKey=您的appKey&appSecret=您的appToken");
}
docs.append("\n- 接口备注:").append(api.getNote())

View File

@ -65,7 +65,7 @@ public class DataServiceApiConfigVO implements Serializable {
private Long databaseId;
@Schema(description = "是否私有 0-否 1-是")
private Integer previlege;
private Integer privates;
@Schema(description = "是否开启事务 0-否 1-是")
private Integer openTrans;

View File

@ -61,11 +61,7 @@
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
<dependency>
<groupId>net.srt</groupId>
<artifactId>srt-cloud-datax</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>

View File

@ -14,7 +14,7 @@ import org.springframework.context.annotation.ComponentScan;
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
@ComponentScan(basePackages = "net.srt.framework.common.cache")
@ComponentScan(basePackages = {"net.srt.framework.common.cache","net.srt"})
public class QuartzApplication {
public static void main(String[] args) {

View File

@ -1,76 +0,0 @@
package net.srt.quartz.api;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import net.srt.api.module.data.integrate.DataAccessApi;
import net.srt.api.module.data.integrate.constant.TaskType;
import net.srt.api.module.data.integrate.dto.DataAccessDto;
import net.srt.api.module.data.integrate.dto.DataAccessTaskDto;
import net.srt.api.module.quartz.QuartzDataAccessApi;
import net.srt.api.module.quartz.constant.QuartzJobType;
import net.srt.datax.feign.DataAccessFeign;
import net.srt.framework.common.utils.Result;
import net.srt.quartz.entity.ScheduleJobEntity;
import net.srt.quartz.enums.JobGroupEnum;
import net.srt.quartz.enums.ScheduleConcurrentEnum;
import net.srt.quartz.enums.ScheduleStatusEnum;
import net.srt.quartz.service.ScheduleJobService;
import net.srt.quartz.task.DataAccessTask;
import net.srt.quartz.utils.ScheduleUtils;
import org.quartz.Scheduler;
import org.springframework.web.bind.annotation.RestController;
/**
* API
*
* @author babamu@126.com
*/
@RestController
@RequiredArgsConstructor
public class QuartzDataAccessApiImpl implements QuartzDataAccessApi {
private final Scheduler scheduler;
private final DataAccessApi dataAccessApi;
private final ScheduleJobService jobService;
private final DataAccessFeign feign;
@Override
public Result<String> releaseAccess(Long id) {
ScheduleJobEntity jobEntity = buildJobEntity(id);
//判断是否存在,不存在,新增,存在,设置主键
jobService.buildSystemJob(jobEntity);
ScheduleUtils.createScheduleJob(scheduler, jobEntity);
return Result.ok();
}
@Override
public Result<String> cancleAccess(Long id) {
ScheduleJobEntity jobEntity = buildJobEntity(id);
jobService.buildSystemJob(jobEntity);
ScheduleUtils.deleteScheduleJob(scheduler, jobEntity);
//更新任务状态为暂停
jobService.pauseSystemJob(jobEntity);
return Result.ok();
}
@Override
public Result<String> handRun(Long id) {
ScheduleJobEntity jobEntity = buildJobEntity(id);
jobEntity.setOnce(true);
jobEntity.setSaveLog(false);
ScheduleUtils.run(scheduler, jobEntity);
return Result.ok();
}
private ScheduleJobEntity buildJobEntity(Long id) {
DataAccessDto dataAccessDto = dataAccessApi.getById(id).getData();
if (dataAccessDto.getIsDatax().equals("datax")){
feign.execute(dataAccessDto);
}
return ScheduleJobEntity.builder().isDatax(dataAccessDto.getIsDatax()).typeId(id).projectId(dataAccessDto.getProjectId()).jobType(QuartzJobType.DATA_ACCESS.getValue()).jobName(String.format("[%s]%s", id.toString(), dataAccessDto.getTaskName())).concurrent(ScheduleConcurrentEnum.NO.getValue())
.beanName("dataAccessTask").method("run").jobGroup(JobGroupEnum.DATA_ACCESS.getValue()).saveLog(true).cronExpression(dataAccessDto.getCron()).status(ScheduleStatusEnum.NORMAL.getValue())
.params(String.valueOf(id)).once(TaskType.ONE_TIME_FULL_SYNC.getCode().equals(dataAccessDto.getTaskType())).build();
}
}

View File

@ -1,6 +1,5 @@
package net.srt.quartz.utils;
import net.srt.datax.feign.DataAccessFeign;
import net.srt.framework.common.exception.ServerException;
import net.srt.quartz.entity.ScheduleJobEntity;
import net.srt.quartz.enums.ScheduleConcurrentEnum;

View File

@ -1,3 +1,3 @@
auth:
ignore_urls:
- /api/quartz/**
- /api/quartz/quality/**