一、Code样例
<?phpnamespace App\Module\Cms\Controller;use Swork\Server\Http\Argument;use ....../*** 资讯内容控制器* @Controller("/cms/info")*/class InfoController extends BeanCollector{/*** @Inject()* @var InfoLogic*/private $infoLogic;/*** 删除资讯内容数据* @param Argument $argument* @Validate(Method::Post)* @return array* @throws*/public function delete(Argument $argument){//外部参数$fid = $argument->post('fid', 0);//删除数据$this->infoLogic->delete($fid);//返回return 'success';}}
二、解析说明
1)类名注释为XX业务块的控制器
2)方法名delete注释为删除XX业务块的数据
3)三段式注释:外部参数、删除数据、返回;
4)无特别要求,通常统一返回字符串 success 。
5)强制使用POST的方式接收数据。
6)在参数小于等于6个时,按单个参数单独传入;超过时,统一使用$others中传中。
即传入参数量最多为6个。
