Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
4c655484
Commit
4c655484
authored
Dec 02, 2019
by
严久程
Browse files
Options
Browse Files
Download
Plain Diff
课程列表页促销标签
parents
b447274c
34f3b72b
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
301 additions
and
179 deletions
+301
-179
api.properties
api.properties
+0
-94
MainActivity.kt
app/src/main/java/com/ydl/component/MainActivity.kt
+1
-2
DemoGlobalConfig.java
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
+7
-5
DemoPresenter.kt
app/src/main/java/com/ydl/component/mvp/DemoPresenter.kt
+4
-0
config.gradle
config.gradle
+7
-7
ConfideHomePresenterImpl.kt
m-confide/src/main/java/com/ydl/confide/home/presenter/ConfideHomePresenterImpl.kt
+3
-17
confide_home_activity.xml
m-confide/src/main/res/layout/confide_home_activity.xml
+1
-0
ConsultAssistantDialogUtils.kt
m-consultant/src/main/java/com/yidianling/consultant/modular/singlton/ConsultAssistantDialogUtils.kt
+2
-0
NetApiStore.java
m-course/src/main/java/com/yidianling/course/net/NetApiStore.java
+23
-7
UserBIConstants.kt
m-user/src/main/java/com/yidianling/user/constants/UserBIConstants.kt
+8
-7
OkHttpConfig.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/config/OkHttpConfig.java
+15
-7
RequestHandler.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestHandler.java
+30
-0
RequestLogInterceptor.java
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestLogInterceptor.java
+22
-4
AppConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/AppConfig.kt
+3
-1
GlobalConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/GlobalConfig.kt
+2
-1
HttpConfig.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
+119
-15
AuthBean.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/bean/AuthBean.kt
+20
-0
ApiRequestUtil.java
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/ApiRequestUtil.java
+12
-2
NetApiStore.java
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/NetApiStore.java
+15
-3
api.properties
ydl-platform/src/main/res/raw/api.properties
+7
-7
No files found.
api.properties
deleted
100644 → 0
View file @
b447274c
# 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
app/src/main/java/com/ydl/component/MainActivity.kt
View file @
4c655484
...
...
@@ -13,7 +13,6 @@ import android.util.Log
import
com.alibaba.android.arouter.launcher.ARouter
import
com.tbruyelle.rxpermissions2.RxPermissions
import
com.umeng.analytics.MobclickAgent
import
com.umeng.commonsdk.framework.UMModuleRegister.getAppContext
import
com.ydl.audioim.YDLavManager
import
com.ydl.component.music.MusicPlayActivity
import
com.ydl.component.mvp.DemoContract
...
...
@@ -137,7 +136,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override
fun
reLoadData
()
{
mPresenter
?.
loadUsers
()
mPresenter
.
loadHome
()
}
...
...
app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
View file @
4c655484
...
...
@@ -2,13 +2,11 @@
package
com
.
ydl
.
component
.
base
;
import
android.content.Context
;
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.YDLConstants
;
import
com.ydl.ydlcommon.base.delegate.IAppLifecycles
;
import
com.ydl.ydlcommon.base.config.GlobalConfig
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.List
;
...
...
@@ -27,9 +25,13 @@ public final class DemoGlobalConfig implements IConfigModule {
@Override
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
)
.
setEnv
(
YDLConstants
.
ENV_TEST
)
.
setEnv
(
env
)
.
setDebug
(
BuildConfig
.
DEBUG
);
}
}
app/src/main/java/com/ydl/component/mvp/DemoPresenter.kt
View file @
4c655484
...
...
@@ -39,6 +39,10 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(),
}
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
;
mView
.
setData
(
cateTitle
)
}
...
...
config.gradle
View file @
4c655484
ext
{
kotlin_version
=
"1.3.21"
dev_mode
=
fals
e
dev_mode
=
tru
e
ydl_app
=
[
appName
:
"心理咨询壹点灵"
,
...
...
@@ -44,12 +44,12 @@ ext {
//第三步 若干
"m-confide"
:
"0.0.29"
,
"m-consultant"
:
"0.0.4
2
"
,
"m-consultant"
:
"0.0.4
4
"
,
"m-course"
:
"0.0.30"
,
"m-fm"
:
"0.0.21"
,
"m-muse"
:
"0.0.19"
,
"m-tests"
:
"0.0.12"
,
"m-user"
:
"0.0.3
4
"
,
"m-user"
:
"0.0.3
7
"
,
//-------------- 业务模块 API 层 --------------
...
...
@@ -64,7 +64,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.2
7
"
,
"ydl-platform"
:
"0.0.2
8.3
"
,
//第二步 若干
"ydl-webview"
:
"0.0.28"
,
...
...
@@ -74,7 +74,7 @@ ext {
//以下 几乎不会动
"router"
:
"0.0.1"
,
"ydl-net"
:
"0.0.
2
"
,
"ydl-net"
:
"0.0.
3
"
,
"ydl-utils"
:
"0.0.3"
,
"ydl-flutter-base"
:
"0.0.3"
,
]
...
...
@@ -101,7 +101,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform"
:
"0.0.2
7
"
,
"ydl-platform"
:
"0.0.2
8.3
"
,
//第二步 若干
"ydl-webview"
:
"0.0.28"
,
...
...
@@ -112,7 +112,7 @@ ext {
//以下 几乎不会动
"router"
:
"0.0.1"
,
"ydl-net"
:
"0.0.
2
"
,
"ydl-net"
:
"0.0.
3
"
,
"ydl-utils"
:
"0.0.3"
,
"ydl-flutter-base"
:
"0.0.3"
,
]
...
...
m-confide/src/main/java/com/ydl/confide/home/presenter/ConfideHomePresenterImpl.kt
View file @
4c655484
...
...
@@ -13,13 +13,11 @@ import com.ydl.ydlcommon.data.http.RxUtils
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
import
com.ydl.ydlcommon.mvp.base.BasePresenter
import
com.ydl.ydlcommon.mvp.base.IView
import
com.ydl.ydlcommon.utils.RxLifecycleUtils
import
com.ydl.ydlcommon.utils.YDLAsyncUtils
import
com.ydl.ydlcommon.utils.YDLCacheUtils
import
com.yidianling.common.tools.RxNetTool
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.functions.Consumer
import
io.reactivex.schedulers.Schedulers
/**
* @author yuanwai
...
...
@@ -54,7 +52,7 @@ class ConfideHomePresenterImpl : BasePresenter<IConfideHomeContract.View,IConfid
override
fun
asyncResult
(
`object`
:
Any
?)
{
//如果没有缓存数据,显示加载框
if
(
`object`
!
is
String
||
TextUtils
.
isEmpty
(
`object`
)){
mView
.
show
Progress
()
mView
.
show
Loading
()
}
if
(
`object`
is
String
){
...
...
@@ -82,20 +80,8 @@ class ConfideHomePresenterImpl : BasePresenter<IConfideHomeContract.View,IConfid
val
disposable
=
mModel
.
confideHomeRequest
()
.
map
{
it
}
.
filter
{
it
!=
null
}
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
{
if
(!
isRefresh
){
mView
.
showLoading
()
//显示进度条
}
}
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doFinally
{
if
(!
isRefresh
){
mView
.
hideLoading
()
//隐藏进度条
}
}.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mView
))
.
compose
(
RxUtils
.
applySchedulers
(
mView
as
IView
))
.
doFinally
{
mView
.
hideLoading
()
}
.
subscribe
(
Consumer
{
mView
.
confideHomeResponse
(
it
)
updateCache
(
it
)
...
...
m-confide/src/main/res/layout/confide_home_activity.xml
View file @
4c655484
...
...
@@ -75,6 +75,7 @@
/>
<com.ydl.ydlcommon.mvp.lce.view.YDLStateView
android:visibility=
"gone"
android:id=
"@+id/lce_state_view"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
m-consultant/src/main/java/com/yidianling/consultant/modular/singlton/ConsultAssistantDialogUtils.kt
View file @
4c655484
...
...
@@ -44,9 +44,11 @@ class ConsultAssistantDialogUtils private constructor() {
}
}
"doctor_list"
->
{
if
(!
ConsultantIn
.
isLogin
()
||
(
ConsultantIn
.
getUserImpl
().
getUserInfo
()
?.
user_type
==
1
&&
ConsultantIn
.
isLogin
()))
{
shouldShowDialog
(
activity
,
origin
,
fromActivity
=
fromActivity
)
}
}
}
}
...
...
m-course/src/main/java/com/yidianling/course/net/NetApiStore.java
View file @
4c655484
...
...
@@ -2,20 +2,36 @@ package com.yidianling.course.net;
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
;
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.model.CourseCategoryBean
;
import
com.yidianling.course.model.TopicCourseBean
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
import
retrofit2.http.*
;
import
java.util.List
;
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_COUPON_URL
;
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.
...
...
@@ -88,7 +104,7 @@ public interface NetApiStore {
* @return
*/
@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
,
@Query
(
"services"
)
String
services
,
@Query
(
"receiveType"
)
String
receiveType
,
...
...
@@ -96,7 +112,7 @@ public interface NetApiStore {
//领取优惠券
@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
);
...
...
m-user/src/main/java/com/yidianling/user/constants/UserBIConstants.kt
View file @
4c655484
...
...
@@ -10,7 +10,8 @@ class UserBIConstants {
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"
//百度监测 应用启动行为
...
...
@@ -41,12 +42,12 @@ class UserBIConstants {
* action type
* 行为数据埋点,sign1字段 是对同一key下多种不同行为的描述
*/
const
val
ACTION_TYPE_CODE_LOGIN
:
String
=
PART_ID_LOGIN_MAIN
+
"code_login"
//验证码登录
const
val
ACTION_TYPE_RESET_PWD
:
String
=
PART_ID_LOGIN_MAIN
+
"reset_pwd"
//重置密码登录
const
val
ACTION_TYPE_PWD_LOGIN
:
String
=
PART_ID_LOGIN_MAIN
+
"pwd_login"
//手机号密码登录
const
val
ACTION_TYPE_DIRECT_LOGIN
:
String
=
PART_ID_LOGIN_MAIN
+
"direct_login"
//一键登录
const
val
ACTION_TYPE_QQ_THIRD_LOGIN
:
String
=
PART_ID_LOGIN_MAIN
+
"qq_login"
//QQ登录
const
val
ACTION_TYPE_WX_THIRD_LOGIN
:
String
=
PART_ID_LOGIN_MAIN
+
"wx_login"
//WX登录
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
_PREFIX
+
"reset_pwd"
//重置密码登录
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
_PREFIX
+
"direct_login"
//一键登录
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
_PREFIX
+
"wx_login"
//WX登录
}
//====================壹点灵用户版首页(ydl_user_main_page)====================
...
...
ydl-net/src/main/java/com/ydl/ydlnet/builder/config/OkHttpConfig.java
View file @
4c655484
...
...
@@ -2,6 +2,7 @@ package com.ydl.ydlnet.builder.config;
import
android.content.Context
;
import
android.text.TextUtils
;
import
com.ydl.ydlnet.builder.cookie.CookieJarImpl
;
import
com.ydl.ydlnet.builder.cookie.store.CookieStore
;
import
com.ydl.ydlnet.builder.factory.ApiFactory
;
...
...
@@ -9,19 +10,22 @@ import com.ydl.ydlnet.builder.http.SSLUtils;
import
com.ydl.ydlnet.builder.interceptor.HeaderInterceptor
;
import
com.ydl.ydlnet.builder.interceptor.NetCacheInterceptor
;
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.manage.HttpUrlManager
;
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.InputStream
;
import
java.util.Map
;
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 .
* Des: 统一OkHttp配置信息
...
...
@@ -80,6 +84,7 @@ public class OkHttpConfig {
private
InputStream
bksFile
;
private
String
password
;
private
InputStream
[]
certificates
;
private
RequestHandler
requestHandler
;
private
Interceptor
[]
interceptors
;
private
Interceptor
[]
netInterceptors
;
private
BuildHeadersListener
buildHeadersListener
;
...
...
@@ -99,6 +104,11 @@ public class OkHttpConfig {
return
this
;
}
public
Builder
setRequestHandler
(
RequestHandler
requestHandler
)
{
this
.
requestHandler
=
requestHandler
;
return
this
;
}
public
Builder
setCache
(
boolean
isCache
)
{
this
.
isCache
=
isCache
;
return
this
;
...
...
@@ -210,9 +220,7 @@ public class OkHttpConfig {
* 配置开发环境
*/
private
void
setDebugConfig
()
{
if
(
isDebug
)
{
okHttpClientBuilder
.
addInterceptor
(
new
RequestLogInterceptor
());
}
okHttpClientBuilder
.
addInterceptor
(
new
RequestLogInterceptor
(
isDebug
,
requestHandler
));
}
...
...
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestHandler.java
0 → 100644
View file @
4c655484
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
;
}
};
}
ydl-net/src/main/java/com/ydl/ydlnet/builder/interceptor/log/RequestLogInterceptor.java
View file @
4c655484
package
com
.
ydl
.
ydlnet
.
builder
.
interceptor
.
log
;
import
android.support.annotation.Nullable
;
import
com.ydl.ydlnet.utils.CharacterHandler
;
import
com.ydl.ydlnet.utils.NetLogUtils
;
import
com.ydl.ydlnet.utils.UrlEncoderUtils
;
import
com.ydl.ydlnet.utils.ZipHelper
;
import
okhttp3.*
;
import
okio.Buffer
;
import
okio.BufferedSource
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
...
...
@@ -15,14 +13,27 @@ import java.net.URLDecoder;
import
java.nio.charset.Charset
;
import
java.util.List
;
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 .
* Des: 解析框架中的网络请求和响应结果并打印
*/
public
class
RequestLogInterceptor
implements
Interceptor
{
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
...
...
@@ -36,6 +47,8 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter
.
printFileRequest
(
request
);
}
if
(
mRequestHandler
!=
null
)
request
=
mRequestHandler
.
onHttpRequestBefore
(
chain
,
request
);
long
t1
=
System
.
nanoTime
()
;
Response
originalResponse
;
...
...
@@ -55,6 +68,10 @@ public class RequestLogInterceptor implements Interceptor {
bodyString
=
printResult
(
request
,
originalResponse
);
}
if
(
mRequestHandler
!=
null
)
mRequestHandler
.
onHttpResultResponse
(
bodyString
,
chain
,
originalResponse
);
if
(
mIsDebug
)
{
final
List
<
String
>
segmentList
=
request
.
url
().
encodedPathSegments
();
final
String
header
=
originalResponse
.
headers
().
toString
();
final
int
code
=
originalResponse
.
code
();
...
...
@@ -69,6 +86,7 @@ public class RequestLogInterceptor implements Interceptor {
mPrinter
.
printFileResponse
(
TimeUnit
.
NANOSECONDS
.
toMillis
(
t2
-
t1
),
isSuccessful
,
code
,
header
,
segmentList
,
message
,
url
);
}
}
return
originalResponse
;
}
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/AppConfig.kt
View file @
4c655484
...
...
@@ -5,5 +5,7 @@ package com.ydl.ydlcommon.base.config
* Des:
*/
const
val
YDL_DOMAIN
=
"Domain-Name:"
//JAVA Api 地址
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"
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/GlobalConfig.kt
View file @
4c655484
...
...
@@ -83,7 +83,7 @@ class GlobalConfig private constructor(var builder: Builder) {
.
config
()
.
setBaseUrl
(
appBaseURL
?:
HttpConfig
.
PHP_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
)
if
(
okHttpClient
==
null
)
{
...
...
@@ -91,6 +91,7 @@ class GlobalConfig private constructor(var builder: Builder) {
}
apiFactory
.
setOkClient
(
okHttpClient
)
HttpConfig
.
getInstance
().
initAuth
()
}
}
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/base/config/HttpConfig.kt
View file @
4c655484
package
com.ydl.ydlcommon.base.config
import
android.annotation.SuppressLint
import
android.content.Context
import
android.text.TextUtils
import
com.facebook.stetho.okhttp3.StethoInterceptor
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.bean.AuthBean
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.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.utils.YDLCacheUtils
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.RxDeviceTool
import
okhttp3.FormBody
import
okhttp3.Interceptor
import
okhttp3.MultipartBody
import
okhttp3.OkHttpClient
import
com.yidianling.common.tools.ToastUtil
import
okhttp3.*
import
okio.Buffer
import
okio.BufferedSink
import
java.util.*
...
...
@@ -32,7 +38,10 @@ class HttpConfig {
//====================应用默认配置====================
private
const
val
AUTHORIZATION_NAME
=
"Authorization"
private
const
val
AUTHORIZATION_JAVA_NAME
=
"AuthorizationJava"
private
const
val
SESSION_KEY
=
"dc59cf294f37d237c1f06240568ffe21"
private
var
DYNAMIC_SESSION_KEY
:
String
=
"dc59cf294f37d237c1f06240568ffe21"
private
const
val
YDL
=
"Ydl"
private
const
val
UID
=
"uid"
private
const
val
FFROM
=
"ffrom"
...
...
@@ -43,18 +52,49 @@ class HttpConfig {
private
const
val
TOKEN
=
"accessToken"
private
val
OS_TYPE
=
"osType"
// 1.ios 2.android
private
val
APP_NAME
=
"appName"
//用于标识 是哪个应用 yidianling:用户版 xinlizixun:心理咨询 haoshi:情感壹点灵 zhuanjia:专家版
//验证签名失败
private
val
AUTH_INEFFECTIVE_CODE
=
"-201"
//====================网络环境====================
/**
* PHP API 地址
*/
var
PHP_BASE_URL
=
""
/**
* Java API 地址
*/
var
JAVA_BASE_URL
=
""
/**
* YDL H5 地址
*/
var
YDL_H5
=
""
/**
* H5 地址
*/
var
H5_URL
=
""
/**
* M站 地址
*/
var
MH5_URL
=
""
/**
* 新 H5 地址
*/
var
WEB_URL
=
""
var
SERVER_COUPON_URL
=
""
/**
* Java API 域名
*/
var
JAVA_URL
=
""
/**
* h5耗时统计 java服务器api地址
*/
var
SERVER_TEMP_JAVA_URL
=
""
var
SERVER_API_JAVA_URL
=
""
/**
* Java 投放系统 地址
*/
var
JAVA_CAST_URL
=
""
/**
* 行为数据 地址
*/
var
ACTION_URL
=
""
fun
getInstance
():
HttpConfig
{
...
...
@@ -75,6 +115,7 @@ class HttpConfig {
return
builder
.
setInterceptor
(
commonParams
(),
requestHead
(
appFrom
))
.
setRequestHandler
(
getRequestHandler
())
.
setReadTimeout
(
15
)
.
setWriteTimeout
(
15
)
.
setConnectTimeout
(
15
)
...
...
@@ -82,6 +123,35 @@ class HttpConfig {
.
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
{
...
...
@@ -178,9 +248,10 @@ class HttpConfig {
private
fun
requestHead
(
appFrom
:
String
):
Interceptor
{
return
Interceptor
{
val
request
=
it
.
request
()
val
body
=
request
.
body
()
val
paramsString
=
StringBuilder
()
val
params
=
ArrayList
<
Param
>()
if
(
"POST"
==
request
.
method
()){
val
body
=
request
.
body
()
if
(
body
is
FormBody
)
{
(
0
until
body
.
size
()).
mapTo
(
destination
=
params
)
{
Param
(
...
...
@@ -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
->
val
res
=
o1
.
name
.
compareTo
(
o2
.
name
)
when
{
...
...
@@ -214,14 +293,14 @@ class HttpConfig {
if
(
index
!=
0
)
paramsString
.
append
(
"&"
)
paramsString
.
append
(
"${param.name}=${param.value}"
)
}
paramsString
.
append
(
SESSION_KEY
)
val
head
=
"$YDL ${EncryptUtils.encryptMD5ToString(
paramsString
.
toString
()
)}
"
val
oldAuth
=
getOldAuth
(
paramsString
)
val
newAuth
=
getNewAuth
(
paramsString
)
val
builder
=
it
.
request
()
.
newBuilder
()
.
header
(
AUTHORIZATION_NAME
,
head
)
.
header
(
AUTHORIZATION_NAME
,
oldAuth
)
.
header
(
AUTHORIZATION_JAVA_NAME
,
newAuth
)
.
addHeader
(
"Connection"
,
"close"
)
.
addHeader
(
FFROM
,
PlatformDataManager
.
getRam
().
getChannelName
())
.
addHeader
(
IS_FROM_APP
,
"1"
)
...
...
@@ -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
)
{
var
appEnv
=
env
...
...
@@ -267,8 +357,22 @@ class HttpConfig {
YDL_H5
=
properties
.
getProperty
(
"ydlh5url.$appEnv"
)
WEB_URL
=
properties
.
getProperty
(
"weburl.$appEnv"
)
SERVER_TEMP_JAVA_URL
=
properties
.
getProperty
(
"javatempurl.$appEnv"
)
SERVER_API_JAVA_URL
=
properties
.
getProperty
(
"javaurl.$appEnv"
)
SERVER_COUPON_URL
=
properties
.
getProperty
(
"javacouponurl.$appEnv"
)
JAVA_CAST_URL
=
properties
.
getProperty
(
"javacasturl.$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
{
...
...
ydl-platform/src/main/java/com/ydl/ydlcommon/bean/AuthBean.kt
0 → 100644
View file @
4c655484
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
}
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/ApiRequestUtil.java
View file @
4c655484
package
com
.
ydl
.
ydlcommon
.
data
.
http
.
api
;
import
com.google.gson.Gson
;
import
com.ydl.ydlcommon.bean.AuthBean
;
import
com.ydl.ydlcommon.bean.MustUP
;
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
;
import
com.ydl.ydlcommon.data.http.BaseResponse
;
...
...
@@ -8,12 +9,13 @@ import com.ydl.ydlcommon.data.http.FormatText;
import
com.ydl.ydlcommon.data.http.params.ActionDataBean
;
import
com.ydl.ydlcommon.utils.NetworkParamsUtils
;
import
com.ydl.ydlnet.YDLHttpUtils
;
import
java.util.List
;
import
io.reactivex.Observable
;
import
okhttp3.MediaType
;
import
okhttp3.RequestBody
;
import
java.util.List
;
/**
* 模块请求工具类
* Created by hgw on 2018/1/23.
...
...
@@ -39,4 +41,12 @@ public class ApiRequestUtil {
RequestBody
body
=
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
new
Gson
().
toJson
(
actionDataParams
));
return
YDLHttpUtils
.
Companion
.
obtainApi
(
NetApiStore
.
class
).
actionDataCount
(
body
);
}
/**
* 获取动态密钥
* @return
*/
public
static
Observable
<
BaseAPIResponse
<
AuthBean
>>
getDynamicToken
()
{
return
YDLHttpUtils
.
Companion
.
obtainApi
(
NetApiStore
.
class
).
getDynamicToken
();
}
}
ydl-platform/src/main/java/com/ydl/ydlcommon/data/http/api/NetApiStore.java
View file @
4c655484
package
com
.
ydl
.
ydlcommon
.
data
.
http
.
api
;
import
com.ydl.ydlcommon.bean.AuthBean
;
import
com.ydl.ydlcommon.bean.MustUP
;
import
com.ydl.ydlcommon.data.http.BaseAPIResponse
;
import
com.ydl.ydlcommon.data.http.BaseResponse
;
import
io.reactivex.Observable
;
import
okhttp3.RequestBody
;
import
retrofit2.http.*
;
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_JAVA
;
import
static
com
.
ydl
.
ydlcommon
.
base
.
config
.
AppConfigKt
.
YDL_DOMAIN_JAVA_URL
;
/**
* 网络请求api
...
...
@@ -32,4 +40,8 @@ interface NetApiStore {
@POST
(
"data/bigdata/maidian/writeMaiDianData"
)
Observable
<
BaseAPIResponse
<
String
>>
actionDataCount
(
@Body
RequestBody
body
);
@Headers
(
YDL_DOMAIN
+
YDL_DOMAIN_JAVA_URL
)
@GET
(
"risk/key/info"
)
Observable
<
BaseAPIResponse
<
AuthBean
>>
getDynamicToken
();
}
ydl-platform/src/main/res/raw/api.properties
View file @
4c655484
...
...
@@ -28,19 +28,19 @@ 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/
java
cast
url.test
=
http://testdelivery.yidianling.com/
java
cast
url.auto_test
=
http://auto_testdelivery.yidianling.com/
java
cast
url.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域名(优惠券)
java
coupon
url.test
=
https://testapi.ydl.com/
java
coupon
url.auto_test
=
https://auto_testapi.ydl.com/
java
coupon
url.prod
=
https://api.ydl.com/
#java服务器
域名
javaurl.test
=
https://testapi.ydl.com/
javaurl.auto_test
=
https://auto_testapi.ydl.com/
javaurl.prod
=
https://api.ydl.com/
#java服务器api域名(h5耗时统计,域名问题后续服务端会统一)
javatempurl.test
=
https://47.97.49.44:8082/api/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment