parent
f3cb94774d
commit
21c5ce25f2
@ -0,0 +1,23 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public record EventFromListDto(
|
||||
@JsonProperty("event_id") String id,
|
||||
String title,
|
||||
String description,
|
||||
|
||||
@JsonProperty("start_date")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy")
|
||||
LocalDate startDate,
|
||||
|
||||
@JsonProperty("end_date")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy")
|
||||
LocalDate endDate,
|
||||
|
||||
@JsonProperty("color_code") String color
|
||||
) {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public record LabelDto(
|
||||
@JsonProperty String id,
|
||||
String title,
|
||||
String description,
|
||||
@JsonProperty("color_code") String color
|
||||
) {
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
public record LoginDto(String login, String password){}
|
@ -0,0 +1,22 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public record NewEventDto(
|
||||
String title,
|
||||
String description,
|
||||
|
||||
@JsonProperty("start_date")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy")
|
||||
LocalDate startDate,
|
||||
|
||||
@JsonProperty("end_date")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy")
|
||||
LocalDate endDate,
|
||||
|
||||
@JsonProperty("color_code") String color
|
||||
) {
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public record NewLabelDto(
|
||||
String title,
|
||||
String description,
|
||||
@JsonProperty("color_code") String color
|
||||
) {
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
public record NewUserDto(String login, String password){}
|
@ -0,0 +1,10 @@
|
||||
package com.flagg10ma.taf.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public record UserDto(
|
||||
@JsonProperty String id,
|
||||
String login,
|
||||
String password
|
||||
) {
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.flagg10ma.taf.resource;
|
||||
|
||||
import com.flagg10ma.taf.model.Event;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@Path("/api/events")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class EventResource {
|
||||
|
||||
@Inject
|
||||
//EventService eventService;
|
||||
|
||||
@GET
|
||||
public Response getAllEvents() {
|
||||
// Retrieve and return a list of events
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
public Response getEventById(@PathParam("id") Long id) {
|
||||
// Retrieve and return a single event by its ID
|
||||
}
|
||||
|
||||
@POST
|
||||
@Transactional
|
||||
public Response createEvent(Event event) {
|
||||
// Create a new event
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response updateEvent(@PathParam("id") Long id, Event event) {
|
||||
// Update an existing event by its ID
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response deleteEvent(@PathParam("id") Long id) {
|
||||
// Delete an event by its ID
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.flagg10ma.taf.resource;
|
||||
|
||||
import com.flagg10ma.taf.model.Label;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@Path("/api/labels")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class LabelResource {
|
||||
|
||||
@Inject
|
||||
//LabelService labelService;
|
||||
|
||||
@GET
|
||||
public Response getAllLabels() {
|
||||
// Retrieve and return a list of labels
|
||||
}
|
||||
|
||||
@POST
|
||||
@Transactional
|
||||
public Response createLabel(Label label) {
|
||||
// Create a new label
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response updateLabel(@PathParam("id") Long id, Label label) {
|
||||
// Update an existing label by its ID
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response deleteLabel(@PathParam("id") Long id) {
|
||||
// Delete a label by its ID
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.flagg10ma.taf.resource;
|
||||
|
||||
import com.flagg10ma.taf.model.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@Path("/api/tasks")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class TaskResource {
|
||||
|
||||
@Inject
|
||||
//TaskService taskService;
|
||||
|
||||
@GET
|
||||
public Response getAllTasks() {
|
||||
// Retrieve and return a list of tasks
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
public Response getTaskById(@PathParam("id") String id) {
|
||||
// Retrieve and return a single task by its ID
|
||||
}
|
||||
|
||||
@POST
|
||||
@Transactional
|
||||
public Response createTask(Task task) {
|
||||
// Create a new task
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response updateTask(@PathParam("id") String id, Task task) {
|
||||
// Update an existing task by its ID
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response deleteTask(@PathParam("id") Long id) {
|
||||
// Delete a task by its ID
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.flagg10ma.taf.resource;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.flagg10ma.taf.model.User;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import java.util.Collections;
|
||||
|
||||
@Path("/api/users")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class UserResource {
|
||||
|
||||
@Inject
|
||||
//UserService userService;
|
||||
|
||||
@POST
|
||||
public Response createUser(JsonNode requestBody) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String login = requestBody.get("login").asText();
|
||||
String password = requestBody.get("password").asText();
|
||||
|
||||
// Create a new user
|
||||
User newUser = new User(null, login, password, Collections.emptyList());
|
||||
//userService.createUser(newUser);
|
||||
|
||||
// Create the response object with createdAt and userId
|
||||
//UserResponse userResponse = new UserResponse(newUser.getId(), newUser.getCreatedAt());
|
||||
|
||||
return Response.created(UriBuilder.fromPath("/api/users/{id}").build(newUser.id())).build();
|
||||
} catch (Exception e) {
|
||||
// Handle any exceptions or validation errors
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity("Invalid request body").build();
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response updateUser(@PathParam("id") Long id, User user) {
|
||||
// Update an existing user by ID
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@Transactional
|
||||
public Response deleteUser(@PathParam("id") Long id) {
|
||||
// Delete a user by ID
|
||||
}
|
||||
}
|
Loading…
Reference in new issue