소스 검색

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/community-service into develop

duqinya 5 년 전
부모
커밋
7a0d3bc5ef
1개의 변경된 파일32개의 추가작업 그리고 4개의 파일을 삭제
  1. 32 4
      app/Repositories/MemberFollowTopicRepository.php

+ 32 - 4
app/Repositories/MemberFollowTopicRepository.php

@@ -9,8 +9,10 @@
 namespace App\Repositories;
 
 use App\Models\MemberFollowTopic;
+use Illuminate\Support\Facades\DB;
 use Tymon\JWTAuth\Facades\JWTAuth;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
 
 class MemberFollowTopicRepository {
     public function __construct(MemberFollowTopic $memberFollowTopic,CategoryRepository $categoryRepository) {
@@ -31,12 +33,38 @@ class MemberFollowTopicRepository {
                     'topic_id' => $value['id'],
                 ];
             }
-            $res = $this->memberFollowTopic->insert($category_topic_data);
-            if($res){
-                return jsonSuccess();
-            }else{
+            DB::beginTransaction();
+            try{
+                $res = $this->memberFollowTopic->insert($category_topic_data);
+                $topic = $this->updataMemberFollowSuggestTopic();
+                DB::commit();
+                if($res){
+                    //更改关注状态
+
+                    return jsonSuccess();
+                }else{
+                    return jsonError('关注失败');
+                }
+            }catch (QueryException $exception){
+                DB::rollBack();
+                Log::debug('新增话题:'.$exception->getMessage());
                 return jsonError('关注失败');
             }
+
+        }
+    }
+    //修改关注状态
+    public function updataMemberFollowSuggestTopic(){
+        try {
+            $sign = generateSign([], config('customer.app_secret'));
+            $url = config("customer.app_service_url").'/user/userInfo';
+            $url = 'http://localhost:8080/v2/member/updateFollowSuggestTopic';
+            $array = [
+                'json' => ['sign' => $sign], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
+            ];
+            return http($url,$array,'put');
+        } catch (\Exception $e) {
+            return [];
         }
     }
     //关注单个话题