diff --git a/APIJSON.NET/APIJSON.NET.Test/Program.cs b/APIJSON.NET/APIJSON.NET.Test/Program.cs index b23ebdc..3a91e1a 100644 --- a/APIJSON.NET/APIJSON.NET.Test/Program.cs +++ b/APIJSON.NET/APIJSON.NET.Test/Program.cs @@ -7,7 +7,7 @@ class Program { static void Main(string[] args) { - var client = new RestClient("http://localhost:5000/"); + var client = new RestClient("http://localhost:3480/"); var login = new RestRequest("token", Method.POST); login.AddJsonBody(new TokenInput() { username = "admin1", password = "123456" }); @@ -19,8 +19,8 @@ static void Main(string[] args) request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer " + token.Data.data.AccessToken); request.AddJsonBody(@"{ - 'User': { - 'id': 38710 + 'Login': { + 'id': 1 } } "); diff --git a/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs b/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs index 1fd8d2e..6145d54 100644 --- a/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs +++ b/APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs @@ -153,12 +153,20 @@ public ActionResult Edit([FromBody]JObject jobject) foreach (var item in jobject) { string key = item.Key.Trim(); - var role = _identitySvc.GetRole(); - if (!role.Update.Table.Contains(key, StringComparer.CurrentCultureIgnoreCase)) - { - ht["code"] = "500"; - ht["msg"] = $"没权限修改{key}"; - break; + var role = _identitySvc.GetRole(); + //if (!role.Update.Table.Contains(key, StringComparer.CurrentCultureIgnoreCase)) + //{ + // ht["code"] = "500"; + // ht["msg"] = $"没权限修改{key}"; + // break; + //} + string tablerole = role.Select.Table.FirstOrDefault(it => it == "*" || it.Equals(key, StringComparison.CurrentCultureIgnoreCase)); + + if (string.IsNullOrEmpty(tablerole)) + { + ht["code"] = "500"; + ht["msg"] = $"没权限修改{key}"; + break; } var value = JObject.Parse(item.Value.ToString()); if (!value.ContainsKey("id")) diff --git a/APIJSON.NET/APIJSON.NET/Data/DbInit.cs b/APIJSON.NET/APIJSON.NET/Data/DbInit.cs index b80bdd2..3ff541f 100644 --- a/APIJSON.NET/APIJSON.NET/Data/DbInit.cs +++ b/APIJSON.NET/APIJSON.NET/Data/DbInit.cs @@ -29,8 +29,6 @@ public static void Initialize(IApplicationBuilder app) ds.Add(d); } db.LoginDb.InsertRange(ds.ToArray()); - - } } diff --git a/APIJSON.NET/APIJSON.NET/Properties/launchSettings.json b/APIJSON.NET/APIJSON.NET/Properties/launchSettings.json new file mode 100644 index 0000000..2f9a670 --- /dev/null +++ b/APIJSON.NET/APIJSON.NET/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3480/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "APIJSON.NET": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:3481/" + } + } +} \ No newline at end of file diff --git a/APIJSON.NET/APIJSON.NET/Startup.cs b/APIJSON.NET/APIJSON.NET/Startup.cs index 15d9b6c..6ac9763 100644 --- a/APIJSON.NET/APIJSON.NET/Startup.cs +++ b/APIJSON.NET/APIJSON.NET/Startup.cs @@ -58,6 +58,8 @@ public void ConfigureServices(IServiceCollection services) services.AddTransient(); services.AddTransient(); + //启用 IISIntegration 组件 + services.Configure(option => { option.ForwardClientCertificate = false; }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -82,7 +84,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) }); app.UseJwtTokenMiddleware(); - DbInit.Initialize(app); + //DbInit.Initialize(app); } } } diff --git a/APIJSON.NET/APIJSON.NET/appsettings.json b/APIJSON.NET/APIJSON.NET/appsettings.json index da52e61..d11065d 100644 --- a/APIJSON.NET/APIJSON.NET/appsettings.json +++ b/APIJSON.NET/APIJSON.NET/appsettings.json @@ -1,8 +1,9 @@ { "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=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;" + "DbType": 1, //0:MySql,1:SqlServer,2:Sqlite + //"ConnectionString": "Server=119.29.91.240:14330;Database=KFDEV;Uid=kinfar;Pwd=kinfar123;Port=3306;Character Set=utf8;" + "ConnectionString": "server=119.29.91.240,50362;uid=kinfar;pwd=kinfar123;database=test1;Connection Lifetime=30" + //"ConnectionString": "Data Source=d:\\sqlitedb\\test.db;" }, "Authentication": { "JwtBearer": { @@ -16,17 +17,17 @@ { "name": "role1", //Ȩ������ Ψһ "select": { //��ѯȨ�� - "table": [ "moment", "User", "Comment" ], //�ɲ����ı� - "column": [ "*", "*", "*" ], //�ɲ������ֶ� + "table": ["*"], //�ɲ����ı� + "column": [ "*"], //�ɲ������ֶ� "where": [] }, "update": { //�޸�Ȩ�� - "table": [ "moment", "User", "Comment" ], - "column": [ "*", "*", "*" ] + "table": [ "*" ], //�ɲ����ı� + "column": [ "*" ] //�ɲ������ֶ� }, "insert": { //����Ȩ�� - "table": [ "moment", "User", "Comment" ], - "column": [ "*", "*", "*" ] + "table": [ "*" ], //�ɲ����ı� + "column": [ "*" ] //�ɲ������ֶ� }, "delete": { //ɾ��Ȩ�� "table": [ "moment", "User", "Comment" ] diff --git a/APIJSON.NET/APIJSON.NET/wwwroot/index.html b/APIJSON.NET/APIJSON.NET/wwwroot/index.html index 4c8f534..3a2dc25 100644 --- a/APIJSON.NET/APIJSON.NET/wwwroot/index.html +++ b/APIJSON.NET/APIJSON.NET/wwwroot/index.html @@ -22,8 +22,8 @@ diff --git a/APIJSON.NET/APIJSONCommon/SelectTable.cs b/APIJSON.NET/APIJSONCommon/SelectTable.cs index de56221..b665733 100644 --- a/APIJSON.NET/APIJSONCommon/SelectTable.cs +++ b/APIJSON.NET/APIJSONCommon/SelectTable.cs @@ -65,7 +65,15 @@ public object ExecFunc(string funcname, object[] param, Type[] types) var result = reflector.Invoke(new FuncList(), param); return result; } - + /// + /// 转换sql语句 + /// + /// + /// + /// + /// + /// + /// private string ToSql(string subtable, int page, int count, int query, string json) { JObject values = JObject.Parse(json);