| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- /**
 
-  * 示例接口
 
-  */
 
- class Version extends Base
 
- {
 
-     //如果$noNeedLogin为空表示所有接口都需要登录才能请求
 
-     //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
 
-     //如果接口已经设置无需登录,那也就无需鉴权了
 
-     //
 
-     // 无需登录的接口,*表示全部
 
-     protected $noNeedLogin = ['getVersion','getLatestVersion'];
 
-     // 无需鉴权的接口,*表示全部
 
-     protected $noNeedRight = ['*'];
 
-    
 
-     public function getVersion()
 
-     {
 
-         $this->success('返回成功', $this->request->param());
 
-     }
 
-     /**
 
-      * 获取指定平台的最新版本
 
-      * @ApiTitle    (获取最新版本信息)
 
-      * @ApiSummary  (根据请求头platform参数返回最新版本)
 
-      * @ApiMethod   (GET)
 
-      * @ApiHeader   (name="platform", type="string", required=true, description="平台标识,如android/ios/h5等")
 
-      */
 
-     public function getLatestVersion()
 
-     {
 
-         $platform = $this->request->header('platform', '');
 
-         if (!$platform) {
 
-             $this->error('缺少platform参数');
 
-         }
 
-         $version = \think\Db::name('version')
 
-             ->where('platform', $platform)
 
-             ->where('status', 'normal')
 
-             ->order('weigh desc, id desc')
 
-             ->find();
 
-         if (!$version) {
 
-             $this->success('获取成功', null);
 
-         }
 
-         $this->success('获取成功', $version);
 
-     }
 
-    
 
- }
 
 
  |