Model
<?php
namespace app\api\model;
class Banner
{
public static function getBannerByID($id){
return null;
}
}
Controller
<?php
namespace app\api\controller\v1;
use app\api\model\Banner as BannerModel;
use app\api\validate\IDMustBePositiveInt;
use think\Exception;
class Banner
{
/**
* 获取指定id的banner信息
* @url/banner/:id
* @http GET
* @id banner的id号
*
*/
public function getBanner($id){
$validate = new IDMustBePositiveInt();
$validate->goCheck();
$banner = BannerModel::getBannerByID($id);
if(!$banner){
throw new Exception('内部错误');
}
return $banner;
}
}
Exception
<?php
namespace app\lib\exception;
use think\exception\Handle;
use think\Exception;
use