| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\ApiController;
- use app\common\validate\IDMustBePositiveInt;
- use app\common\model\Banner as BannerModel;
- use app\http\IResponse;
- use Lettered\Support\Exceptions\TokenException;
- class Banner extends ApiController
- {
- /**
- * 获取Banner信息
- *
- * @url /banner/:id
- * @http GET
- * @param $id
- *
- * @return mixed
- * @throws \Lettered\Support\Exceptions\EvidentException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function getBannerByID($id)
- {
- // 输入参数检查
- (new IDMustBePositiveInt())->valid();
- // throw new TokenException();
- // 获取ID数据
- $banner = BannerModel::getBannerById($id);
- if (!$banner) {
- // 错误返回
- return $this->ApiJson(-1,"请求数据不存在");
- }
-
- return $this->ApiJson(0,'OK!', $banner);
- }
- }
|