-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
use Respect\Validation\Validator as DataValidator; | ||
|
||
DataValidator::with('CustomValidations', true); | ||
/** | ||
* @api {post} /system/add-project Add project | ||
* @apiVersion 4.11.0 | ||
* | ||
* @apiName Add project | ||
* | ||
* @apiGroup System | ||
* | ||
* @apiDescription This path create a new project. | ||
* | ||
* @apiPermission staff3 | ||
* | ||
* @apiParam {String} name Name of the new project. | ||
* | ||
* @apiUse NO_PERMISSION | ||
* | ||
* @apiSuccess {Object} data Empty object | ||
* | ||
*/ | ||
|
||
class AddProjectController extends Controller { | ||
const PATH = '/add-project'; | ||
const METHOD = 'POST'; | ||
|
||
public function validations() { | ||
return [ | ||
'permission' => 'staff_3', | ||
'requestData' => [ | ||
'name' => [ | ||
'validation' => DataValidator::AllOf( | ||
DataValidator::notBlank()->length(LengthConfig::MIN_LENGTH_NAME, LengthConfig::MAX_LENGTH_NAME), | ||
DataValidator::ValidProjectName() | ||
), | ||
'error' => ERRORS::INVALID_NAME | ||
] | ||
] | ||
]; | ||
} | ||
|
||
public function handler() { | ||
$name = Controller::request('name', true); | ||
|
||
$projectInstance = new Project(); | ||
|
||
$projectInstance->setProperties([ | ||
'name' => $name , | ||
]); | ||
$projectInstance->store(); | ||
|
||
Log::createLog('ADD_PROJECT', $name); | ||
|
||
Response::respondSuccess(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
use Respect\Validation\Validator as DataValidator; | ||
|
||
|
||
/** | ||
* @api {post} /ticket/add-tag Add tag | ||
* @apiVersion 4.11.0 | ||
* | ||
* @apiName Add tag | ||
* | ||
* @apiGroup Ticket | ||
* | ||
* @apiDescription This path attaches a new tag to a ticket. | ||
* | ||
* @apiPermission staff1 | ||
* | ||
* @apiParam {String} userId The number of the ticket which the tag is going to be attached. | ||
* @apiParam {String} projectId The id of the tag to attach. | ||
* | ||
* @apiUse NO_PERMISSION | ||
* @apiUse INVALID_TICKET | ||
* @apiUse INVALID_TAG | ||
* @apiUse TAG_EXISTS | ||
* | ||
* @apiSuccess {Object} data Empty object | ||
* | ||
*/ | ||
|
||
class AddTagController extends Controller { | ||
const PATH = '/add-project'; | ||
const METHOD = 'POST'; | ||
|
||
public function validations() { | ||
return [ | ||
'permission' => 'staff_1', | ||
'requestData' => [ | ||
'userId' => [ | ||
'validation' => DataValidator::dataStoreId('user'), | ||
'error' => ERRORS::INVALID_USER | ||
], | ||
'projectId' => [ | ||
'validation' => DataValidator::dataStoreId('project'), | ||
'error' => ERRORS::INVALID_USER | ||
] | ||
] | ||
]; | ||
} | ||
|
||
public function handler() { | ||
|
||
$user = User::getDataStore(Controller::request('userId')); | ||
|
||
$project = Project::getDataStore(Controller::request('projectId')); | ||
|
||
Response::respondSuccess(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
use RedBeanPHP\Facade as RedBean; | ||
|
||
/** | ||
* @api {OBJECT} Project Project | ||
* @apiVersion 4.11.0 | ||
* @apiGroup Data Structures | ||
* @apiParam {Number} id Id of the project. | ||
* @apiParam {String} name Name of the project. | ||
*/ | ||
|
||
class Project extends DataStore { | ||
const TABLE = 'project'; | ||
|
||
public static function getProps() { | ||
return [ | ||
'name', | ||
'sharedTicketList', | ||
]; | ||
} | ||
|
||
public function getDefaultProps() { | ||
return [ | ||
]; | ||
} | ||
|
||
public static function getAllProjectNames() { | ||
$projectsList = RedBean::findAll(Project::TABLE); | ||
$projectsNameList = []; | ||
|
||
foreach($projectsList as $project) { | ||
$projectsNameList[] = [ | ||
'id' => $project->id, | ||
'name' => $project->name | ||
]; | ||
} | ||
|
||
return $projectsNameList; | ||
} | ||
|
||
public function toArray() { | ||
return [ | ||
'id' => $this->id, | ||
'name' => $this->name, | ||
]; | ||
} | ||
} |