first commit
This commit is contained in:
1
Swoft_BackEndApi/app/Bean/.pydio
Normal file
1
Swoft_BackEndApi/app/Bean/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
3ea41287-a390-4560-b6bc-0c9784e318da
|
||||
30
Swoft_BackEndApi/app/Bean/ResponseBean.php
Normal file
30
Swoft_BackEndApi/app/Bean/ResponseBean.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Bean;
|
||||
use Exception;
|
||||
use Swoft\Bean\Annotation\Mapping\Bean;
|
||||
|
||||
/**
|
||||
* @Bean("ResponseBean")
|
||||
* @package App\Bean
|
||||
*/
|
||||
class ResponseBean {
|
||||
public function success($data = [], string $message = "") {
|
||||
$response = context()->getResponse();
|
||||
return $response->withData([
|
||||
'code' => 200,
|
||||
'result' => $data,
|
||||
'message' => $message
|
||||
]);
|
||||
}
|
||||
|
||||
public function fail($e) {
|
||||
$response = context()->getResponse();
|
||||
return $response->withData([
|
||||
'code' => $e->getCode(),
|
||||
'result' => null,
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
16
Swoft_BackEndApi/app/Bean/TestBean.php
Normal file
16
Swoft_BackEndApi/app/Bean/TestBean.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Bean;
|
||||
|
||||
use Swoft\Bean\Annotation\Mapping\Bean;
|
||||
|
||||
/**
|
||||
* @Bean("test")
|
||||
* @package App\Bean
|
||||
*/
|
||||
class TestBean {
|
||||
public function hello () {
|
||||
return "ddcdcdefefe";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user