Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
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
bp
ShenghuoquanBusiness
Commits
c43fdfa1
Commit
c43fdfa1
authored
Jul 13, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add TowerPro通用配置模块接入
parent
8ebb2ab9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
220 additions
and
1 deletion
+220
-1
build.gradle
CommonLib/Common/build.gradle
+1
-0
AppConfig.kt
...onLib/Common/src/main/java/com/yidian/common/AppConfig.kt
+8
-0
CommonDataSource.kt
.../src/main/java/com/yidian/common/http/CommonDataSource.kt
+33
-0
CommonService.kt
...mon/src/main/java/com/yidian/common/http/CommonService.kt
+13
-0
HttpResultObserver.kt
...rc/main/java/com/yidian/common/http/HttpResultObserver.kt
+70
-0
GetCommonConfigBean.kt
...n/java/com/yidian/common/http/bean/GetCommonConfigBean.kt
+80
-0
IGetCommonConfigCallback.kt
...m/yidian/common/http/callback/IGetCommonConfigCallback.kt
+13
-0
config.gradle
config/config.gradle
+2
-1
No files found.
CommonLib/Common/build.gradle
View file @
c43fdfa1
...
@@ -23,6 +23,7 @@ android {
...
@@ -23,6 +23,7 @@ android {
buildConfigField
(
"boolean"
,
"IS_UMENG_RELEASE"
,
rootProject
.
ext
.
android
.
isUmengRelease
)
buildConfigField
(
"boolean"
,
"IS_UMENG_RELEASE"
,
rootProject
.
ext
.
android
.
isUmengRelease
)
buildConfigField
(
"boolean"
,
"IS_ENCRYPT_DEBUG_KEY"
,
rootProject
.
ext
.
android
.
isEncryptDebugKey
)
buildConfigField
(
"boolean"
,
"IS_ENCRYPT_DEBUG_KEY"
,
rootProject
.
ext
.
android
.
isEncryptDebugKey
)
buildConfigField
(
"boolean"
,
"IS_APP_UPGRADE_ONLINE"
,
rootProject
.
ext
.
android
.
isAppUpgradeOnline
)
buildConfigField
(
"boolean"
,
"IS_APP_UPGRADE_ONLINE"
,
rootProject
.
ext
.
android
.
isAppUpgradeOnline
)
buildConfigField
(
"String"
,
"TOWER_API_ENV"
,
rootProject
.
ext
.
android
.
towerApiEnv
)
manifestPlaceholders
=
[
qqappid:
"101923771"
]
manifestPlaceholders
=
[
qqappid:
"101923771"
]
...
...
CommonLib/Common/src/main/java/com/yidian/common/AppConfig.kt
View file @
c43fdfa1
...
@@ -29,6 +29,14 @@ class AppConfig {
...
@@ -29,6 +29,14 @@ class AppConfig {
const
val
TowerProPlatformId
=
29
const
val
TowerProPlatformId
=
29
const
val
TowerProPlatform
=
"Android"
const
val
TowerProPlatform
=
"Android"
// TowerPro 通用配置模块
const
val
TowerApiEnvTest
=
"0"
// 测试环境
const
val
TowerApiEnvPro
=
"2"
// 外网-正式环境
const
val
TowerApiEnv
=
BuildConfig
.
TOWER_API_ENV
const
val
TowerApiOS
=
"2"
// 0:ios 1:安卓 2:全部
const
val
TowerApiKeyTag
=
"function-config"
const
val
TowerApiVersion
=
"1.0.0"
// 分享相关的三方平台配置
// 分享相关的三方平台配置
const
val
WeChatAppKey
=
"wxef4c37f254e29e84"
const
val
WeChatAppKey
=
"wxef4c37f254e29e84"
const
val
WeChatAppSecret
=
"fb596ed3641b481b6f973774987fd04f"
const
val
WeChatAppSecret
=
"fb596ed3641b481b6f973774987fd04f"
...
...
CommonLib/Common/src/main/java/com/yidian/common/http/CommonDataSource.kt
View file @
c43fdfa1
package
com.yidian.common.http
package
com.yidian.common.http
import
com.google.gson.reflect.TypeToken
import
com.google.gson.reflect.TypeToken
import
com.yidian.common.AppConfig
import
com.yidian.common.BuildConfig
import
com.yidian.common.YdBaseApplication
import
com.yidian.common.YdBaseApplication
import
com.yidian.common.http.bean.GetCommonConfigBean
import
com.yidian.common.http.bean.GetKSYunObjectIdBean
import
com.yidian.common.http.bean.GetKSYunObjectIdBean
import
com.yidian.common.http.bean.GetKSYunTokenBean
import
com.yidian.common.http.bean.GetKSYunTokenBean
import
com.yidian.common.http.callback.IGetCommonConfigCallback
import
com.yidian.common.http.callback.IGetKSYunObjectIdCallback
import
com.yidian.common.http.callback.IGetKSYunObjectIdCallback
import
com.yidian.http.ServiceFactory
import
com.yidian.http.ServiceFactory
import
com.yidian.utils.ToastUtil
import
com.yidian.utils.ToastUtil
...
@@ -15,6 +19,19 @@ import com.yidian.utils.ToastUtil
...
@@ -15,6 +19,19 @@ import com.yidian.utils.ToastUtil
*/
*/
object
CommonDataSource
{
object
CommonDataSource
{
// Tower-Api 域名
private
val
domainTowerApi
by
lazy
{
if
(
BuildConfig
.
TOWER_API_ENV
==
AppConfig
.
TowerApiEnvTest
)
{
CommonService
.
DOMAIN_TOWER_API_TEST
}
else
{
CommonService
.
DOMAIN_TOWER_API_PRO
}
}
private
val
towerApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
,
domainTowerApi
)
}
// 301 获取金山云token接口
// 301 获取金山云token接口
fun
getKSYunToken
(
requestParams
:
HashMap
<
String
,
String
?
>):
HttpResult
<
GetKSYunTokenBean
.
Response
>?
{
fun
getKSYunToken
(
requestParams
:
HashMap
<
String
,
String
?
>):
HttpResult
<
GetKSYunTokenBean
.
Response
>?
{
val
timeStamp
=
System
.
currentTimeMillis
()
val
timeStamp
=
System
.
currentTimeMillis
()
...
@@ -53,4 +70,20 @@ object CommonDataSource {
...
@@ -53,4 +70,20 @@ object CommonDataSource {
}
}
})
})
}
}
// TowerPro 获取配置数据
fun
getCommonConfig
(
apiCallback
:
IGetCommonConfigCallback
,
requestParams
:
HashMap
<
String
,
String
>)
{
towerApi
.
getCommonConfig
(
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultObserver
<
GetCommonConfigBean
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetCommonConfigBean
>?)
{
apiCallback
.
getCommonConfigSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetCommonConfigBean
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
})
}
}
}
CommonLib/Common/src/main/java/com/yidian/common/http/CommonService.kt
View file @
c43fdfa1
package
com.yidian.common.http
package
com.yidian.common.http
import
com.yidian.common.http.bean.GetCommonConfigBean
import
io.reactivex.rxjava3.core.Observable
import
io.reactivex.rxjava3.core.Observable
import
retrofit2.Call
import
retrofit2.Call
import
retrofit2.http.*
import
retrofit2.http.*
...
@@ -11,6 +12,15 @@ import retrofit2.http.*
...
@@ -11,6 +12,15 @@ import retrofit2.http.*
*/
*/
interface
CommonService
{
interface
CommonService
{
companion
object
{
// Tower Api域名定义
const
val
DOMAIN_TOWER_API_TEST
=
"http://open-tower-api.test.int.yidian-inc.com:8222"
const
val
DOMAIN_TOWER_API_PRO
=
"https://open-tower-api.go2yd.com"
// tower-api 获取配置数据
private
const
val
getCommonConfig
=
"/api/resource"
}
@Headers
(
"Content-Type: application/json"
)
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
getKSYunToken
)
@POST
(
URLs
.
getKSYunToken
)
fun
getKSYunToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
Map
<
String
,
String
?
>):
Call
<
HttpResult
<
Any
?
>>
fun
getKSYunToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
Map
<
String
,
String
?
>):
Call
<
HttpResult
<
Any
?
>>
...
@@ -20,4 +30,7 @@ interface CommonService {
...
@@ -20,4 +30,7 @@ interface CommonService {
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
requestParams
:
Map
<
String
,
String
?
>
@QueryMap
requestParams
:
Map
<
String
,
String
?
>
):
Observable
<
HttpResult
<
Any
?
>>
):
Observable
<
HttpResult
<
Any
?
>>
@GET
(
getCommonConfig
)
fun
getCommonConfig
(
@QueryMap
requestParams
:
Map
<
String
,
String
>):
Observable
<
HttpResult
<
GetCommonConfigBean
>>
}
}
CommonLib/Common/src/main/java/com/yidian/common/http/HttpResultObserver.kt
0 → 100644
View file @
c43fdfa1
package
com.yidian.common.http
import
com.google.gson.JsonParseException
import
com.yidian.common.YdBaseApplication
import
com.yidian.utils.ToastUtil
import
io.reactivex.rxjava3.core.Observer
import
io.reactivex.rxjava3.disposables.Disposable
/**
* author: yinjiacheng
* date: 7/13/21 9:00 AM
* description: 网路请求解析
* 非商户后台使用
*/
abstract
class
HttpResultObserver
<
T
>
:
Observer
<
HttpResult
<
T
>>
{
private
var
isShowErrorMsg
=
true
override
fun
onSubscribe
(
d
:
Disposable
)
{
//网络请求之前
}
override
fun
onComplete
()
{
//网络请求完成
}
override
fun
onError
(
e
:
Throwable
)
{
if
(
e
.
toString
().
contains
(
"ConnectException"
)
||
e
.
toString
().
contains
(
"Unable to resolve host"
))
{
if
(
isShowErrorMsg
)
{
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
"当前网络链接不畅,请检查您的网络情况"
)
}
}
else
if
(
"connect timed out"
==
e
.
message
)
{
if
(
isShowErrorMsg
)
{
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
"服务器连接超时"
)
}
}
else
if
(
e
is
JsonParseException
||
e
.
toString
().
contains
(
"Json"
)
||
e
.
toString
().
contains
(
"Gson"
))
{
if
(
isShowErrorMsg
)
{
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
"数据解析异常"
)
}
}
else
{
if
(
isShowErrorMsg
)
{
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
"网络请求异常"
)
}
}
onRequestFailure
(
Exception
(
e
.
toString
()))
}
override
fun
onNext
(
result
:
HttpResult
<
T
>)
{
if
(
result
.
code
==
0
)
{
onRequestSuccess
(
result
)
}
else
{
onFailure
(
result
)
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
result
.
reason
)
}
}
abstract
fun
onSuccess
(
result
:
HttpResult
<
T
>?)
abstract
fun
onFailure
(
result
:
HttpResult
<
T
>?)
private
fun
onRequestFailure
(
e
:
Throwable
?)
{
val
result
:
HttpResult
<
T
>
=
HttpResult
()
result
.
code
=
-
100
result
.
reason
=
e
?.
message
result
.
status
=
"failed"
onFailure
(
result
)
}
private
fun
onRequestSuccess
(
result
:
HttpResult
<
T
>)
{
onSuccess
(
result
)
}
}
CommonLib/Common/src/main/java/com/yidian/common/http/bean/GetCommonConfigBean.kt
0 → 100644
View file @
c43fdfa1
package
com.yidian.common.http.bean
import
com.google.gson.annotations.SerializedName
/**
* author: yinjiacheng
* date: 7/12/21 10:10 PM
* description: open-tower-api.go2yd.com/api/resource
*/
data class
GetCommonConfigBean
(
@SerializedName
(
"appid"
)
val
appid
:
String
,
@SerializedName
(
"created_at"
)
val
createdAt
:
String
,
@SerializedName
(
"creator"
)
val
creator
:
String
,
@SerializedName
(
"data"
)
val
`data`
:
Data
,
@SerializedName
(
"env"
)
val
env
:
Int
,
@SerializedName
(
"_id"
)
val
id
:
String
,
@SerializedName
(
"keyTag"
)
val
keyTag
:
String
,
@SerializedName
(
"note"
)
val
note
:
String
,
@SerializedName
(
"os"
)
val
os
:
Int
,
@SerializedName
(
"status"
)
val
status
:
String
,
@SerializedName
(
"uniqueKey"
)
val
uniqueKey
:
String
,
@SerializedName
(
"updated_at"
)
val
updatedAt
:
String
,
@SerializedName
(
"version"
)
val
version
:
String
)
data class
Data
(
@SerializedName
(
"is_show_app_upgrade"
)
val
isShowAppUpgrade
:
Int
,
@SerializedName
(
"merchant_manager_center"
)
val
merchantManagerCenter
:
MerchantManagerCenter
)
data class
MerchantManagerCenter
(
@SerializedName
(
"disable_text"
)
val
disableText
:
String
,
@SerializedName
(
"disable_url"
)
val
disableUrl
:
Any
,
@SerializedName
(
"items"
)
val
items
:
List
<
Item
>,
@SerializedName
(
"show"
)
val
show
:
Int
)
data class
Item
(
@SerializedName
(
"functions"
)
val
functions
:
List
<
Function
>,
@SerializedName
(
"group_id"
)
val
groupId
:
Int
,
@SerializedName
(
"group_name"
)
val
groupName
:
String
,
@SerializedName
(
"show"
)
val
show
:
Int
)
data class
Function
(
@SerializedName
(
"function_id"
)
val
functionId
:
Int
,
@SerializedName
(
"function_name"
)
val
functionName
:
String
,
@SerializedName
(
"icon_url"
)
val
iconUrl
:
String
,
@SerializedName
(
"link_url"
)
val
linkUrl
:
Any
,
@SerializedName
(
"show"
)
val
show
:
Int
)
CommonLib/Common/src/main/java/com/yidian/common/http/callback/IGetCommonConfigCallback.kt
0 → 100644
View file @
c43fdfa1
package
com.yidian.common.http.callback
import
com.yidian.common.http.bean.GetCommonConfigBean
/**
* author: yinjiacheng
* date: 7/12/21 10:24 PM
* description: open-tower-api.go2yd.com/api/resource
*/
interface
IGetCommonConfigCallback
{
fun
getCommonConfigSuccess
(
result
:
GetCommonConfigBean
?)
fun
getCommonConfigFailure
(
message
:
String
?)
}
config/config.gradle
View file @
c43fdfa1
...
@@ -9,7 +9,8 @@ ext {
...
@@ -9,7 +9,8 @@ ext {
isEncryptDebugKey
:
'true'
,
// 上线前需要使用正式加密key 置为false
isEncryptDebugKey
:
'true'
,
// 上线前需要使用正式加密key 置为false
isUmengRelease
:
'false'
,
// 上线时改成true,使用上线版本的友盟配置
isUmengRelease
:
'false'
,
// 上线时改成true,使用上线版本的友盟配置
isApplication
:
false
,
isApplication
:
false
,
isAppUpgradeOnline:
'true'
// 上线前需要开启版本升级线上环境 true
isAppUpgradeOnline:
'true'
,
// 上线前需要开启版本升级线上环境 true
towerApiEnv
:
'"2"'
// Tower Api环境 0:测试环境 1:内网-正式环境 2:外网-正式环境 3:内网外网-正式环境
]
]
// 高德地图的key
// 高德地图的key
amap
=
[
amap
=
[
...
...
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