Skip to content

Commit 74a845f

Browse files
committed
##
1 parent efb5263 commit 74a845f

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

‎APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8+
<PackageReferenceInclude="AspectCore.Extensions.Reflection"Version="0.7.0" />
89
<PackageReferenceInclude="Microsoft.AspNetCore.App" />
910
<PackageReferenceInclude="Microsoft.AspNetCore.Authentication.JwtBearer"Version="2.1.0" />
1011
<PackageReferenceInclude="Microsoft.VisualStudio.Web.CodeGeneration.Design"Version="2.1.0" />

‎APIJSON.NET/APIJSON.NET/Controllers/JsonController.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public ActionResult Add([FromBody]string json)
200200
vardt=newDictionary<string,object>();
201201
foreach(varfinJObject.Parse(item.Value.ToString()))
202202
{
203-
if(f.Key.ToLower()!="id"&&role.Insert.Column.Contains(f.Key,StringComparer.CurrentCultureIgnoreCase))
203+
if(f.Key.ToLower()!="id"&&selectTable.IsCol(key,f.Key)&&(role.Insert.Column.Contains("*")||role.Insert.Column.Contains(f.Key,StringComparer.CurrentCultureIgnoreCase)))
204204
dt.Add(f.Key,f.Value);
205205
}
206206
intid=db.Db.Insertable(dt).AS(key).ExecuteReturnIdentity();
@@ -252,7 +252,7 @@ public ActionResult Edit([FromBody]string json)
252252
dt.Add("id",value["id"]);
253253
foreach(varfinvalue)
254254
{
255-
if(f.Key.ToLower()!="id"&&role.Update.Column.Contains(f.Key,StringComparer.CurrentCultureIgnoreCase))
255+
if(f.Key.ToLower()!="id"&&selectTable.IsCol(key,f.Key)&&(role.Update.Column.Contains("*")||role.Update.Column.Contains(f.Key,StringComparer.CurrentCultureIgnoreCase)))
256256
{
257257
dt.Add(f.Key,f.Value);
258258
}
@@ -290,7 +290,7 @@ public ActionResult Remove([FromBody]string json)
290290
stringkey=item.Key.Trim();
291291
varvalue=JObject.Parse(item.Value.ToString());
292292
varsb=newSystem.Text.StringBuilder(100);
293-
sb.Append($"delete [{key}] where");
293+
sb.Append($"delete FROM {key} where");
294294
if(role.Delete==null||role.Delete.Table==null)
295295
{
296296
ht["code"]="500";

‎APIJSON.NET/APIJSON.NET/Controllers/TokenController.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public IActionResult Create([FromBody]TokenInput input)
7474
[HttpGet]
7575
publicIActionResultGetRole()
7676
{
77-
returnOk(User.Identity.Name);
77+
returnOk(User.FindFirstValue(ClaimTypes.Role));
7878
}
7979
privatestringCreateAccessToken(IEnumerable<Claim>claims,TimeSpan?expiration=null)
8080
{

‎APIJSON.NET/APIJSON.NET/SelectTable.cs‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
usingSystem.Collections.Generic;
99
usingSystem.Dynamic;
1010
usingSystem.Linq;
11-
usingSystem.Reflection;
11+
usingAspectCore.Extensions.Reflection;
1212
usingSystem.Text.RegularExpressions;
1313

1414
publicclassSelectTable
@@ -50,14 +50,19 @@ public bool IsCol(string table, string col)
5050
/// <returns></returns>
5151
publicobjectExecFunc(stringfuncname,object[]param,Type[]types)
5252
{
53-
Typetype=typeof(FuncList);
54-
Objectobj=Activator.CreateInstance(type);
55-
MethodInfomt=type.GetMethod(funcname,types);
56-
if(mt==null)
57-
{
58-
thrownewException($"{funcname}没有获取到相应的函数");
59-
}
60-
returnmt.Invoke(obj,param);
53+
varmethod=typeof(FuncList).GetMethod(funcname);
54+
55+
varreflector=method.GetReflector();
56+
varresult=reflector.Invoke(newFuncList(),param);
57+
//Type type = typeof(FuncList);
58+
//Object obj = Activator.CreateInstance(type);
59+
//MethodInfo mt = type.GetMethod(funcname,types);
60+
//if (mt==null)
61+
//{
62+
// throw new Exception($"{funcname}没有获取到相应的函数");
63+
//}
64+
//return mt.Invoke(obj, param);
65+
returnresult;
6166
}
6267

6368
public(dynamic,int)GetTableData(stringsubtable,intpage,intcount,stringjson,JObjectdd)

‎APIJSON.NET/APIJSON.NET/Startup.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void ConfigureServices(IServiceCollection services)
6060
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
6161
publicvoidConfigure(IApplicationBuilderapp,IHostingEnvironmentenv)
6262
{
63+
app.UseAuthentication();
6364
app.UseMvc(routes =>
6465
{
6566
routes.MapRoute(
@@ -74,7 +75,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
7475
c.SwaggerEndpoint("/swagger/v1/swagger.json","My API V1");
7576

7677
});
77-
app.UseAuthentication();
78+
7879
app.UseJwtTokenMiddleware();
7980
DbInit.Initialize(app);
8081
}

0 commit comments

Comments
(0)