first commit
This commit is contained in:
1
Swoft_BackEndApi/app/Http/Controller/.pydio
Normal file
1
Swoft_BackEndApi/app/Http/Controller/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
675329f0-6a31-4094-9bea-19e67e56a8d0
|
||||
20
Swoft_BackEndApi/app/Http/Controller/BaseController.php
Normal file
20
Swoft_BackEndApi/app/Http/Controller/BaseController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controller;
|
||||
|
||||
use BmobObject;
|
||||
use Swoft\Bean\Annotation\Mapping\Inject;
|
||||
use App\Bean\ResponseBean;
|
||||
|
||||
abstract class BaseController {
|
||||
/**
|
||||
* @Inject("ResponseBean")
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
protected function newBmobObject(string $tabeName = '') {
|
||||
return new BmobObject($tabeName);
|
||||
}
|
||||
|
||||
}
|
||||
33
Swoft_BackEndApi/app/Http/Controller/CourseController.php
Normal file
33
Swoft_BackEndApi/app/Http/Controller/CourseController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controller;
|
||||
|
||||
use Swoft\Bean\Annotation\Mapping\Inject;
|
||||
use Swoft\Http\Message\Request;
|
||||
use Swoft\Http\Server\Annotation\Mapping\Controller;
|
||||
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
|
||||
use Swoft\Http\Server\Annotation\Mapping\RequestMethod;
|
||||
use BmobObject;
|
||||
|
||||
|
||||
/**
|
||||
* @Controller("admin")
|
||||
* @package App\Http\Controller
|
||||
*/
|
||||
class CourseController extends BaseController {
|
||||
|
||||
/**
|
||||
* @Inject("CourseService")
|
||||
*/
|
||||
private $CourseService;
|
||||
/**
|
||||
* @RequestMapping("newCourse", method=RequestMethod::POST)
|
||||
* @param Request $request
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
public function newCourse (Request $request) {
|
||||
$status = $this->CourseService->addNewCourse($request->post());
|
||||
return $this->response->success($status,'发布课程成功');
|
||||
}
|
||||
}
|
||||
21
Swoft_BackEndApi/app/Http/Controller/ExceptionController.php
Executable file
21
Swoft_BackEndApi/app/Http/Controller/ExceptionController.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace App\Http\Controller;
|
||||
|
||||
use App\Exception\ApiException;
|
||||
use Swoft\Http\Server\Annotation\Mapping\Controller;
|
||||
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
|
||||
|
||||
/**
|
||||
* @Controller(prefix="ex")
|
||||
*/
|
||||
class ExceptionController
|
||||
{
|
||||
/**
|
||||
* @RequestMapping(route="api")
|
||||
*
|
||||
* @throws ApiException
|
||||
*/
|
||||
public function api(){
|
||||
throw new ApiException("api of ExceptionController");
|
||||
}
|
||||
}
|
||||
27
Swoft_BackEndApi/app/Http/Controller/OrderController.php
Normal file
27
Swoft_BackEndApi/app/Http/Controller/OrderController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace App\Http\Controller;
|
||||
|
||||
use BmobObject;
|
||||
use App\Exception\ApiException;
|
||||
use Exception;
|
||||
use Swoft\Http\Server\Annotation\Mapping\Controller;
|
||||
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
|
||||
use Swoft\Http\Message\Request;
|
||||
|
||||
/**
|
||||
* @Controller("/order")
|
||||
* @package App\Http\Controller
|
||||
*/
|
||||
class OrderController extends BaseController {
|
||||
|
||||
/**
|
||||
* @RequestMapping("list")
|
||||
*/
|
||||
// 通过AOP切面自动捕获代码的 AfterThrowing 错误,并统一序列化返回错误信息
|
||||
public function getOrderList(Request $request) {
|
||||
$bmobObj = $this->newBmobObject("coures");
|
||||
$data = $bmobObj->get($request->get("id"));
|
||||
return $this->response->success($data);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controller;
|
||||
|
||||
|
||||
use Swoft\Http\Server\Annotation\Mapping\Controller;
|
||||
use Qiniu\Auth;
|
||||
use Qiniu\Storage\UploadManager;
|
||||
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
|
||||
|
||||
/**
|
||||
* @Controller("admin")
|
||||
* @package App\Http\Controller
|
||||
*/
|
||||
class QiniuTokenController extends BaseController {
|
||||
|
||||
/**
|
||||
* @RequestMapping("token")
|
||||
*/
|
||||
public function getToken () {
|
||||
$accessKey = '0MGmT_rkMiaOeXY09B4EhBnXuDcIYyKlGumQ-zUt';
|
||||
$secretKey = '59dfmEi9Q50rMlz9sxTBCvYDhM7biERAjflBXALb';
|
||||
$auth = new Auth($accessKey, $secretKey);
|
||||
|
||||
return $this->response->success([
|
||||
"token" => $auth->uploadToken("guaikevideo")
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user