Commit 4c655484 by 严久程

课程列表页促销标签

parents b447274c 34f3b72b
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
#org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
#org.gradle.parallel=true
# org.gradle.parallel=true
#org.gradle.parallel=true
android.useDeprecatedNdk=true
android.enableAapt2=false
# pack:test|prod|pre test测试 prod正式
#pack=pre
#pack=auto_test
#pack=test
pack=prod
#予发布环境
#http://prem.yidianling.com/
#server php服务器api域名
serverurl.test=https://testapp2.yidianling.com/v3/
serverurl.auto_test=https://auto_testapp2.yidianling.com/v3/
serverurl.prod=https://app2.yidianling.com/v3/
serverurl.pre=https://preapp.yidianling.com/v3/
#行为数据埋点域名
actionurl.test=https://testapi.ydl.com/api/data/bigdata/
actionurl.auto_test=https://auto_testapi.ydl.com/api/data/bigdata/
actionurl.prod=https://api.ydl.com/api/data/bigdata/
#新h5
weburl.test=https://testwebapp.ydl.com/
weburl.auto_test=https://auto_testwebapp.ydl.com/
weburl.prod=https://webapp.ydl.com/
#ydlh5
ydlh5url.test=https://testh5.ydl.com/
ydlh5url.auto_test=https://auto_testh5.ydl.com/
#ydlh5url.test=http://192.168.204.5:3006/
ydlh5url.prod=https://h5.ydl.com/
#h5
h5url.test=https://testh2.yidianling.com/
h5url.auto_test=https://auto_testh2.yidianling.com/
h5url.prod=https://h2.yidianling.com/
h5url.pre=https://preh.yidianling.com/
#java服务器api域名(投放系统)
javaurl.test = http://testdelivery.yidianling.com/
javaurl.auto_test = http://auto_testdelivery.yidianling.com/
javaurl.prod = https://delivery.yidianling.com/
#m站H5地址
mh5url.test = https://testnewm.ydl.com/
mh5url.auto_test = https://auto_testnewm.ydl.com/
mh5url.prod = https://m.ydl.com/
#java服务器api域名(优惠券)
javacouponurl.test = https://testapi.ydl.com/
javacouponurl.auto_test = https://auto_testapi.ydl.com/
javacouponurl.prod = https://api.ydl.com/
#java服务器api域名(h5耗时统计,域名问题后续服务端会统一)
javatempurl.test = https://47.97.49.44:8082/api/
javatempurl.prod = https://dc.ydl.com/api/
#java服务器api统一域名
javaapi.test = https://testapi.ydl.com/api/
javaapi.auto_test = https://auto_testapi.ydl.com/api/
javaapi.prod = https://api.ydl.com/api/
#android.enableBuildCache=true
#org.gradle.caching=true
#org.gradle.daemon=true
#org.gradle.jvmargs=-Xmx4096M
#systemProp.http.proxyHost=192.168.98.150
#systemProp.http.proxyPort=8123
org.gradle.jvmargs=-Xmx1024M
...@@ -13,7 +13,6 @@ import android.util.Log ...@@ -13,7 +13,6 @@ import android.util.Log
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import com.umeng.analytics.MobclickAgent import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.framework.UMModuleRegister.getAppContext
import com.ydl.audioim.YDLavManager import com.ydl.audioim.YDLavManager
import com.ydl.component.music.MusicPlayActivity import com.ydl.component.music.MusicPlayActivity
import com.ydl.component.mvp.DemoContract import com.ydl.component.mvp.DemoContract
...@@ -137,7 +136,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -137,7 +136,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override fun reLoadData() { override fun reLoadData() {
mPresenter?.loadUsers() mPresenter.loadHome()
} }
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
package com.ydl.component.base; package com.ydl.component.base;
import android.content.Context; import android.content.Context;
import com.ydl.component.BuildConfig; import com.ydl.component.BuildConfig;
import com.ydl.ydlcommon.base.config.GlobalConfig;
import com.ydl.ydlcommon.base.config.IConfigModule; import com.ydl.ydlcommon.base.config.IConfigModule;
import com.ydl.ydlcommon.base.config.YDLConstants; import com.ydl.ydlcommon.base.config.YDLConstants;
import com.ydl.ydlcommon.base.delegate.IAppLifecycles; import com.ydl.ydlcommon.base.delegate.IAppLifecycles;
import com.ydl.ydlcommon.base.config.GlobalConfig;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
...@@ -27,9 +25,13 @@ public final class DemoGlobalConfig implements IConfigModule { ...@@ -27,9 +25,13 @@ public final class DemoGlobalConfig implements IConfigModule {
@Override @Override
public void applyOptions(@NotNull Context context, @NotNull GlobalConfig.Builder builder) { public void applyOptions(@NotNull Context context, @NotNull GlobalConfig.Builder builder) {
builder.setFrom("ydl".equals(BuildConfig.FLAVOR) ? YDLConstants.FROM_YDL : YDLConstants.FROM_XLZX) // String env = YDLConstants.ENV_AUTO_TEST;
// String env = YDLConstants.ENV_PROD;
String env = YDLConstants.ENV_TEST;
builder.setFrom( "ydl".equals(BuildConfig.FLAVOR) ?YDLConstants.FROM_YDL :YDLConstants.FROM_XLZX)
.addUrl("github", APP_DOMAIN) .addUrl("github", APP_DOMAIN)
.setEnv(YDLConstants.ENV_TEST) .setEnv(env)
.setDebug(BuildConfig.DEBUG); .setDebug(BuildConfig.DEBUG);
} }
} }
...@@ -39,6 +39,10 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(), ...@@ -39,6 +39,10 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(),
} }
override fun onSuccess(users: JsonObject) { override fun onSuccess(users: JsonObject) {
if (users.getAsJsonObject("data")==null){
mView.setData("")
return
}
var cateTitle = users.getAsJsonObject("data").getAsJsonArray("askCategoryData").get(0).asJsonObject.get("cateTitle").asString; var cateTitle = users.getAsJsonObject("data").getAsJsonArray("askCategoryData").get(0).asJsonObject.get("cateTitle").asString;
mView.setData(cateTitle) mView.setData(cateTitle)
} }
......
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = false dev_mode = true
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
...@@ -44,12 +44,12 @@ ext { ...@@ -44,12 +44,12 @@ ext {
//第三步 若干 //第三步 若干
"m-confide" : "0.0.29", "m-confide" : "0.0.29",
"m-consultant" : "0.0.42", "m-consultant" : "0.0.44",
"m-course" : "0.0.30", "m-course" : "0.0.30",
"m-fm" : "0.0.21", "m-fm" : "0.0.21",
"m-muse" : "0.0.19", "m-muse" : "0.0.19",
"m-tests" : "0.0.12", "m-tests" : "0.0.12",
"m-user" : "0.0.34", "m-user" : "0.0.37",
//-------------- 业务模块 API 层 -------------- //-------------- 业务模块 API 层 --------------
...@@ -64,7 +64,7 @@ ext { ...@@ -64,7 +64,7 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.27", "ydl-platform" : "0.0.28.3",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.28", "ydl-webview" : "0.0.28",
...@@ -74,7 +74,7 @@ ext { ...@@ -74,7 +74,7 @@ ext {
//以下 几乎不会动 //以下 几乎不会动
"router" : "0.0.1", "router" : "0.0.1",
"ydl-net" : "0.0.2", "ydl-net" : "0.0.3",
"ydl-utils" : "0.0.3", "ydl-utils" : "0.0.3",
"ydl-flutter-base": "0.0.3", "ydl-flutter-base": "0.0.3",
] ]
...@@ -101,7 +101,7 @@ ext { ...@@ -101,7 +101,7 @@ ext {
//-------------- 功能组件 -------------- //-------------- 功能组件 --------------
//第一步 //第一步
"ydl-platform" : "0.0.27", "ydl-platform" : "0.0.28.3",
//第二步 若干 //第二步 若干
"ydl-webview" : "0.0.28", "ydl-webview" : "0.0.28",
...@@ -112,7 +112,7 @@ ext { ...@@ -112,7 +112,7 @@ ext {
//以下 几乎不会动 //以下 几乎不会动
"router" : "0.0.1", "router" : "0.0.1",
"ydl-net" : "0.0.2", "ydl-net" : "0.0.3",
"ydl-utils" : "0.0.3", "ydl-utils" : "0.0.3",
"ydl-flutter-base": "0.0.3", "ydl-flutter-base": "0.0.3",
] ]
......
...@@ -13,13 +13,11 @@ import com.ydl.ydlcommon.data.http.RxUtils ...@@ -13,13 +13,11 @@ import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.mvp.base.BasePresenter import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.mvp.base.IView import com.ydl.ydlcommon.mvp.base.IView
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import com.ydl.ydlcommon.utils.YDLAsyncUtils import com.ydl.ydlcommon.utils.YDLAsyncUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.yidianling.common.tools.RxNetTool import com.yidianling.common.tools.RxNetTool
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
/** /**
* @author yuanwai * @author yuanwai
...@@ -54,7 +52,7 @@ class ConfideHomePresenterImpl : BasePresenter<IConfideHomeContract.View,IConfid ...@@ -54,7 +52,7 @@ class ConfideHomePresenterImpl : BasePresenter<IConfideHomeContract.View,IConfid
override fun asyncResult(`object`: Any?) { override fun asyncResult(`object`: Any?) {
//如果没有缓存数据,显示加载框 //如果没有缓存数据,显示加载框
if (`object` !is String || TextUtils.isEmpty(`object`)){ if (`object` !is String || TextUtils.isEmpty(`object`)){
mView.showProgress() mView.showLoading()
} }
if (`object` is String){ if (`object` is String){
...@@ -82,20 +80,8 @@ class ConfideHomePresenterImpl : BasePresenter<IConfideHomeContract.View,IConfid ...@@ -82,20 +80,8 @@ class ConfideHomePresenterImpl : BasePresenter<IConfideHomeContract.View,IConfid
val disposable = mModel.confideHomeRequest() val disposable = mModel.confideHomeRequest()
.map { it } .map { it }
.filter { it != null } .filter { it != null }
.subscribeOn(Schedulers.io()) .compose(RxUtils.applySchedulers(mView as IView))
.doOnSubscribe { .doFinally { mView.hideLoading() }
if (!isRefresh){
mView.showLoading()//显示进度条
}
}
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doFinally {
if (!isRefresh){
mView.hideLoading()//隐藏进度条
}
}.compose(RxLifecycleUtils.bindToLifecycle(mView))
.subscribe(Consumer { .subscribe(Consumer {
mView.confideHomeResponse(it) mView.confideHomeResponse(it)
updateCache(it) updateCache(it)
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
/> />
<com.ydl.ydlcommon.mvp.lce.view.YDLStateView <com.ydl.ydlcommon.mvp.lce.view.YDLStateView
android:visibility="gone"
android:id="@+id/lce_state_view" android:id="@+id/lce_state_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -44,9 +44,11 @@ class ConsultAssistantDialogUtils private constructor() { ...@@ -44,9 +44,11 @@ class ConsultAssistantDialogUtils private constructor() {
} }
} }
"doctor_list" -> { "doctor_list" -> {
if (!ConsultantIn.isLogin() || (ConsultantIn.getUserImpl().getUserInfo()?.user_type == 1 && ConsultantIn.isLogin())) {
shouldShowDialog(activity, origin, fromActivity = fromActivity) shouldShowDialog(activity, origin, fromActivity = fromActivity)
} }
} }
}
} }
......
...@@ -2,20 +2,36 @@ package com.yidianling.course.net; ...@@ -2,20 +2,36 @@ package com.yidianling.course.net;
import com.ydl.ydlcommon.data.http.BaseAPIResponse; import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.ydl.ydlcommon.data.http.BaseResponse; import com.ydl.ydlcommon.data.http.BaseResponse;
import com.yidianling.course.bean.*; import com.yidianling.course.bean.CouponHintResponseBean;
import com.yidianling.course.bean.Course;
import com.yidianling.course.bean.CourseAddOrderBean;
import com.yidianling.course.bean.CourseCouponBean;
import com.yidianling.course.bean.CourseListDataBean;
import com.yidianling.course.bean.CourseMediaDetailBean;
import com.yidianling.course.bean.CoursePlayBean;
import com.yidianling.course.bean.PostersShareBean;
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean; import com.yidianling.course.course_special_list.bean.CourseSpecialListBean;
import com.yidianling.course.model.CourseCategoryBean; import com.yidianling.course.model.CourseCategoryBean;
import com.yidianling.course.model.TopicCourseBean; import com.yidianling.course.model.TopicCourseBean;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.QueryMap;
import retrofit2.http.Url;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_COUPON_URL;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA_URL;
/** /**
* Created by Jim on 2018/2/26 0026. * Created by Jim on 2018/2/26 0026.
...@@ -88,7 +104,7 @@ public interface NetApiStore { ...@@ -88,7 +104,7 @@ public interface NetApiStore {
* @return * @return
*/ */
@GET("marketing/coupon/new/available") @GET("marketing/coupon/new/available")
@Headers(YDL_DOMAIN + YDL_DOMAIN_COUPON_URL) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA_URL)
Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(@Query("uid") String uid, Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(@Query("uid") String uid,
@Query("services") String services, @Query("services") String services,
@Query("receiveType") String receiveType, @Query("receiveType") String receiveType,
...@@ -96,7 +112,7 @@ public interface NetApiStore { ...@@ -96,7 +112,7 @@ public interface NetApiStore {
//领取优惠券 //领取优惠券
@POST("marketing/coupon/new/receives") @POST("marketing/coupon/new/receives")
@Headers(YDL_DOMAIN + YDL_DOMAIN_COUPON_URL) @Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA_URL)
Observable<BaseResponse<List<String>>> receiveCoupon(@Body RequestBody body); Observable<BaseResponse<List<String>>> receiveCoupon(@Body RequestBody body);
......
...@@ -10,7 +10,8 @@ class UserBIConstants { ...@@ -10,7 +10,8 @@ class UserBIConstants {
const val OS = "Android" //android系统 const val OS = "Android" //android系统
//用户埋点板块 //用户埋点板块
const val PART_ID_LOGIN_MAIN = "login_main|" const val PART_ID_LOGIN_MAIN = "login_main"
const val PART_ID_LOGIN_MAIN_PREFIX = "login_main|"
//咨询筛选页 //咨询筛选页
const val PART_ID_CONSULT_FILTER_PAGE = "consult_filter_page" const val PART_ID_CONSULT_FILTER_PAGE = "consult_filter_page"
//百度监测 应用启动行为 //百度监测 应用启动行为
...@@ -41,12 +42,12 @@ class UserBIConstants { ...@@ -41,12 +42,12 @@ class UserBIConstants {
* action type * action type
* 行为数据埋点,sign1字段 是对同一key下多种不同行为的描述 * 行为数据埋点,sign1字段 是对同一key下多种不同行为的描述
*/ */
const val ACTION_TYPE_CODE_LOGIN: String = PART_ID_LOGIN_MAIN+"code_login" //验证码登录 const val ACTION_TYPE_CODE_LOGIN: String = PART_ID_LOGIN_MAIN_PREFIX+"code_login" //验证码登录
const val ACTION_TYPE_RESET_PWD: String = PART_ID_LOGIN_MAIN+"reset_pwd" //重置密码登录 const val ACTION_TYPE_RESET_PWD: String = PART_ID_LOGIN_MAIN_PREFIX+"reset_pwd" //重置密码登录
const val ACTION_TYPE_PWD_LOGIN: String = PART_ID_LOGIN_MAIN+"pwd_login" //手机号密码登录 const val ACTION_TYPE_PWD_LOGIN: String = PART_ID_LOGIN_MAIN_PREFIX+"pwd_login" //手机号密码登录
const val ACTION_TYPE_DIRECT_LOGIN: String = PART_ID_LOGIN_MAIN+"direct_login" //一键登录 const val ACTION_TYPE_DIRECT_LOGIN: String = PART_ID_LOGIN_MAIN_PREFIX+"direct_login" //一键登录
const val ACTION_TYPE_QQ_THIRD_LOGIN: String = PART_ID_LOGIN_MAIN+"qq_login" //QQ登录 const val ACTION_TYPE_QQ_THIRD_LOGIN: String = PART_ID_LOGIN_MAIN_PREFIX+"qq_login" //QQ登录
const val ACTION_TYPE_WX_THIRD_LOGIN: String = PART_ID_LOGIN_MAIN+"wx_login" //WX登录 const val ACTION_TYPE_WX_THIRD_LOGIN: String = PART_ID_LOGIN_MAIN_PREFIX+"wx_login" //WX登录
} }
//====================壹点灵用户版首页(ydl_user_main_page)==================== //====================壹点灵用户版首页(ydl_user_main_page)====================
......
...@@ -2,6 +2,7 @@ package com.ydl.ydlnet.builder.config; ...@@ -2,6 +2,7 @@ package com.ydl.ydlnet.builder.config;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import com.ydl.ydlnet.builder.cookie.CookieJarImpl; import com.ydl.ydlnet.builder.cookie.CookieJarImpl;
import com.ydl.ydlnet.builder.cookie.store.CookieStore; import com.ydl.ydlnet.builder.cookie.store.CookieStore;
import com.ydl.ydlnet.builder.factory.ApiFactory; import com.ydl.ydlnet.builder.factory.ApiFactory;
...@@ -9,19 +10,22 @@ import com.ydl.ydlnet.builder.http.SSLUtils; ...@@ -9,19 +10,22 @@ import com.ydl.ydlnet.builder.http.SSLUtils;
import com.ydl.ydlnet.builder.interceptor.HeaderInterceptor; import com.ydl.ydlnet.builder.interceptor.HeaderInterceptor;
import com.ydl.ydlnet.builder.interceptor.NetCacheInterceptor; import com.ydl.ydlnet.builder.interceptor.NetCacheInterceptor;
import com.ydl.ydlnet.builder.interceptor.NoNetCacheInterceptor; import com.ydl.ydlnet.builder.interceptor.NoNetCacheInterceptor;
import com.ydl.ydlnet.builder.interceptor.log.RequestHandler;
import com.ydl.ydlnet.builder.interceptor.log.RequestLogInterceptor; import com.ydl.ydlnet.builder.interceptor.log.RequestLogInterceptor;
import com.ydl.ydlnet.builder.manage.HttpUrlManager; import com.ydl.ydlnet.builder.manage.HttpUrlManager;
import com.ydl.ydlnet.client.interfaces.BuildHeadersListener; import com.ydl.ydlnet.client.interfaces.BuildHeadersListener;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import javax.net.ssl.HostnameVerifier;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
/** /**
* Created by haorui on 2019-09-02 . * Created by haorui on 2019-09-02 .
* Des: 统一OkHttp配置信息 * Des: 统一OkHttp配置信息
...@@ -80,6 +84,7 @@ public class OkHttpConfig { ...@@ -80,6 +84,7 @@ public class OkHttpConfig {
private InputStream bksFile; private InputStream bksFile;
private String password; private String password;
private InputStream[] certificates; private InputStream[] certificates;
private RequestHandler requestHandler;
private Interceptor[] interceptors; private Interceptor[] interceptors;
private Interceptor[] netInterceptors; private Interceptor[] netInterceptors;
private BuildHeadersListener buildHeadersListener; private BuildHeadersListener buildHeadersListener;
...@@ -99,6 +104,11 @@ public class OkHttpConfig { ...@@ -99,6 +104,11 @@ public class OkHttpConfig {
return this; return this;
} }
public Builder setRequestHandler(RequestHandler requestHandler) {
this.requestHandler= requestHandler;
return this;
}
public Builder setCache(boolean isCache) { public Builder setCache(boolean isCache) {
this.isCache = isCache; this.isCache = isCache;
return this; return this;
...@@ -210,9 +220,7 @@ public class OkHttpConfig { ...@@ -210,9 +220,7 @@ public class OkHttpConfig {
* 配置开发环境 * 配置开发环境
*/ */
private void setDebugConfig() { private void setDebugConfig() {
if (isDebug) { okHttpClientBuilder.addInterceptor(new RequestLogInterceptor(isDebug,requestHandler));
okHttpClientBuilder.addInterceptor(new RequestLogInterceptor());
}
} }
......
package com.ydl.ydlnet.builder.interceptor.log;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/**
* Created by haorui on 2019-11-26 .
* Des:
*/
public interface RequestHandler {
Response onHttpResultResponse(String httpResult, Interceptor.Chain chain, Response response);
Request onHttpRequestBefore(Interceptor.Chain chain, Request request);
RequestHandler EMPTY = new RequestHandler() {
@Override
public Response onHttpResultResponse(String httpResult, Interceptor.Chain chain, Response response) {
//不管是否处理,都必须将response返回出去
return response;
}
@Override
public Request onHttpRequestBefore(Interceptor.Chain chain, Request request) {
//不管是否处理,都必须将request返回出去
return request;
}
};
}
package com.ydl.ydlnet.builder.interceptor.log; package com.ydl.ydlnet.builder.interceptor.log;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.ydl.ydlnet.utils.CharacterHandler; import com.ydl.ydlnet.utils.CharacterHandler;
import com.ydl.ydlnet.utils.NetLogUtils; import com.ydl.ydlnet.utils.NetLogUtils;
import com.ydl.ydlnet.utils.UrlEncoderUtils; import com.ydl.ydlnet.utils.UrlEncoderUtils;
import com.ydl.ydlnet.utils.ZipHelper; import com.ydl.ydlnet.utils.ZipHelper;
import okhttp3.*;
import okio.Buffer;
import okio.BufferedSource;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
...@@ -15,14 +13,27 @@ import java.net.URLDecoder; ...@@ -15,14 +13,27 @@ import java.net.URLDecoder;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okio.Buffer;
import okio.BufferedSource;
/** /**
* Created by haorui on 2019-09-01 . * Created by haorui on 2019-09-01 .
* Des: 解析框架中的网络请求和响应结果并打印 * Des: 解析框架中的网络请求和响应结果并打印
*/ */
public class RequestLogInterceptor implements Interceptor { public class RequestLogInterceptor implements Interceptor {
private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter(); private DefaultFormatPrinter mPrinter = new DefaultFormatPrinter();
private boolean mIsDebug ;
private RequestHandler mRequestHandler;
public RequestLogInterceptor() { public RequestLogInterceptor(boolean isDebug, RequestHandler requestHandler) {
this.mIsDebug = isDebug;
this.mRequestHandler = requestHandler;
} }
@Override @Override
...@@ -36,6 +47,8 @@ public class RequestLogInterceptor implements Interceptor { ...@@ -36,6 +47,8 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter.printFileRequest(request); mPrinter.printFileRequest(request);
} }
if (mRequestHandler != null)
request = mRequestHandler.onHttpRequestBefore(chain, request);
long t1 =System.nanoTime() ; long t1 =System.nanoTime() ;
Response originalResponse; Response originalResponse;
...@@ -55,6 +68,10 @@ public class RequestLogInterceptor implements Interceptor { ...@@ -55,6 +68,10 @@ public class RequestLogInterceptor implements Interceptor {
bodyString = printResult(request, originalResponse); bodyString = printResult(request, originalResponse);
} }
if (mRequestHandler != null)
mRequestHandler.onHttpResultResponse(bodyString, chain, originalResponse);
if(mIsDebug) {
final List<String> segmentList = request.url().encodedPathSegments(); final List<String> segmentList = request.url().encodedPathSegments();
final String header = originalResponse.headers().toString(); final String header = originalResponse.headers().toString();
final int code = originalResponse.code(); final int code = originalResponse.code();
...@@ -69,6 +86,7 @@ public class RequestLogInterceptor implements Interceptor { ...@@ -69,6 +86,7 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1), mPrinter.printFileResponse(TimeUnit.NANOSECONDS.toMillis(t2 - t1),
isSuccessful, code, header, segmentList, message, url); isSuccessful, code, header, segmentList, message, url);
} }
}
return originalResponse; return originalResponse;
} }
......
...@@ -5,5 +5,7 @@ package com.ydl.ydlcommon.base.config ...@@ -5,5 +5,7 @@ package com.ydl.ydlcommon.base.config
* Des: * Des:
*/ */
const val YDL_DOMAIN = "Domain-Name:" const val YDL_DOMAIN = "Domain-Name:"
//JAVA Api 地址
const val YDL_DOMAIN_JAVA = "JAVA_BASE_URL" const val YDL_DOMAIN_JAVA = "JAVA_BASE_URL"
const val YDL_DOMAIN_COUPON_URL = "SERVER_COUPON_URL" //JAVA 域名
const val YDL_DOMAIN_JAVA_URL = "YDL_DOMAIN_JAVA_URL"
...@@ -83,7 +83,7 @@ class GlobalConfig private constructor(var builder: Builder) { ...@@ -83,7 +83,7 @@ class GlobalConfig private constructor(var builder: Builder) {
.config() .config()
.setBaseUrl(appBaseURL ?: HttpConfig.PHP_BASE_URL) .setBaseUrl(appBaseURL ?: HttpConfig.PHP_BASE_URL)
.addUrl(YDL_DOMAIN_JAVA, HttpConfig.JAVA_BASE_URL) .addUrl(YDL_DOMAIN_JAVA, HttpConfig.JAVA_BASE_URL)
.addUrl(YDL_DOMAIN_COUPON_URL, HttpConfig.SERVER_COUPON_URL) .addUrl(YDL_DOMAIN_JAVA_URL, HttpConfig.JAVA_URL)
.setMultipleUrlMap(multipleUrl) .setMultipleUrlMap(multipleUrl)
if (okHttpClient == null) { if (okHttpClient == null) {
...@@ -91,6 +91,7 @@ class GlobalConfig private constructor(var builder: Builder) { ...@@ -91,6 +91,7 @@ class GlobalConfig private constructor(var builder: Builder) {
} }
apiFactory.setOkClient(okHttpClient) apiFactory.setOkClient(okHttpClient)
HttpConfig.getInstance().initAuth()
} }
} }
......
package com.ydl.ydlcommon.base.config package com.ydl.ydlcommon.base.config
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.text.TextUtils import android.text.TextUtils
import com.facebook.stetho.okhttp3.StethoInterceptor import com.facebook.stetho.okhttp3.StethoInterceptor
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.bean.AuthBean
import com.ydl.ydlcommon.data.PlatformDataManager import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.EncryptUtils import com.ydl.ydlcommon.data.http.EncryptUtils
import com.ydl.ydlcommon.data.http.GsonProvider
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.api.ApiRequestUtil
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.YDLCacheUtils import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlnet.builder.config.OkHttpConfig import com.ydl.ydlnet.builder.config.OkHttpConfig
import com.ydl.ydlnet.builder.interceptor.log.RequestHandler
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool import com.yidianling.common.tools.RxDeviceTool
import okhttp3.FormBody import com.yidianling.common.tools.ToastUtil
import okhttp3.Interceptor import okhttp3.*
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okio.Buffer import okio.Buffer
import okio.BufferedSink import okio.BufferedSink
import java.util.* import java.util.*
...@@ -32,7 +38,10 @@ class HttpConfig { ...@@ -32,7 +38,10 @@ class HttpConfig {
//====================应用默认配置==================== //====================应用默认配置====================
private const val AUTHORIZATION_NAME = "Authorization" private const val AUTHORIZATION_NAME = "Authorization"
private const val AUTHORIZATION_JAVA_NAME = "AuthorizationJava"
private const val SESSION_KEY = "dc59cf294f37d237c1f06240568ffe21" private const val SESSION_KEY = "dc59cf294f37d237c1f06240568ffe21"
private var DYNAMIC_SESSION_KEY :String= "dc59cf294f37d237c1f06240568ffe21"
private const val YDL = "Ydl" private const val YDL = "Ydl"
private const val UID = "uid" private const val UID = "uid"
private const val FFROM = "ffrom" private const val FFROM = "ffrom"
...@@ -43,18 +52,49 @@ class HttpConfig { ...@@ -43,18 +52,49 @@ class HttpConfig {
private const val TOKEN = "accessToken" private const val TOKEN = "accessToken"
private val OS_TYPE = "osType"// 1.ios 2.android private val OS_TYPE = "osType"// 1.ios 2.android
private val APP_NAME = "appName"//用于标识 是哪个应用 yidianling:用户版 xinlizixun:心理咨询 haoshi:情感壹点灵 zhuanjia:专家版 private val APP_NAME = "appName"//用于标识 是哪个应用 yidianling:用户版 xinlizixun:心理咨询 haoshi:情感壹点灵 zhuanjia:专家版
//验证签名失败
private val AUTH_INEFFECTIVE_CODE = "-201"
//====================网络环境==================== //====================网络环境====================
/**
* PHP API 地址
*/
var PHP_BASE_URL = "" var PHP_BASE_URL = ""
/**
* Java API 地址
*/
var JAVA_BASE_URL = "" var JAVA_BASE_URL = ""
/**
* YDL H5 地址
*/
var YDL_H5 = "" var YDL_H5 = ""
/**
* H5 地址
*/
var H5_URL = "" var H5_URL = ""
/**
* M站 地址
*/
var MH5_URL = "" var MH5_URL = ""
/**
* 新 H5 地址
*/
var WEB_URL = "" var WEB_URL = ""
var SERVER_COUPON_URL = "" /**
* Java API 域名
*/
var JAVA_URL = ""
/**
* h5耗时统计 java服务器api地址
*/
var SERVER_TEMP_JAVA_URL = "" var SERVER_TEMP_JAVA_URL = ""
var SERVER_API_JAVA_URL = "" /**
* Java 投放系统 地址
*/
var JAVA_CAST_URL = ""
/**
* 行为数据 地址
*/
var ACTION_URL = "" var ACTION_URL = ""
fun getInstance(): HttpConfig { fun getInstance(): HttpConfig {
...@@ -75,6 +115,7 @@ class HttpConfig { ...@@ -75,6 +115,7 @@ class HttpConfig {
return builder return builder
.setInterceptor(commonParams(),requestHead(appFrom)) .setInterceptor(commonParams(),requestHead(appFrom))
.setRequestHandler(getRequestHandler())
.setReadTimeout(15) .setReadTimeout(15)
.setWriteTimeout(15) .setWriteTimeout(15)
.setConnectTimeout(15) .setConnectTimeout(15)
...@@ -82,6 +123,35 @@ class HttpConfig { ...@@ -82,6 +123,35 @@ class HttpConfig {
.build() .build()
} }
private fun getRequestHandler():RequestHandler{
return object :RequestHandler{
override fun onHttpResultResponse(
httpResult: String,
chain: Interceptor.Chain,
response: Response
): Response {
val gson = GsonProvider.getGson()
val resultData= gson.fromJson(httpResult, BaseAPIResponse::class.java)
when (resultData.code) {
AUTH_INEFFECTIVE_CODE -> {
//签证签名失败
ToastUtil.toastShort(resultData.msg)
//更新动态密钥
if (resultData.data!=null){
var authBean = gson.fromJson<AuthBean>(gson.toJson(resultData.data),AuthBean::class.java)
DYNAMIC_SESSION_KEY = authBean?.appKey.toString()
}
}
}
return response
}
override fun onHttpRequestBefore(chain: Interceptor.Chain?, request: Request): Request {
return request
}
}
}
// 添加公共参数 // 添加公共参数
private fun commonParams(): Interceptor { private fun commonParams(): Interceptor {
...@@ -178,9 +248,10 @@ class HttpConfig { ...@@ -178,9 +248,10 @@ class HttpConfig {
private fun requestHead(appFrom: String): Interceptor { private fun requestHead(appFrom: String): Interceptor {
return Interceptor { return Interceptor {
val request = it.request() val request = it.request()
val body = request.body()
val paramsString = StringBuilder() val paramsString = StringBuilder()
val params = ArrayList<Param>() val params = ArrayList<Param>()
if ("POST"==request.method()){
val body = request.body()
if (body is FormBody) { if (body is FormBody) {
(0 until body.size()).mapTo(destination = params) { (0 until body.size()).mapTo(destination = params) {
Param( Param(
...@@ -202,6 +273,14 @@ class HttpConfig { ...@@ -202,6 +273,14 @@ class HttpConfig {
} }
} }
} }
} else if ("GET"==request.method()){
val url = request.url()
val queryParameterNames = url.queryParameterNames()
queryParameterNames.forEach { string ->
params.add(Param(string, url.queryParameter(string)?:""))
}
}
params.sortWith(Comparator { o1, o2 -> params.sortWith(Comparator { o1, o2 ->
val res = o1.name.compareTo(o2.name) val res = o1.name.compareTo(o2.name)
when { when {
...@@ -214,14 +293,14 @@ class HttpConfig { ...@@ -214,14 +293,14 @@ class HttpConfig {
if (index != 0) paramsString.append("&") if (index != 0) paramsString.append("&")
paramsString.append("${param.name}=${param.value}") paramsString.append("${param.name}=${param.value}")
} }
paramsString.append(SESSION_KEY)
val head = "$YDL ${EncryptUtils.encryptMD5ToString( val oldAuth = getOldAuth(paramsString)
paramsString.toString() val newAuth = getNewAuth(paramsString)
)}"
val builder = it.request() val builder = it.request()
.newBuilder() .newBuilder()
.header(AUTHORIZATION_NAME, head) .header(AUTHORIZATION_NAME, oldAuth)
.header(AUTHORIZATION_JAVA_NAME, newAuth )
.addHeader("Connection", "close") .addHeader("Connection", "close")
.addHeader(FFROM, PlatformDataManager.getRam().getChannelName()) .addHeader(FFROM, PlatformDataManager.getRam().getChannelName())
.addHeader(IS_FROM_APP, "1") .addHeader(IS_FROM_APP, "1")
...@@ -243,6 +322,17 @@ class HttpConfig { ...@@ -243,6 +322,17 @@ class HttpConfig {
} }
} }
private fun getOldAuth(paramsString: StringBuilder): String {
return "$YDL ${EncryptUtils.encryptMD5ToString(
paramsString.toString()+ SESSION_KEY
)}"
}
private fun getNewAuth(paramsString: StringBuilder): String {
//md5({静态秘钥} + {参数} + md5{动态秘钥(明文)}
return "$YDL ${EncryptUtils.encryptMD5ToString(SESSION_KEY+ paramsString.toString()+EncryptUtils.encryptMD5ToString(DYNAMIC_SESSION_KEY))}"
}
//初始化网络环境 //初始化网络环境
fun initEnv(c: Context, env: String) { fun initEnv(c: Context, env: String) {
var appEnv = env var appEnv = env
...@@ -267,8 +357,22 @@ class HttpConfig { ...@@ -267,8 +357,22 @@ class HttpConfig {
YDL_H5 = properties.getProperty("ydlh5url.$appEnv") YDL_H5 = properties.getProperty("ydlh5url.$appEnv")
WEB_URL = properties.getProperty("weburl.$appEnv") WEB_URL = properties.getProperty("weburl.$appEnv")
SERVER_TEMP_JAVA_URL = properties.getProperty("javatempurl.$appEnv") SERVER_TEMP_JAVA_URL = properties.getProperty("javatempurl.$appEnv")
SERVER_API_JAVA_URL = properties.getProperty("javaurl.$appEnv") JAVA_CAST_URL = properties.getProperty("javacasturl.$appEnv")
SERVER_COUPON_URL = properties.getProperty("javacouponurl.$appEnv") JAVA_URL = properties.getProperty("javaurl.$appEnv")
}
@SuppressLint("CheckResult")
fun initAuth(){
ApiRequestUtil.getDynamicToken()
.compose(RxUtils.applySchedulers())
.compose(RxUtils.resultJavaData())
.subscribe({
if (!TextUtils.isEmpty(it.appKey)){
DYNAMIC_SESSION_KEY = it?.appKey.toString()
}
}) {
LogUtil.i("HttpConfig", it.toString())
}
} }
private object Holder { private object Holder {
......
package com.ydl.ydlcommon.bean
/**
* Created by haorui on 2019-11-26.
* Des:
*/
class AuthBean {
/**
* id : 1
* appId : android_zhuzhan
* appKey : 123456
* version : 4.0.00
*/
var id: Int = 0
var appId: String? = null
var appKey: String? = null
var version: String? = null
}
package com.ydl.ydlcommon.data.http.api; package com.ydl.ydlcommon.data.http.api;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.ydl.ydlcommon.bean.AuthBean;
import com.ydl.ydlcommon.bean.MustUP; import com.ydl.ydlcommon.bean.MustUP;
import com.ydl.ydlcommon.data.http.BaseAPIResponse; import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.ydl.ydlcommon.data.http.BaseResponse; import com.ydl.ydlcommon.data.http.BaseResponse;
...@@ -8,12 +9,13 @@ import com.ydl.ydlcommon.data.http.FormatText; ...@@ -8,12 +9,13 @@ import com.ydl.ydlcommon.data.http.FormatText;
import com.ydl.ydlcommon.data.http.params.ActionDataBean; import com.ydl.ydlcommon.data.http.params.ActionDataBean;
import com.ydl.ydlcommon.utils.NetworkParamsUtils; import com.ydl.ydlcommon.utils.NetworkParamsUtils;
import com.ydl.ydlnet.YDLHttpUtils; import com.ydl.ydlnet.YDLHttpUtils;
import java.util.List;
import io.reactivex.Observable; import io.reactivex.Observable;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import java.util.List;
/** /**
* 模块请求工具类 * 模块请求工具类
* Created by hgw on 2018/1/23. * Created by hgw on 2018/1/23.
...@@ -39,4 +41,12 @@ public class ApiRequestUtil { ...@@ -39,4 +41,12 @@ public class ApiRequestUtil {
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(actionDataParams)); RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(actionDataParams));
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).actionDataCount(body); return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).actionDataCount(body);
} }
/**
* 获取动态密钥
* @return
*/
public static Observable<BaseAPIResponse<AuthBean>> getDynamicToken() {
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getDynamicToken();
}
} }
package com.ydl.ydlcommon.data.http.api; package com.ydl.ydlcommon.data.http.api;
import com.ydl.ydlcommon.bean.AuthBean;
import com.ydl.ydlcommon.bean.MustUP; import com.ydl.ydlcommon.bean.MustUP;
import com.ydl.ydlcommon.data.http.BaseAPIResponse; import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.ydl.ydlcommon.data.http.BaseResponse; import com.ydl.ydlcommon.data.http.BaseResponse;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.*;
import java.util.Map; import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA;
import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA_URL;
/** /**
* 网络请求api * 网络请求api
...@@ -32,4 +40,8 @@ interface NetApiStore { ...@@ -32,4 +40,8 @@ interface NetApiStore {
@POST("data/bigdata/maidian/writeMaiDianData") @POST("data/bigdata/maidian/writeMaiDianData")
Observable<BaseAPIResponse<String>> actionDataCount(@Body RequestBody body); Observable<BaseAPIResponse<String>> actionDataCount(@Body RequestBody body);
@Headers(YDL_DOMAIN+ YDL_DOMAIN_JAVA_URL)
@GET("risk/key/info")
Observable<BaseAPIResponse<AuthBean>> getDynamicToken();
} }
...@@ -28,19 +28,19 @@ h5url.prod=https://h2.yidianling.com/ ...@@ -28,19 +28,19 @@ h5url.prod=https://h2.yidianling.com/
h5url.pre=https://preh.yidianling.com/ h5url.pre=https://preh.yidianling.com/
#java服务器api域名(投放系统) #java服务器api域名(投放系统)
javaurl.test = http://testdelivery.yidianling.com/ javacasturl.test = http://testdelivery.yidianling.com/
javaurl.auto_test = http://auto_testdelivery.yidianling.com/ javacasturl.auto_test = http://auto_testdelivery.yidianling.com/
javaurl.prod = https://delivery.yidianling.com/ javacasturl.prod = https://delivery.yidianling.com/
#m站H5地址 #m站H5地址
mh5url.test = https://testnewm.ydl.com/ mh5url.test = https://testnewm.ydl.com/
mh5url.auto_test = https://auto_testnewm.ydl.com/ mh5url.auto_test = https://auto_testnewm.ydl.com/
mh5url.prod = https://m.ydl.com/ mh5url.prod = https://m.ydl.com/
#java服务器api域名(优惠券) #java服务器域名
javacouponurl.test = https://testapi.ydl.com/ javaurl.test = https://testapi.ydl.com/
javacouponurl.auto_test = https://auto_testapi.ydl.com/ javaurl.auto_test = https://auto_testapi.ydl.com/
javacouponurl.prod = https://api.ydl.com/ javaurl.prod = https://api.ydl.com/
#java服务器api域名(h5耗时统计,域名问题后续服务端会统一) #java服务器api域名(h5耗时统计,域名问题后续服务端会统一)
javatempurl.test = https://47.97.49.44:8082/api/ javatempurl.test = https://47.97.49.44:8082/api/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment