Ver Fonte

公众号列表

zhaoyang há 1 ano atrás
pai
commit
2f146649f8

+ 51 - 0
modules/WechatPlatform/Http/Controllers/WechatAuthorizationInfoController.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace Modules\WechatPlatform\Http\Controllers;
+
+use Catch\Base\CatchController;
+use Illuminate\Http\Request;
+use Modules\User\Http\Controllers\UserTrait;
+use Modules\WechatPlatform\Models\WechatAuthorizationInfo;
+
+class WechatAuthorizationInfoController extends CatchController
+{
+
+    public function __construct(protected readonly WechatAuthorizationInfo $wechatAuthorizationInfo)
+    {
+        
+    }
+
+    use UserTrait;
+
+    public function index(Request $request)
+    {
+        
+        if($this->isOptimizer()){
+            $where = [
+                ['wechat_authorization_infos.user_id','=',$this->getLoginUserId()],
+                ['wechat_authorization_infos.is_enabled','=',1]
+            ];
+        }elseif($this->isCompanyManager()){
+            $where = [
+                ['wechat_authorization_infos.puser_id','=',$this->getLoginUserId()],
+                ['wechat_authorization_infos.is_enabled','=',1]
+            ];
+        }else{
+            return [];
+        }
+        
+        $result = $this->wechatAuthorizationInfo->where($where)
+        ->join('wechat_open_platform_infos','wechat_open_platform_infos.app_id','=','wechat_authorization_infos.component_appid')
+        ->join('miniprogram','wechat_open_platform_infos.xcx_appid','=','miniprogram.appid')
+        ->select('wechat_authorization_infos.nick_name','wechat_authorization_infos.authorizer_appid','miniprogram.name as xcx_name')
+        ->paginate($request->input('limit', 20));
+
+
+        foreach($result as $item){
+            //获取粉丝数
+            $item->fans_count = 100;
+        }
+
+        return $result;
+    }
+}

+ 16 - 0
modules/WechatPlatform/Models/WechatAuthorizationInfo.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace Modules\WechatPlatform\Models;
+
+use Modules\Common\Models\BaseModel;
+
+
+class WechatAuthorizationInfo extends BaseModel
+{
+    protected $table = 'wechat_authorization_infos';
+
+    protected $fillable = [
+        'id', 'authorizer_appid', 'component_appid', 'user_id', 'puser_id', 'authorizer_refresh_token', 'created_at', 'updated_at', 'nick_name', 'is_enabled', 
+    ];
+
+}

+ 4 - 0
modules/WechatPlatform/routes/route.php

@@ -2,6 +2,7 @@
 
 use Illuminate\Support\Facades\Route;
 use Modules\WechatPlatform\Http\Controllers\KFMessageController;
+use Modules\WechatPlatform\Http\Controllers\WechatAuthorizationInfoController;
 use Modules\WechatPlatform\Http\Controllers\WechatKeywordsController;
 
 Route::prefix('wechatPlatform')->group(function(){
@@ -16,6 +17,9 @@ Route::prefix('wechatPlatform')->group(function(){
 
     // 微信公众号设置
     Route::prefix('officialAccount')->group(function () {
+        //公众号列表
+        Route::get("list",[WechatAuthorizationInfoController::class,'index']);
+
         // 关键字列表
         Route::prefix('keyword')->group(function () {
             // 列表

+ 2 - 1
tests/Feature/VideoStatTest.php

@@ -13,7 +13,8 @@ class VideoStatTest extends TestCase
      */
     public function test_example(): void
     {
-        $response = $this->get('/api/statistic/video/stats');
+        //$response = $this->get('/api/statistic/video/stats');
+        $response = $this->get('/api/wechatPlatform/officialAccount/list');
         echo $response->getContent();
         $response->assertStatus(200);
     }