公共文件下载-结构设计

======================================供网关调用==============================================================

class FileDownloadService

  @Autowired
  private ApplicationContext applicationContext;

  private IDownloadService downloadService;

  //获取具体的实现类
  downloadService = applicationContext.getBean(config.getBeanName(), IDownloadService.class);

  this.downloadService.download(req);

===================================================================================================

abstract class AbstractB<T,K>

  void download(){

    ...

    List<T> datas = this.getData(JSONObject.parseObject(download.getDownloadCondition(),this.getQueryClass()));

    ...

  }

 1     /**
 2      * 获取查询泛型的类对象
 3      * @return
 4      */
 5     protected Class<K> getQueryClass(){
 6         Type t = getClass().getGenericSuperclass();
 7         Type[] param = ((ParameterizedType) t).getActualTypeArguments();
 8         Class<K> cls = (Class<K>) param[1];
 9         return cls;
10     }

  public abstract List<T> getData(K k);

=================================================================================================================

class AService

  public List<AVo> getData(ARequest req){...}

原文地址:https://www.cnblogs.com/joke0406/p/10906391.html