|
@@ -9,8 +9,10 @@
|
|
namespace App\Repositories;
|
|
namespace App\Repositories;
|
|
|
|
|
|
use App\Models\MemberFollowTopic;
|
|
use App\Models\MemberFollowTopic;
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
class MemberFollowTopicRepository {
|
|
class MemberFollowTopicRepository {
|
|
public function __construct(MemberFollowTopic $memberFollowTopic,CategoryRepository $categoryRepository) {
|
|
public function __construct(MemberFollowTopic $memberFollowTopic,CategoryRepository $categoryRepository) {
|
|
@@ -31,12 +33,38 @@ class MemberFollowTopicRepository {
|
|
'topic_id' => $value['id'],
|
|
'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('关注失败');
|
|
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 [];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//关注单个话题
|
|
//关注单个话题
|