-
Notifications
You must be signed in to change notification settings - Fork 0
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
283885f
commit 21520a0
Showing
9 changed files
with
234 additions
and
8 deletions.
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
src/main/java/de/app/fivegla/controller/JobController.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,51 @@ | ||
package de.app.fivegla.controller; | ||
|
||
import de.app.fivegla.controller.api.BaseMappings; | ||
import de.app.fivegla.controller.api.swagger.OperationTags; | ||
import de.app.fivegla.controller.dto.request.DisableJobRequest; | ||
import de.app.fivegla.persistence.ApplicationDataRepository; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* The JobController class handles requests related to job operations. | ||
*/ | ||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping(BaseMappings.JOB) | ||
public class JobController { | ||
|
||
private final ApplicationDataRepository applicationDataRepository; | ||
|
||
/** | ||
* Disables a job for a manufacturer. | ||
* | ||
* @param request The request to disable a job. | ||
* @return A ResponseEntity indicating the success of the job disabling. | ||
*/ | ||
@Operation( | ||
operationId = "job.disable", | ||
description = "Disables a job for a manufacturer.", | ||
tags = OperationTags.JOB | ||
) | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "The job has been disabled successfully." | ||
) | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "The request is invalid." | ||
) | ||
@PatchMapping | ||
public ResponseEntity<Void> disable(@RequestBody DisableJobRequest request) { | ||
log.debug("Disabling job for manufacturer: {}", request.getManufacturer()); | ||
applicationDataRepository.disableJob(request.getManufacturer()); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/de/app/fivegla/controller/dto/request/DisableJobRequest.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,19 @@ | ||
package de.app.fivegla.controller.dto.request; | ||
|
||
import de.app.fivegla.api.Manufacturer; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Represents a request to disable a job. | ||
*/ | ||
@Getter | ||
@Setter | ||
public class DisableJobRequest { | ||
|
||
/** | ||
* Represents the manufacturer of a sensor or device. | ||
*/ | ||
private Manufacturer manufacturer; | ||
|
||
} |
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
43 changes: 43 additions & 0 deletions
43
src/main/java/de/app/fivegla/persistence/entity/DisabledJob.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,43 @@ | ||
package de.app.fivegla.persistence.entity; | ||
|
||
import de.app.fivegla.api.Manufacturer; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.time.Instant; | ||
|
||
/** | ||
* Represents a job disabled for a specific manufacturer. | ||
*/ | ||
@Getter | ||
@Setter | ||
public class DisabledJob { | ||
|
||
/** | ||
* Represents the timestamp when a job is disabled for a specific manufacturer. | ||
* <p> | ||
* The disabledAt variable is of type Instant. It represents the exact moment when the job is disabled for the manufacturer. | ||
* Instant is a class in Java that represents a moment on the timeline, measured in milliseconds from the Unix epoch of 1970-01-01T00:00:00Z. | ||
* <p> | ||
* The value of disabledAt can be set and retrieved using getter and setter methods. The getter method is named "getDisabledAt" and returns an Instant object. | ||
* The setter method is named "setDisabledAt" and accepts an Instant object as a parameter. | ||
* <p> | ||
* Example usage: | ||
* DisabledJob job = new DisabledJob(); | ||
* Instant disabledAt = Instant.now(); // Get current timestamp | ||
* job.setDisabledAt(disabledAt); // Set disabledAt to the current timestamp | ||
* Instant retrievedDisabledAt = job.getDisabledAt(); // Get the disabledAt value | ||
* <p> | ||
* Note: This documentation assumes that you have the necessary imports and declarations for the Instant and DisabledJob classes. | ||
* | ||
* @see DisabledJob | ||
* @see Instant | ||
*/ | ||
private Instant disabledAt; | ||
|
||
/** | ||
* Represents a disabled manufacturer. | ||
*/ | ||
private Manufacturer disabledManufacturers; | ||
|
||
} |
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