-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7ee607
commit ab23e03
Showing
7 changed files
with
219 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...tarter/src/main/java/com/jmsoftware/maf/springcloudstarter/function/BooleanCheckUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.jmsoftware.maf.springcloudstarter.function; | ||
|
||
import cn.hutool.core.util.BooleanUtil; | ||
|
||
import java.util.function.Consumer; | ||
import java.util.function.Supplier; | ||
|
||
import static java.util.Objects.nonNull; | ||
|
||
/** | ||
* Description: BooleanCheckUtil, change description here. | ||
* | ||
* @author Johnny Miller (锺俊), email: [email protected], date: 9/27/2021 12:03 PM | ||
**/ | ||
public class BooleanCheckUtil { | ||
/** | ||
* Require true or else throw exception. | ||
* | ||
* @param aBoolean the aBoolean | ||
* @param after the after | ||
* @return the throw exception function | ||
*/ | ||
public static ThrowExceptionFunction requireTrue(Boolean aBoolean, Consumer<Boolean> after) { | ||
if (nonNull(after)) { | ||
after.accept(aBoolean); | ||
} | ||
return exceptionSupplier -> { | ||
if (BooleanUtil.isFalse(aBoolean)) { | ||
throw exceptionSupplier.get(); | ||
} | ||
}; | ||
} | ||
|
||
@FunctionalInterface | ||
public interface ThrowExceptionFunction { | ||
/** | ||
* Or else throw. | ||
* | ||
* @param exceptionSupplier the exception supplier | ||
* @throws Throwable the throwable | ||
*/ | ||
void orElseThrow(Supplier<? extends Throwable> exceptionSupplier) throws Throwable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package com.jmsoftware.maf.springcloudstarter.quartz.controller; | ||
|
||
import com.jmsoftware.maf.common.bean.PageResponseBodyBean; | ||
import com.jmsoftware.maf.springcloudstarter.poi.AbstractExcelDataController; | ||
import com.jmsoftware.maf.springcloudstarter.quartz.entity.GetQuartzJobConfigurationPageListItem; | ||
import com.jmsoftware.maf.springcloudstarter.quartz.entity.GetQuartzJobConfigurationPageListPayload; | ||
import com.jmsoftware.maf.springcloudstarter.quartz.entity.QuartzJobConfigurationExcel; | ||
import com.jmsoftware.maf.springcloudstarter.quartz.service.QuartzJobConfigurationService; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.validation.Valid; | ||
import java.time.Instant; | ||
import java.util.List; | ||
|
||
/** | ||
* <h1>QuartzJobConfigurationController</h1> | ||
|
@@ -20,11 +26,13 @@ | |
* | ||
* @author Johnny Miller (鍾俊), email: [email protected], 9/26/21 11:58 PM | ||
**/ | ||
@Slf4j | ||
@Validated | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/quartz-job") | ||
@Api(tags = {"Quartz Job Configuration API"}) | ||
public class QuartzJobConfigurationController { | ||
public class QuartzJobConfigurationController extends AbstractExcelDataController<QuartzJobConfigurationExcel> { | ||
private final QuartzJobConfigurationService service; | ||
|
||
@GetMapping("/quartz-job-configurations") | ||
|
@@ -34,4 +42,32 @@ public PageResponseBodyBean<GetQuartzJobConfigurationPageListItem> getPageList( | |
) { | ||
return this.service.getPageList(payload); | ||
} | ||
|
||
@Override | ||
protected void onExceptionOccurred() { | ||
log.error("Exception occurred when uploading excel. Excel class: {}", QuartzJobConfigurationExcel.class); | ||
this.fileName.set(String.format("quartz-job-configuration-stat-%s.xlsx", Instant.now())); | ||
} | ||
|
||
@Override | ||
protected void validateBeforeAddToBeanList(List<QuartzJobConfigurationExcel> beanList, | ||
QuartzJobConfigurationExcel bean, int index) | ||
throws IllegalArgumentException { | ||
this.service.validateBeforeAddToBeanList(beanList, bean, index); | ||
} | ||
|
||
@Override | ||
protected void executeDatabaseOperation(List<QuartzJobConfigurationExcel> beanList) { | ||
this.service.save(beanList); | ||
} | ||
|
||
@Override | ||
protected String getTemplateFileName() { | ||
return QuartzJobConfigurationService.TEMPLATE_EXCEL; | ||
} | ||
|
||
@Override | ||
protected List<QuartzJobConfigurationExcel> getListForExporting() { | ||
return this.service.getListForExporting(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...java/com/jmsoftware/maf/springcloudstarter/quartz/entity/QuartzJobConfigurationExcel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.jmsoftware.maf.springcloudstarter.quartz.entity; | ||
|
||
import lombok.Data; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* Description: QuartzJobConfigurationExcel, change description here. | ||
* | ||
* @author Johnny Miller (锺俊), email: [email protected], date: 9/27/2021 11:26 AM | ||
**/ | ||
@Data | ||
public class QuartzJobConfigurationExcel { | ||
@NotBlank | ||
private String name; | ||
private String group; | ||
private String serviceName; | ||
@NotBlank | ||
private String invokeTarget; | ||
@NotBlank | ||
private String cronExpression; | ||
private Byte misfirePolicy; | ||
private Byte concurrent; | ||
@NotBlank | ||
private String description; | ||
private Byte status; | ||
private String createdBy; | ||
private LocalDateTime createdTime; | ||
private String modifiedBy; | ||
private LocalDateTime modifiedTime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters