|
24 | 24 | import act.app.DevModeClassLoader; |
25 | 25 | import act.app.Source; |
26 | 26 | import act.app.data.StringValueResolverManager; |
27 | | -import act.db.DbBind; |
28 | 27 | import act.handler.RequestHandler; |
29 | 28 | import act.handler.builtin.controller.RequestHandlerProxy; |
30 | 29 | import act.handler.builtin.controller.impl.ReflectedHandlerInvoker; |
|
40 | 39 | import org.osgl.mvc.result.Result; |
41 | 40 | import org.osgl.storage.ISObject; |
42 | 41 | import org.osgl.util.C; |
| 42 | +import org.osgl.util.Generics; |
43 | 43 | import org.osgl.util.N; |
44 | 44 | import org.osgl.util.StringValueResolver; |
45 | 45 | import org.rythmengine.utils.S; |
@@ -339,10 +339,10 @@ private ParamInfo paramInfo(Type type, Annotation[] annos, DependencyInjector in |
339 | 339 | if (ParamValueLoaderService.providedButNotDbBind(spec, injector)) { |
340 | 340 | return null; |
341 | 341 | } |
342 | | - if (spec.hasAnnotation(DbBind.class)) { |
| 342 | + if (ParamValueLoaderService.hasDbBind(spec.allAnnotations())) { |
343 | 343 | return new ParamInfo(name, BeanSpec.of(String.class, Act.injector()), name + " id"); |
344 | 344 | } |
345 | | - String description = spec.toString(); |
| 345 | + String description = spec.rawType().getSimpleName(); |
346 | 346 | Description descAnno = spec.getAnnotation(Description.class); |
347 | 347 | if (null != descAnno) { |
348 | 348 | description = descAnno.value(); |
@@ -462,19 +462,36 @@ private static Object generateSampleData(BeanSpec spec, Set<Class<?>> typeChain) |
462 | 462 | return null; |
463 | 463 | } else if (Map.class.isAssignableFrom(type)) { |
464 | 464 | Map map = $.cast(Act.getInstance(type)); |
465 | | - Type keyType = spec.typeParams().get(0); |
466 | | - Type valType = spec.typeParams().get(1); |
467 | | - map.put( |
468 | | - generateSampleData(BeanSpec.of(keyType, null, Act.injector()), typeChain), |
469 | | - generateSampleData(BeanSpec.of(valType, null, Act.injector()), typeChain)); |
470 | | - map.put( |
471 | | - generateSampleData(BeanSpec.of(keyType, null, Act.injector()), typeChain), |
472 | | - generateSampleData(BeanSpec.of(valType, null, Act.injector()), typeChain)); |
| 465 | + List<Type> typeParams = spec.typeParams(); |
| 466 | + if (typeParams.isEmpty()) { |
| 467 | + typeParams = Generics.typeParamImplementations(type, Map.class); |
| 468 | + } |
| 469 | + if (typeParams.size() < 2) { |
| 470 | + map.put(S.random(), S.random()); |
| 471 | + map.put(S.random(), S.random()); |
| 472 | + } else { |
| 473 | + Type keyType = typeParams.get(0); |
| 474 | + Type valType = typeParams.get(1); |
| 475 | + map.put( |
| 476 | + generateSampleData(BeanSpec.of(keyType, null, Act.injector()), typeChain), |
| 477 | + generateSampleData(BeanSpec.of(valType, null, Act.injector()), typeChain)); |
| 478 | + map.put( |
| 479 | + generateSampleData(BeanSpec.of(keyType, null, Act.injector()), typeChain), |
| 480 | + generateSampleData(BeanSpec.of(valType, null, Act.injector()), typeChain)); |
| 481 | + } |
473 | 482 | } else if (Iterable.class.isAssignableFrom(type)) { |
474 | 483 | Collection col = $.cast(Act.getInstance(type)); |
475 | | - Type componentType = spec.typeParams().get(0); |
476 | | - col.add(generateSampleData(BeanSpec.of(componentType, null, Act.injector()), typeChain)); |
477 | | - col.add(generateSampleData(BeanSpec.of(componentType, null, Act.injector()), typeChain)); |
| 484 | + List<Type> typeParams = spec.typeParams(); |
| 485 | + if (typeParams.isEmpty()) { |
| 486 | + typeParams = Generics.typeParamImplementations(type, Map.class); |
| 487 | + } |
| 488 | + if (typeParams.isEmpty()) { |
| 489 | + col.add(S.random()); |
| 490 | + } else { |
| 491 | + Type componentType = typeParams.get(0); |
| 492 | + col.add(generateSampleData(BeanSpec.of(componentType, null, Act.injector()), typeChain)); |
| 493 | + col.add(generateSampleData(BeanSpec.of(componentType, null, Act.injector()), typeChain)); |
| 494 | + } |
478 | 495 | return col; |
479 | 496 | } |
480 | 497 |
|
|
0 commit comments