Your Name 4 달 전
부모
커밋
89a1ecf89b
2개의 변경된 파일140개의 추가작업 그리고 1개의 파일을 삭제
  1. 130
    1
      application/api/controller/Cms.php
  2. 10
    0
      config/database.php

+ 130
- 1
application/api/controller/Cms.php 파일 보기

@@ -25,7 +25,7 @@ use think\Db;
25 25
 class Cms extends MemberApi
26 26
 {
27 27
 
28
-    protected $noNeedLogin = ['login', 'register','getProduct','getProductSmall','createTask','tagHandle','taskHandle','getAreaJson','getTagListHandle'];
28
+    protected $noNeedLogin = ['login', 'register','getProduct','getProductSmall','createTask','tagHandle','taskHandle','getAreaJson','getTagListHandle','articleContentHandle','hkContent','upContent'];
29 29
     protected $noNeedRight = [];
30 30
 
31 31
     //初始化
@@ -906,5 +906,134 @@ class Cms extends MemberApi
906 906
 
907 907
     }
908 908
 
909
+    /*
910
+     * 处理内容 ai命令
911
+     * http://console.zx2049.com/api/cms/articleContentHandle
912
+     */
913
+    public function articleContentHandle(){
914
+
915
+        $list = Db::connect('db2')->table('ey_ai_content')->where('is_handle',0)->limit(80)->select();
916
+
917
+        $num = 0;
918
+        foreach ($list as $k=>$v){
919
+            //echo $v['content_5'];
920
+            $html = htmlspecialchars_decode($v['content_5']);
921
+            $result = strip_tags($html);
922
+            $ml = '请对以下内容进行洗稿,洗稿方式以采用同义词或近义词的方式替换进行洗稿,以下是需要洗稿的文章:”'.$result.'“';
923
+            //echo $ml;
924
+            Db::connect('db2')->table('ey_ai_content')
925
+                ->where('id',$v['id'])->update([
926
+                    'content_ml' => $ml,
927
+                    'is_handle' => 1,
928
+                ]);
929
+            $num++;
930
+
931
+        }
932
+        echo $num;
933
+    }
934
+
935
+    /*
936
+     * 去除 :</p> 第一段 重新保存
937
+     * http://console.zx2049.com/api/cms/hkContent
938
+     */
939
+    public function hkContent(){
940
+
941
+
942
+        $list = Db::connect('db2')
943
+            ->table('ey_ai_content')
944
+            ->where('is_handle',2)
945
+            //->where('id',51)
946
+            ->limit(80)
947
+            ->select();
909 948
 
949
+        $num = 0;
950
+        foreach ($list as $k=>$v){
951
+
952
+            //先将实体转为字符
953
+            //查看网页源码即可
954
+            //htmlspecialchars  //转为&lt;p&gt
955
+            //htmlspecialchars_decode //转为html标签 本身是html标签不会转
956
+            $str = htmlspecialchars_decode($v['content']);
957
+            //echo $str;
958
+            //判断是否包含该字符 以下
959
+            if (strpos($str, '以下') !== false) {
960
+                //echo "字符串中包含子字符串";
961
+
962
+                $str_1 = explode('以下',$str);
963
+                $str_2 = explode('</p>',$str_1[1]);
964
+                $keywords =  '<p>以下'.$str_2[0].'</p>';
965
+                $result = str_replace($keywords,'', $str);
966
+                $result = str_replace('<p>“','<p>', $result);
967
+                $result = str_replace('”</p>','</p>', $result);
968
+                //echo $result;
969
+                //更新到新字段
970
+                Db::connect('db2')->table('ey_ai_content')
971
+                    ->where('id',$v['id'])->update([
972
+                        'content_h' => $result,
973
+                        'is_handle' => 3,
974
+                    ]);
975
+                $info = '已处理';
976
+            } else {
977
+                //echo "字符串中不包含子字符串";
978
+                //更新到新字段
979
+                Db::connect('db2')->table('ey_ai_content')
980
+                    ->where('id',$v['id'])->update([
981
+                        'is_handle' => 3,
982
+                    ]);
983
+                $info = '未发现';
984
+            }
985
+            $num++;
986
+            echo $num."-".$info."<br/>";
987
+        }
988
+    }
989
+
990
+
991
+    /*
992
+     * 更新到主记录
993
+     * http://console.zx2049.com/api/cms/upContent
994
+     */
995
+    public function upContent(){
996
+        $list = Db::connect('db2')
997
+            ->table('ey_ai_content')
998
+            ->where('is_handle',3)
999
+            //->where('id',51)
1000
+            ->limit(80)
1001
+            ->select();
1002
+
1003
+        $num = 0;
1004
+        foreach ($list as $k=>$v){
1005
+
1006
+            $info = '';
1007
+
1008
+            if(empty($v['content_h'])){
1009
+                $str = $v['content'];
1010
+            }else{
1011
+                $str = $v['content_h'];
1012
+            }
1013
+            $str = htmlspecialchars($str);
1014
+            //echo $str;
1015
+
1016
+            //更新正文
1017
+            Db::connect('db2')
1018
+                ->table('ey_zczygz_content')
1019
+                ->where('aid',$v['aid'])->update([
1020
+                    'content_5' => $str,
1021
+                ]);
1022
+            //更新seo
1023
+            /*Db::connect('db2')
1024
+                ->table('ey_archives')
1025
+                ->where('aid',$v['aid'])->update([
1026
+                    'seo_description' => $str,
1027
+                ]);*/
1028
+
1029
+            Db::connect('db2')->table('ey_ai_content')
1030
+                ->where('id',$v['id'])->update([
1031
+                    'is_handle' => 4, //表示已同步
1032
+                ]);
1033
+
1034
+            $num++;
1035
+            $info = '文档id:'.$v['aid'];
1036
+            echo $num."-".$info."<br/>";
1037
+        }
1038
+    }
910 1039
 }

+ 10
- 0
config/database.php 파일 보기

@@ -68,4 +68,14 @@ return [
68 68
         'prefix'          => 'ey_',
69 69
         // 其他的数据库连接参数...
70 70
     ],
71
+    'db2' => [
72
+        'type'            => 'mysql',
73
+        'hostname'        => '120.55.79.149',
74
+        'database'        => 'www_zc10000_com',
75
+        'username'        => 'www_zc10000_com',
76
+        'password'        => '85HKpn7pAPTP',
77
+        'hostport'        => '',
78
+        'prefix'          => 'ey_',
79
+        // 其他的数据库连接参数...
80
+    ],
71 81
 ];

Loading…
취소
저장