xiaogang 4 vuotta sitten
vanhempi
commit
b291b00e7d

+ 15 - 0
app/Helper/function.php

xqd
@@ -86,4 +86,19 @@ function uc_time_ago($ptime)
     return $msg;
 }
 
+/**
+ * 根据生日计算年龄
+ * @param $birthday  1999-02-01
+ * @return int|string   21
+ */
+function birthday($birthday){
+    list($year,$month,$day) = explode("-",$birthday);
+    $year_diff = date("Y") - $year;
+    $month_diff = date("m") - $month;
+    $day_diff  = date("d") - $day;
+    if ($day_diff < 0 || $month_diff < 0)
+        $year_diff--;
+    return $year_diff;
+}
+
 

+ 4 - 4
app/Http/Controllers/Api/DynamicController.php

xqd xqd xqd xqd
@@ -65,7 +65,7 @@ class DynamicController extends Controller
             DB::rollBack();
             return $this->response->errorForbidden($exception->getMessage());
         }
-        return $this->response->noContent();
+        return response()->json(['message'=>"发布成功"]);
     }
 
     /**
@@ -142,7 +142,7 @@ class DynamicController extends Controller
             DB::rollBack();
             return $this->response->errorForbidden($exception->getMessage());
         }
-        return $this->response->noContent();
+        return response()->json(['message'=>"点赞成功"]);
     }
 
     /**
@@ -156,7 +156,7 @@ class DynamicController extends Controller
         }catch (\Exception $exception){
             return $this->response->errorForbidden($exception->getMessage());
         }
-        return $this->response->noContent();
+        return response()->json(['message'=>"删除成功"]);
     }
 
     /**
@@ -177,6 +177,6 @@ class DynamicController extends Controller
         }catch (\Exception $exception){
             return $this->response->errorForbidden($exception->getMessage());
         }
-        return $this->response->noContent();
+        return response()->json(['message'=>"举报成功"]);
     }
 }

+ 7 - 0
app/Models/UserInfoModel.php

xqd
@@ -10,4 +10,11 @@ class UserInfoModel extends BaseModel
     public $timestamps = false;
     protected $primaryKey="user_id";
     protected $fillable = ['user_id', 'nickname','avatar','birthday','height','weight','work','info'];
+
+    protected $appends = ['age'];
+
+    //年龄
+    public function getAgeAttribute(){
+        return birthday($this->attributes['birthday']);
+    }
 }

+ 9 - 0
app/Models/UserLookModel.php

xqd
@@ -10,4 +10,13 @@ class UserLookModel extends BaseModel
     public $timestamps = false;
     protected $fillable = ['user_id', 'look_id','atime'];
 
+    public function users()
+    {
+        return $this->belongsTo(User::class,'look_id','id');
+    }
+
+    public function users_info()
+    {
+        return $this->belongsTo(UserInfoModel::class,'look_id','user_id');
+    }
 }

+ 1 - 1
app/Services/DynamicService.php

xqd
@@ -71,7 +71,7 @@ class DynamicService
     public function dynamic_list($where){
         $dynamic = DynamicModel::query();
         $dynamic = $dynamic->with(["users"=>function($query){
-                $query->select('id','sex','is_vip');
+                $query->select('id','sex','is_vip','tencent_im_user_id');
             },'users_info']);
         //查询条件
         //类型  type 1全部  2关注  3附近

+ 3 - 3
app/Services/NoticeService.php

xqd xqd
@@ -25,12 +25,12 @@ class NoticeService
         if($param['type']==1){
             //我喜欢
             $query = $query->with(['like_users'=>function($query){
-                $query->select('id','sex','is_vip');
+                $query->select('id','sex','is_vip','tencent_im_user_id');
             },'like_users_info'])->where('user_id',$param['user_id']);
         }else{
             //喜欢我
             $query = $query->with(['users'=>function($query){
-                $query->select('id','sex','is_vip');
+                $query->select('id','sex','is_vip','tencent_im_user_id');
             },'users_info'])->where('like_id',$param['user_id']);
 
             //清除喜欢我未读状态
@@ -57,7 +57,7 @@ class NoticeService
             $query = $query->with(['dynamic'=>function($query){
                 $query->select('id','content','img_url');
             },'dynamic.users'=>function($querty){
-                $querty->select('id','sex','is_vip');
+                $querty->select('id','sex','is_vip','tencent_im_user_id');
             },'dynamic.users_info'])
             ->where('user_id',$param['user_id']);
         }else{

+ 8 - 1
app/Services/UserService.php

xqd xqd
@@ -5,6 +5,7 @@ namespace App\Services;
 
 
 use App\Http\Params\ProblemParam;
+use App\Models\UserLookModel;
 use App\Models\UserProblemModel;
 use PHPUnit\Util\Exception;
 
@@ -30,6 +31,12 @@ class UserService
      * 看过我
      */
     public function looked_me($param){
-
+        $res = UserLookModel::query()
+            ->with(['users'=>function($query){
+                $query->select('id','sex','is_vip','tencent_im_user_id');
+            },'users_info'])
+            ->where('user_id',$param['user_id'])
+            ->paginate(request('perPage',20));
+        return $res;
     }
 }

