mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: add API entry point for POSTing calendar range
This commit is contained in:
parent
ee4d23ff82
commit
329d3cc3d8
@ -18,16 +18,19 @@ class CalendarRangeAPIController extends ApiController
|
||||
*/
|
||||
public function availableRanges(Request $request, string $_format): JsonResponse
|
||||
{
|
||||
if ($request->query->has('user')) {
|
||||
$user = $request->query->get('user');
|
||||
}
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$query = $em->createQuery(
|
||||
'SELECT c FROM ChillCalendarBundle:CalendarRange c
|
||||
WHERE NOT EXISTS (SELECT cal.id FROM ChillCalendarBundle:Calendar cal WHERE cal.calendarRange = c.id)')
|
||||
;
|
||||
$sql = 'SELECT c FROM ChillCalendarBundle:CalendarRange c
|
||||
WHERE NOT EXISTS (SELECT cal.id FROM ChillCalendarBundle:Calendar cal WHERE cal.calendarRange = c.id)';
|
||||
|
||||
if ($request->query->has('user')) {
|
||||
$user = $request->query->get('user');
|
||||
$sql = $sql . ' AND c.user = :user';
|
||||
$query = $em->createQuery($sql)
|
||||
->setParameter('user', $user);
|
||||
} else {
|
||||
$query = $em->createQuery($sql);
|
||||
}
|
||||
|
||||
$results = $query->getResult();
|
||||
|
||||
|
@ -72,7 +72,8 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
|
||||
'_entity' => [
|
||||
'methods' => [
|
||||
Request::METHOD_GET => true,
|
||||
Request::METHOD_HEAD => true
|
||||
Request::METHOD_HEAD => true,
|
||||
Request::METHOD_POST => true,
|
||||
]
|
||||
],
|
||||
]
|
||||
|
@ -25,19 +25,19 @@ class CalendarRange
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @Groups({"read"})
|
||||
* @groups({"read", "write"})
|
||||
*/
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz_immutable")
|
||||
* @groups({"read"})
|
||||
* @groups({"read", "write"})
|
||||
*/
|
||||
private \DateTimeImmutable $startDate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz_immutable")
|
||||
* @groups({"read"})
|
||||
* @groups({"read", "write"})
|
||||
*/
|
||||
private \DateTimeImmutable $endDate;
|
||||
|
||||
|
@ -8,6 +8,28 @@ servers:
|
||||
- url: "/api"
|
||||
description: "Your current dev server"
|
||||
|
||||
components:
|
||||
schemas:
|
||||
Date:
|
||||
type: object
|
||||
properties:
|
||||
datetime:
|
||||
type: string
|
||||
format: date-time
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
enum:
|
||||
- user
|
||||
username:
|
||||
type: string
|
||||
text:
|
||||
type: string
|
||||
|
||||
paths:
|
||||
/1.0/calendar/calendar.json:
|
||||
get:
|
||||
@ -48,6 +70,34 @@ paths:
|
||||
responses:
|
||||
200:
|
||||
description: "ok"
|
||||
post:
|
||||
tags:
|
||||
- calendar
|
||||
summary: create a new calendar range
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
user:
|
||||
$ref: '#/components/schemas/User'
|
||||
startDate:
|
||||
$ref: '#/components/schemas/Date'
|
||||
endDate:
|
||||
$ref: '#/components/schemas/Date'
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
404:
|
||||
description: "Not found"
|
||||
200:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "Unprocessable entity (validation errors)"
|
||||
400:
|
||||
description: "transition cannot be applyed"
|
||||
|
||||
/1.0/calendar/calendar-range/{id}.json:
|
||||
get:
|
||||
|
Loading…
x
Reference in New Issue
Block a user