From f3ddc75a24ee748f895fac9be8be471640fc2b8e Mon Sep 17 00:00:00 2001 From: andyz168 <810802300@qq.com> Date: Sun, 15 Mar 2020 22:41:07 +0800 Subject: [PATCH 1/2] 11 --- APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj | 2 + APIJSON.NET/APIJSON.NET/wwwroot/js/main.js | 276 +++++++++--------- .../APIJSONCommon/ApiJson.Common.csproj | 3 +- .../Services/IIdentityService.cs | 2 +- 4 files changed, 143 insertions(+), 140 deletions(-) diff --git a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj index 634243e..96ad777 100644 --- a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj +++ b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj @@ -2,6 +2,8 @@ netcoreapp2.2 + false + 801d0f5b-e25d-416a-999f-0a82f7674301 diff --git a/APIJSON.NET/APIJSON.NET/wwwroot/js/main.js b/APIJSON.NET/APIJSON.NET/wwwroot/js/main.js index 7f32e28..7bf3db1 100644 --- a/APIJSON.NET/APIJSON.NET/wwwroot/js/main.js +++ b/APIJSON.NET/APIJSON.NET/wwwroot/js/main.js @@ -22,74 +22,74 @@ template: '#val-template' }) - Vue.use({ - install: function (Vue, options) { - - // 判断数据类型 - Vue.prototype.getTyp = function (val) { - return toString.call(val).split(']')[0].split(' ')[1] - } + Vue.use({ + install: function (Vue, options) { - // 判断是否是对象或者数组,以对下级进行渲染 - Vue.prototype.isObjectArr = function (val) { - return ['Object', 'Array'].indexOf(this.getTyp(val)) > -1 - } + // 判断数据类型 + Vue.prototype.getTyp = function (val) { + return toString.call(val).split(']')[0].split(' ')[1] + } - // 折叠 - Vue.prototype.fold = function ($event) { - var target = Vue.prototype.expandTarget($event) - target.siblings('svg').show() - target.hide().parent().siblings('.expand-view').hide() - target.parent().siblings('.fold-view').show() - } - // 展开 - Vue.prototype.expand = function ($event) { - var target = Vue.prototype.expandTarget($event) - target.siblings('svg').show() - target.hide().parent().siblings('.expand-view').show() - target.parent().siblings('.fold-view').hide() - } + // 判断是否是对象或者数组,以对下级进行渲染 + Vue.prototype.isObjectArr = function (val) { + return ['Object', 'Array'].indexOf(this.getTyp(val)) > -1 + } - //获取展开折叠的target - Vue.prototype.expandTarget = function ($event) { - switch($event.target.tagName.toLowerCase()) { - case 'use': - return $($event.target).parent() - case 'label': - return $($event.target).closest('.fold-view').siblings('.expand-wraper').find('.icon-square-plus').first() - default: - return $($event.target) - } - } + // 折叠 + Vue.prototype.fold = function ($event) { + var target = Vue.prototype.expandTarget($event) + target.siblings('svg').show() + target.hide().parent().siblings('.expand-view').hide() + target.parent().siblings('.fold-view').show() + } + // 展开 + Vue.prototype.expand = function ($event) { + var target = Vue.prototype.expandTarget($event) + target.siblings('svg').show() + target.hide().parent().siblings('.expand-view').show() + target.parent().siblings('.fold-view').hide() + } - // 格式化值 - Vue.prototype.formatVal = function (val) { - switch(Vue.prototype.getTyp(val)) { - case 'String': - return '"' + val + '"' - break + //获取展开折叠的target + Vue.prototype.expandTarget = function ($event) { + switch ($event.target.tagName.toLowerCase()) { + case 'use': + return $($event.target).parent() + case 'label': + return $($event.target).closest('.fold-view').siblings('.expand-wraper').find('.icon-square-plus').first() + default: + return $($event.target) + } + } - case 'Null': - return 'null' - break + // 格式化值 + Vue.prototype.formatVal = function (val) { + switch (Vue.prototype.getTyp(val)) { + case 'String': + return '"' + val + '"'; + break; - default: - return val + case 'Null': + return 'null'; + break; - } - } + default: + return val; - // 判断值是否是链接 - Vue.prototype.isaLink = function (val) { - return /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/.test(val) - } + } + }; - // 计算对象的长度 - Vue.prototype.objLength = function (obj) { - return Object.keys(obj).length - } - } - }) + // 判断值是否是链接 + Vue.prototype.isaLink = function (val) { + return /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/.test(val) + }; + + // 计算对象的长度 + Vue.prototype.objLength = function (obj) { + return Object.keys(obj).length + }; + } + }); var initJson = { "[]": { @@ -160,104 +160,104 @@ }, // 全部展开 expandAll: function () { - $('.icon-square-min').show() - $('.icon-square-plus').hide() - $('.expand-view').show() - $('.fold-view').hide() + $('.icon-square-min').show(); + $('.icon-square-plus').hide(); + $('.expand-view').show(); + $('.fold-view').hide(); }, // 全部折叠 collapseAll: function () { - $('.icon-square-min').hide() - $('.icon-square-plus').show() - $('.expand-view').hide() - $('.fold-view').show() + $('.icon-square-min').hide(); + $('.icon-square-plus').show(); + $('.expand-view').hide(); + $('.fold-view').show(); }, // 压缩 compress: function () { - App.jsoncon = Parse.compress(App.jsoncon) + App.jsoncon = Parse.compress(App.jsoncon); }, // diff diffTwo: function () { - var oldJSON = {} - var newJSON = {} - App.view = 'code' + var oldJSON = {}; + var newJSON = {}; + App.view = 'code'; try { oldJSON = jsonlint.parse(App.jsoncon) } catch (ex) { - App.view = 'error' - App.error = { - msg: '原 JSON 解析错误\r\n' + ex.message - } - return + App.view = 'error'; + App.error = { + msg: '原 JSON 解析错误\r\n' + ex.message + }; + return; } try { - newJSON = jsonlint.parse(App.newjsoncon) + newJSON = jsonlint.parse(App.newjsoncon); } catch (ex) { - App.view = 'error' - App.error = { - msg: '新 JSON 解析错误\r\n' + ex.message - } - return + App.view = 'error'; + App.error = { + msg: '新 JSON 解析错误\r\n' + ex.message + }; + return; } var base = difflib.stringAsLines(JSON.stringify(oldJSON, '', 4)) var newtxt = difflib.stringAsLines(JSON.stringify(newJSON, '', 4)) var sm = new difflib.SequenceMatcher(base, newtxt) var opcodes = sm.get_opcodes() - $('#diffoutput').empty().append(diffview.buildView({ - baseTextLines: base, - newTextLines: newtxt, - opcodes: opcodes, - baseTextName: '原 JSON', - newTextName: '新 JSON', - contextSize: 2, - viewType: 0 - })) + $('#diffoutput').empty().append(diffview.buildView({ + baseTextLines: base, + newTextLines: newtxt, + opcodes: opcodes, + baseTextName: '原 JSON', + newTextName: '新 JSON', + contextSize: 2, + viewType: 0 + })); }, // 清空 clearAll: function () { - App.jsoncon = '' + App.jsoncon = ''; }, // 美化 beauty: function () { - App.jsoncon = JSON.stringify(JSON.parse(App.jsoncon), '', 4) + App.jsoncon = JSON.stringify(JSON.parse(App.jsoncon), '', 4); }, baseViewToDiff: function () { - App.baseview = 'diff' - App.diffTwo() + App.baseview = 'diff'; + App.diffTwo(); }, // 回到格式化视图 baseViewToFormater: function () { - App.baseview = 'formater' - App.view = 'code' - App.showJsonView() + App.baseview = 'formater'; + App.view = 'code'; + App.showJsonView(); }, // 根据json内容变化格式化视图 showJsonView: function () { if (App.baseview === 'diff') { - return + return; } try { if (this.jsoncon.trim() === '') { - App.view = 'empty' - } else { - App.view = 'code' - App.jsonhtml = jsonlint.parse(this.jsoncon) + App.view = 'empty'; + } else {; + App.view = 'code'; + App.jsonhtml = jsonlint.parse(this.jsoncon); } } catch (ex) { - App.view = 'error' - App.error = { - msg: ex.message - } + App.view = 'error'; + App.error = { + msg: ex.message + }; } }, @@ -265,19 +265,19 @@ save: function () { if (App.history.name.trim() === '') { Helper.alert('名称不能为空!', 'danger') - return - } - var val = { - name: App.history.name, - data: App.jsoncon + return; } - var key = String(Date.now()) - localforage.setItem(key, val, function (err, value) { - Helper.alert('保存成功!', 'success') - App.isSaveShow = false - val.key = key - App.historys.push(val) - }) + var val = { + name: App.history.name, + data: App.jsoncon + }; + var key = String(Date.now()); + localforage.setItem(key, val, function (err, value) { + Helper.alert('保存成功!', 'success'); + App.isSaveShow = false; + val.key = key; + App.historys.push(val); + }); }, // 删除已保存的 @@ -321,31 +321,31 @@ }, // 获取分享的链接 - shareUrl: function (key) { - return `${window.location.origin}?key=${key}` + shareUrl: function (key) { + console.log(window.location.origin); + return `${window.location.origin}?key=${key}`; }, // 分享 share: function () { - let con = App.jsoncon + let con = App.jsoncon; if (con.trim() === '') { - return + return; } - App.isSharing = true - $.ajax({ - type: 'POST', - url: `${ApiUrl}/json`, - contentType: 'application/json; charset=utf-8', - data: JSON.stringify({con: con, key: App.shareKey}), - success: (data) => { - App.isSharing = false - App.shareKey = uuidv1() - if (data.status) { - Helper.alert('分享成功,已将链接复制到剪贴板,只能保存24小时', 'success') - } else { - } - } - }) + App.isSharing = true; + $.ajax({ + type: 'POST', + url: `${ApiUrl}/json`, + contentType: 'application/json; charset=utf-8', + data: JSON.stringify({ con: con, key: App.shareKey }), + success: (data) => { + App.isSharing = false; + App.shareKey = uuidv1(); + if (data.status) { + Helper.alert('分享成功,已将链接复制到剪贴板,只能保存24小时', 'success'); + } + } + }); } }, watch: { diff --git a/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj b/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj index 66d75af..e89cd9f 100644 --- a/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj +++ b/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj @@ -1,9 +1,10 @@ - + netstandard2.0 0.0.1 通用查询组件 + false diff --git a/APIJSON.NET/APIJSONCommon/Services/IIdentityService.cs b/APIJSON.NET/APIJSONCommon/Services/IIdentityService.cs index d911702..db6c8ce 100644 --- a/APIJSON.NET/APIJSONCommon/Services/IIdentityService.cs +++ b/APIJSON.NET/APIJSONCommon/Services/IIdentityService.cs @@ -25,7 +25,7 @@ public interface IIdentityService /// /// /// - Tuple GetSelectRole(string table); + (bool, string) GetSelectRole(string table); bool ColIsRole(string col, string[] selectrole); From 38292505293a633dacfd3f067ea9eacedcc318eb Mon Sep 17 00:00:00 2001 From: andyz168 <810802300@qq.com> Date: Mon, 16 Mar 2020 22:35:42 +0800 Subject: [PATCH 2/2] 1 --- APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs | 5 +---- APIJSON.NET/APIJSON.NET/Controllers/TokenController.cs | 2 +- APIJSON.NET/APIJSON.NET/appsettings.json | 10 +++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs b/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs index 1fd8d2e..e7f327c 100644 --- a/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs +++ b/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs @@ -99,7 +99,7 @@ public async Task QueryByTable([FromRoute]string table) /// /// [HttpPost("/add")] - public ActionResult Add([FromBody]JObject jobject) + public async Task Add([FromBody]JObject jobject) { JObject ht = new JObject(); @@ -107,9 +107,6 @@ public ActionResult Add([FromBody]JObject jobject) ht.Add("msg", "success"); try { - - - foreach (var item in jobject) { string key = item.Key.Trim(); diff --git a/APIJSON.NET/APIJSON.NET/Controllers/TokenController.cs b/APIJSON.NET/APIJSON.NET/Controllers/TokenController.cs index 2979019..ffc6860 100644 --- a/APIJSON.NET/APIJSON.NET/Controllers/TokenController.cs +++ b/APIJSON.NET/APIJSON.NET/Controllers/TokenController.cs @@ -30,7 +30,7 @@ public TokenController(DbContext _db, IOptions configura } [HttpPost("/token")] [AllowAnonymous] - public ActionResult Create([FromBody]TokenInput input) + public async Task< ActionResult> Create([FromBody]TokenInput input) { JObject ht = new JObject(); ht.Add("code", "200"); diff --git a/APIJSON.NET/APIJSON.NET/appsettings.json b/APIJSON.NET/APIJSON.NET/appsettings.json index da52e61..53f9f41 100644 --- a/APIJSON.NET/APIJSON.NET/appsettings.json +++ b/APIJSON.NET/APIJSON.NET/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { "DbType": 0, //0:MySql,1:SqlServer,2:Sqlite - "ConnectionString": "Server=192.168.2.25;Database=yunwei;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;" + "ConnectionString": "Server=;Database=wordpress;Uid=roota;Pwd=@Abc;Port=3306;Character Set=utf8;" //"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;" }, "Authentication": { @@ -16,20 +16,20 @@ { "name": "role1", //Ȩ Ψһ "select": { //ѯȨ - "table": [ "moment", "User", "Comment" ], //ɲı + "table": [ "guopindata" ], //ɲı "column": [ "*", "*", "*" ], //ɲֶ "where": [] }, "update": { //޸Ȩ - "table": [ "moment", "User", "Comment" ], + "table": [ "guopindata" ], "column": [ "*", "*", "*" ] }, "insert": { //Ȩ - "table": [ "moment", "User", "Comment" ], + "table": [ "guopindata"], "column": [ "*", "*", "*" ] }, "delete": { //ɾȨ - "table": [ "moment", "User", "Comment" ] + "table": [ "guopindata" ] } }, {