+ 1 - 0
composer.json

xqd
@@ -18,6 +18,7 @@
         "overtrue/easy-sms": "^1.3",
         "spatie/laravel-activitylog": "^3.17",
         "tencent/tls-sig-api-v2": "1.0",
+        "tencentcloud/tencentcloud-sdk-php": "^3.0",
         "tymon/jwt-auth": "^1.0"
     },
     "require-dev": {

+ 55 - 1
composer.lock

xqd xqd
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "baf076c44f6e6b91a80f4a56cc955f40",
+    "content-hash": "b7aeab616caaba4d1f629d1bc4c7f7f2",
     "packages": [
         {
             "name": "asm89/stack-cors",
@@ -6171,6 +6171,60 @@
             },
             "time": "2019-06-20T08:42:03+00:00"
         },
+        {
+            "name": "tencentcloud/tencentcloud-sdk-php",
+            "version": "3.0.418",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
+                "reference": "d3db04c09baa70399d034a7436d211a9c74ede70"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/d3db04c09baa70399d034a7436d211a9c74ede70",
+                "reference": "d3db04c09baa70399d034a7436d211a9c74ede70",
+                "shasum": "",
+                "mirrors": [
+                    {
+                        "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+                        "preferred": true
+                    }
+                ]
+            },
+            "require": {
+                "guzzlehttp/guzzle": "^6.3 || ^7.0.1",
+                "guzzlehttp/psr7": "^1.4",
+                "php": ">=5.6.0"
+            },
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "src/QcloudApi/QcloudApi.php"
+                ],
+                "psr-4": {
+                    "TencentCloud\\": "./src/TencentCloud"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "Apache-2.0"
+            ],
+            "authors": [
+                {
+                    "name": "coolli",
+                    "email": "tencentcloudapi@tencent.com",
+                    "homepage": "https://cloud.tencent.com/document/sdk/PHP",
+                    "role": "Developer"
+                }
+            ],
+            "description": "TencentCloudApi php sdk",
+            "homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
+            "support": {
+                "issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
+                "source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.418"
+            },
+            "time": "2021-06-22T01:14:22+00:00"
+        },
         {
             "name": "tijsverkoyen/css-to-inline-styles",
             "version": "2.2.3",

+ 1 - 0
routes/api.php

xqd
@@ -75,6 +75,7 @@ $api->version('v1', [
             $api->post('/updateinfo', 'UserController@updateinfo')->name('user.updateinfo');
             $api->post('/updateext', 'UserController@updateext')->name('user.updateext');
             $api->post('/problem', 'UserController@problem')->name('user.problem');
+            $api->post('/looked_me', 'UserController@looked_me')->name('user.looked_me');
 
         });