add function publishers for event and group #14
@ -24,6 +24,8 @@ public class EventEntity extends PanacheMongoEntity {
|
|||||||
|
|
||||||
public Collection<String> interesses;
|
public Collection<String> interesses;
|
||||||
|
|
||||||
|
public Collection<String> publication;
|
||||||
|
|
||||||
public String reservation;
|
public String reservation;
|
||||||
|
|
||||||
public Confidentialite confidentialite;
|
public Confidentialite confidentialite;
|
||||||
|
@ -17,6 +17,8 @@ public class GroupEntity extends PanacheMongoEntity {
|
|||||||
|
|
||||||
public Collection<String> membres;
|
public Collection<String> membres;
|
||||||
|
|
||||||
|
public Collection<String> publication;
|
||||||
|
|
||||||
public LocalDateTime created_at;
|
public LocalDateTime created_at;
|
||||||
public LocalDateTime updated_at;
|
public LocalDateTime updated_at;
|
||||||
public LocalDateTime deleted_at;
|
public LocalDateTime deleted_at;
|
||||||
|
@ -270,4 +270,31 @@ public class EventRessources {
|
|||||||
}
|
}
|
||||||
return Response.status(status).build();
|
return Response.status(status).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Patch
|
||||||
|
|
||||||
|
@PATCH
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@RolesAllowed({"Admin", "User"})
|
||||||
|
@Path("{id}")
|
||||||
|
@Transactional
|
||||||
|
public Response createPublishers(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("id") String id, @PathParam("publisher") String publisher) {
|
||||||
|
|
||||||
|
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
||||||
|
UsersEntity user = UsersEntity.findById(kid);
|
||||||
|
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||||
|
if (status.equals(Response.Status.OK)) {
|
||||||
|
EventEntity singleEvent = EventEntity.find("id", new ObjectId(id)).firstResult();
|
||||||
|
status = Response.Status.NOT_FOUND;
|
||||||
|
if(singleEvent != null){
|
||||||
|
status = Response.Status.NOT_MODIFIED;
|
||||||
|
if(singleEvent.publication.add(publisher)){
|
||||||
|
singleEvent.updated_at = LocalDateTime.now();
|
||||||
|
singleEvent.persist();
|
||||||
|
status = Response.Status.CREATED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.status(status).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,33 @@ public class GroupRessources {
|
|||||||
return Response.status(status).entity(newGroup).build();
|
return Response.status(status).entity(newGroup).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Patch
|
||||||
|
|
||||||
|
@PATCH
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@RolesAllowed({"Admin", "User"})
|
||||||
|
@Path("{id}")
|
||||||
|
@Transactional
|
||||||
|
public Response createPublishers(@Context SecurityContext ctx, @CookieParam("user") String userCookie, @PathParam("id") String id, @PathParam("publisher") String publisher) {
|
||||||
|
|
||||||
|
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
|
||||||
|
UsersEntity user = UsersEntity.findById(kid);
|
||||||
|
Response.Status status = getResponseCheck(ctx, userCookie, user);
|
||||||
|
if (status.equals(Response.Status.OK)) {
|
||||||
|
GroupEntity singleGroup = GroupEntity.find("id", new ObjectId(id)).firstResult();
|
||||||
|
status = Response.Status.NOT_FOUND;
|
||||||
|
if(singleGroup != null){
|
||||||
|
status = Response.Status.NOT_MODIFIED;
|
||||||
|
if(singleGroup.publication.add(publisher)){
|
||||||
|
singleGroup.updated_at = LocalDateTime.now();
|
||||||
|
singleGroup.persist();
|
||||||
|
status = Response.Status.CREATED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.status(status).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// DELETE
|
// DELETE
|
||||||
@DELETE
|
@DELETE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user