xiaogang 4 years ago
parent
commit
9471e4f8ff

+ 6 - 0
.env.example

@@ -64,3 +64,9 @@ API_VERSION=v1
 API_DEBUG=false
 API_DEBUG=false
 
 
 JWT_SECRET=4bn0C5ro2sypvi1c1WcaLN1eUHaMLXv5Uzv1yoS1cIc3B6eDCXR4zq1tsM00AjqM
 JWT_SECRET=4bn0C5ro2sypvi1c1WcaLN1eUHaMLXv5Uzv1yoS1cIc3B6eDCXR4zq1tsM00AjqM
+
+
+ALI_OSS_ACCESS_ID=LTAI4FgJdnfwsj5Bb6ioWSD9
+ALI_OSS_ACCESS_KEY=S4Tp2eNVKHROuNOLjTvAICTnjqXFFR
+ALI_OSS_BUCKET=zhengda
+ALI_OSS_ENDPOINT=oss-accelerate.aliyuncs.com

+ 19 - 1
app/Http/Controllers/Api/AuthorizationsController.php

@@ -11,6 +11,7 @@ use App\Transformers\UserTransformer;
 use Carbon\Carbon;
 use Carbon\Carbon;
 use Illuminate\Http\Request;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Hash;
 use Illuminate\Support\Facades\Hash;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\Facades\Validator;
 
 
@@ -196,6 +197,23 @@ class AuthorizationsController extends Controller
         }
         }
     }
     }
 
 
