wupengfei 2 лет назад
Родитель
Сommit
78517dd8f8

+ 11 - 9
.idea/workspace.xml

@@ -2,7 +2,9 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
+      <change afterPath="$PROJECT_DIR$/application/common/service/OpenSearch.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/controller/Datum.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Datum.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -122,7 +124,7 @@
   <component name="PropertiesComponent">
     <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
     <property name="WebServerToolWindowFactoryState" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$/../sp" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/application/common/service" />
     <property name="node.js.detected.package.eslint" value="true" />
     <property name="node.js.detected.package.tslint" value="true" />
     <property name="node.js.path.for.package.eslint" value="project" />
@@ -133,19 +135,19 @@
     <property name="two.files.diff.last.used.folder" value="$PROJECT_DIR$" />
   </component>
   <component name="RecentsManager">
-    <key name="CopyFile.RECENT_KEYS">
-      <recent name="D:\zs\gaoyixia\application\api\controller" />
-      <recent name="D:\zs\gaoyixia\vendor\alibabacloud" />
-      <recent name="D:\zs\gaoyixia\application\nutrition\view" />
-      <recent name="D:\zs\gaoyixia\application\nutrition\controller" />
-      <recent name="D:\zs\gaoyixia\application\common\model" />
-    </key>
     <key name="MoveFile.RECENT_KEYS">
       <recent name="D:\zs\gaoyixia\public\a" />
       <recent name="D:\zs\gaoyixia\public" />
       <recent name="D:\zs\gaoyixia\public\wx_cert" />
       <recent name="D:\zs\gaoyixia\application\api\controller" />
     </key>
+    <key name="CopyFile.RECENT_KEYS">
+      <recent name="D:\zs\gaoyixia\application\common\service" />
+      <recent name="D:\zs\gaoyixia\application\api\controller" />
+      <recent name="D:\zs\gaoyixia\vendor\alibabacloud" />
+      <recent name="D:\zs\gaoyixia\application\nutrition\view" />
+      <recent name="D:\zs\gaoyixia\application\nutrition\controller" />
+    </key>
   </component>
   <component name="SvnConfiguration">
     <configuration />
@@ -251,7 +253,7 @@
       <workItem from="1678149106133" duration="24129000" />
       <workItem from="1678236784872" duration="19064000" />
       <workItem from="1678322422199" duration="23277000" />
-      <workItem from="1678410737283" duration="501000" />
+      <workItem from="1678410737283" duration="10155000" />
     </task>
     <servers />
   </component>

+ 1 - 1
application/api/controller/Datum.php

@@ -708,7 +708,7 @@ class Datum extends Base
             $v['like_num'] = DatumLike::where('url_id',$v['url_id'])->count();
             $v['like_num'] = numTransform($v['like_num']);
         });
-        $total_num =UserCollect::where($sel_where)->leftJoin('DatumUrl i','t.children_id = i.id')->count();
+        $total_num =UserCollect::where($sel_where)->alias('t')->leftJoin('DatumUrl i','t.children_id = i.id')->count();
         $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
     }
 

+ 59 - 0
application/common/service/OpenSearch.php

@@ -0,0 +1,59 @@
+<?php
+namespace app\common\service;
+require_once("../vendor/alibabacloud/opensearch-sdk-php/OpenSearch/Autoloader/Autoloader.php");
+header("Content-Type:text/html;charset=utf-8");
+use AlibabaCloud\Client\Clients\BearerTokenClient;
+use OpenSearch\Client\OpenSearchClient;
+use OpenSearch\Client\DocumentClient;
+use OpenSearch\Client\SearchClient;
+use OpenSearch\Util\SearchParamsBuilder;
+
+/**
+ *
+ * Class SerBase
+ */
+class OpenSearch
+{
+
+    public static $accessKeyId = 'LTAI5tJ5p12drZegeWVG33xZ';
+    public static $secret = '82UWAiY5e5wH8tSkRvMtqVoGO0h8SB';
+    public static $endPoint = 'http://opensearch-cn-shanghai.aliyuncs.com';
+    public static $appName = 'GYXTEST';
+    public static $suggestName = 'qc_ts';// 下拉提示名
+    public static $tableName = 'dd_video_cate';// 结构
+    public static $options = ['debug' => true];
+
+    /**
+     * opensearch数据推送
+     * @param $module 模块
+     * @param $id  记录id
+     * @param int $type 推送类型1新增2更新
+     * @return mixed
+     */
+    public static function push($module,$id,$type = 1)
+    {
+        $client = new OpenSearchClient(static::$accessKeyId, static::$secret, static::$endPoint, static::$options);
+        //设置数据需推送到对应应用表中
+        //创建文档操作client
+        $documentClient = new DocumentClient($client);
+        $push_data= [];
+        $push_data['cmd'] = $type == 1 ?  'ADD' : 'UPDATE';
+        $push_data['fields'] = [];
+        switch ($module)
+        {
+            case 'video':
+                break;
+            case 'atricle':
+                break;
+            case 'datum':
+                break;
+        }
+        //提交推送文档
+        $ret = $documentClient->push(json_encode([$push_data]), static::$appName, static::$tableName);
+        $ret_array = json_decode(json_encode($ret),true);
+        $ret_val = json_decode($ret_array['result'],true);
+        return  $ret_val;
+    }
+
+
+}