Your Name 6 months ago
parent
commit
ab592e5bdc

+ 44
- 0
application/admin/controller/cms/Cms.php View File

@@ -206,10 +206,38 @@ class Cms extends Adminbase
206 206
                 $this->error("请指定栏目ID!");
207 207
             }
208 208
             $category = getCategory($catid);
209
+
210
+            //dump($data['modelField']);die;
209 211
             if (empty($category)) {
210 212
                 $this->error('该栏目不存在!');
211 213
             }
212 214
             if ($category['type'] == 2) {
215
+
216
+                //模型类型
217
+                if((int)$catid === 17){
218
+                    //关键词栏目
219
+                    //进行判断标题是否存在
220
+                    //不用考虑状态还有指令类型
221
+                    $one = Db::name('cms_zl')->where([
222
+                            'gzxh' => $data['modelField']['gzxh'],
223
+                            'title' => $data['modelField']['title'],
224
+                        ])->find();
225
+                    if(!empty($one)){
226
+                        $this->error("该规则下此标题已存在!");
227
+                    }
228
+
229
+                    if((int)$data['modelField']['is_qj'] == 1){
230
+                        //是全局
231
+                        $t_data = [
232
+                                '全局-非主非副','全局-主词类型','全局-副词类型'
233
+                            ];
234
+                        if(!in_array($data['modelField']['title'],$t_data)){
235
+                            $this->error("标题必须是'全局-非主非副','全局-主词类型','全局-副词类型'其中一个!");
236
+                        }
237
+                    }
238
+                }
239
+
240
+
213 241
                 $data['modelFieldExt'] = $data['modelFieldExt'] ?? [];
214 242
                 try {
215 243
                     $this->CmsModel->addModelData($data['modelField'], $data['modelFieldExt']);
@@ -258,6 +286,22 @@ class Cms extends Adminbase
258 286
         if ($this->request->isPost()) {
259 287
             $data                  = $this->request->post();
260 288
             $data['modelFieldExt'] = $data['modelFieldExt'] ?? [];
289
+
290
+
291
+
292
+            //模型类型
293
+            if((int)$data['modelField']['catid'] === 17){
294
+                if((int)$data['modelField']['is_qj'] == 1){
295
+                    //是全局
296
+                    $t_data = [
297
+                        '全局-非主非副','全局-主词类型','全局-副词类型'
298
+                    ];
299
+                    if(!in_array($data['modelField']['title'],$t_data)){
300
+                        $this->error("标题必须是'全局-非主非副','全局-主词类型','全局-副词类型'其中一个!");
301
+                    }
302
+                }
303
+            }
304
+
261 305
             try {
262 306
                 $this->CmsModel->editModelData($data['modelField'], $data['modelFieldExt']);
263 307
             } catch (\Exception $ex) {

+ 13
- 160
application/admin/view/cms/cms/classlist.html View File

@@ -10,52 +10,13 @@
10 10
     data-auth-remove="{:$auth->check('cms.cms/remove')}"
11 11
     data-auth-recycle="{:$auth->check('cms.cms/recycle')}"
12 12
 ></table>
13
-<script type="text/html" id="barTool">
14
-    {if $cmsConfig['doc_edit_mode'] == 1}
15
-    <a class="layui-btn layui-btn-xs btn-addtabs{:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-menu-id="{$catid}-{{ d.id }}" data-url='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
16
-    {else}
17
-    <a class="layui-btn layui-btn-xs {:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
18
-    {/if}
19
-    <a href='{:url("del",["catid"=>$catid])}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('cms.cms/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>
20
-</script>
21
-<script type="text/html" id="title">
22
-    {{# if(d.flag.indexOf("1")!==-1){ }}
23
-  <span class="text-danger">[置顶]</span>
24
-  {{#  } }}
25
-  {{# if(d.flag.indexOf("2")!==-1){ }}
26
-  <span class="text-danger">[头条]</span>
27
-  {{#  } }}
28
-  {{# if(d.flag.indexOf("3")!==-1){ }}
29
-  <span class="text-danger">[特荐]</span>
30
-  {{#  } }}
31
-  {{# if(d.flag.indexOf("4")!==-1){ }}
32
-  <span class="text-danger">[推荐]</span>
33
-  {{#  } }}
34
-  {{# if(d.flag.indexOf("5")!==-1){ }}
35
-  <span class="text-danger">[热点]</span>
36
-  {{#  } }}
37
-  {{# if(d.flag.indexOf("6")!==-1){ }}
38
-  <span class="text-danger">[幻灯]</span>
39
-  {{#  } }}
40
-  {{# if(d.thumb){ }}
41
-  <span class="text-success">[有图]</span>
42
-  {{#  } }}
43
-  <a  data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true">{{ d.title }}</a>
44
-</script>
45
-<script type="text/html" id="username">
46
-    {{# if(d.sysadd==1){ }}
47
-  {{ d.username }}
48
-  {{#  } else { }}
49
-  <span class="text-danger">{{ d.username }}</span>
50
-  {{#  } }}
51
-</script>
52
-<script type="text/html" id="statusTpl">
53
-    <input type="checkbox" name="status" data-href='{:url("setstate",["catid"=>$catid])}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="通过|待审核" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
54
-</script>
55 13
 
56
-<script type="text/html" id="areaTpl">
57
-    {{ d.diqu }}
58
-</script>
14
+
15
+{switch $catid}
16
+{case 17}{include file="../application/admin/view/cms/cms/script/catid_17.html" /}{/case}
17
+{case 18}{include file="../application/admin/view/cms/cms/script/catid_18.html" /}{/case}
18
+{default /}{include file="../application/admin/view/cms/cms/script/default.html" /}
19
+{/switch}
59 20
 
60 21
 
61 22
 <div id="remove" style="display: none;">
@@ -76,125 +37,17 @@
76 37
     overflow: inherit;
77 38
 }
78 39
 </style>
79
-{/block}
80
-{block name="script"}
81
-<script>
82
-layui.use(['yzn','table', 'yznTable'], function() {
83
-    var table = layui.table,
84
-        $ = layui.$,
85
-        form = layui.form,
86
-        table = layui.table,
87
-        yzn = layui.yzn,
88
-        yznTable = layui.yznTable;
89
-
90
-    var init = {
91
-        table_elem: '#currentTable',
92
-        table_render_id: 'currentTable',
93
-        add_url: "{:url('add',['catid'=>$catid])}",
94
-        delete_url: "{:url('del',['catid'=>$catid])}",
95
-        modify_url: '{:url("listorder",["catid"=>$catid])}',
96
-    };
97
-
98
-    yznTable.render({
99
-        init: init,
100
-        toolbar: ['refresh',
101
-            [{
102
-                text: '添加',
103
-                url: init.add_url,
104
-                method: 'open',
105
-                auth: 'add',
106
-                icon: 'iconfont icon-add',
107
-                class: 'layui-btn layui-btn-normal layui-btn-sm btn-add',
108
-                extend: 'data-full="true"',
109
-            }], 'delete',
110
-            [{
111
-                html: '<button class="layui-btn layui-btn-sm layui-btn-normal move"><i class="iconfont icon-yidong"></i>&nbsp;批量移动</button> ',
112
-                auth: 'remove',
113
-            }],
114
-            [{
115
-                html: '<button class="layui-btn layui-btn-warm layui-btn-sm" data-table="currentTable" data-open="{:url("recycle",["catid"=>$catid])}"><i class="iconfont icon-recycle-line"></i>&nbsp;回收站</button>',
116
-                auth: 'recycle',
117
-            }],
118
-        ],
119
-        url: '{:url("classlist",["catid"=>$catid])}',
120
-        cols: [
121
-            [
122
-                { type: 'checkbox', fixed: 'left' },
123
-                { field: 'listorder', width: 70, title: '排序', edit: 'text',search:false },
124
-                { field: 'id', width: 60, title: 'ID' },
125
-                { field: 'title', align: "left", title: '标题', templet: '#title', searchOp: 'like' },
126
-                { field: 'flag', width: 100, title: '属性',hide: true, selectList: { 1: '置顶', 2: '头条', 3: '特荐', 4: '推荐', 5: '热点', 6: '幻灯' }, searchOp: 'FIND_IN_SET' },
127
-                { field: 'thumb', width: 100, title: '图片', search: false, templet: yznTable.formatter.image },
128
-                { field: 'hits', width: 80, title: '点击量',search: 'between',searchTip:'点击量' },
129
-                { field: 'update_time', width: 160, title: '更新时间', search: 'range' },
130
-                { field: 'username', width: 80, title: '发布人', templet: '#username' },
131
-                { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.formatter.url, search: false },
132
-                { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
133
-                { field: 'diqu', width: 100, align: "center", title: '区域', templet: '#areaTpl', unresize: true, selectList: {"1":"广东","30":"福建","6872":"陕西","6791":"西藏","6645":"云南","6344":"四川","6303":"重庆","6003":"海南","5879":"广西","5742":"湖南","5625":"湖北","5448":"河南","5179":"江西","5056":"安徽","4833":"江苏","4813":"上海","4667":"黑龙江","4589":"吉林","4474":"辽宁","4228":"山西","4042":"河北","4023":"天津","4003":"浙江","6547":"贵州","4359":"内蒙古","4004":"北京","6990":"甘肃","7092":"青海","7144":"宁夏","7171":"新疆","10000":"主站"} },
134 40
 
135 41
 
136
-                { fixed: 'right', width: 90, title: '操作', toolbar: '#barTool' }
137
-            ]
138
-        ],
139
-        page: {}
140
-    });
141
-
142
-    yznTable.bindevent();
143
-
144
-    $('body').on('click', '.btn-add', function() {
145
-        var url = $(this).attr('data-open');
146
-        {if $cmsConfig['doc_edit_mode'] == 0}
147
-        yzn.open('添加', url,'100%','100%');
148
-        {else}
149
-        window.top.layui.admin.addTab('cms_add','添加',url)
150
-        {/if}
151
-        return false;
152
-    });
153 42
 
43
+{/block}
44
+{block name="script"}
154 45
 
155
-    $('body').on('click', '.move', function() {
156
-        var checkStatus = table.checkStatus('currentTable'),
46
+{switch $catid}
47
+{case 17}{include file="../application/admin/view/cms/cms/list/catid_17.html" /}{/case}
48
+{case 18}{include file="../application/admin/view/cms/cms/list/catid_18.html" /}{/case}
49
+{default /}{include file="../application/admin/view/cms/cms/list/default.html" /}
50
+{/switch}
157 51
 
158
-            ids = [],
159
-            id = tag = '';
160
-        var data = checkStatus.data;
161
-        if (data.length > 0) {
162
-            for (let i in data) {
163
-                id += tag + data[i].id;
164
-                tag = '|';
165
-                //ids.push(data[i].id);
166
-            }
167
-            layer.open({
168
-                title: '批量移动',
169
-                type: 1,
170
-                content: $('#remove'),
171
-                area: ['300px', '250px'],
172
-                btn: ['移动'],
173
-                yes: function(index, layero) {
174
-                    var tocatid = $("select[name='remove']").val();
175
-                    if (tocatid == 0) {
176
-                        layer.msg("请选择移动的栏目",{icon: 2});
177
-                        return;
178
-                    }
179
-                    $.post('{:url("remove",["catid"=>$catid])}', { 'ids': id, 'tocatid': tocatid }, function(data) {
180
-                        if (data.code == 1) {
181
-                            table.reload('currentTable');
182
-                            layer.msg(data.msg,{icon: 1});
183
-                            layer.close(index);
184
-                        } else {
185
-                            layer.msg(data.msg,{icon: 2});
186
-                        }
187
-                    })
188
-                },
189
-                end: function(){ 
190
-                    $('#remove').hide();
191
-                }
192
-            });
193
-        } else {
194
-            layer.msg("请选择需要移动的数据",{icon: 2});
195
-        }
196
-    });
197 52
 
198
-});
199
-</script>
200 53
 {/block}

+ 121
- 0
application/admin/view/cms/cms/list/catid_17.html View File

@@ -0,0 +1,121 @@
1
+
2
+<script>
3
+    layui.use(['yzn','table', 'yznTable'], function() {
4
+        var table = layui.table,
5
+            $ = layui.$,
6
+            form = layui.form,
7
+            table = layui.table,
8
+            yzn = layui.yzn,
9
+            yznTable = layui.yznTable;
10
+
11
+        var init = {
12
+            table_elem: '#currentTable',
13
+            table_render_id: 'currentTable',
14
+            add_url: "{:url('add',['catid'=>$catid])}",
15
+            delete_url: "{:url('del',['catid'=>$catid])}",
16
+            modify_url: '{:url("listorder",["catid"=>$catid])}',
17
+        };
18
+
19
+        yznTable.render({
20
+            init: init,
21
+            toolbar: ['refresh',
22
+                [{
23
+                    text: '添加',
24
+                    url: init.add_url,
25
+                    method: 'open',
26
+                    auth: 'add',
27
+                    icon: 'iconfont icon-add',
28
+                    class: 'layui-btn layui-btn-normal layui-btn-sm btn-add',
29
+                    extend: 'data-full="true"',
30
+                }], 'delete',
31
+                [{
32
+                    html: '<button class="layui-btn layui-btn-sm layui-btn-normal move"><i class="iconfont icon-yidong"></i>&nbsp;批量移动</button> ',
33
+                    auth: 'remove',
34
+                }],
35
+                [{
36
+                    html: '<button class="layui-btn layui-btn-warm layui-btn-sm" data-table="currentTable" data-open="{:url("recycle",["catid"=>$catid])}"><i class="iconfont icon-recycle-line"></i>&nbsp;回收站</button>',
37
+                    auth: 'recycle',
38
+                }],
39
+            ],
40
+            url: '{:url("classlist",["catid"=>$catid])}',
41
+            cols: [
42
+                [
43
+                    { type: 'checkbox', fixed: 'left' },
44
+                    { field: 'listorder', width: 70, title: '排序', edit: 'text',search:false },
45
+                    { field: 'id', width: 60, title: 'ID' },
46
+                    { field: 'gzxh', width: 80 ,align: "left", title: '规则', templet: '#gzxh', selectList: { 0: '默认',1: '规则1', 2: '规则2', 3: '规则3', 4: '规则4', 5: '规则5', 6: '规则6',7: '规则7',8: '规则8',9: '规则9',10: '规则10' }, searchOp: 'FIND_IN_SET' },
47
+                    { field: 'title', align: "left", title: '标题', templet: '#title', searchOp: 'like' },
48
+                    //{ field: 'flag', width: 100, title: '属性',hide: true, selectList: { 1: '置顶', 2: '头条', 3: '特荐', 4: '推荐', 5: '热点', 6: '幻灯' }, searchOp: 'FIND_IN_SET' },
49
+                    //{ field: 'thumb', width: 100, title: '图片', search: false, templet: yznTable.formatter.image },
50
+                    { field: 'hits', width: 80, title: '点击量',search: 'between',searchTip:'点击量' },
51
+                    { field: 'update_time', width: 160, title: '更新时间', search: 'range' },
52
+                    { field: 'username', width: 80, title: '发布人', templet: '#username' },
53
+                    { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.formatter.url, search: false },
54
+                    { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
55
+                    { field: 'diqu', width: 100, align: "center", title: '区域', templet: '#areaTpl', unresize: true, selectList: {"1":"广东","30":"福建","6872":"陕西","6791":"西藏","6645":"云南","6344":"四川","6303":"重庆","6003":"海南","5879":"广西","5742":"湖南","5625":"湖北","5448":"河南","5179":"江西","5056":"安徽","4833":"江苏","4813":"上海","4667":"黑龙江","4589":"吉林","4474":"辽宁","4228":"山西","4042":"河北","4023":"天津","4003":"浙江","6547":"贵州","4359":"内蒙古","4004":"北京","6990":"甘肃","7092":"青海","7144":"宁夏","7171":"新疆","10000":"主站"} },
56
+
57
+
58
+                    { fixed: 'right', width: 90, title: '操作', toolbar: '#barTool' }
59
+                ]
60
+            ],
61
+            page: {}
62
+        });
63
+
64
+        yznTable.bindevent();
65
+
66
+        $('body').on('click', '.btn-add', function() {
67
+            var url = $(this).attr('data-open');
68
+            {if $cmsConfig['doc_edit_mode'] == 0}
69
+            yzn.open('添加', url,'100%','100%');
70
+            {else}
71
+            window.top.layui.admin.addTab('cms_add','添加',url)
72
+            {/if}
73
+                return false;
74
+            });
75
+
76
+
77
+            $('body').on('click', '.move', function() {
78
+                var checkStatus = table.checkStatus('currentTable'),
79
+
80
+                    ids = [],
81
+                    id = tag = '';
82
+                var data = checkStatus.data;
83
+                if (data.length > 0) {
84
+                    for (let i in data) {
85
+                        id += tag + data[i].id;
86
+                        tag = '|';
87
+                        //ids.push(data[i].id);
88
+                    }
89
+                    layer.open({
90
+                        title: '批量移动',
91
+                        type: 1,
92
+                        content: $('#remove'),
93
+                        area: ['300px', '250px'],
94
+                        btn: ['移动'],
95
+                        yes: function(index, layero) {
96
+                            var tocatid = $("select[name='remove']").val();
97
+                            if (tocatid == 0) {
98
+                                layer.msg("请选择移动的栏目",{icon: 2});
99
+                                return;
100
+                            }
101
+                            $.post('{:url("remove",["catid"=>$catid])}', { 'ids': id, 'tocatid': tocatid }, function(data) {
102
+                                if (data.code == 1) {
103
+                                    table.reload('currentTable');
104
+                                    layer.msg(data.msg,{icon: 1});
105
+                                    layer.close(index);
106
+                                } else {
107
+                                    layer.msg(data.msg,{icon: 2});
108
+                                }
109
+                            })
110
+                        },
111
+                        end: function(){
112
+                            $('#remove').hide();
113
+                        }
114
+                    });
115
+                } else {
116
+                    layer.msg("请选择需要移动的数据",{icon: 2});
117
+                }
118
+            });
119
+
120
+        });
121
+</script>

+ 123
- 0
application/admin/view/cms/cms/list/catid_18.html View File

@@ -0,0 +1,123 @@
1
+
2
+<script>
3
+    layui.use(['yzn','table', 'yznTable'], function() {
4
+        var table = layui.table,
5
+            $ = layui.$,
6
+            form = layui.form,
7
+            table = layui.table,
8
+            yzn = layui.yzn,
9
+            yznTable = layui.yznTable;
10
+
11
+        var init = {
12
+            table_elem: '#currentTable',
13
+            table_render_id: 'currentTable',
14
+            add_url: "{:url('add',['catid'=>$catid])}",
15
+            delete_url: "{:url('del',['catid'=>$catid])}",
16
+            modify_url: '{:url("listorder",["catid"=>$catid])}',
17
+        };
18
+
19
+        yznTable.render({
20
+            init: init,
21
+            toolbar: ['refresh',
22
+                [{
23
+                    text: '添加',
24
+                    url: init.add_url,
25
+                    method: 'open',
26
+                    auth: 'add',
27
+                    icon: 'iconfont icon-add',
28
+                    class: 'layui-btn layui-btn-normal layui-btn-sm btn-add',
29
+                    extend: 'data-full="true"',
30
+                }], 'delete',
31
+                [{
32
+                    html: '<button class="layui-btn layui-btn-sm layui-btn-normal move"><i class="iconfont icon-yidong"></i>&nbsp;批量移动</button> ',
33
+                    auth: 'remove',
34
+                }],
35
+                [{
36
+                    html: '<button class="layui-btn layui-btn-warm layui-btn-sm" data-table="currentTable" data-open="{:url("recycle",["catid"=>$catid])}"><i class="iconfont icon-recycle-line"></i>&nbsp;回收站</button>',
37
+                    auth: 'recycle',
38
+                }],
39
+            ],
40
+            url: '{:url("classlist",["catid"=>$catid])}',
41
+            cols: [
42
+                [
43
+                    { type: 'checkbox', fixed: 'left' },
44
+                    { field: 'listorder', width: 70, title: '排序', edit: 'text',search:false },
45
+                    { field: 'id', width: 60, title: 'ID' },
46
+                    { field: 'gzxh', width: 60, title: '规则' },
47
+                    { field: 'title', align: "left", title: '标题', templet: '#title', searchOp: 'like' },
48
+                    { field: 'is_use', width: 100, align: "center", title: '匹配', templet: '#is_useTpl', unresize: true, selectList: { 0: '非法', 1: '合法' } },
49
+                    { field: 'desc', align: "left", title: '匹配结果', templet: '#desc', searchOp: 'like' },
50
+                    { field: 'flag', width: 100, title: '属性',hide: true, selectList: { 1: '置顶', 2: '头条', 3: '特荐', 4: '推荐', 5: '热点', 6: '幻灯' }, searchOp: 'FIND_IN_SET' },
51
+                    //{ field: 'thumb', width: 100, title: '图片', search: false, templet: yznTable.formatter.image },
52
+                    //{ field: 'hits', width: 80, title: '点击量',search: 'between',searchTip:'点击量' },
53
+                    { field: 'update_time', width: 160, title: '更新时间', search: 'range' },
54
+                    //{ field: 'username', width: 80, title: '发布人', templet: '#username' },
55
+                    { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.formatter.url, search: false },
56
+                    { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
57
+                    //{ field: 'diqu', width: 100, align: "center", title: '区域', templet: '#areaTpl', unresize: true, selectList: {"1":"广东","30":"福建","6872":"陕西","6791":"西藏","6645":"云南","6344":"四川","6303":"重庆","6003":"海南","5879":"广西","5742":"湖南","5625":"湖北","5448":"河南","5179":"江西","5056":"安徽","4833":"江苏","4813":"上海","4667":"黑龙江","4589":"吉林","4474":"辽宁","4228":"山西","4042":"河北","4023":"天津","4003":"浙江","6547":"贵州","4359":"内蒙古","4004":"北京","6990":"甘肃","7092":"青海","7144":"宁夏","7171":"新疆","10000":"主站"} },
58
+
59
+
60
+                    { fixed: 'right', width: 90, title: '操作', toolbar: '#barTool' }
61
+                ]
62
+            ],
63
+            page: {}
64
+        });
65
+
66
+        yznTable.bindevent();
67
+
68
+        $('body').on('click', '.btn-add', function() {
69
+            var url = $(this).attr('data-open');
70
+            {if $cmsConfig['doc_edit_mode'] == 0}
71
+            yzn.open('添加', url,'100%','100%');
72
+            {else}
73
+            window.top.layui.admin.addTab('cms_add','添加',url)
74
+            {/if}
75
+                return false;
76
+            });
77
+
78
+
79
+            $('body').on('click', '.move', function() {
80
+                var checkStatus = table.checkStatus('currentTable'),
81
+
82
+                    ids = [],
83
+                    id = tag = '';
84
+                var data = checkStatus.data;
85
+                if (data.length > 0) {
86
+                    for (let i in data) {
87
+                        id += tag + data[i].id;
88
+                        tag = '|';
89
+                        //ids.push(data[i].id);
90
+                    }
91
+                    layer.open({
92
+                        title: '批量移动',
93
+                        type: 1,
94
+                        content: $('#remove'),
95
+                        area: ['300px', '250px'],
96
+                        btn: ['移动'],
97
+                        yes: function(index, layero) {
98
+                            var tocatid = $("select[name='remove']").val();
99
+                            if (tocatid == 0) {
100
+                                layer.msg("请选择移动的栏目",{icon: 2});
101
+                                return;
102
+                            }
103
+                            $.post('{:url("remove",["catid"=>$catid])}', { 'ids': id, 'tocatid': tocatid }, function(data) {
104
+                                if (data.code == 1) {
105
+                                    table.reload('currentTable');
106
+                                    layer.msg(data.msg,{icon: 1});
107
+                                    layer.close(index);
108
+                                } else {
109
+                                    layer.msg(data.msg,{icon: 2});
110
+                                }
111
+                            })
112
+                        },
113
+                        end: function(){
114
+                            $('#remove').hide();
115
+                        }
116
+                    });
117
+                } else {
118
+                    layer.msg("请选择需要移动的数据",{icon: 2});
119
+                }
120
+            });
121
+
122
+        });
123
+</script>

+ 120
- 0
application/admin/view/cms/cms/list/default.html View File

@@ -0,0 +1,120 @@
1
+
2
+<script>
3
+    layui.use(['yzn','table', 'yznTable'], function() {
4
+        var table = layui.table,
5
+            $ = layui.$,
6
+            form = layui.form,
7
+            table = layui.table,
8
+            yzn = layui.yzn,
9
+            yznTable = layui.yznTable;
10
+
11
+        var init = {
12
+            table_elem: '#currentTable',
13
+            table_render_id: 'currentTable',
14
+            add_url: "{:url('add',['catid'=>$catid])}",
15
+            delete_url: "{:url('del',['catid'=>$catid])}",
16
+            modify_url: '{:url("listorder",["catid"=>$catid])}',
17
+        };
18
+
19
+        yznTable.render({
20
+            init: init,
21
+            toolbar: ['refresh',
22
+                [{
23
+                    text: '添加',
24
+                    url: init.add_url,
25
+                    method: 'open',
26
+                    auth: 'add',
27
+                    icon: 'iconfont icon-add',
28
+                    class: 'layui-btn layui-btn-normal layui-btn-sm btn-add',
29
+                    extend: 'data-full="true"',
30
+                }], 'delete',
31
+                [{
32
+                    html: '<button class="layui-btn layui-btn-sm layui-btn-normal move"><i class="iconfont icon-yidong"></i>&nbsp;批量移动</button> ',
33
+                    auth: 'remove',
34
+                }],
35
+                [{
36
+                    html: '<button class="layui-btn layui-btn-warm layui-btn-sm" data-table="currentTable" data-open="{:url("recycle",["catid"=>$catid])}"><i class="iconfont icon-recycle-line"></i>&nbsp;回收站</button>',
37
+                    auth: 'recycle',
38
+                }],
39
+            ],
40
+            url: '{:url("classlist",["catid"=>$catid])}',
41
+            cols: [
42
+                [
43
+                    { type: 'checkbox', fixed: 'left' },
44
+                    { field: 'listorder', width: 70, title: '排序', edit: 'text',search:false },
45
+                    { field: 'id', width: 60, title: 'ID' },
46
+                    { field: 'title', align: "left", title: '标题', templet: '#title', searchOp: 'like' },
47
+                    { field: 'flag', width: 100, title: '属性',hide: true, selectList: { 1: '置顶', 2: '头条', 3: '特荐', 4: '推荐', 5: '热点', 6: '幻灯' }, searchOp: 'FIND_IN_SET' },
48
+                    { field: 'thumb', width: 100, title: '图片', search: false, templet: yznTable.formatter.image },
49
+                    { field: 'hits', width: 80, title: '点击量',search: 'between',searchTip:'点击量' },
50
+                    { field: 'update_time', width: 160, title: '更新时间', search: 'range' },
51
+                    { field: 'username', width: 80, title: '发布人', templet: '#username' },
52
+                    { field: 'url', width: 60, align: "center", title: 'URL', templet: yznTable.formatter.url, search: false },
53
+                    { field: 'status', width: 100, align: "center", title: '状态', templet: '#statusTpl', unresize: true, selectList: { 0: '待审核', 1: '通过' } },
54
+                    { field: 'diqu', width: 100, align: "center", title: '区域', templet: '#areaTpl', unresize: true, selectList: {"1":"广东","30":"福建","6872":"陕西","6791":"西藏","6645":"云南","6344":"四川","6303":"重庆","6003":"海南","5879":"广西","5742":"湖南","5625":"湖北","5448":"河南","5179":"江西","5056":"安徽","4833":"江苏","4813":"上海","4667":"黑龙江","4589":"吉林","4474":"辽宁","4228":"山西","4042":"河北","4023":"天津","4003":"浙江","6547":"贵州","4359":"内蒙古","4004":"北京","6990":"甘肃","7092":"青海","7144":"宁夏","7171":"新疆","10000":"主站"} },
55
+
56
+
57
+                    { fixed: 'right', width: 90, title: '操作', toolbar: '#barTool' }
58
+                ]
59
+            ],
60
+            page: {}
61
+        });
62
+
63
+        yznTable.bindevent();
64
+
65
+        $('body').on('click', '.btn-add', function() {
66
+            var url = $(this).attr('data-open');
67
+            {if $cmsConfig['doc_edit_mode'] == 0}
68
+            yzn.open('添加', url,'100%','100%');
69
+            {else}
70
+            window.top.layui.admin.addTab('cms_add','添加',url)
71
+            {/if}
72
+                return false;
73
+            });
74
+
75
+
76
+            $('body').on('click', '.move', function() {
77
+                var checkStatus = table.checkStatus('currentTable'),
78
+
79
+                    ids = [],
80
+                    id = tag = '';
81
+                var data = checkStatus.data;
82
+                if (data.length > 0) {
83
+                    for (let i in data) {
84
+                        id += tag + data[i].id;
85
+                        tag = '|';
86
+                        //ids.push(data[i].id);
87
+                    }
88
+                    layer.open({
89
+                        title: '批量移动',
90
+                        type: 1,
91
+                        content: $('#remove'),
92
+                        area: ['300px', '250px'],
93
+                        btn: ['移动'],
94
+                        yes: function(index, layero) {
95
+                            var tocatid = $("select[name='remove']").val();
96
+                            if (tocatid == 0) {
97
+                                layer.msg("请选择移动的栏目",{icon: 2});
98
+                                return;
99
+                            }
100
+                            $.post('{:url("remove",["catid"=>$catid])}', { 'ids': id, 'tocatid': tocatid }, function(data) {
101
+                                if (data.code == 1) {
102
+                                    table.reload('currentTable');
103
+                                    layer.msg(data.msg,{icon: 1});
104
+                                    layer.close(index);
105
+                                } else {
106
+                                    layer.msg(data.msg,{icon: 2});
107
+                                }
108
+                            })
109
+                        },
110
+                        end: function(){
111
+                            $('#remove').hide();
112
+                        }
113
+                    });
114
+                } else {
115
+                    layer.msg("请选择需要移动的数据",{icon: 2});
116
+                }
117
+            });
118
+
119
+        });
120
+</script>

+ 56
- 0
application/admin/view/cms/cms/script/catid_17.html View File

@@ -0,0 +1,56 @@
1
+<script type="text/html" id="barTool">
2
+    {if $cmsConfig['doc_edit_mode'] == 1}
3
+    <a class="layui-btn layui-btn-xs btn-addtabs{:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-menu-id="{$catid}-{{ d.id }}" data-url='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
4
+    {else}
5
+    <a class="layui-btn layui-btn-xs {:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
6
+    {/if}
7
+    <a href='{:url("del",["catid"=>$catid])}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('cms.cms/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>
8
+</script>
9
+<script type="text/html" id="title">
10
+    {{# if(d.flag.indexOf("1")!==-1){ }}
11
+    <span class="text-danger">[置顶]</span>
12
+    {{#  } }}
13
+    {{# if(d.flag.indexOf("2")!==-1){ }}
14
+    <span class="text-danger">[头条]</span>
15
+    {{#  } }}
16
+    {{# if(d.flag.indexOf("3")!==-1){ }}
17
+    <span class="text-danger">[特荐]</span>
18
+    {{#  } }}
19
+    {{# if(d.flag.indexOf("4")!==-1){ }}
20
+    <span class="text-danger">[推荐]</span>
21
+    {{#  } }}
22
+    {{# if(d.flag.indexOf("5")!==-1){ }}
23
+    <span class="text-danger">[热点]</span>
24
+    {{#  } }}
25
+    {{# if(d.flag.indexOf("6")!==-1){ }}
26
+    <span class="text-danger">[幻灯]</span>
27
+    {{#  } }}
28
+    {{# if(d.thumb){ }}
29
+    <span class="text-success">[有图]</span>
30
+    {{#  } }}
31
+    <a  data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true">{{ d.title }}</a>
32
+</script>
33
+
34
+<script type="text/html" id="gzxh">
35
+    {{# if(d.gzxh == 0){ }}
36
+    <span class="text-danger">[默认]</span>
37
+    {{#  } else { }}
38
+    <span class="text-danger">[规则_{{ d.gzxh }}]</span>
39
+    {{#  } }}
40
+</script>
41
+
42
+
43
+<script type="text/html" id="username">
44
+    {{# if(d.sysadd==1){ }}
45
+    {{ d.username }}
46
+    {{#  } else { }}
47
+    <span class="text-danger">{{ d.username }}</span>
48
+    {{#  } }}
49
+</script>
50
+<script type="text/html" id="statusTpl">
51
+    <input type="checkbox" name="status" data-href='{:url("setstate",["catid"=>$catid])}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="通过|待审核" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
52
+</script>
53
+
54
+<script type="text/html" id="areaTpl">
55
+    {{ d.diqu }}
56
+</script>

+ 51
- 0
application/admin/view/cms/cms/script/catid_18.html View File

@@ -0,0 +1,51 @@
1
+<script type="text/html" id="barTool">
2
+    {if $cmsConfig['doc_edit_mode'] == 1}
3
+    <a class="layui-btn layui-btn-xs btn-addtabs{:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-menu-id="{$catid}-{{ d.id }}" data-url='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
4
+    {else}
5
+    <a class="layui-btn layui-btn-xs {:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
6
+    {/if}
7
+    <a href='{:url("del",["catid"=>$catid])}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('cms.cms/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>
8
+</script>
9
+<script type="text/html" id="title">
10
+    {{# if(d.flag.indexOf("1")!==-1){ }}
11
+    <span class="text-danger">[置顶]</span>
12
+    {{#  } }}
13
+    {{# if(d.flag.indexOf("2")!==-1){ }}
14
+    <span class="text-danger">[头条]</span>
15
+    {{#  } }}
16
+    {{# if(d.flag.indexOf("3")!==-1){ }}
17
+    <span class="text-danger">[特荐]</span>
18
+    {{#  } }}
19
+    {{# if(d.flag.indexOf("4")!==-1){ }}
20
+    <span class="text-danger">[推荐]</span>
21
+    {{#  } }}
22
+    {{# if(d.flag.indexOf("5")!==-1){ }}
23
+    <span class="text-danger">[热点]</span>
24
+    {{#  } }}
25
+    {{# if(d.flag.indexOf("6")!==-1){ }}
26
+    <span class="text-danger">[幻灯]</span>
27
+    {{#  } }}
28
+    {{# if(d.thumb){ }}
29
+    <span class="text-success">[有图]</span>
30
+    {{#  } }}
31
+    <a  data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true">{{ d.title }}</a>
32
+</script>
33
+<script type="text/html" id="username">
34
+    {{# if(d.sysadd==1){ }}
35
+    {{ d.username }}
36
+    {{#  } else { }}
37
+    <span class="text-danger">{{ d.username }}</span>
38
+    {{#  } }}
39
+</script>
40
+<script type="text/html" id="statusTpl">
41
+    <input type="checkbox" name="status" data-href='{:url("setstate",["catid"=>$catid])}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="通过|待审核" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
42
+</script>
43
+
44
+<script type="text/html" id="is_useTpl">
45
+    <input type="checkbox" name="is_use"  lay-skin="switch" lay-text="合法|不匹配" lay-filter="" {{ d.is_use==1 ? 'checked' : '' }}>
46
+</script>
47
+
48
+
49
+<script type="text/html" id="areaTpl">
50
+    {{ d.diqu }}
51
+</script>

+ 46
- 0
application/admin/view/cms/cms/script/default.html View File

@@ -0,0 +1,46 @@
1
+<script type="text/html" id="barTool">
2
+    {if $cmsConfig['doc_edit_mode'] == 1}
3
+    <a class="layui-btn layui-btn-xs btn-addtabs{:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-menu-id="{$catid}-{{ d.id }}" data-url='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
4
+    {else}
5
+    <a class="layui-btn layui-btn-xs {:$auth->check('cms.cms/edit')?'':'layui-hide'}" data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true"><i class='iconfont icon-brush_fill'></i></a>
6
+    {/if}
7
+    <a href='{:url("del",["catid"=>$catid])}?id={{ d.id }}' class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('cms.cms/del')?'':'layui-hide'}"><i class='iconfont icon-trash_fill'></i></a>
8
+</script>
9
+<script type="text/html" id="title">
10
+    {{# if(d.flag.indexOf("1")!==-1){ }}
11
+    <span class="text-danger">[置顶]</span>
12
+    {{#  } }}
13
+    {{# if(d.flag.indexOf("2")!==-1){ }}
14
+    <span class="text-danger">[头条]</span>
15
+    {{#  } }}
16
+    {{# if(d.flag.indexOf("3")!==-1){ }}
17
+    <span class="text-danger">[特荐]</span>
18
+    {{#  } }}
19
+    {{# if(d.flag.indexOf("4")!==-1){ }}
20
+    <span class="text-danger">[推荐]</span>
21
+    {{#  } }}
22
+    {{# if(d.flag.indexOf("5")!==-1){ }}
23
+    <span class="text-danger">[热点]</span>
24
+    {{#  } }}
25
+    {{# if(d.flag.indexOf("6")!==-1){ }}
26
+    <span class="text-danger">[幻灯]</span>
27
+    {{#  } }}
28
+    {{# if(d.thumb){ }}
29
+    <span class="text-success">[有图]</span>
30
+    {{#  } }}
31
+    <a  data-open='{:url("edit",["catid"=>$catid])}?id={{ d.id }}' data-title="编辑内容" data-full="true">{{ d.title }}</a>
32
+</script>
33
+<script type="text/html" id="username">
34
+    {{# if(d.sysadd==1){ }}
35
+    {{ d.username }}
36
+    {{#  } else { }}
37
+    <span class="text-danger">{{ d.username }}</span>
38
+    {{#  } }}
39
+</script>
40
+<script type="text/html" id="statusTpl">
41
+    <input type="checkbox" name="status" data-href='{:url("setstate",["catid"=>$catid])}?id={{d.id}}' value="{{d.id}}" lay-skin="switch" lay-text="通过|待审核" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
42
+</script>
43
+
44
+<script type="text/html" id="areaTpl">
45
+    {{ d.diqu }}
46
+</script>

+ 26
- 0
application/api/behavior/CORS.php View File

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+
4
+namespace app\api\behavior;
5
+
6
+use think\facade\Session;
7
+use think\Request;
8
+
9
+/**
10
+ * CORS跨域
11
+ * Class CORS
12
+ * @package app\api\behavior
13
+ */
14
+class CORS
15
+{
16
+    public function run()
17
+    {// 响应头设置 我们就是通过设置header来跨域的 这就主要代码了 定义行为只是为了前台每次请求都能走这段代码
18
+        header('Access-Control-Allow-Origin:*');
19
+        header('Access-Control-Allow-Methods:*');
20
+        header('Access-Control-Allow-Headers:*');
21
+        header('Access-Control-Allow-Credentials:false');
22
+        if (request()->isOptions()) {
23
+            sendResponse('',200,'ok');
24
+        }
25
+    }
26
+}

+ 7
- 0
application/api/config/rule.php View File

@@ -0,0 +1,7 @@
1
+<?php
2
+
3
+
4
+return [
5
+    'a1' => '',//批次
6
+    'b1' => []
7
+];

+ 457
- 0
application/api/controller/Ai.php View File

@@ -0,0 +1,457 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | Yzncms [ 御宅男工作室 ]
4
+// +----------------------------------------------------------------------
5
+// | Copyright (c) 2018 http://yzncms.com All rights reserved.
6
+// +----------------------------------------------------------------------
7
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
+// +----------------------------------------------------------------------
9
+// | fastadmin: https://www.fastadmin.net/
10
+// +----------------------------------------------------------------------
11
+
12
+// +----------------------------------------------------------------------
13
+// | 邮箱验证码接口
14
+// +----------------------------------------------------------------------
15
+namespace app\api\controller;
16
+
17
+use app\member\controller\MemberApi;
18
+use think\Db;
19
+
20
+/**
21
+ * @title 邮箱验证码接口
22
+ * @controller api\controller\Ems
23
+ * @group base
24
+ */
25
+class Ai extends MemberApi
26
+{
27
+
28
+    protected $noNeedLogin = ['login', 'register','uploadCsv','uploadCsvFrom','exportCsv'];
29
+    protected $noNeedRight = [];
30
+
31
+    //初始化
32
+    protected function initialize()
33
+    {
34
+        //yzncms本身已经做了跨域处理 妈的
35
+        //$this->getHook();
36
+        parent::initialize();
37
+
38
+    }
39
+
40
+    public static function getHook()
41
+    {
42
+        //需要使用静态方法Facade 不然会报错
43
+        \think\Facade\Hook::listen('response_send');
44
+    }
45
+    /*
46
+     *  业务控制器
47
+     * 上传csv关键词数据
48
+     * https://console.zx2049.com/api/ai/uploadCsv?file=20240504/eebcb4ca6a8a69fdd9e0f60c16b55746.csv
49
+     */
50
+    public function uploadCsv(){
51
+
52
+        //测试
53
+        $url = request()->get('file',0);
54
+        if($url !== 0){
55
+            $this->csvHandle('./uploads/'.$url);
56
+            return json([]);
57
+        }
58
+
59
+        $file = request()->file('file'); //$file = $_FILES['file'];
60
+        $info = $file->move( './uploads');
61
+        if($info){
62
+            // 成功上传后 获取上传信息
63
+            // 输出 jpg
64
+            //$url = $info->getExtension();
65
+            // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
66
+            $url = $info->getSaveName();
67
+            // 输出 42a79759f284b767dfcb2a0197904287.jpg
68
+            //echo $info->getFilename();
69
+            $data = ['code' => 0, 'msg' => '文件上传成功', 'data' =>['src'=>$url]];
70
+        }else{
71
+            // 上传失败获取错误信息
72
+            $info = $file->getError();
73
+            $data = ['code' => 1, 'msg' => '文件上传失败', 'data' =>$info];
74
+        }
75
+        return json($data);
76
+    }
77
+
78
+
79
+    /*
80
+     * 业务控制器
81
+     * 处理表单
82
+     */
83
+    public function uploadCsvFrom(){
84
+
85
+        $post = request()->post();
86
+
87
+        /*
88
+         * rule:
89
+        0
90
+        title:
91
+        建筑职称
92
+        file:
93
+        url:
94
+        20240505/2aff80b14c861480183278bbc9442f56.csv
95
+         */
96
+
97
+        //判断关键词是否存在
98
+        $one = Db::name('options')->where('title','=',$post['title'])->where('status','=',1)->find();
99
+        if(empty($one)){
100
+            $data = ['code' => 1, 'msg' => '关键词不存在', 'data' => []];
101
+            return json($data);
102
+        }
103
+        if(!empty($post['url'])){
104
+            $this->csvHandle('./uploads/'.$post['url'],$post['rule'],$post['title']);
105
+            $data = ['code' => 0, 'msg' => '提交成功', 'data' =>$post];
106
+        }else{
107
+            $data = ['code' => 1, 'msg' => '提交失败', 'data' => []];
108
+        }
109
+        return json($data);
110
+    }
111
+
112
+
113
+    /*
114
+     * 逻辑控制器
115
+     * 规则的指令集和创意 如果为空 调用全局的即可 同样优先调用自身规则
116
+     */
117
+    public function csvHandle($url,$rule,$title){
118
+        // 读取CSV文件
119
+        $filename = $url;
120
+        if (file_exists($filename)) {
121
+            $file = fopen($filename, 'r');
122
+
123
+            //任务批次
124
+            $task_no = date('YmdHis',time()).'-'.rand(1,10000);
125
+            $pid = time(); //不考虑并发提交多次间隔也是秒级
126
+            $num = 1;
127
+            $log_content = '';
128
+            $log_content_error = '';
129
+            $s_num = 0;
130
+            $f_num = 0;
131
+            while (($line = fgetcsv($file)) !== FALSE) {
132
+                // $line是一个数组,包含CSV的一行数据
133
+                //print_r($line);
134
+                if($num === 1){
135
+                    $row = $line;
136
+                }else{
137
+                    if(!empty($line[0])) {
138
+                        //关键词步骤省略 需要去站长之家搜索并导出 这个步骤由人工操作
139
+                        //判断是否存在短标题 重复性检测
140
+                        //相同规则 短标题只能存在一个
141
+                        $one = Db::name('cms_zl')
142
+                            ->where('title', '=', $line[0])
143
+                            ->where('catid', '=', 18)
144
+                            ->where('gzxh', '=', $rule)
145
+                            ->find();
146
+                        if (empty($one)) {
147
+                            //过滤标题是否合法的函数 这个可以用定时任务处理
148
+                            [$is_use, $desc, $rule_id] = $this->titleHandle($line[0], $rule, $title);
149
+                            //构建详情
150
+                            $html = '';
151
+                            for ($i = 1; $i < 10; $i++) {
152
+                                $html .= $row[$i] . ':' . $line[$i] . '<br/>';
153
+                            }
154
+                            $data = [
155
+                                'catid' => 18, //短标题
156
+                                'title' => $line[0], //短标题
157
+                                'content' => $html,
158
+                                'create_time' => time(),
159
+                                'update_time' => time(),
160
+                                'status' => 0, //默认禁用状态 定时手动开启 自动化再读取即可
161
+                                'pid' => $pid, //关联日志的aid,可查询到规则序号 主词 文件地址 执行情况
162
+                                'ptlx' => 0,
163
+                                'is_use' => $is_use, //是否合法
164
+                                'desc' => $desc, //非法原因 或者 合法匹配结果
165
+                                'gzxh' => $rule,
166
+                                'is_use_id' => (int)$rule_id, //写入具体规则id 可查询到对应规则是什么 判断是否合法
167
+                            ];
168
+                            //dump($data);
169
+                            //插入记录
170
+                            $doc_id = Db::name('cms_zl')->insertGetId($data);
171
+                            //写入日志
172
+                            $log_content .= '指令id-' . $doc_id . '-' . json_encode($line, JSON_UNESCAPED_UNICODE) . '<br/>';
173
+                            $s_num++;
174
+                        } else {
175
+                            //写日志
176
+                            $log_content_error .= '<p>短标题-' . $line[0] . '-已存在-指令短标题id:' . $one['id'] . '</p>';
177
+                            $f_num++;
178
+                        }
179
+                    }
180
+                }
181
+                $num++;
182
+            }
183
+
184
+            //每次操作 1-2条 日志记录
185
+            if(!empty($log_content)){
186
+                Db::name('log')->insert([
187
+                    'catid' => 27,
188
+                    'title' => '批次'.$task_no.'成功导入处理-'.$s_num.'条数据',
189
+                    'keywords' => $title, //主词
190
+                    'description' => $filename,//对应文件地址
191
+                    'create_time' => time(),
192
+                    'update_time' => time(),
193
+                    'status' => 1,
194
+                    'site_id'=> 1,
195
+                    'cid' => (int)$rule, //规则序号
196
+                    'aid' => $pid, //对应记录id
197
+                    'content' => '<p>'.$log_content.'</p>',
198
+                ]);
199
+            }
200
+
201
+            if(!empty($log_content_error)){
202
+                Db::name('log')->insert([
203
+                    'catid' => 27,
204
+                    'title' => '批次'.$task_no.'导入处理已存在-'.$f_num.'条数据',
205
+                    'keywords' => $title, //主词
206
+                    'description' => $filename,//对应文件地址
207
+                    'create_time' => time(),
208
+                    'update_time' => time(),
209
+                    'status' => 1,
210
+                    'site_id'=> 1,
211
+                    'cid' => (int)$rule, //规则序号
212
+                    'aid' => $pid, //对应记录id
213
+                    'content' => '<p>'.$log_content_error.'</p>',
214
+                ]);
215
+            }
216
+
217
+            fclose($file);
218
+        }
219
+
220
+        /*// 写入CSV文件
221
+        $data = [
222
+            ['Name', 'Age', 'Email'],
223
+            ['Alice', 25, 'alice@example.com'],
224
+            ['Bob', 30, 'bob@example.com']
225
+        ];
226
+
227
+        $filename = 'output.csv';
228
+        $file = fopen($filename, 'w');
229
+        foreach ($data as $row) {
230
+            fputcsv($file, $row);
231
+        }
232
+        fclose($file);*/
233
+    }
234
+
235
+    /*
236
+     * 模型控制器 操作数据
237
+     */
238
+
239
+    /*
240
+     * 处理函数
241
+     * $title 主词
242
+     */
243
+    public function titleHandle($line,$rule,$title){
244
+        //规则1
245
+        $desc = '';
246
+
247
+        //是否完全匹配主词
248
+        if (strpos($line, $title) !== false) {
249
+            //包含主词
250
+        }else{
251
+            return [0,'短标题不包含主词['.$title.']',0];
252
+        }
253
+
254
+        //1.查询是否存在主词规则
255
+        $one = Db::name('cms_zl')
256
+            ->where('catid','=',17)
257
+            ->where('title','=',$title) //只能一条 已做标题重复校验
258
+            ->where('is_qj','=',0) //非全局
259
+            ->where('zllx','=',1) //指令类型是 主词
260
+            ->where('gzxh','=',$rule)
261
+            ->where('status','=',1) //多条需要控制开关
262
+            ->order('id asc') //可能添加多条 以第一条为主 理论每个规则只添加一条
263
+            ->find();
264
+        //2.查询全局主词规则
265
+        if(empty($one)){
266
+            $one = Db::name('cms_zl')
267
+                ->where('catid','=',17)
268
+                ->where('title','=','全局-主词类型') //只能一条 已做标题重复校验
269
+                ->where('is_qj','=',1) //是全局
270
+                ->where('zllx','=',1) //指令类型是 主词
271
+                ->where('gzxh','=',$rule)
272
+                ->where('status','=',1) //多条需要控制开关
273
+                ->order('id asc') //可能添加多条 以第一条为主 理论每个规则只添加一条
274
+                ->find();
275
+        }
276
+        //3.查询全局规则
277
+        if(empty($one)){
278
+            $one = Db::name('cms_zl')
279
+                ->where('catid','=',17)
280
+                ->where('title','=','全局-非主非副') //只能一条 已做标题重复校验
281
+                ->where('is_qj','=',1) //是全局
282
+                ->where('zllx','=',0) //指令类型是 非主非副
283
+                ->where('gzxh','=',$rule)
284
+                ->where('status','=',1) //多条需要控制开关
285
+                ->order('id asc') //可能添加多条 以第一条为主 理论每个规则只添加一条
286
+                ->find();
287
+        }
288
+        if(empty($one)){
289
+            return [0,'不存在全局通用规则,全局主词规则,当前主词规则',0];
290
+        }
291
+
292
+        //4.获取到全局或主词的副词
293
+        $two = [];
294
+        if(empty($one['fclb']) || (string)$one['fclb'] === '0'){
295
+            //不存在副词规则
296
+            $desc .= '不存在副词规则-|-';
297
+        }else{
298
+            //存在副词规则
299
+            $one['fclb'] = $one['fclb'].',';
300
+            $fclb = explode(',',$one['fclb']);
301
+            $line_sor = str_replace($title, "", $line); //短标题去除主词
302
+            $is_bh = 0;
303
+            $fc = '';
304
+            $fc_num = 0;
305
+            foreach ($fclb as $k => $v) {
306
+                //该判断 主词和副词 不一定是连在一起的
307
+                if(!empty($v)) {
308
+                    if (strpos($line_sor, $v) !== false) {
309
+                        //包含
310
+                        $is_bh = 1;
311
+                        $fc = $v;
312
+                        //break; //跳出 目前只匹配一个 存在多个不做处理 以第一个为主
313
+                        $fc_num++;
314
+                    }
315
+                }
316
+            }
317
+            //存在多个副词 不合理
318
+            if($fc_num > 1){
319
+                return [0,'存在多个副词,不合法',$one['id']];
320
+            }
321
+            //5.查询是否存在副词
322
+            if($is_bh === 1){
323
+                //6.查询主词+副词是否存在规则
324
+                $two = Db::name('cms_zl')
325
+                    ->where('catid','=',17)
326
+                    ->where('title','=',$title.$fc) //查询设置 按照主词+副词 格式查询 //只能一条 已做标题重复校验
327
+                    ->where('is_qj','=',0) //非全局
328
+                    ->where('zllx','=',2) //指令类型是 副词
329
+                    ->where('gzxh','=',$rule)
330
+                    ->where('status','=',1) //多条需要控制开关
331
+                    ->order('id asc') //可能添加多条 以第一条为主 理论每个规则只添加一条
332
+                    ->find();
333
+                //7.查询副词通用全局规则
334
+                if(empty($two)){
335
+                    $two = Db::name('cms_zl')
336
+                        ->where('catid','=',17)
337
+                        ->where('title','=','全局-副词类型') //查询设置 按照主词+副词 格式查询 //只能一条 已做标题重复校验
338
+                        ->where('is_qj','=',1) //非全局
339
+                        ->where('zllx','=',2) //指令类型是 副词
340
+                        ->where('gzxh','=',$rule)
341
+                        ->where('status','=',1) //多条需要控制开关
342
+                        ->order('id asc') //可能添加多条 以第一条为主 理论每个规则只添加一条
343
+                        ->find();
344
+                }
345
+            }else{
346
+                //短标题不包含副词
347
+                $desc .= '短标题不包含副词-|-';
348
+            }
349
+        }
350
+
351
+
352
+        //短标题的主词和副词 不一定是连在一起的
353
+        if(!empty($two)){
354
+            //存在副词规则 按照此规则执行
355
+            $data = $two;
356
+        }else{
357
+            //按照$one规则记录执行
358
+            $data = $one;
359
+        }
360
+
361
+        //8.判断是否合法 地区词
362
+        [$is_bh,$fc] = $this->isInRule($data['dqc'],$line);
363
+        if($is_bh > 0){
364
+            $desc .= '存在地区词'.$fc.',不合法-|-';
365
+            return [0,$desc,$data['id']];
366
+        }
367
+
368
+        //9.判断是否合法 分类词
369
+        [$is_bh,$fc] = $this->isInRule($data['flc'],$line);
370
+        if($is_bh > 0){
371
+            $desc .= '存在分类词'.$fc.',不合法-|-';
372
+            return [0,$desc,$data['id']];
373
+        }
374
+
375
+        //10.判断是否合法 时间词
376
+        [$is_bh,$fc] = $this->isInRule($data['sjc'],$line);
377
+        if($is_bh > 0){
378
+            $desc .= '存在时间词'.$fc.',不合法-|-';
379
+            return [0,$desc,$data['id']];
380
+        }
381
+
382
+        //11.判断是否合法 屏蔽词
383
+        [$is_bh,$fc] = $this->isInRule($data['pbc'],$line);
384
+        if($is_bh > 0){
385
+            $desc .= '存在屏蔽词'.$fc.',不合法-|-';
386
+            return [0,$desc,$data['id']];
387
+        }
388
+
389
+        //12.判断是否合法 同时存在触发词和并发词
390
+        [$is_bh1,$fc1] = $this->isInRule($data['cfc'],$line);
391
+        [$is_bh2,$fc2] = $this->isInRule($data['bfc'],$line);
392
+        if($is_bh1 > 0 && $is_bh2 > 0){
393
+            //同时存在
394
+            $desc .= '同时存在并发词['.$fc2.']和触发词['.$fc1.']合法';
395
+            return [1,$desc,$data['id']];
396
+        }else{
397
+            $desc .= '不同时存在并发词['.$fc2.']和触发词['.$fc1.'],不合法';
398
+            return [0,$desc,$data['id']];
399
+        }
400
+    }
401
+
402
+    /*
403
+     * 规则设定
404
+     */
405
+    public function setRule(){
406
+
407
+        //方案1: 定义config配置文件
408
+        //方案2: 直接代码写死
409
+        //方案3: 后台设置 -- 采用这个
410
+        $json = [
411
+            ''
412
+        ];
413
+    }
414
+
415
+    /*
416
+     * 函数 是否包含
417
+     */
418
+    public function isInRule($data,$str){
419
+        $data = $data.',';
420
+        $data = explode(',',$data);
421
+        $is_bh = 0;
422
+        $fc = '';
423
+        foreach ($data as $k => $v) {
424
+            //该判断 主词和副词 不一定是连在一起的
425
+            if(!empty($v)) {
426
+                if (strpos($str, $v) !== false) {
427
+                    //包含
428
+                    $is_bh = 1;
429
+                    $fc = $v;
430
+                    break; //跳出 目前只匹配一个 存在多个不做处理 以第一个为主
431
+                }
432
+            }
433
+        }
434
+        return [$is_bh,$fc];
435
+    }
436
+
437
+    /*
438
+     * 导出csv
439
+     * http://console.zx2049.com/api/ai/exportCsv
440
+     */
441
+    public function exportCsv(){
442
+
443
+        $list = Db::name('cms_zl')->field('id,title,desc')->where('catid','=',18)->select();
444
+/*        $data = [
445
+            ['Name', 'Age', 'Email'],
446
+            ['Alice', 25, 'alice@example.com'],
447
+            ['Bob', 30, 'bob@example.com']
448
+        ];*/
449
+
450
+        $filename = 'output.csv';
451
+        $file = fopen($filename, 'w');
452
+        foreach ($list as $row) {
453
+            fputcsv($file, $row);
454
+        }
455
+        fclose($file);
456
+    }
457
+}

+ 4
- 0
application/tags.php View File

@@ -27,4 +27,8 @@ return [
27 27
     'log_write'    => [],
28 28
     // 应用结束
29 29
     'app_end'      => [],
30
+    //响应
31
+    'response_send' => [
32
+        'app\\api\\behavior\\CORS'
33
+    ],
30 34
 ];

+ 1
- 1
config/app.php View File

@@ -172,7 +172,7 @@ return [
172 172
     //插件纯净模式,插件启用后是否删除插件目录的application、public和assets文件夹
173 173
     'addon_pure_mode'         => true,
174 174
     //允许跨域的域名,多个以,分隔
175
-    'cors_request_domain'     => 'localhost,127.0.0.1',
175
+    'cors_request_domain'     => 'localhost,127.0.0.1,workerman.dev.zx2049.com',
176 176
     //是否开启后台自动日志记录
177 177
     'auto_record_admin_log'   => true,
178 178
     //文件保存格式

+ 1140
- 0
public/output.csv
File diff suppressed because it is too large
View File


Loading…
Cancel
Save