mirror of https://gitee.com/zorlan/skycaiji
parent
281acc380f
commit
a4d3531d5d
@ -0,0 +1,13 @@
|
|||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
|
||||||
|
#dataapi_list .status{color:green;}
|
||||||
|
#dataapi_list .status-close{color:red;}
|
||||||
|
|
||||||
|
#config_conds tr>th:first-child,#config_conds tr>td:first-child{padding-left:15px;}
|
||||||
|
#config_conds thead th{padding-top:13px;padding-bottom:13px;}
|
||||||
|
#config_conds tbody tr>td:last-child{vertical-align:middle;font-size:14px;}
|
||||||
|
#config_conds .config-cond-move{font-size:12px;}
|
||||||
|
#config_conds .config-cond-dlt{margin-left:2px;margin-right:2px;}
|
||||||
|
#config_conds .config-cond-sub td:FIRST-CHILD{padding-left:50px; background:url('../images/bg_column.gif') no-repeat 15px 15px;}
|
||||||
|
#config_conds .config-cond-sub .config-cond-add{display:none;}
|
@ -0,0 +1,51 @@
|
|||||||
|
@CHARSET "UTF-8";
|
||||||
|
/*数据集*/
|
||||||
|
#dataset_list .fields{
|
||||||
|
border:0;padding:0px 5px;height:20px;line-height:14px;font-size:12px;color:#555;background:#fff;
|
||||||
|
}
|
||||||
|
#dataset_db_list td .txt-big{height:100px!important;}
|
||||||
|
#dataset_db_list td{vertical-align:middle;}
|
||||||
|
#dataset_db_list td .form-control{
|
||||||
|
height: 30px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataset-db-list::-webkit-scrollbar{
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
}
|
||||||
|
.dataset-search::-webkit-scrollbar{
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
}
|
||||||
|
.dataset-db-list::-webkit-scrollbar-button,.dataset-search::-webkit-scrollbar-button{
|
||||||
|
background-color:#efefef;
|
||||||
|
}
|
||||||
|
.dataset-db-list::-webkit-scrollbar-track,.dataset-search::-webkit-scrollbar-track{
|
||||||
|
background:#efefef;
|
||||||
|
}
|
||||||
|
.dataset-db-list::-webkit-scrollbar-thumb,.dataset-search::-webkit-scrollbar-thumb{
|
||||||
|
background: #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dataset-search{width:100%;overflow-x:scroll;white-space:nowrap;padding-bottom:5px;padding-right:5px;}
|
||||||
|
|
||||||
|
#dataset_db_list input::placeholder,#dataset_db_list textarea::placeholder{color:#bbb!important;}
|
||||||
|
|
||||||
|
#dataset_fields tr>th:first-child,#dataset_fields tr>td:first-child{padding-left:15px;}
|
||||||
|
#dataset_fields thead th{padding-top:13px;padding-bottom:13px;}
|
||||||
|
|
||||||
|
|
||||||
|
.dataset-sep{
|
||||||
|
color: #999;
|
||||||
|
text-indent: -9999px;
|
||||||
|
display: inline-block;
|
||||||
|
width: 3px;
|
||||||
|
line-height: 12px;
|
||||||
|
margin-left: 2px;
|
||||||
|
border-left: 1px solid #aaa;
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
/*发布设置*/
|
||||||
|
#dataset_config table tr td{height:50px;vertical-align:middle!important;}
|
||||||
|
.dataset-field-txt>.input-group-addon{padding:0;}
|
||||||
|
.dataset-field-txt>.input-group-addon a.dropdown-toggle{border-color:#fff;padding:6px 12px;color:#666;}
|
||||||
|
.dataset-field-txt>.input-group-addon a.dropdown-toggle:hover{color:#000;}
|
||||||
|
.dataset-field-txt>.input-group-addon a.dropdown-toggle .caret{margin-top:-2px;}
|
||||||
|
|
||||||
|
.rele-db-error{margin-top:10px;color:red;font-weight:bold;}
|
||||||
|
.db-table-bind-params{padding:0;margin-bottom:0;border:0;}
|
||||||
|
.db-table-bind-params .table{margin-bottom:0;}
|
||||||
|
.db-table-bind-params .table tr>th:first-child,.db-table-bind-params .table tr>td:first-child{padding-left:15px;}
|
||||||
|
.db-table-bind-params .table thead th{padding-top:13px;padding-bottom:13px;}
|
||||||
|
.db-table-bind-op{width:auto;height:auto;display:inline;padding:0;}
|
||||||
|
.db-table-bind-where-tpl,.db-table-bind-query-tpl{display:none;}
|
||||||
|
|
||||||
|
.db-table-bind-where,.db-table-bind-query{display:none;}
|
||||||
|
.db-table-bind-data-seq{display:none;}
|
||||||
|
.db-table-bind-where,.db-table-bind-query,.db-table-bind-data{border:0;}
|
||||||
|
|
||||||
|
.db-table-bind-signs>.input-group-btn{position:static;}
|
||||||
|
|
||||||
|
.dm-db-charset li {padding:5px 15px;}
|
||||||
|
.dm-db-charset li.divider{padding:0;}
|
||||||
|
.dm-db-charset li span{padding:5px; cursor:pointer;color:#555;}
|
||||||
|
.dm-db-charset li span:hover{background:#eee;}
|
||||||
|
|
||||||
|
.toapi-param-table table,.toapi-header-table table{margin-bottom:0;}
|
||||||
|
.toapi-param-table td:first-child,.toapi-header-table td:first-child{width:200px;}
|
||||||
|
.toapi-param-table td:last-child,.toapi-header-table td:last-child{width:50px;text-align:center;}
|
||||||
|
|
||||||
|
#toapi_resp_module_help .help-block{display:none;margin:0;}
|
||||||
|
|
||||||
|
.toapi-app-table table tr td{height:50px;vertical-align:middle!important;}
|
||||||
|
.toapi-field-txt>.input-group-addon{padding:0;}
|
||||||
|
.toapi-field-txt>.input-group-addon a.dropdown-toggle{border-color:#fff;padding:6px 12px;color:#666;}
|
||||||
|
.toapi-field-txt>.input-group-addon a.dropdown-toggle:hover{color:#000;}
|
||||||
|
.toapi-field-txt>.input-group-addon a.dropdown-toggle .caret{margin-top:-2px;}
|
||||||
|
|
||||||
|
.toapi-field-slt select.form-control{min-width:120px!important;margin-right:-1px;min-height:34px;max-height:90px;}
|
||||||
|
.toapi-field-slt textarea.form-control{height:90px;}
|
||||||
|
.toapi-field-slt input.form-control,.toapi-field-slt textarea.form-control,.toapi-field-slt .input-group-addon{display:none!important;}
|
||||||
|
|
||||||
|
.toapi-field-slt-txt input.form-control,.toapi-field-slt-txt textarea.form-control,.toapi-field-slt-txt .input-group-addon{display:table-cell!important;}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
#cms_bind em{color:red;}
|
||||||
|
#cms_bind .box{margin-bottom:0;}
|
||||||
|
#cms_bind .table{margin-bottom:0;}
|
||||||
|
#toapi_app_params em{color:red;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@media (min-width: 1200px) {
|
||||||
|
/*table-responsive设置overflow:inherit;可正常显示dropdown-menu*/
|
||||||
|
.db-table-bind-where,.db-table-bind-query,.db-table-bind-data{overflow:inherit;}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1199px) {
|
||||||
|
/*dropdown-menu用fixed避免被table-responsive的overflow:hidden;影响*/
|
||||||
|
.db-table-bind-signs .dropdown-menu{padding:0;border:4px solid #ddd;border-radius:4px;background:transparent;position:fixed;left:10px;right:10px;bottom:10px;top:auto;max-height:80%;overflow-y:scroll;}
|
||||||
|
.db-table-bind-signs .dropdown-menu table{margin:0;}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 900px) {
|
||||||
|
#dataset_config .table tr td:FIRST-CHILD{width:200px;white-space:nowrap;padding-right:10px;}
|
||||||
|
.toapi-app-table .table tr td:FIRST-CHILD{width:200px;white-space:nowrap;padding-right:10px;}
|
||||||
|
#cms_bind .table tr td:FIRST-CHILD{width:200px;white-space:nowrap;padding-right:10px;}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 550px){
|
||||||
|
.mobile-input-group{width:100%;}
|
||||||
|
.mobile-input-group>.input-group-addon{display:table-caption;width:100%;background:#fafafa;margin-bottom:5px;border-right:1px solid #ccc;}
|
||||||
|
.mobile-input-group1>.input-group-addon{display:block;}
|
||||||
|
|
||||||
|
.toapi-param-table td:first-child,.toapi-header-table td:first-child{width:auto;}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
#task_list_folder .taskgroup-opened .icon-folder-pre:before{content:"\2212"}
|
||||||
|
#task_list_folder .taskgroup-opened .icon-folder:before{content:"\e118"}
|
||||||
|
|
||||||
|
#task_list_folder .icon-folder-pre:before{font-size:12px;content:"\002b"}
|
||||||
|
#task_list_folder .icon-folder:before{content:"\e117";margin-right:5px;}
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| SkyCaiji (蓝天采集器)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 使用协议 https://www.skycaiji.com/licenses
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'use strict';function DataapiClass(){this.formid='#form_dataapi'}
|
||||||
|
DataapiClass.prototype={constructor:DataapiClass,init_list:function(search){$('#dataapi_list .delete').bind('click',function(){var curTr=$(this).parents('tr[data-da-id]').eq(0);confirmRight('删除后将无法请求该接口!确定删除?',function(){ajaxOpen({type:'post',url:ulink('dataapi/op?op=delete'),data:{'id':curTr.attr('data-da-id')},success:function(data){ajaxDataMsg(data);if(data.code==1){curTr.remove()}}})})});$('#dataapi_list .status').bind('click',function(){var curTr=$(this).parents('tr[data-da-id]').eq(0);var curObj=$(this);ajaxOpen({type:'post',url:ulink('dataapi/op?op=status'),data:{'id':curTr.attr('data-da-id'),'status':(curObj.hasClass('status-close')?0:1)},success:function(data){ajaxDataMsg(data);data=data.data;if(data.status){curObj.removeClass('status-close').html('开启')}else{curObj.addClass('status-close').html('关闭')}}})});if(isObject(search)){for(var i in search){$('#form_search').find('[name="'+i+'"]').val(search[i])}}},init:function(dataapi){var $_o=this;$('#btn_dataset').bind('click',function(){windowModal('数据集',ulink('dataset/select?from=dataapi'))});$('#tips_config_cond').bind('click',function(){confirmRight({msg:'<b>传入参数名:</b>请求接口时url中传入或post提交数据中的参数名称',yes:'确定',textAlign:'left'})});$('#add_config_cond').bind('click',function(){$_o.add_cond(null)});$('#config_conds').on('click','.config-cond-add',function(){$_o.add_cond({sub:1},this)});$('#config_conds').on('change','[name="conds[field][]"]',function(){var curTr=$(this).parents('tr[id^="cond_"]').eq(0);var fname=$(this).val();fname=fname?('默认:'+fname):'';curTr.find('[name="conds[name][]"]').attr('placeholder',fname)});$('#config_conds').on('click','.config-cond-dlt',function(){var curObj=$(this);confirmRight('确定删除?',function(){curObj.parents('tr[id^="cond_"]').remove();$_o.first_cond()})});eleExchange('#config_conds','.config-cond-move','tr[id^="cond_"]',{stop:function(event,ui){$_o.first_cond()}});if(isObject(dataapi)){$($_o.formid).find('[name="name"]').val(dataapi.name?dataapi.name:'');$($_o.formid).find('[name="route"]').val(dataapi.route?dataapi.route:'');$($_o.formid).find('[name="desc"]').val(dataapi.desc?dataapi.desc:'');$($_o.formid).find('[name="sort"]').val(dataapi.sort?toInt(dataapi.sort):0);$($_o.formid).find('[name="status"][value="'+toInt(dataapi.status)+'"]').prop('checked',!0);var config=dataapi.config;$_o.dataset_load({'dataset_id':dataapi.ds_id},dataapi.config)}},first_cond:function(){var firstObj=$('#config_conds').find('tr[id^="cond_"]:first').eq(0);if(firstObj.hasClass('config-cond-sub')){firstObj.removeClass('config-cond-sub');firstObj.find('[name="conds[sub][]"]').val('')}},add_cond:function(cond,curObj){cond=isObject(cond)?cond:null;var trId='cond_'+generateUUID();var tr=$('#tpl_config_cond').clone();tr.attr('id',trId);trId='#'+trId;var isSub=!1;if(cond){for(var i in cond){tr.find('[name="conds['+i+'][]"]').val(cond[i]?cond[i]:'')}
|
||||||
|
if(cond.sub){isSub=!0}}
|
||||||
|
if(isSub&&curObj){var endTr=null;var curTr=$(curObj).parents('tr[id^="cond_"]').eq(0);curTr.nextAll().each(function(){if(!$(this).hasClass('config-cond-sub')){return!1}
|
||||||
|
endTr=$(this)});if(!endTr){endTr=curTr}
|
||||||
|
endTr.after(tr)}else{$('#config_conds tbody').append(tr)}
|
||||||
|
if(cond){$(trId).find('[name="conds[field][]"]').trigger('change')}
|
||||||
|
if(isSub){$(trId).addClass('config-cond-sub')}},dataset_load:function(dsConfig,daConfig){var $_o=this;dsConfig=isObject(dsConfig)?dsConfig:{};daConfig=isObject(daConfig)?daConfig:null;var dsId=toInt(dsConfig.dataset_id);if(dsId>0){ajaxOpen({url:ulink('dataapi/dataset?ds_id='+dsId),success:function(data){var dsData=data.data;if(isObject(dsData)){var fields=isObject(dsData.fields)?dsData.fields:{};$('#config_conds_box').show();$($_o.formid).find('[name="ds_id"]').val(dsData.id);$('#btn_dataset').html('数据集:'+dsData.name);var opts='<option value="">无</option>';var chks='';for(var i in fields){opts+='<option value="'+i+'">'+htmlspecialchars(fields[i])+'</option>';chks+='<label class="checkbox-inline"><input type="checkbox" name="config[hide_fields][]" value="'+i+'"> '+htmlspecialchars(fields[i])+'</label>'}
|
||||||
|
$('#tpl_config_cond').find('[name="conds[field][]"]').html(opts);$($_o.formid+' [name="config[order_field]"]').html(opts);$('#config_hide_fields').html(chks);$('#config_conds').find('[name="conds[field][]"]').each(function(){var curVal=$(this).val();$(this).html(opts).val(curVal)});if(daConfig){var conds=daConfig.conds;if(isObject(conds)){for(var i in conds.logic){$_o.add_cond({sub:conds.sub[i],logic:conds.logic[i],field:conds.field[i],op:conds.op[i],name:conds.name[i]})}}
|
||||||
|
delete daConfig.conds}}
|
||||||
|
$('#myModal').modal('hide');if(daConfig){for(var i in daConfig){var curObj=$($_o.formid).find('[name="config['+i+']"]').eq(0);if(curObj.length>0&&!curObj.is('input:radio')&&!curObj.is('input:checkbox')){curObj.val(daConfig[i])}}
|
||||||
|
$($_o.formid).find('[name="config[order_sort]"][value="'+daConfig.order_sort+'"]').prop('checked',!0);if(isObject(daConfig.hide_fields)){for(var i in daConfig.hide_fields){$($_o.formid).find('[name="config[hide_fields][]"][value="'+daConfig.hide_fields[i]+'"]').prop('checked',!0)}}}}})}},};var dataapiClass=new DataapiClass()
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| SkyCaiji (蓝天采集器)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 使用协议 https://www.skycaiji.com/licenses
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'use strict';function DatasetClass(){this.formid='#form_dataset'}
|
||||||
|
DatasetClass.prototype={constructor:DatasetClass,init_list:function(search){$('#dataset_list .delete').bind('click',function(){var curTr=$(this).parents('tr[data-ds-id]').eq(0);confirmRight('将清空该数据集的所有数据,确定删除?',function(){ajax_check_userpwd({type:'post',url:ulink('dataset/op?op=delete'),data:{'id':curTr.attr('data-ds-id')},success:function(data){ajaxDataMsg(data);if(data.code==1){curTr.remove()}}})})});var dsIds=[];$('tr[data-ds-id]').each(function(){dsIds.push($(this).attr('data-ds-id'))});ajaxOpen({type:'post',url:ulink('dataset/dbCount'),data:{ids:dsIds},success:function(data){if(data.code==1){var ids=data.data;if(isObject(ids)){for(var i in ids){$('tr[data-ds-id="'+i+'"]').find('.db-count').text(ids[i])}}}}});if(isObject(search)){for(var i in search){$('#form_search').find('[name="'+i+'"]').val(search[i])}}},init:function(dataset){var $_o=this;$('#form_dataset').bind('submit',function(){var formObj=$(this);var settings=getFormAjaxSettings(formObj);settings.complete=function(){formObj.find('button[type="submit"]').removeAttr('disabled')};ajax_check_userpwd(settings);return!1});$('#add_dataset_field').bind('click',function(){windowModal('添加字段',ulink('dataset/field'))});$('#set_dataset_indexes').bind('click',function(){windowModal('合理设置索引可提升数据查询速度',ulink('dataset/indexes?ds_id='+$('#form_dataset').find('[name="id"]').val()),{lg:1})});$('#dataset_fields').on('click','.field-name',function(){var tr=$_o.field_tr(this);var objid=tr.attr('id');var field=tr.find('[name="fields[]"]').val();var options={};options.ajax={type:'post',data:{objid:objid,field:field}};windowModal('编辑字段',ulink('dataset/field'),options)});$('#dataset_fields').on('click','.field-dlt',function(){var tr=$_o.field_tr(this);confirmRight('会清空该字段的所有数据,确定删除?',function(){tr.remove()})});eleExchange('#dataset_fields','.field-move','[id^="field_"]');if(isObject(dataset)){$($_o.formid).find('[name="name"]').val(dataset.name?dataset.name:'');$($_o.formid).find('[name="desc"]').val(dataset.desc?dataset.desc:'');var config=dataset.config;if(isObject(config)){var fields=config.fields;if(isObject(fields)){for(var i in fields){var field=fields[i];if(isObject(field)){field.name_original=field.name;$_o.field_add(field,null)}}}}}},db_init:function(list,search){var $_o=this;$('#dataset_db_list').on('change','input[type="text"],input[type="number"],textarea',function(){$(this).parents('tr').eq(0).find('input[name="ids[]"]').prop('checked',!0)});$('#dataset_db_list').on('focus','textarea',function(){$(this).addClass('txt-big')});$('#dataset_db_list').on('blur','textarea',function(){$(this).removeClass('txt-big')});$.datetimepicker.setLocale('zh');$('#addnew').bind('click',function(){var minId=0;$('[name="ids[]"]').each(function(){var val=toInt($(this).val());if(minId>val){minId=val}});minId=minId-1;$_o.db_add([{id:minId}])});$('#deleteall').bind('click',function(){confirmRight('确定删除选中的数据?',function(){var ids=[];$('input[name="ids[]"]:checked').each(function(){ids.push($(this).val())});$_o.db_delete(ids)})});$('#dataset_db_list').on('click','.db-delete',function(){var tr=$(this).parents('tr').eq(0);var id=tr.find('[name="ids[]"]').val();confirmRight('确定删除数据?',function(){$_o.db_delete(id)})});$_o.db_add(list);if(isObject(search)){for(var i in search){$('#form_search').find('[name="'+i+'"]').val(search[i])}}},db_add:function(list){if(!isObject(list)){list=[]}
|
||||||
|
var tr=$('#tpl_db').clone();tr.removeAttr('id');var trHtmls='';for(var i in list){var item=list[i];if(!isObject(item)){item={}}
|
||||||
|
var id=item.id?item.id:'';trHtmls+='<tr data-db-id="'+id+'">'+tr.html().replace(/\[_id_\]/g,'['+id+']')+'</tr>'}
|
||||||
|
$('#dataset_db_list tbody').append(trHtmls);$('#dataset_db_list').find('.db-time').datetimepicker({format:'Y-m-d H:i:s'});for(var i in list){var item=list[i];if(!isObject(item)){item={}}
|
||||||
|
var id=item.id?item.id:'';var trObj=$('#dataset_db_list').find('[data-db-id="'+id+'"]');trObj.find('[data-field="id"]').html(id>0?id:' ');trObj.find('[name="ids[]"]').val(id);trObj.find('input[data-field],textarea[data-field]').each(function(){var name=$(this).attr('data-field');$(this).val(item[name]?item[name]:'')})}
|
||||||
|
$('#form_list').find('.overlay').hide()},db_delete:function(ids){if(!isObject(ids)){ids=isNull(ids)?[]:[ids]}
|
||||||
|
if(ids.length>0){var ids1=[];for(var i in ids){if(ids[i]<0){$('tr[data-db-id="'+ids[i]+'"]').remove()}else{ids1.push(ids[i])}}
|
||||||
|
ids=ids1}
|
||||||
|
if(ids.length>0){ajaxOpen({type:'post',url:ulink('dataset/dbDelete?ds_id='+$('#form_list').find('[name="ds_id"]').val()),data:{ids:ids},success:function(data){ajaxDataMsg(data);if(data.code==1){var ids=data.data;if(isObject(ids)){for(var i in ids){$('tr[data-db-id="'+ids[i]+'"]').remove()}}}}})}},field_add:function(field,objid){var tr=null;if(objid){tr=$('#'+objid)}else{tr=$('#tpl_field').clone();tr.attr('id','field_'+generateUUID())}
|
||||||
|
var fname=field.name;if(field.type=='varchar'&&field.len>0){fname+=' ('+field.len+')'}
|
||||||
|
tr.find('.field-name').text(fname).attr('data-dbname',field.name_dbname);tr.find('.field-type').text(window.tpl_lang['ds_f_type_'+field.type]);tr.find('.field-desc').text(field.desc);tr.find('[name="fields[]"]').val(encode_json2urlbase(field));if(!objid){$('#dataset_fields tbody').append(tr)}},field_init:function(objid,fieldData){var $_o=this;inputSelectCustom('#form_field [name="type"]','len',null,'varchar');$('#form_field').bind('submit',function(){ajaxOpen({type:'POST',dataType:'json',url:$('#form_field').attr('action'),data:$('#form_field').serialize(),success:function(data){if(data.code==1){data=data.data;if(isObject(data)){var objid=data.objid;var field=data.field;if(isObject(field)){var hasField=!1;var totalLen=0;if(field.type=='varchar'){field.len=toInt(field.len);field.len=field.len>0?field.len:500;totalLen+=field.len}
|
||||||
|
$('#dataset_fields tr[id^="field_"]').each(function(){var curId=$(this).attr('id');var dbname=$(this).find('.field-name').attr('data-dbname');if(dbname==field.name_dbname){if(objid&&objid==curId){hasField=!1}else{hasField=!0}}
|
||||||
|
if(!objid||objid!=curId){var fData=$(this).find('[name="fields[]"]').val();fData=decode_urlbase2json(fData);if(fData.type=='varchar'){fData.len=toInt(fData.len);fData.len=fData.len>0?fData.len:500;totalLen+=fData.len}}});if(hasField){toastr.error('字段名称已存在!')}else if(totalLen>16383){toastr.error('所有字符串字段的总长度不能超过16383')}else{$_o.field_add(field,objid);$('#myModal').modal('hide')}}}}else{toastr.error(data.msg)}}});return!1});if(objid&&isObject(fieldData)){$('#form_field [name="objid"]').val(objid);$('#form_field [name="name"]').val(fieldData.name?fieldData.name:'');$('#form_field [name="name_original"]').val(fieldData.name_original?fieldData.name_original:'');$('#form_field [name="desc"]').val(fieldData.desc?fieldData.desc:'');$('#form_field [name="type"]').val(fieldData.type?fieldData.type:'').trigger('change');fieldData.len=toInt(fieldData.len);$('#form_field [name="len"]').val(fieldData.len>0?fieldData.len:'')}},field_tr:function(curObj){return $(curObj).parents('tr[id^="field_"]').eq(0)},indexes_init:function(indexes){var $_o=this;var tplIndex='#win_dataset_indexes .index-tpl [data-tpl="index"]';var tplFields='#win_dataset_indexes .index-tpl [data-tpl="fields"]';var tableEle='#win_dataset_indexes form table.index-list';$('#win_dataset_indexes .index-add-index').bind('click',function(){$_o.indexes_add(tplIndex,tplFields,tableEle,null)});$('#win_dataset_indexes').on('change','.index-field',function(){var curTr=$(this).parents('tr[id^="index_"]').eq(0);if($(this).val()=='-1'){if(curTr.find('.index-field').length<=1){toastr.error('最少保留一个字段!');$(this).val('')}else{$(this).parents('td').eq(0).remove()}}
|
||||||
|
var ixSlt=curTr.find('.index-type');var ixVal=ixSlt.val();ixSlt.find('option').prop('disabled',!1).show();var allowIxs={};curTr.find('.index-field').each(function(){var type=$(this).find('option[value="'+$(this).val()+'"]').attr('data-type');var allowTypes={bigint:['index','unique'],double:['index','unique'],mediumtext:['fulltext'],datetime:['index','unique']};if(isObject(allowTypes[type])){ixSlt.find('option').each(function(){if(!$(this).is(':disabled')){var optVal=$(this).attr('value');if(optVal&&allowTypes[type].indexOf(optVal)<0){$(this).prop('disabled',!0).hide()}}})}});if(ixSlt.find('option[value="'+ixVal+'"]').is(':disabled')){var showVal='';ixSlt.find('option').each(function(){var optVal=$(this).attr('value');if(optVal&&!$(this).is(':disabled')){showVal=optVal;return!1}});ixSlt.val(showVal)}});$(tableEle).on('click','.index-add-field',function(){var curTr=$(this).parents('tr[id^="index_"]').eq(0);var indexId=curTr.attr('id');var fieldsObj=$(tplFields).clone();fieldsObj.find('.index-field').attr('name','indexes['+indexId+'][fields][]');curTr.find('.index-fields').append(fieldsObj)});$(tableEle).on('click','.index-delete-index',function(){var curObj=$(this);confirmRight('确定删除?',function(){curObj.parents('tr[id^="index_"]').eq(0).remove()})});if(!isObject(indexes)){indexes={}}
|
||||||
|
for(var i in indexes){var index=indexes[i];if(isObject(index)){$_o.indexes_add(tplIndex,tplFields,tableEle,index)}}},indexes_add:function(tplIndex,tplFields,tableEle,indexData){if(!isObject(indexData)){indexData={}}
|
||||||
|
var trObj=$(tplIndex).clone();var indexId='index_'+generateUUID();trObj.attr('id',indexId);trObj.find('.index-type').attr('name','indexes['+indexId+'][type]').val(indexData.type?indexData.type:'');if(isObject(indexData.fields)){for(var fi in indexData.fields){var fieldsObj=$(tplFields).clone();fieldsObj.find('.index-field').attr('name','indexes['+indexId+'][fields][]').val(fi);trObj.find('.index-fields').append(fieldsObj)}}else{var fieldsObj=$(tplFields).clone();fieldsObj.find('.index-field').attr('name','indexes['+indexId+'][fields][]');trObj.find('.index-fields').append(fieldsObj)}
|
||||||
|
$(tableEle).append(trObj)}};var datasetClass=new DatasetClass()
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| SkyCaiji (蓝天采集器)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 使用协议 https://www.skycaiji.com/licenses
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace skycaiji\admin\event;
|
||||||
|
use skycaiji\admin\model\CacheModel;
|
||||||
|
use skycaiji\common\model\DatasetTable;
|
||||||
|
class Rdataset extends Release{
|
||||||
|
protected $dataset_db=array();
|
||||||
|
/**
|
||||||
|
* 设置页面post过来的config
|
||||||
|
* @param unknown $config
|
||||||
|
*/
|
||||||
|
public function setConfig($config){
|
||||||
|
$dataset=\util\UnmaxPost::val('dataset/a',array(),null);
|
||||||
|
$dataset['dataset_id']=intval($dataset['dataset_id']);
|
||||||
|
|
||||||
|
if($dataset['auto_create']){
|
||||||
|
|
||||||
|
$mtask=model('Task');
|
||||||
|
$mds=model('Dataset');
|
||||||
|
$taskId=\util\UnmaxPost::val('task_id/d');
|
||||||
|
$taskData=$mtask->getById($taskId);
|
||||||
|
if(empty($taskData)){
|
||||||
|
$this->error('任务不存在');
|
||||||
|
}
|
||||||
|
$dsFields=array();
|
||||||
|
$dsName=$taskData['name'];
|
||||||
|
do{
|
||||||
|
|
||||||
|
$hasName=$mds->where('name',$dsName)->count()>0?true:false;
|
||||||
|
if($hasName){
|
||||||
|
$dsName.='_1';
|
||||||
|
}
|
||||||
|
}while($hasName);
|
||||||
|
|
||||||
|
$collFields=$this->get_coll_fields($taskData['id'],$taskData['module']);
|
||||||
|
$md5Fields=array();
|
||||||
|
foreach ($collFields as $collField){
|
||||||
|
$checkResult=$mds->check_field_name($collField);
|
||||||
|
if(!$checkResult['success']){
|
||||||
|
$md5Fields[md5($collField)]=$collField;
|
||||||
|
$collField=md5($collField);
|
||||||
|
}
|
||||||
|
$dsFields[$collField]=array('name'=>$collField,'type'=>'mediumtext');
|
||||||
|
}
|
||||||
|
$dsFields=$mds->filter_fields($dsFields);
|
||||||
|
$dsData=array('name'=>$dsName,'desc'=>'','sort'=>0,'config'=>serialize(array('fields'=>$dsFields)));
|
||||||
|
$dataset['dataset_id']=$mds->strict(false)->insert($dsData,false,true);
|
||||||
|
if($dataset['dataset_id']>0){
|
||||||
|
|
||||||
|
$dataset['fields']=array();
|
||||||
|
foreach ($dsFields as $k=>$v){
|
||||||
|
$dataset['fields'][$k]='[采集字段:'.($md5Fields[$v['name']]?:$v['name']).']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($dataset['dataset_id']<=0){
|
||||||
|
$this->error('请设置数据集');
|
||||||
|
}
|
||||||
|
$config['dataset']=$dataset;
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
/*导出数据*/
|
||||||
|
public function export($collFieldsList,$options=null){
|
||||||
|
$addedNum=0;
|
||||||
|
$dsConfig=$this->config['dataset'];
|
||||||
|
init_array($dsConfig['fields']);
|
||||||
|
$dsId=intval($dsConfig['dataset_id']);
|
||||||
|
if(empty($this->dataset_db[$dsId])){
|
||||||
|
$dsData=model('Dataset')->getById($dsId);
|
||||||
|
if(empty($dsData)){
|
||||||
|
$this->echo_msg('数据集id'.$dsId.'不存在');
|
||||||
|
return $addedNum;
|
||||||
|
}
|
||||||
|
$this->dataset_db[$dsId]=DatasetTable::getInstance($dsId)->db();
|
||||||
|
}
|
||||||
|
$db=&$this->dataset_db[$dsId];
|
||||||
|
foreach ($collFieldsList as $collFieldsKey=>$collFields){
|
||||||
|
$contTitle=$collFields['title'];
|
||||||
|
$contContent=$collFields['content'];
|
||||||
|
$contUrl=$collFields['url'];
|
||||||
|
$collFields=$collFields['fields'];
|
||||||
|
$this->init_download_config($this->task,$collFields);
|
||||||
|
$db->startTrans();
|
||||||
|
$returnData=array('id'=>'','target'=>'','desc'=>'','error'=>'');
|
||||||
|
try{
|
||||||
|
$dbData=$this->_replace_fields($dsConfig['fields'],$collFields);
|
||||||
|
$returnData['id']=$db->strict(false)->insert($dbData,false,true);
|
||||||
|
if($returnData['id']>0){
|
||||||
|
$addedNum++;
|
||||||
|
$returnData['target']=sprintf('@%d:%d',$dsId,$returnData['id']);
|
||||||
|
}
|
||||||
|
}catch (\Exception $ex){
|
||||||
|
$returnData['error']=$ex->getMessage();
|
||||||
|
}
|
||||||
|
if(empty($returnData['error'])){
|
||||||
|
$db->commit();
|
||||||
|
}else{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
$this->record_collected($contUrl,$returnData,$this->release,array('title'=>$contTitle,'content'=>$contContent));
|
||||||
|
|
||||||
|
unset($collFieldsList[$collFieldsKey]['fields']);
|
||||||
|
}
|
||||||
|
return $addedNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _replace_fields($data,$collFields){
|
||||||
|
if(is_array($data)){
|
||||||
|
foreach ($data as $k=>$v){
|
||||||
|
$data[$k]=$this->_replace_fields($v,$collFields);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$data=preg_replace_callback('/\[\x{91c7}\x{96c6}\x{5b57}\x{6bb5}\:(.+?)\]/u',function($match)use($collFields){
|
||||||
|
$match=$match[1];
|
||||||
|
return $this->get_field_val($collFields[$match]);
|
||||||
|
},$data);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -0,0 +1,78 @@
|
|||||||
|
{extend name="common:main" /}
|
||||||
|
{block name="cssjs"}
|
||||||
|
<link rel="stylesheet" href="__PUBLIC__/static/css/dataapi.css?{$Think.config.html_v}">
|
||||||
|
<script type="text/javascript" src="__PUBLIC__/static/js/admin/dataapi.js?{$Think.config.html_v}"></script>
|
||||||
|
{/block}
|
||||||
|
{block name="content"}
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-body">
|
||||||
|
<form id="form_list" method="post" ajax-submit="true" action="{:url('dataapi/op')}">
|
||||||
|
{:html_usertoken()}
|
||||||
|
<div class="table-responsive" style="border:0;">
|
||||||
|
<table id="dataapi_list" class="table table-hover datatable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{$Think.lang.sort}</th>
|
||||||
|
<th>名称</th>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>状态</th>
|
||||||
|
<th>数据集</th>
|
||||||
|
<th style="width:150px;">{$Think.lang.op}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach name="daList" item="item"}
|
||||||
|
<tr data-ds-id="{$item['id']}" data-da-id="{$item['id']}">
|
||||||
|
<td class="sort"><input type="text" name="newsort[{$item['id']}]" class="form-control" value="{$item['sort']}" autocomplete="off" /></td>
|
||||||
|
<td><a href="{:url('dataapi/set?id='.$item['id'])}">{$item['name']}</a></td>
|
||||||
|
<td>{$item['id']}</td>
|
||||||
|
<td><a href="javascript:;" class="status{$item['status']?'':' status-close'}">{$item['status']?'开启':'关闭'}</a></td>
|
||||||
|
<td><a href="{:url('dataset/set?id='.$item['ds_id'])}">{$dsNames[$item['ds_id']]}</a></td>
|
||||||
|
<td>
|
||||||
|
<ul class="in-line">
|
||||||
|
<li><a href="{:url('dataapi/set?id='.$item['id'])}">编辑</a></li>
|
||||||
|
<li class="sep">|</li>
|
||||||
|
<li><a href="javascript:;" class="delete">{$Think.lang.delete}</a></li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5">
|
||||||
|
<button type="submit" class="btn btn-default">{$Think.lang.save}</button>
|
||||||
|
<a href="{:url('dataapi/set')}" class="btn btn-primary">添加数据接口</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{if condition="!empty($pagenav)"}
|
||||||
|
<tr>
|
||||||
|
<td colspan="5">{$pagenav}</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="list-footer">
|
||||||
|
<form id="form_search" method="post" action="{:url('dataapi/list')}" class="form-inline">
|
||||||
|
{:html_usertoken()}
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label>ID</label>
|
||||||
|
<input type="number" name="id" class="form-control" value="" placeholder="精确搜索" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label>名称</label>
|
||||||
|
<input type="text" name="name" class="form-control" value="" placeholder="模糊搜索" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<button type="submit" class="btn btn-default btn-sm">{$Think.lang.search}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
dataapiClass.init_list({$search|json_encode});
|
||||||
|
</script>
|
||||||
|
{/block}
|
@ -0,0 +1,103 @@
|
|||||||
|
{extend name="common:main" /}
|
||||||
|
{block name="cssjs"}
|
||||||
|
<link href="__PUBLIC__/static/css/jquery.datetimepicker.css?{$Think.config.html_v}" rel="stylesheet">
|
||||||
|
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.datetimepicker.js?{$Think.config.html_v}"></script>
|
||||||
|
<link rel="stylesheet" href="__PUBLIC__/static/css/dataset.css?{$Think.config.html_v}">
|
||||||
|
<script type="text/javascript" src="__PUBLIC__/static/js/admin/dataset.js?{$Think.config.html_v}"></script>
|
||||||
|
{/block}
|
||||||
|
{block name="content"}
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-body">
|
||||||
|
<form id="form_list" ajax-submit="true" method="post" action="{:url('dataset/dbSet')}">
|
||||||
|
<div class="overlay">
|
||||||
|
<i class="fa fa-refresh fa-spin"></i>
|
||||||
|
</div>
|
||||||
|
{:html_usertoken()}
|
||||||
|
{if !empty($dsData)}
|
||||||
|
<input type="hidden" name="ds_id" value="{$dsData['id']}"/>
|
||||||
|
{/if}
|
||||||
|
<div class="table-responsive dataset-db-list" style="border:0;">
|
||||||
|
<table id="dataset_db_list" class="table table-striped datatable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="chk">ID</th>
|
||||||
|
{foreach $fields as $field}
|
||||||
|
<th>{$field['name']}</th>
|
||||||
|
{/foreach}
|
||||||
|
<th style="width:50px;">{$Think.lang.op}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
{php}$colspan=count($fields)+2;{/php}
|
||||||
|
<tr>
|
||||||
|
<td class="chk"><label class="chk-all"><input type="checkbox" id="chkall" onclick="checkall(this,'ids[]')"><span>全部</span></label></td>
|
||||||
|
<td colspan="{$colspan}">
|
||||||
|
<button type="submit" class="btn btn-default">保存</button>
|
||||||
|
<button type="button" class="btn btn-danger" id="deleteall">删除</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="addnew">新增</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{if condition="!empty($pagenav)"}
|
||||||
|
<tr>
|
||||||
|
<td colspan="{$colspan+1}">{$pagenav}</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="list-footer dataset-search">
|
||||||
|
<form id="form_search" method="post" action="{:url('dataset/db')}" class="form-inline">
|
||||||
|
{:html_usertoken()}
|
||||||
|
{if !empty($dsData)}
|
||||||
|
<input type="hidden" name="ds_id" value="{$dsData['id']}"/>
|
||||||
|
{/if}
|
||||||
|
<div class="form-group form-group-sm" style="margin-bottom:5px;">
|
||||||
|
<label>每页显示</label>
|
||||||
|
<select name="num" class="form-control">
|
||||||
|
<option value="30">30个</option>
|
||||||
|
<option value="50">50个</option>
|
||||||
|
<option value="100">100个</option>
|
||||||
|
<option value="150">150个</option>
|
||||||
|
<option value="200">200个</option>
|
||||||
|
<option value="300">300个</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm" style="margin-bottom:5px;">
|
||||||
|
<label>ID</label>
|
||||||
|
<input type="number" name="id" class="form-control" value="" placeholder="精确搜索" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
{foreach $fields as $fname=>$field}
|
||||||
|
<div class="form-group form-group-sm" style="margin-bottom:5px;">
|
||||||
|
<label>{$field['name']}</label>
|
||||||
|
<input type="text" name="{$fname}" class="form-control" value="" placeholder="模糊搜索" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
||||||
|
<div class="form-group form-group-sm" style="margin-bottom:5px;margin-right:10px;">
|
||||||
|
<button type="submit" class="btn btn-default btn-sm">{$Think.lang.search}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<table style="display:none;">
|
||||||
|
<tr id="tpl_db" data-db-id="">
|
||||||
|
<td class="chk"><label class="checkbox-inline"><input type="checkbox" name="ids[]" value=""> <span data-field="id"></span></label></td>
|
||||||
|
{foreach $fields as $fname=>$field}
|
||||||
|
<td>
|
||||||
|
{if $field['type']=='mediumtext'}
|
||||||
|
<textarea data-field="{$fname}" name="{$fname}[_id_]" class="form-control" placeholder="{:lang('ds_f_type_'.$field['type'])}"></textarea>
|
||||||
|
{else/}
|
||||||
|
<input type="{if $field['type']=='bigint'}number{else/}text{/if}" data-field="{$fname}" name="{$fname}[_id_]" class="form-control{if $field['type']=='datetime'} db-time{/if}" placeholder="{:lang('ds_f_type_'.$field['type'])}" autocomplete="off" />
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
{/foreach}
|
||||||
|
<td><a href="javascript:;" class="db-delete">{$Think.lang.delete}</a></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<script type="text/javascript">
|
||||||
|
datasetClass.db_init({$list|json_encode},{$search|json_encode});
|
||||||
|
</script>
|
||||||
|
{/block}
|
@ -0,0 +1,61 @@
|
|||||||
|
<div id="win_dataset_indexes" style="margin-top:-10px;margin-bottom:-10px;">
|
||||||
|
<form method="post" ajax-submit="true" action="{:url('dataset/indexes')}">
|
||||||
|
{:html_usertoken()}
|
||||||
|
{if !empty($dsData)}
|
||||||
|
<input type="hidden" name="ds_id" value="{$dsData['id']}" />
|
||||||
|
{/if}
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover index-list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width:130px;">索引类型</th>
|
||||||
|
<th>字段(多个字段为联合索引)</th>
|
||||||
|
<th style="width:70px;">操作<a href="javascript:;" class="glyphicon glyphicon-plus index-add-index" style="margin-left:5px;font-size:12px;" title="添加索引"></a></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary btn-block">保存</button>
|
||||||
|
</form>
|
||||||
|
<div class="index-tpl" style="display:none;">
|
||||||
|
<table>
|
||||||
|
<tr data-tpl="index">
|
||||||
|
<td>
|
||||||
|
<select class="form-control index-type">
|
||||||
|
<option value="">无</option>
|
||||||
|
<option value="index">{$Think.lang.ds_ix_type_index}</option>
|
||||||
|
<option value="unique">{$Think.lang.ds_ix_type_unique}</option>
|
||||||
|
<option value="fulltext">{$Think.lang.ds_ix_type_fulltext}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<table class="table">
|
||||||
|
<tr class="index-fields"></tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon"><a href="javascript:;" class="glyphicon glyphicon-plus index-add-field" style="font-size:12px;" title="添加字段"></a></div>
|
||||||
|
<div class="input-group-addon" style="border-left:1px solid #d2d6de;"><a href="javascript:;" class="glyphicon glyphicon-remove index-delete-index" style="font-size:12px;" title="删除索引"></a></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td data-tpl="fields">
|
||||||
|
<select class="form-control index-field">
|
||||||
|
<option value="">无</option>
|
||||||
|
{foreach $fields as $k=>$v}
|
||||||
|
<option value="{$k}" data-type="{$v['type']}">{$v['name']}</option>
|
||||||
|
{/foreach}
|
||||||
|
<option value="-1">删除字段</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
datasetClass.indexes_init({$dbIndexes|json_encode});
|
||||||
|
</script>
|
@ -0,0 +1,80 @@
|
|||||||
|
{extend name="common:main" /}
|
||||||
|
{block name="cssjs"}
|
||||||
|
<link rel="stylesheet" href="__PUBLIC__/static/css/dataset.css?{$Think.config.html_v}">
|
||||||
|
<script type="text/javascript" src="__PUBLIC__/static/js/admin/dataset.js?{$Think.config.html_v}"></script>
|
||||||
|
{/block}
|
||||||
|
{block name="content"}
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-body">
|
||||||
|
<form id="form_list" method="post" ajax-submit="true" action="{:url('dataset/op')}">
|
||||||
|
{:html_usertoken()}
|
||||||
|
<div class="table-responsive" style="border:0;">
|
||||||
|
<table id="dataset_list" class="table table-hover datatable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{$Think.lang.sort}</th>
|
||||||
|
<th style="width:150px;">名称</th>
|
||||||
|
<th style="width:50px;">ID</th>
|
||||||
|
<th>字段</th>
|
||||||
|
<th style="width:100px;">数据量</th>
|
||||||
|
<th style="width:150px;">{$Think.lang.op}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach name="dsList" item="item"}
|
||||||
|
<tr data-ds-id="{$item['id']}">
|
||||||
|
<td class="sort"><input type="text" name="newsort[{$item['id']}]" class="form-control" value="{$item['sort']}" autocomplete="off" /></td>
|
||||||
|
<td><a href="{:url('dataset/set?id='.$item['id'])}">{$item['name']}</a></td>
|
||||||
|
<td>{$item['id']}</td>
|
||||||
|
<td>{if !empty($dsFields[$item['id']])}<input type="text" class="form-control fields" readonly="true" value="{$dsFields[$item['id']]|htmlspecialchars}">{/if}</td>
|
||||||
|
<td>共<a href="{:url('dataset/db?ds_id='.$item['id'])}" class="db-count">0</a>条</td>
|
||||||
|
<td>
|
||||||
|
<ul class="in-line">
|
||||||
|
<li><a href="{:url('dataset/db?ds_id='.$item['id'])}">数据</a></li>
|
||||||
|
<li class="sep">|</li>
|
||||||
|
<li><a href="{:url('dataset/set?id='.$item['id'])}">编辑</a></li>
|
||||||
|
<li class="sep">|</li>
|
||||||
|
<li><a href="javascript:;" class="delete">{$Think.lang.delete}</a></li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5">
|
||||||
|
<button type="submit" class="btn btn-default">{$Think.lang.save}</button>
|
||||||
|
<a href="{:url('dataset/set')}" class="btn btn-primary">添加数据集</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{if condition="!empty($pagenav)"}
|
||||||
|
<tr>
|
||||||
|
<td colspan="5">{$pagenav}</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="list-footer">
|
||||||
|
<form id="form_search" method="post" action="{:url('dataset/list')}" class="form-inline">
|
||||||
|
{:html_usertoken()}
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label>ID</label>
|
||||||
|
<input type="number" name="id" class="form-control" value="" placeholder="精确搜索" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label>名称</label>
|
||||||
|
<input type="text" name="name" class="form-control" value="" placeholder="模糊搜索" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<button type="submit" class="btn btn-default btn-sm">{$Think.lang.search}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
datasetClass.init_list({$search|json_encode});
|
||||||
|
</script>
|
||||||
|
{/block}
|
@ -0,0 +1,51 @@
|
|||||||
|
{if !empty($dsList)}
|
||||||
|
<div id="window_dataset_list">
|
||||||
|
<ul class="row">
|
||||||
|
{foreach $dsList as $v}
|
||||||
|
<li class="col-xs-6" style="padding:3px 15px 3px 0;">
|
||||||
|
<a href="javascript:;" data-id="{$v['id']}" data-title="{$v['name']|htmlentities}">
|
||||||
|
{$v['name']}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
||||||
|
{$pagenav}
|
||||||
|
<form method="get" action="{:url('dataset/select?from='.$from)}" class="form-inline" style="padding-top:15px;margin-top:10px;border-top:solid 1px #f4f4f4;">
|
||||||
|
{:html_usertoken()}
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label>ID</label>
|
||||||
|
<input type="number" name="id" class="form-control" value="{$search['id']}" placeholder="精确搜索" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<label>名称</label>
|
||||||
|
<input type="text" name="name" class="form-control" value="{$search['name']}" placeholder="模糊搜索" />
|
||||||
|
</div>
|
||||||
|
<div class="form-group form-group-sm">
|
||||||
|
<button type="submit" class="btn btn-default btn-sm" style="margin-bottom:0;">{$Think.lang.search}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{else/}
|
||||||
|
没有数据集!<a href="{:url('dataset/set')}" target="_blank">创建一个</a>
|
||||||
|
{/if}
|
||||||
|
<script type="text/javascript">
|
||||||
|
'use strict';
|
||||||
|
(function(){
|
||||||
|
$('#window_dataset_list .pagination').addClass('pagination-sm');
|
||||||
|
$('#window_dataset_list .pagination a').bind('click',function(){
|
||||||
|
windowModal('数据集',$(this).attr('href'));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('#window_dataset_list form').bind('submit',function(){
|
||||||
|
windowModal('数据集',$(this).attr('action'),{ajax:{data:$(this).serialize()}});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('#window_dataset_list a[data-id]').bind('click',function(){
|
||||||
|
{if $from=='release'}
|
||||||
|
releaseClass.dataset_load({'dataset_id':$(this).attr('data-id')});
|
||||||
|
{else if $from=='dataapi'}
|
||||||
|
dataapiClass.dataset_load({'dataset_id':$(this).attr('data-id')});
|
||||||
|
{/if}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
@ -0,0 +1,40 @@
|
|||||||
|
<div class="box box-primary">
|
||||||
|
<div class="box-body">
|
||||||
|
<input type="hidden" name="dataset[dataset_id]" value="{$dsData['id']|intval}" />
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>数据集</th>
|
||||||
|
<th>绑定数据</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach $fields as $k=>$v}
|
||||||
|
<tr>
|
||||||
|
<td>{$v['name']}</td>
|
||||||
|
<td>
|
||||||
|
<div class="input-group dataset-field-txt">
|
||||||
|
<input type="text" name="dataset[fields][{$k}]" class="form-control" autocomplete="off" />
|
||||||
|
<div class="input-group-addon">
|
||||||
|
<a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">字段 <span class="caret"></span></a>
|
||||||
|
<ul class="dropdown-menu dropdown-menu-right">
|
||||||
|
{if !empty($collFields)}
|
||||||
|
{foreach $collFields as $v}
|
||||||
|
<li><a href="javascript:;" data-val="[采集字段:{$v}]">采集字段:{$v}</a></li>
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function(){
|
||||||
|
$('#rele_module_dataset #btn_dataset').html("数据集:{$dsData['name']?:''} <span class='caret'></span>");
|
||||||
|
})();
|
||||||
|
</script>
|
@ -1,7 +0,0 @@
|
|||||||
{extend name="common:main" /}
|
|
||||||
{block name="cssjs"}
|
|
||||||
{/block}
|
|
||||||
{block name="content"}
|
|
||||||
{include file="task:save_form" /}
|
|
||||||
{include file="task:stepsbar" /}
|
|
||||||
{/block}
|
|
@ -1,3 +0,0 @@
|
|||||||
<div class="">
|
|
||||||
{include file="task:save_form" /}
|
|
||||||
</div>
|
|
@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| SkyCaiji (蓝天采集器)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 使用协议 https://www.skycaiji.com/licenses
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace skycaiji\api\controller;
|
||||||
|
use skycaiji\common\controller\BaseController;
|
||||||
|
class Data extends BaseController {
|
||||||
|
public function indexAction(){
|
||||||
|
$params=input('param.');
|
||||||
|
$mda=model('Dataapi');
|
||||||
|
$daData=array();
|
||||||
|
if(is_numeric($params['i'])){
|
||||||
|
$daData=$mda->getById($params['i']);
|
||||||
|
}else{
|
||||||
|
$daData=$mda->where('route',$params['i'])->find();
|
||||||
|
$daData=$mda->get_da_data($daData);
|
||||||
|
}
|
||||||
|
if(empty($daData)){
|
||||||
|
$this->jsonSend('数据接口不存在');
|
||||||
|
}
|
||||||
|
$config=$daData['config'];
|
||||||
|
if(empty($config)){
|
||||||
|
$this->jsonSend('无效的数据接口');
|
||||||
|
}
|
||||||
|
if(!empty($config['api_key'])){
|
||||||
|
|
||||||
|
$iptK=$params['k']?:'';
|
||||||
|
if(empty($config['api_mode'])){
|
||||||
|
if(strcasecmp($iptK,md5($config['api_key']))!==0){
|
||||||
|
|
||||||
|
$this->jsonSend('密钥错误');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$iptK=explode('_', $iptK);
|
||||||
|
if(strcasecmp($iptK[0],md5(md5($config['api_key']).$iptK[1]))!==0){
|
||||||
|
|
||||||
|
$this->jsonSend('密钥错误');
|
||||||
|
}
|
||||||
|
if(abs(time()-$iptK[1])>300){
|
||||||
|
$this->jsonSend('密钥已过期');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!empty($config['api_method'])){
|
||||||
|
|
||||||
|
if(strtolower($config['api_method'])=='post'){
|
||||||
|
if(!$this->request->isPost()){
|
||||||
|
$this->jsonSend('请使用post模式请求接口');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(!$this->request->isGet()){
|
||||||
|
$this->jsonSend('请使用get模式请求接口');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(empty($daData['status'])){
|
||||||
|
$this->jsonSend('接口已关闭');
|
||||||
|
}
|
||||||
|
$dsData=$daData['ds_id']?model('Dataset')->getById($daData['ds_id']):array();
|
||||||
|
if(empty($dsData)){
|
||||||
|
$this->jsonSend('接口无数据');
|
||||||
|
}
|
||||||
|
if(empty($config['conds'])){
|
||||||
|
$this->jsonSend('接口没有数据查询条件');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageNo=intval($params[$config['page_name']?:'p']);
|
||||||
|
$pageNo=$pageNo<=1?1:$pageNo;
|
||||||
|
|
||||||
|
$config['page_max']=intval($config['page_max']);
|
||||||
|
if($config['page_max']>0&&$pageNo>$config['page_max']){
|
||||||
|
$this->jsonSend('已超出最大分页数');
|
||||||
|
}
|
||||||
|
|
||||||
|
$error='';
|
||||||
|
try{
|
||||||
|
$queryData=$mda->do_query_conds($pageNo,$config,$dsData,$params);
|
||||||
|
}catch (\Exception $ex){
|
||||||
|
$error=$ex->getMessage();
|
||||||
|
}
|
||||||
|
if($error){
|
||||||
|
$this->jsonSend($error);
|
||||||
|
}
|
||||||
|
if($queryData['count']<=0){
|
||||||
|
$this->jsonSend('没有查询到数据');
|
||||||
|
}
|
||||||
|
$options=array();
|
||||||
|
if($queryData['pages']>1){
|
||||||
|
$options['page']=$pageNo;
|
||||||
|
$options['pages']=$queryData['pages'];
|
||||||
|
}
|
||||||
|
$this->jsonSend('',$queryData['data'],1,$options);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| SkyCaiji (蓝天采集器)
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 使用协议 https://www.skycaiji.com/licenses
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace skycaiji\common\model;
|
||||||
|
|
||||||
|
class Dataset extends BaseModel{
|
||||||
|
public function getById($id){
|
||||||
|
$data=$this->where('id',$id)->find();
|
||||||
|
$data=$this->get_ds_data($data);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
public function get_ds_data($dsData){
|
||||||
|
$dsData=$dsData?$dsData->toArray():array();
|
||||||
|
if($dsData){
|
||||||
|
$dsData['config']=unserialize($dsData['config']);
|
||||||
|
init_array($dsData['config']);
|
||||||
|
}
|
||||||
|
return $dsData;
|
||||||
|
}
|
||||||
|
public function get_config_field($dsData,$fname){
|
||||||
|
$field=array();
|
||||||
|
if($dsData['config']&&$dsData['config']['fields']){
|
||||||
|
$field=$dsData['config']['fields'][$fname];
|
||||||
|
}
|
||||||
|
init_array($field);
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check_field_name($name){
|
||||||
|
$result=return_result('');
|
||||||
|
if(empty($name)){
|
||||||
|
$result['msg']='字段名称不能为空!';
|
||||||
|
}elseif(strcasecmp($name,'id')===0){
|
||||||
|
$result['msg']='字段名称不能设为id';
|
||||||
|
}elseif(!preg_match('/^[\x{4e00}-\x{9fa5}\w\-]+$/u', $name)){
|
||||||
|
$result['msg']='字段名称只能由汉字、字母、数字和下划线组成';
|
||||||
|
}elseif(strlen($name)<=1){
|
||||||
|
$result['msg']='字段名称最少2个字符';
|
||||||
|
}else{
|
||||||
|
$result['success']=true;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check_field_type($type){
|
||||||
|
$result=return_result('');
|
||||||
|
static $types=array('bigint','double','varchar','mediumtext','datetime');
|
||||||
|
if(!in_array($type, $types)){
|
||||||
|
$result['msg']='请选择数据类型';
|
||||||
|
}else{
|
||||||
|
$result['success']=true;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function filter_fields($fields){
|
||||||
|
init_array($fields);
|
||||||
|
$newFields=array();
|
||||||
|
foreach ($fields as $v){
|
||||||
|
init_array($v);
|
||||||
|
$check=$this->check_field_name($v['name']);
|
||||||
|
if($check['success']){
|
||||||
|
$check=$this->check_field_type($v['type']);
|
||||||
|
if($check['success']){
|
||||||
|
$key=$this->field_db_name($v['name']);
|
||||||
|
$newFields[$key]=$v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $newFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function field_db_name($name){
|
||||||
|
$name=strtolower($name);
|
||||||
|
if(!preg_match('/^[a-z]\w{0,30}$/i',$name)){
|
||||||
|
|
||||||
|
$md5=md5($name);
|
||||||
|
$name='';
|
||||||
|
if(preg_match('/[a-z]/i',$md5,$mfirst)){
|
||||||
|
$name=$mfirst[0];
|
||||||
|
}
|
||||||
|
$name=$name?:'a';
|
||||||
|
$name.=substr($md5,-4,4);
|
||||||
|
}
|
||||||
|
$name=strtolower($name);
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| SkyCaiji (蓝天采集器)
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| 使用协议 https://www.skycaiji.com/licenses
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*日志驱动*/
|
|
||||||
namespace util;
|
|
||||||
use think\log\driver\File;
|
|
||||||
class Log extends File{
|
|
||||||
public function save(array $log = [], $append = false){
|
|
||||||
|
|
||||||
static $passList=array(
|
|
||||||
'未定义','Undefined',
|
|
||||||
'A session had already been started','DOMDocument::loadHTML',
|
|
||||||
'MySQL server has gone away',"Error reading result set's header",
|
|
||||||
'The /e modifier is deprecated',
|
|
||||||
'Invalid argument supplied for foreach',
|
|
||||||
'CURLOPT_FOLLOWLOCATION',
|
|
||||||
'open_basedir restriction in effect',
|
|
||||||
']unlink(',']rmdir('
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($log as $type => $val) {
|
|
||||||
foreach ($val as $key=>$msg) {
|
|
||||||
if (!is_string($msg)) {
|
|
||||||
$msg = var_export($msg, true);
|
|
||||||
}
|
|
||||||
foreach ($passList as $passStr){
|
|
||||||
if(stripos($msg, $passStr)!==false){
|
|
||||||
|
|
||||||
unset($val[$key]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$log[$type]=$val;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::save($log,$append);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue