mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-18 05:04:51 +08:00
Add InitBuffer annotation
This commit is contained in:
parent
4af90e00ff
commit
5f43cf4f00
@ -5,7 +5,10 @@ namespace Module\Example;
|
||||
|
||||
|
||||
use Framework\Console;
|
||||
use Framework\ZMBuf;
|
||||
use ZM\Annotation\CQ\CQCommand;
|
||||
use ZM\Annotation\Http\Controller;
|
||||
use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Module\Closed;
|
||||
use ZM\Annotation\Swoole\SwooleEventAt;
|
||||
use ZM\Connection\CQConnection;
|
||||
@ -14,7 +17,7 @@ use ZM\ModBase;
|
||||
/**
|
||||
* Class Hello
|
||||
* @package Module\Example
|
||||
* @Closed()
|
||||
* @Controller("/view")
|
||||
*/
|
||||
class Hello extends ModBase
|
||||
{
|
||||
@ -31,4 +34,18 @@ class Hello extends ModBase
|
||||
public function hello(){
|
||||
return "你好啊,我是由炸毛框架构建的机器人!";
|
||||
}
|
||||
|
||||
/**
|
||||
* @RequestMapping("/test/{ping}")
|
||||
*/
|
||||
public function ping($param){
|
||||
return "You input id is: ".$param["ping"];
|
||||
}
|
||||
|
||||
/**
|
||||
* @RequestMapping("/test/pong")
|
||||
*/
|
||||
public function pong(){
|
||||
$this->response->end("ping");
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,8 @@ namespace Module\TestMod;
|
||||
use Framework\Console;
|
||||
use ZM\Annotation\CQ\CQCommand;
|
||||
use ZM\Annotation\CQ\CQNotice;
|
||||
use ZM\Annotation\Http\Controller;
|
||||
use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Swoole\SwooleEventAt;
|
||||
use ZM\Connection\CQConnection;
|
||||
use ZM\ModBase;
|
||||
@ -14,6 +16,7 @@ use ZM\ModBase;
|
||||
/**
|
||||
* Class CQTest
|
||||
* @package Module\TestMod
|
||||
* @Controller("/view/test2")
|
||||
*/
|
||||
class CQTest extends ModBase
|
||||
{
|
||||
@ -36,6 +39,16 @@ class CQTest extends ModBase
|
||||
return "我也不知道".$arg[0]."是什么呀";
|
||||
}
|
||||
|
||||
/**
|
||||
* @RequestMapping("/ping")
|
||||
*/
|
||||
public function ping(){}
|
||||
|
||||
/**
|
||||
* @RequestMapping("/pong")
|
||||
*/
|
||||
public function pong(){}
|
||||
|
||||
/**
|
||||
* @CQNotice(notice_type="group_admin")
|
||||
*/
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
namespace Module\TestMod;
|
||||
|
||||
use Framework\Console;
|
||||
use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Swoole\SwooleEventAt;
|
||||
use ZM\Connection\WSConnection;
|
||||
use ZM\ModBase;
|
||||
@ -25,4 +26,9 @@ class Hola extends ModBase
|
||||
Console::stackTrace();
|
||||
$this->connection->close();
|
||||
}
|
||||
|
||||
/** @RequestMapping("/ping") */
|
||||
public function ping(){
|
||||
return "OKK";
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,7 @@ use ZM\Annotation\Http\RequestMapping;
|
||||
use ZM\Annotation\Interfaces\CustomAnnotation;
|
||||
use ZM\Annotation\Interfaces\Level;
|
||||
use ZM\Annotation\Module\Closed;
|
||||
use ZM\Annotation\Module\InitBuffer;
|
||||
use ZM\Annotation\Module\SaveBuffer;
|
||||
use ZM\Annotation\Swoole\SwooleEventAfter;
|
||||
use ZM\Annotation\Swoole\SwooleEventAt;
|
||||
@ -52,6 +53,8 @@ class AnnotationParser
|
||||
$class_prefix = $vs->prefix;
|
||||
} elseif ($vs instanceof SaveBuffer) {
|
||||
DataProvider::addSaveBuffer($vs->buf_name, $vs->sub_folder);
|
||||
} elseif ($vs instanceof InitBuffer) {
|
||||
ZMBuf::set($vs->buf_name, []);
|
||||
}
|
||||
}
|
||||
foreach ($methods as $vs) {
|
||||
|
||||
19
src/ZM/Annotation/Module/InitBuffer.php
Normal file
19
src/ZM/Annotation/Module/InitBuffer.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ZM\Annotation\Module;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation\Required;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
|
||||
/**
|
||||
* Class InitBuffer
|
||||
* @Annotation
|
||||
* @Target("CLASS")
|
||||
* @package ZM\Annotation\Module
|
||||
*/
|
||||
class InitBuffer
|
||||
{
|
||||
/** @var string @Required() */
|
||||
public $buf_name;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user