Просмотр исходного кода

c端新增:获取及搜索调研选题

FengR 6 часов назад
Родитель
Сommit
fa086d5a51
3 измененных файлов с 74 добавлено и 0 удалено
  1. 38 0
      app/JsonRpc/WebService.php
  2. 5 0
      app/JsonRpc/WebServiceInterface.php
  3. 31 0
      app/Model/ResearchTopic.php

+ 38 - 0
app/JsonRpc/WebService.php

@@ -67,6 +67,7 @@ use Hyperf\Coroutine\Concurrent;
 use function Hyperf\Coroutine\batch;
 use Swoole\Coroutine;
 use App\Model\Message;
+use App\Model\ResearchTopic;
 #[RpcService(name: "WebService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebService implements WebServiceInterface
 {
@@ -3820,4 +3821,41 @@ class WebService implements WebServiceInterface
     $result = Result::buildCityTree($province_city);
     return Result::success($result);
   }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteResearchTopic(array $data): array
+  {
+    $web = Website::where('id',$data['website_id'])->first();
+    if (empty($web)) {
+      return Result::error("暂无相关网站信息", 0);
+    }
+    $column_arr = json_decode($web['website_column_arr_id'] ?? [], true);
+    $where['level'] = 1;
+    if (isset($data['province_id']) && !empty($data['province_id'])) {
+      $where['province_id'] = $data['province_id'];
+    }
+    if (isset($data['city_id']) && !empty($data['city_id'])) {
+      $where['city_id'] = $data['city_id'];
+    }
+    if (isset($data['county_id']) && !empty($data['county_id'])) {
+      $where['county_id'] = $data['county_id'];
+    }
+    if(isset($data['title']) && !empty($data['title'])){
+      array_push($where,['title','like','%'.$data['title'].'%']);
+    }
+    $research_topic = ResearchTopic::whereIn('column_id', $column_arr)
+      ->where($where)
+      ->select('id', 'title', 'keyword', 'description','province_id','city_id','county_id')
+      ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+    if (empty($research_topic->items())) {  
+      return Result::error("暂无相关研究主题信息", 0);
+    }
+    $result = [
+      'rows' => $research_topic->items(),
+      'count' => $research_topic->total(),
+    ];
+    return Result::success($result);
+  }
 }

+ 5 - 0
app/JsonRpc/WebServiceInterface.php

@@ -216,4 +216,9 @@ interface WebServiceInterface
      * @return array
      */
     public function getWebsiteProvinceCity(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteResearchTopic(array $data): array;
 }

+ 31 - 0
app/Model/ResearchTopic.php

@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ResearchTopic extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'research_topic';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $guarded = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+    public function retopicUsers()
+    {
+        return $this->hasMany(RetopicUser::class, 'retopic_id', 'id');
+    }
+}