+    /**
+     * 用户协议
+     */
+    public function xieyi(Request $request){
+        if(isset($request->cont) && $request->cont==1){
+            $data = DB::table("document")->where(['id'=>$request->type])->first();
+            return response()->json(['data'=>$data]);
+        }else{
+            if($request->type==1){
+                $url = "https://".$_SERVER['HTTP_HOST'].'/xieyi/yhxy.html';
+            }else{
+                $url = "https://".$_SERVER['HTTP_HOST'].'/xieyi/yszc.html';
+            }
+            return response()->json(['url'=>$url]);
+        }
+    }
+
     /**
     /**
      * Get the authenticated User.
      * Get the authenticated User.
      *
      *
@@ -216,7 +234,7 @@ class AuthorizationsController extends Controller
     {
     {
         auth('api')->logout();
         auth('api')->logout();
 
 
-        return response()->json(['message' => 'Successfully logged out']);
+        return response()->json(['message' => '退出成功!']);
     }
     }
 
 
     /**
     /**

+ 33 - 0
app/Http/Controllers/Api/UploadConfigController.php

@@ -0,0 +1,33 @@
+<?php
+
+
+namespace App\Http\Controllers\Api;
+
+
+
+class UploadConfigController extends Controller
+{
+    //获取oss配置
+    public function config(){
+        $config = config("filesystems.disks.oss");
+
+        $policy=array(
+            "expiration"=>date("Y-m-d\\TH:i:s",(time()+60)).".000Z",//"2020-01-01T12:00:00.000Z"
+            "conditions"=>array(
+                array(
+                    "content-length-range", 0, 1048576000
+                )
+            )
+        );
+        $policyText=json_encode($policy);
+        $policyBase64=base64_encode($policyText);
+        $bytes=hash_hmac("sha1",$policyBase64,$config['access_key'],true);
+        $signature=base64_encode($bytes);
+        $res['policy']=$policyBase64;
+        $res['signature']=$signature;
+        $res['OSSAccessKeyId']=$config['access_id'];
+        $res['domain']="https://".$config['bucket'].'.'.$config['endpoint'];
+        $res['folder']="chengluApp";
+        return response()->json($res)->setStatusCode(201);
+    }
+}

+ 9 - 7
app/Http/Controllers/Api/UserController.php

@@ -64,14 +64,12 @@ class UserController extends Controller
 
 
         DB::beginTransaction();
         DB::beginTransaction();
         try {
         try {
-            $userinfo = UserInfoModel::firstOrCreate([
+            UserInfoModel::firstOrCreate([
                 'user_id' => $user->id,
                 'user_id' => $user->id,
+                'avatar' =>$request->avatar,
+                'nickname' =>$request->nickname,
+                'birthday' =>$request->birthday,
             ]);
             ]);
-            $userinfo->avatar = $request->avatar;
-            $userinfo->nickname = $request->nickname;
-            $userinfo->birthday = $request->birthday;
-            $userinfo->save();
-
             if($pid!=0){
             if($pid!=0){
                $user->pid = $pid;
                $user->pid = $pid;
                $user->save();
                $user->save();
@@ -79,7 +77,11 @@ class UserController extends Controller
             DB::commit();
             DB::commit();
         } catch (\Exception $e) {
         } catch (\Exception $e) {
             DB::rollBack();
             DB::rollBack();
-            abort(403, '保存失败');
+            return $this->response->errorForbidden($e->getMessage());
         }
         }
+        return $this->response->noContent();
     }
     }
+
+
+
 }
 }

+ 3 - 0
app/Models/UserInfoModel.php

@@ -7,4 +7,7 @@ namespace App\Models;
 class UserInfoModel extends BaseModel
 class UserInfoModel extends BaseModel
 {
 {
     protected $table = 'users_info';
     protected $table = 'users_info';
+    public $timestamps = false;
+    protected $primaryKey="user_id";
+    protected $fillable = ['user_id', 'nickname','avatar','birthday','height','weight','work','info'];
 }
 }

+ 3 - 3
config/admin.php

@@ -254,12 +254,12 @@ return [
     'upload' => [
     'upload' => [
 
 
         // Disk in `config/filesystem.php`.
         // Disk in `config/filesystem.php`.
-        'disk' => 'public',
+        'disk' => 'oss',
 
 
         // Image and file upload path under the disk above.
         // Image and file upload path under the disk above.
         'directory' => [
         'directory' => [
-            'image' => 'images',
-            'file'  => 'files',
+            'image' => 'chengluApp',
+            'file'  => 'chengluApp/files',
         ],
         ],
     ],
     ],
 
 

+ 12 - 0
config/filesystems.php

@@ -53,6 +53,18 @@ return [
             'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
             'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
         ],
         ],
 
 
+
+        'oss' => [
+            'driver'     => 'oss',
+            'access_id'  => env('ALI_OSS_ACCESS_ID',""),//Your Aliyun OSS AccessKeyId
+            'access_key' => env('ALI_OSS_ACCESS_KEY',""),//Your Aliyun OSS AccessKeySecret
+            'bucket'     => env('ALI_OSS_BUCKET',""),//OSS bucket name
+            'endpoint'   => env('ALI_OSS_ENDPOINT',""),
+            'ssl'        => true, // true to use 'https://' and false to use 'http://'. default is false,
+            'isCName'    => false, // 是否使用自定义域名,true: 则Storage.url()会使用自定义的cdn或域名生成文件url, false: 则使用外部节点生成url
+            'debug'      => false,
+        ],
+
     ],
     ],
 
 
     /*
     /*

File diff suppressed because it is too large
+ 1 - 0
public/xieyi/jquery-2.1.1.min.js


+ 26 - 0
public/xieyi/yhxy.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>用户协议</title>
+</head>
+<body>
+<h1 style="text-align: center;">用户协议</h1>
+
+
+</body>
+<script src="jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
+<script>
+
+    $.ajax({
+        url:'https://t22.9026.com/api/login/xieyi?type=1&cont=1',
+        type:'get',
+        data:{},
+        dataType:'json',
+        success:function(res){
+            $('body').append(res.data.content);
+        }
+    })
+</script>
+</html>

+ 25 - 0
public/xieyi/yszc.html

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>隐私政策</title>
+</head>
+<body>
+<h1 style="text-align: center;">隐私政策</h1>
+</body>
+<script src="jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
+<script>
+
+    $.ajax({
+        url:'https://t22.9026.com/api/login/xieyi?type=2&cont=1',
+        type:'get',
+        data:{},
+        dataType:'json',
+        success:function(res){
+            $('body').append(res.data.content);
+        }
+    })
+</script>
+</html>
+

+ 10 - 0
routes/api.php

@@ -33,6 +33,16 @@ $api->version('v1', [
             $api->post('/loginByPassword', 'AuthorizationsController@loginByAccountPassword')->name('login.password');
             $api->post('/loginByPassword', 'AuthorizationsController@loginByAccountPassword')->name('login.password');
             $api->post('/forgetPassword', 'AuthorizationsController@forgetPassword')->name('login.forget');
             $api->post('/forgetPassword', 'AuthorizationsController@forgetPassword')->name('login.forget');
             $api->post('/register', 'AuthorizationsController@register')->name('login.register');
             $api->post('/register', 'AuthorizationsController@register')->name('login.register');
+            $api->get('/xieyi', 'AuthorizationsController@xieyi')->name('login.xieyi');
+        });
+
+        /*
+        |--------------------------------------------------------------
+        |  获取oss上传配置
+        |--------------------------------------------------------------
+        */
+        $api->group(['prefix' => 'upload-config'], function ($api) {
+            $api->get('/config', 'UploadConfigController@config')->name('upload.config');
         });
         });
 
 
         /*
         /*

Some files were not shown because too many files changed in this diff