10
10
using SqlSugar ;
11
11
using System . Linq ;
12
12
using APIJSON . NET . Services ;
13
-
13
+ using System . Reflection ;
14
14
15
15
[ Route ( "api/[controller]" ) ]
16
16
[ ApiController ]
@@ -27,6 +27,7 @@ public JsonController(SelectTable _selectTable, DbContext _db,IIdentityService i
27
27
db = _db ;
28
28
_identitySvc = identityService ;
29
29
}
30
+
30
31
/// <summary>
31
32
/// 查询
32
33
/// </summary>
@@ -64,11 +65,11 @@ public ActionResult Query([FromBody]string json)
64
65
{
65
66
string table = tables [ 0 ] ;
66
67
var temp = selectTable . GetTableData ( table , page , count , where [ 0 ] , null ) ;
67
- if ( query > 0 )
68
+ if ( query > 0 )
68
69
{
69
70
total = temp . Item2 ;
70
71
}
71
-
72
+
72
73
foreach ( var dd in temp . Item1 )
73
74
{
74
75
var zht = new JObject ( ) ;
@@ -125,6 +126,34 @@ public ActionResult Query([FromBody]string json)
125
126
}
126
127
ht . Add ( key , htt ) ;
127
128
}
129
+ else if ( key . Equals ( "func" ) )
130
+ {
131
+ jb = JObject . Parse ( item . Value . ToString ( ) ) ;
132
+ Type type = typeof ( MethodList ) ;
133
+ Object obj = Activator . CreateInstance ( type ) ;
134
+ var bb = new JObject ( ) ;
135
+ foreach ( var f in jb )
136
+ {
137
+ var types = new List < Type > ( ) ;
138
+ var param = new List < string > ( ) ;
139
+ foreach ( var va in JArray . Parse ( f . Value . ToString ( ) ) )
140
+ {
141
+ types . Add ( typeof ( string ) ) ;
142
+ param . Add ( va . ToString ( ) ) ;
143
+ }
144
+ MethodInfo mt = type . GetMethod ( f . Key , types . ToArray ( ) ) ;
145
+ if ( mt == null )
146
+ {
147
+ bb . Add ( f . Key , "没有获取到相应的函数!" ) ;
148
+ }
149
+ else
150
+ {
151
+ bb . Add ( f . Key , JToken . FromObject ( mt . Invoke ( obj , param . ToArray ( ) ) ) ) ;
152
+ }
153
+
154
+ }
155
+ ht . Add ( "func" , bb ) ;
156
+ }
128
157
else if ( key . IsTable ( ) )
129
158
{
130
159
var template = selectTable . GetFirstData ( key , item . Value . ToString ( ) , ht ) ;
@@ -137,6 +166,7 @@ public ActionResult Query([FromBody]string json)
137
166
{
138
167
ht . Add ( "total" , total ) ;
139
168
}
169
+
140
170
}
141
171
}
142
172
catch ( Exception ex )
0 commit comments