fix(修改): 修改模板生成
This commit is contained in:
parent
3407536e85
commit
5b370dd9f1
|
@ -36,7 +36,7 @@ import java.util.stream.Stream;
|
||||||
@Service
|
@Service
|
||||||
public class WebGeneratorCode {
|
public class WebGeneratorCode {
|
||||||
// 公共路径
|
// 公共路径
|
||||||
public static String commonPath = "D:\\MyFolder\\auth-admin\\auth-web\\src";
|
public static String commonPath = "D:\\Project\\web\\PC\\auth\\auth-web\\src";
|
||||||
// 生成API请求路径
|
// 生成API请求路径
|
||||||
public static String apiPath = commonPath + "\\api\\v1\\";
|
public static String apiPath = commonPath + "\\api\\v1\\";
|
||||||
// 生成vue路径
|
// 生成vue路径
|
||||||
|
@ -44,11 +44,11 @@ public class WebGeneratorCode {
|
||||||
// 生成仓库路径
|
// 生成仓库路径
|
||||||
public static String storePath = commonPath + "\\store\\monitor\\";
|
public static String storePath = commonPath + "\\store\\monitor\\";
|
||||||
// 后端controller
|
// 后端controller
|
||||||
public static String controllerPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\";
|
public static String controllerPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\";
|
||||||
public static String servicePath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\";
|
public static String servicePath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\";
|
||||||
public static String serviceImplPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\";
|
public static String serviceImplPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\";
|
||||||
public static String mapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\";
|
public static String mapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\";
|
||||||
public static String resourceMapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
public static String resourceMapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Class<?> originalClass = Schedulers.class;
|
Class<?> originalClass = Schedulers.class;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||||
#foreach($item in $baseFieldList)
|
#foreach($item in $baseFieldList)
|
||||||
<el-form-item :label="$t('${lowercaseName}_${item.name}')" prop="$item.name">
|
<el-form-item :label="$t('${lowercaseName}_${item.name}')" prop="$item.name">
|
||||||
<el-input v-model="form.$item.name" autocomplete="off" type="text" />
|
<el-input v-model="form.$item.name" autocomplete="off" type="text" :placeholder="$t('input') + $t('${lowercaseName}_${item.name}')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SchedulersController {
|
||||||
return Mono.just(Result.success(pageResult));
|
return Mono.just(Result.success(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "添加Schedulers视图", description = "添加Schedulers视图")
|
@Operation(summary = "添加Schedulers任务", description = "添加Schedulers任务")
|
||||||
@PostMapping("addSchedulers")
|
@PostMapping("addSchedulers")
|
||||||
public Mono<Result<String>> addSchedulers(@Valid @RequestBody SchedulersAddDto dto) {
|
public Mono<Result<String>> addSchedulers(@Valid @RequestBody SchedulersAddDto dto) {
|
||||||
schedulersService.addSchedulers(dto);
|
schedulersService.addSchedulers(dto);
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,28 +69,25 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
|
||||||
@Override
|
@Override
|
||||||
public void addSchedulers(@Valid SchedulersAddDto dto) {
|
public void addSchedulers(@Valid SchedulersAddDto dto) {
|
||||||
try {
|
try {
|
||||||
String jobGroup = dto.getJobGroup();
|
|
||||||
String jobName = dto.getJobName();
|
|
||||||
String cronExpression = dto.getCronExpression();
|
|
||||||
String description = dto.getDescription();
|
|
||||||
String jobMethodName = dto.getJobMethodName();
|
|
||||||
String jobClassName = dto.getJobClassName();
|
|
||||||
|
|
||||||
|
|
||||||
// 动态创建Class对象
|
// 动态创建Class对象
|
||||||
Class<?> className = Class.forName(jobClassName);
|
Class<?> className = Class.forName(dto.getJobClassName());
|
||||||
Constructor<?> constructor = className.getConstructor(); // 获取无参构造函数
|
|
||||||
constructor.newInstance(); // 创建实例
|
// 获取无参构造函数
|
||||||
|
className.getConstructor().newInstance();
|
||||||
|
|
||||||
// 创建任务
|
// 创建任务
|
||||||
JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) className).withIdentity(jobName, jobGroup)
|
JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) className)
|
||||||
.withDescription(description).build();
|
.withIdentity(dto.getJobName(), dto.getJobGroup())
|
||||||
jobDetail.getJobDataMap().put("jobMethodName", jobMethodName);
|
.withDescription(dto.getDescription())
|
||||||
|
.build();
|
||||||
|
jobDetail.getJobDataMap().put("jobMethodName", dto.getJobMethodName());
|
||||||
|
|
||||||
// 执行任务
|
// 执行任务
|
||||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
|
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(dto.getCronExpression());
|
||||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger" + jobName, jobGroup)
|
CronTrigger trigger = TriggerBuilder.newTrigger()
|
||||||
.startNow().withSchedule(cronScheduleBuilder).build();
|
.withIdentity("trigger" + dto.getJobName(), dto.getJobGroup())
|
||||||
|
.startNow()
|
||||||
|
.withSchedule(cronScheduleBuilder).build();
|
||||||
scheduler.scheduleJob(jobDetail, trigger);
|
scheduler.scheduleJob(jobDetail, trigger);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
throw new BunnyException(exception.getMessage());
|
throw new BunnyException(exception.getMessage());
|
||||||
|
|
Loading…
Reference in New Issue