rework ui

This commit is contained in:
verboomp
2026-01-29 12:37:44 +01:00
parent 38979c99e5
commit e062b4c688
18 changed files with 462 additions and 246 deletions

View File

@@ -1,8 +1,12 @@
package marketing.heyday.hartmann.fotodocumentation.core.service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import jakarta.annotation.security.PermitAll;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Stateless;
import jakarta.persistence.EntityNotFoundException;
import marketing.heyday.hartmann.fotodocumentation.core.model.Picture;
import marketing.heyday.hartmann.fotodocumentation.core.utils.StorageUtils.StorageState;
@@ -19,8 +23,22 @@ import marketing.heyday.hartmann.fotodocumentation.core.utils.StorageUtils.Stora
@LocalBean
@PermitAll
public class PictureService extends AbstractService {
private static final Log LOG = LogFactory.getLog(PictureService.class);
public StorageState delete(Long id) {
return super.delete(Picture.class, id);
}
public StorageState updateEvaluationStatus(Long id, Integer value) {
try {
Picture entity = entityManager.getReference(Picture.class, id);
entity.setEvaluation(value);
entityManager.flush();
return StorageState.OK;
} catch (EntityNotFoundException e) {
LOG.warn("Failed to update evaluation value not found " + id, e);
ejbContext.setRollbackOnly();
return StorageState.NOT_FOUND;
}
}
}

View File

@@ -7,9 +7,7 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.ejb.EJB;
import jakarta.enterprise.context.RequestScoped;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.ResponseBuilder;
import jakarta.ws.rs.core.Response.Status;
@@ -45,6 +43,18 @@ public class PictureResource {
return deleteResponse(state).build();
}
@PUT
@Path("evaluation/{id}")
@Operation(summary = "Update evaluation for picture data to database")
@ApiResponse(responseCode = "200", description = "Task successfully updated")
public Response doUpdateTask(@PathParam("id") Long id, @QueryParam("evaluation") Integer value) {
if(value == null || value < 1 || value >3) {
return Response.status(Status.BAD_REQUEST).build();
}
StorageState state = pictureService.updateEvaluationStatus(id, value);
return deleteResponse(state).build();
}
protected ResponseBuilder deleteResponse(StorageState state) {
return switch(state) {
case OK -> Response.status(Status.OK);