[关闭]
@puke3615 2016-08-28T09:25:57.000000Z 字数 1179 阅读 1060

ApiGenerator

  1. //传统方式接口编写
  2. public class LoginApi {
  3. public ICall login(String username, String password, int age, CallbackList.IRemoteCompletedCallback<User> callback) {
  4. Map<String, Object> params = new HashMap();
  5. params.put("username", username);
  6. params.put("password", password);
  7. params.put("age", age);
  8. return EasyRemote.getRemote()
  9. .method(MethodEnum.POST)
  10. .apiAndVersionIs("http://www.baidu.com", "1")
  11. .needCache(true)
  12. .parameterIs(params)
  13. .asyncCall(callback);
  14. }
  15. public int queryUser(String username, String password, int age, IRemoteCallback callback) throws Exception {
  16. Map<String, Object> params = new HashMap();
  17. params.put("username", username);
  18. params.put("password", password);
  19. params.put("age", age);
  20. EasyRemote.getRemote()
  21. .method(MethodEnum.POST)
  22. .apiAndVersionIs("http://www.baidu.com", "1")
  23. .needCache(true)
  24. .parameterIs(params)
  25. .asyncCall(callback);
  26. return 0;
  27. }
  28. }
  1. //ApiGenerator方式接口编写
  2. @MWP
  3. public interface LoginApi {
  4. @Api(
  5. api = "http://www.baidu.com",
  6. version = "1"
  7. )
  8. ICall login(String username, String password, int age, @Callback CallbackList.IRemoteCompletedCallback<User> callback);
  9. @Api(
  10. api = "http://www.baidu.com",
  11. version = "1",
  12. method = "POST",
  13. needCache = true
  14. )
  15. int queryUser(String username, String password, int age, @Callback IRemoteCallback callback) throws Exception;
  16. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注