File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed
EasyRest/src/main/java/tech/dbgsoftware/easyrest/model/request
Example/Example-Quick-Start/src/main/java/com/example Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -83,11 +83,21 @@ private void analysisMethod(){
8383 MethodInfo methodInfo = cm .getMethodInfo ();
8484 CodeAttribute codeAttribute = methodInfo .getCodeAttribute ();
8585 LocalVariableAttribute attr = (LocalVariableAttribute ) codeAttribute .getAttribute (LocalVariableAttribute .tag );
86- int pos = Modifier .isStatic (cm .getModifiers ()) ? 0 : 1 ;
86+ boolean afterThis = false ;
87+ List <String > paraName = new ArrayList <>(method .getParameters ().length );
88+ for (int i = 0 ; i < attr .tableLength (); i ++) {
89+ String name = attr .variableName (i );
90+ if (!afterThis && name .equalsIgnoreCase ("this" )){
91+ afterThis = true ;
92+ continue ;
93+ }
94+ if (afterThis && paraName .size () < method .getParameters ().length ) {
95+ paraName .add (name );
96+ }
97+ }
8798 for (int i = 0 ; i < method .getParameters ().length ; i ++) {
88- String parameterName = attr .variableName (i + pos );
8999 Type type = method .getParameters ()[i ].getParameterizedType ();
90- parameterTypeMap .put (parameterName , type );
100+ parameterTypeMap .put (paraName . get ( i ) , type );
91101 }
92102 } catch (Exception e ){
93103 e .printStackTrace ();
Original file line number Diff line number Diff line change 22
33import tech .dbgsoftware .easyrest .annotations .method .BindURL ;
44import tech .dbgsoftware .easyrest .annotations .method .Get ;
5+ import tech .dbgsoftware .easyrest .annotations .method .Post ;
6+ import tech .dbgsoftware .easyrest .annotations .parameter .AllDefined ;
57
68@ BindURL ("/test" )
79public interface TestRestService {
810
911 @ Get
1012 String ping ();
1113
14+ @ Post
15+ @ AllDefined
16+ String test (String a , String b );
17+
1218}
Original file line number Diff line number Diff line change @@ -11,4 +11,27 @@ public String ping() {
1111 return ("Pong" );
1212 }
1313
14+ @ Override
15+ public String test (String a , String b ) {
16+ String c ;
17+ String d ;
18+ String e ;
19+ String f ;
20+ String g ;
21+ if (a .equalsIgnoreCase (b )){
22+ c = a ;
23+ d = a ;
24+ e = a ;
25+ f = a ;
26+ g = a ;
27+ } else {
28+ c = a ;
29+ d = b ;
30+ e = "e" ;
31+ f = "f" ;
32+ g = "g" ;
33+ }
34+ return c + "-" + d + "-" + e + "-" + f + "-" + g ;
35+ }
36+
1437}
You can’t perform that action at this time.
0 commit comments