Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
183f4e63
Commit
183f4e63
authored
Dec 11, 2017
by
Guillaume Wauquier
Browse files
De quoi ajouter modifier les produits et catégories
parent
72728726
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/http/routes/category.php
View file @
183f4e63
<?php
use
Pasteque\Server\System\API\APICaller
;
use
Pasteque\Server\System\API\APIResult
;
/**
* GET categoryGetAll
Get
* GET categoryGetAll
* Summary:
* Notes: Get an array of all Categories
* Output-Formats: [application/json]
...
...
@@ -10,8 +10,47 @@ use Pasteque\Server\System\API\APIResult;
$app
->
GET
(
'/api/category/getAll'
,
function
(
$request
,
$response
,
$args
)
{
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
return
$response
->
withApiResult
(
APICaller
::
run
(
$ptApp
,
'category'
,
'getAll'
));
});
/**
* GET categoryGetChildrens
* Summary:
* Notes: Get an array of Categories from a parent Category Id
* Output-Formats: [application/json]
* * @SWG\Get(
* path="/api/category/getChildrens",
* @SWG\Response(response="200", description="Get an array of Categories from a parent Category Id")
* )
*/
$app
->
GET
(
'/api/category/getChildrens'
,
function
(
$request
,
$response
,
$args
)
{
$queryParams
=
$request
->
getQueryParams
();
$parentId
=
$queryParams
[
'parentId'
];
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
return
$response
->
withApiResult
(
APICaller
::
run
(
$ptApp
,
'category'
,
'getChildren'
,[
$parentId
]));
});
/**
* GET categoryId
* Summary:
* Notes: Get a Category
* Output-Formats: [application/json]
* @SWG\Get(
* path="/api/category/{id}",
* @SWG\Response(response="200", description="get a category")
* )
*/
$app
->
GET
(
'/api/category/{id}'
,
function
(
$request
,
$response
,
$args
)
{
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
return
$response
->
withApiResult
(
APICaller
::
run
(
$ptApp
,
'category'
,
'get'
,
$args
));
});
src/http/routes/product.php
View file @
183f4e63
...
...
@@ -46,6 +46,7 @@ $app->GET('/api/product/getByCode/{code}', function($request, $response, $args)
*/
$app
->
GET
(
'/api/product/getByReference/{reference}'
,
function
(
$request
,
$response
,
$args
)
{
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
return
$response
->
withApiResult
(
APICaller
::
run
(
$ptApp
,
'product'
,
'getByReference'
,
$args
[
'reference'
]));
});
...
...
@@ -60,3 +61,53 @@ $app->GET('/api/product/{id}', function($request, $response, $args) {
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
return
$response
->
withApiResult
(
APICaller
::
run
(
$ptApp
,
'product'
,
'get'
,
$args
[
'id'
]));
});
/**
* PUT productCreateupdate
* Summary:
* Notes: create or modify a product
* Output-Formats: [application/json]
* @SWG\Put(
* path="/api/product",
* tags={"product"},
* operationId="updateProduct",
* summary="Update an existing product",
* description="",
* consumes={"application/json", "application/xml"},
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="body",
* in="body",
* description="Product object that needs to be added",
* required=true,
* @SWG\Schema(ref="#/definitions/Product"),
* ),
* @SWG\Response(
* response=400,
* description="Invalid ID supplied",
* ),
* @SWG\Response(
* response=404,
* description="Product not found",
* ),
* @SWG\Response(
* response=405,
* description="Validation exception",
* ),
* security={{"pasteque_auth":{"write:products", "read:products"}}}
* )
*/
$app
->
PUT
(
'/api/product'
,
function
(
$request
,
$response
,
$args
)
{
$ptApp
=
$this
->
get
(
'settings'
)[
'ptApp'
];
$tab
=
$request
->
getParsedBody
();
// $ptApp->getLogger()->info(json_encode($tab));
$product
=
\
Pasteque\Server\Model\Product
::
fromStruct
(
$tab
,
$ptApp
->
getDao
());
// $ptApp->getLogger()->info($product->getId());
return
$response
->
withApiResult
(
APICaller
::
run
(
$ptApp
,
'product'
,
'write'
,
$product
));
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment