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
672b2865
Commit
672b2865
authored
Aug 03, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update TowerPro通用配置数据获取迁移到BGeneralBusiness组件
parent
60eb2874
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
152 additions
and
572 deletions
+152
-572
AppConfig.kt
...on/src/main/java/com/yidian/bcommon/constant/AppConfig.kt
+4
-0
CommonDataSource.kt
...src/main/java/com/yidian/bcommon/http/CommonDataSource.kt
+0
-82
CommonService.kt
...on/src/main/java/com/yidian/bcommon/http/CommonService.kt
+3
-23
BCommonManager.kt
...on/src/main/java/com/yidian/bcommon/sdk/BCommonManager.kt
+5
-3
ZapServiceActionConstants.kt
.../com/yidian/bcommon/services/ZapServiceActionConstants.kt
+3
-0
KS3Core.kt
...BCommon/src/main/java/com/yidian/bcommon/utils/KS3Core.kt
+0
-374
ShareUtils.kt
...mmon/src/main/java/com/yidian/bcommon/utils/ShareUtils.kt
+0
-10
ViewHolderUtil.kt
.../src/main/java/com/yidian/bcommon/utils/ViewHolderUtil.kt
+0
-15
GeneralBusinessApiService.kt
...uoquan/bgeneralbusiness/http/GeneralBusinessApiService.kt
+9
-1
GeneralBusinessRemoteDataService.kt
...bgeneralbusiness/http/GeneralBusinessRemoteDataService.kt
+34
-0
GeneralAbilityService.kt
...huoquan/bgeneralbusiness/service/GeneralAbilityService.kt
+33
-4
Constant.kt
...m/yidian/shenghuoquan/bmanagercenter/constant/Constant.kt
+2
-0
MerchantCenterActivity.kt
...uoquan/bmanagercenter/ui/center/MerchantCenterActivity.kt
+59
-60
No files found.
CommonLib/BCommon/src/main/java/com/yidian/bcommon/constant/AppConfig.kt
View file @
672b2865
...
...
@@ -32,6 +32,10 @@ class AppConfig {
const
val
TowerProXBridUpgradePlatformId
=
32
// XBrid版本升级
const
val
TowerProPlatform
=
"Android"
// Tower Api域名定义
const
val
TowerApiDomainTest
=
"http://open-tower-api.test.int.yidian-inc.com:8222"
const
val
TowerApiDomainPro
=
"https://open-tower-api.go2yd.com"
// TowerPro 通用配置模块
const
val
TowerApiEnvTest
=
0
// 测试环境
const
val
TowerApiEnvPro
=
2
// 外网-正式环境
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/CommonDataSource.kt
View file @
672b2865
package
com.yidian.bcommon.http
import
com.google.gson.reflect.TypeToken
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.http.bean.CommitFeedbackBean
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.bean.GetKSYunObjectIdBean
import
com.yidian.bcommon.http.bean.GetKSYunTokenBean
import
com.yidian.bcommon.http.callback.ICommitFeedbackCallback
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.bcommon.http.callback.IGetKSYunObjectIdCallback
import
com.yidian.http.ServiceFactory
import
com.yidian.utils.ToastUtil
/**
* author: yinjiacheng
...
...
@@ -21,82 +11,10 @@ import com.yidian.utils.ToastUtil
*/
object
CommonDataSource
{
// Tower-Api 域名
private
val
domainTowerApi
by
lazy
{
if
(
RunConfig
.
TOWER_API_ENV
==
AppConfig
.
TowerApiEnvTest
)
{
CommonService
.
SCHEME_HTTP
+
CommonService
.
DOMAIN_TOWER_API_TEST
}
else
{
CommonService
.
SCHEME_HTTPS
+
CommonService
.
DOMAIN_TOWER_API_PRO
}
}
private
val
towerApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
,
domainTowerApi
)
}
private
val
ydJiraApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
,
CommonService
.
SCHEME_HTTPS
+
CommonService
.
DOMAIN_YD_JIRA
)
}
// 301 获取金山云token接口
fun
getKSYunToken
(
requestParams
:
HashMap
<
String
,
String
?
>):
HttpResult
<
GetKSYunTokenBean
.
Response
>?
{
val
timeStamp
=
System
.
currentTimeMillis
()
val
publicParamsMap
=
HttpParamsUtils
.
getPublicParamsMap
(
timeStamp
)
val
privateParamsMap
=
HttpParamsUtils
.
getPrivateParamsMap
(
requestParams
,
timeStamp
)
val
res
:
HttpResult
<
Any
?>?
=
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
getKSYunToken
(
publicParamsMap
,
privateParamsMap
)
.
execute
().
body
()
if
(
res
?.
code
==
0
)
{
return
HttpParamsUtils
.
rsaDecryptResult
(
res
,
object
:
TypeToken
<
GetKSYunTokenBean
.
Response
>()
{}.
type
)
}
else
{
val
decodeResult
=
HttpResult
<
GetKSYunTokenBean
.
Response
>()
decodeResult
.
code
=
res
?.
code
!!
decodeResult
.
reason
=
res
.
reason
decodeResult
.
status
=
res
.
status
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
res
.
reason
)
}
return
null
}
// 302 获取金山云ObjectId和Bucket接口
fun
getKSYunObjectId
(
apiCallback
:
IGetKSYunObjectIdCallback
,
requestParams
:
HashMap
<
String
,
String
?
>)
{
val
timeStamp
=
System
.
currentTimeMillis
()
val
publicParamsMap
=
HttpParamsUtils
.
getPublicParamsMap
(
timeStamp
)
val
privateParamsMap
=
HttpParamsUtils
.
getPrivateParamsMap
(
requestParams
,
timeStamp
)
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
getKSYunObjectId
(
publicParamsMap
,
privateParamsMap
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultSubscriber
<
GetKSYunObjectIdBean
.
Response
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetKSYunObjectIdBean
.
Response
>?)
{
apiCallback
.
getKSYunObjectIdSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetKSYunObjectIdBean
.
Response
>?)
{
apiCallback
.
getKSYunObjectIdFailure
(
result
?.
reason
)
}
})
}
// TowerPro 获取配置数据
fun
getCommonConfig
(
apiCallback
:
IGetCommonConfigCallback
,
requestParams
:
HashMap
<
String
,
String
>)
{
towerApi
.
getCommonConfig
(
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultObserver
<
GetCommonConfigBean
.
GetCommonConfigResponse
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
override
fun
onNetworkFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
})
}
// 用户反馈提交
fun
commitFeedback
(
apiCallback
:
ICommitFeedbackCallback
,
requestParams
:
CommitFeedbackBean
.
CommitFeedbackRequest
)
{
ydJiraApi
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/CommonService.kt
View file @
672b2865
package
com.yidian.bcommon.http
import
com.yidian.bcommon.http.bean.CommitFeedbackBean
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
io.reactivex.rxjava3.core.Observable
import
retrofit2.Call
import
retrofit2.http.*
import
retrofit2.http.Body
import
retrofit2.http.Headers
import
retrofit2.http.POST
/**
* author: yinjiacheng
...
...
@@ -17,33 +17,13 @@ interface CommonService {
const
val
SCHEME_HTTP
=
"http://"
const
val
SCHEME_HTTPS
=
"https://"
// Tower Api域名定义
const
val
DOMAIN_TOWER_API_TEST
=
"open-tower-api.test.int.yidian-inc.com:8222"
const
val
DOMAIN_TOWER_API_PRO
=
"open-tower-api.go2yd.com"
// 一点jira域名定义
const
val
DOMAIN_YD_JIRA
=
"hub.go2yd.com"
// tower-api 获取配置数据
private
const
val
getCommonConfig
=
"/api/resource"
// 用户反馈提交
private
const
val
commitFeedback
=
"/feedback/save"
}
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
getKSYunToken
)
fun
getKSYunToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
Map
<
String
,
String
?
>):
Call
<
HttpResult
<
Any
?
>>
@GET
(
URLs
.
getKSYunObjectId
)
fun
getKSYunObjectId
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
requestParams
:
Map
<
String
,
String
?
>
):
Observable
<
HttpResult
<
Any
?
>>
@GET
(
getCommonConfig
)
fun
getCommonConfig
(
@QueryMap
requestParams
:
Map
<
String
,
String
>):
Observable
<
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>>
@Headers
(
"Content-Type: application/json"
)
@POST
(
commitFeedback
)
fun
commitFeedback
(
@Body
requestParams
:
CommitFeedbackBean
.
CommitFeedbackRequest
):
Observable
<
HttpResult
<
CommitFeedbackBean
.
CommitFeedbackResponse
>>
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/sdk/BCommonManager.kt
View file @
672b2865
...
...
@@ -47,9 +47,11 @@ object BCommonManager {
*/
fun
getUid
():
String
?
{
var
userId
:
String
?
=
null
if
(
JudgeClientUtils
.
judgeClient
(
YdBaseApplication
.
context
.
packageName
)
==
ClientType
.
MERCHANT_C
)
{
ZapTicket
(
ZapServiceNameConstants
.
ClientInfoService
).
withAction
(
ZapServiceActionConstants
.
ActionGetUserInfo
).
onResult
{
userId
=
(
it
.
result
as
JSONObject
).
optString
(
"userId"
)
}.
ship
()
}
return
userId
}
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/services/ZapServiceActionConstants.kt
View file @
672b2865
...
...
@@ -45,5 +45,8 @@ class ZapServiceActionConstants {
// 延迟初始化
const
val
ActionLazyInit
=
"lazyInit"
// 获取TowerPro通用配置数据
const
val
ActionGetTowerProCommonConfig
=
"getTowerProCommonConfig"
}
}
CommonLib/BCommon/src/main/java/com/yidian/bcommon/utils/KS3Core.kt
deleted
100644 → 0
View file @
60eb2874
package
com.yidian.bcommon.utils
import
android.content.Context
import
android.util.Log
import
com.google.gson.Gson
import
com.ksyun.ks3.exception.Ks3Error
import
com.ksyun.ks3.model.acl.CannedAccessControlList
import
com.ksyun.ks3.services.AuthListener
import
com.ksyun.ks3.services.Ks3Client
import
com.ksyun.ks3.services.Ks3ClientConfiguration
import
com.ksyun.ks3.services.handler.PutObjectACLResponseHandler
import
com.ksyun.ks3.services.handler.PutObjectResponseHandler
import
com.ksyun.ks3.services.request.PutObjectRequest
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.http.CommonDataSource
import
com.yidian.bcommon.http.bean.GetKSYunObjectIdBean
import
com.yidian.bcommon.http.callback.IGetKSYunObjectIdCallback
import
com.yidian.utils.MD5Util
import
com.yidian.yac.ftdevicefinger.core.FtDeviceFingerManager
import
cz.msebera.android.httpclient.Header
import
java.io.File
/**
* author: yinjiacheng
* date: 5/20/21 11:08 AM
* description: 金山云存储
*/
class
KS3Core
private
constructor
(
val
context
:
Context
)
:
AuthListener
{
private
val
client
by
lazy
{
Ks3Client
(
this
,
context
)
}
private
val
gson
by
lazy
{
Gson
()
}
private
val
putObjectResponseHandler
by
lazy
{
object
:
PutObjectResponseHandler
()
{
override
fun
onTaskProgress
(
progress
:
Double
)
{
// work thread
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
error
:
Ks3Error
?,
responceHeaders
:
Array
<
out
Header
>?,
response
:
String
?,
throwable
:
Throwable
?
)
{
Log
.
e
(
TAG
,
"put object fail:, errorMsg: ${error?.errorMessage}"
)
}
override
fun
onTaskSuccess
(
statesCode
:
Int
,
responceHeaders
:
Array
<
out
Header
>?)
{
Log
.
d
(
TAG
,
"put object success."
)
}
override
fun
onTaskStart
()
{
}
override
fun
onTaskFinish
()
{
}
override
fun
onTaskCancel
()
{
}
}
}
private
val
putObjectACLResponseHandler
by
lazy
{
object
:
PutObjectACLResponseHandler
()
{
override
fun
onSuccess
(
statesCode
:
Int
,
responceHeaders
:
Array
<
out
Header
>?)
{
Log
.
d
(
TAG
,
"put object acl success."
)
}
override
fun
onFailure
(
statesCode
:
Int
,
error
:
Ks3Error
?,
responceHeaders
:
Array
<
out
Header
>?,
response
:
String
?,
throwable
:
Throwable
?
)
{
Log
.
e
(
TAG
,
"put object acl fail:, errorMsg: ${error?.errorMessage}"
)
}
}
}
companion
object
{
const
val
TAG
=
"KS3Core"
const
val
DEFAULT_BUCKET_NAME
=
"bp-yidian"
const
val
DEFAULT_END_POINT
=
"ks3-cn-beijing.ksyun.com"
const
val
VIDEO_SUFFIX
=
".mp4"
const
val
IMAGE_SUFFIX
=
".jpg"
val
INSTANCE
:
KS3Core
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
KS3Core
(
context
=
YdBaseApplication
.
context
)
}
}
init
{
setupClient
()
}
/**
* 配置金山云client
*/
private
fun
setupClient
()
{
client
.
setConfiguration
(
Ks3ClientConfiguration
.
getDefaultConfiguration
())
client
.
setEndpoint
(
DEFAULT_END_POINT
)
}
/**
* 文件上传
* @param path 本地文件全路径
* @param type 文件类型
* @param scenario 业务场景
*/
fun
uploadObject
(
path
:
String
,
type
:
ObjectType
,
scenario
:
ScenarioType
,
listener
:
OnKS3TaskListener
)
{
CommonDataSource
.
getKSYunObjectId
(
object
:
IGetKSYunObjectIdCallback
{
override
fun
getKSYunObjectIdSuccess
(
result
:
GetKSYunObjectIdBean
.
Response
?)
{
Log
.
d
(
TAG
,
"request getKSYun objectId success, objectId: ${result?.objectId}, bucket: ${result?.bucket}"
)
// 执行金山云上传
val
request
=
PutObjectRequest
(
result
?.
bucket
,
result
?.
objectId
+
getObjectKeySuffix
(
type
),
File
(
path
)
)
request
.
cannedAcl
=
CannedAccessControlList
.
Private
client
.
putObject
(
request
,
KS3CorePutObjectResponseHandler
(
result
?.
bucket
,
result
?.
objectId
+
getObjectKeySuffix
(
type
),
listener
)
)
}
override
fun
getKSYunObjectIdFailure
(
message
:
String
?)
{
Log
.
e
(
TAG
,
"request get KSYun objectId fail, message: $message"
)
}
},
hashMapOf
(
Pair
(
"scenario"
,
scenario
.
scenario
)))
}
/**
* 文件上传
* @param path 本地文件全路径
* @param scenario 业务场景
*/
fun
uploadObject
(
path
:
String
,
scenario
:
ScenarioType
,
listener
:
OnKS3TaskListener
)
{
CommonDataSource
.
getKSYunObjectId
(
object
:
IGetKSYunObjectIdCallback
{
override
fun
getKSYunObjectIdSuccess
(
result
:
GetKSYunObjectIdBean
.
Response
?)
{
Log
.
d
(
TAG
,
"request getKSYun objectId success, objectId: ${result?.objectId}, bucket: ${result?.bucket}"
)
// 执行金山云上传
val
request
=
PutObjectRequest
(
result
?.
bucket
,
result
?.
objectId
,
File
(
path
))
request
.
cannedAcl
=
CannedAccessControlList
.
Private
client
.
putObject
(
request
,
KS3CorePutObjectResponseHandler
(
result
?.
bucket
,
result
?.
objectId
,
listener
)
)
}
override
fun
getKSYunObjectIdFailure
(
message
:
String
?)
{
Log
.
e
(
TAG
,
"request get KSYun objectId fail, message: $message"
)
}
},
hashMapOf
(
Pair
(
"scenario"
,
scenario
.
scenario
)))
}
/**
* 文件上传
* @param file 文件实体
* @param scenario 业务场景
*/
fun
uploadObject
(
file
:
File
,
scenario
:
ScenarioType
,
listener
:
OnKS3TaskListener
)
{
CommonDataSource
.
getKSYunObjectId
(
object
:
IGetKSYunObjectIdCallback
{
override
fun
getKSYunObjectIdSuccess
(
result
:
GetKSYunObjectIdBean
.
Response
?)
{
Log
.
d
(
TAG
,
"request getKSYun objectId success, objectId: ${result?.objectId}, bucket: ${result?.bucket}"
)
// 执行金山云上传
val
request
=
PutObjectRequest
(
result
?.
bucket
,
result
?.
objectId
,
file
)
request
.
cannedAcl
=
CannedAccessControlList
.
Private
client
.
putObject
(
request
,
KS3CorePutObjectResponseHandler
(
result
?.
bucket
,
result
?.
objectId
,
listener
)
)
}
override
fun
getKSYunObjectIdFailure
(
message
:
String
?)
{
Log
.
e
(
TAG
,
"request get KSYun objectId fail, message: $message"
)
}
},
hashMapOf
(
Pair
(
"scenario"
,
scenario
.
scenario
)))
}
/**
* 文件上传
* @param file 文件实体
* @param type 文件类型
* @param scenario 业务场景
*/
fun
uploadObject
(
file
:
File
,
type
:
ObjectType
,
scenario
:
ScenarioType
,
listener
:
OnKS3TaskListener
)
{
CommonDataSource
.
getKSYunObjectId
(
object
:
IGetKSYunObjectIdCallback
{
override
fun
getKSYunObjectIdSuccess
(
result
:
GetKSYunObjectIdBean
.
Response
?)
{
Log
.
d
(
TAG
,
"request getKSYun objectId success, objectId: ${result?.objectId}, bucket: ${result?.bucket}"
)
// 执行金山云上传
val
request
=
PutObjectRequest
(
result
?.
bucket
,
result
?.
objectId
+
getObjectKeySuffix
(
type
),
file
)
request
.
cannedAcl
=
CannedAccessControlList
.
Private
client
.
putObject
(
request
,
KS3CorePutObjectResponseHandler
(
result
?.
bucket
,
result
?.
objectId
+
getObjectKeySuffix
(
type
),
listener
)
)
}
override
fun
getKSYunObjectIdFailure
(
message
:
String
?)
{
Log
.
e
(
TAG
,
"request get KSYun objectId fail, message: $message"
)
}
},
hashMapOf
(
Pair
(
"scenario"
,
scenario
.
scenario
)))
}
/**
* 获取ObjectKey后缀
*/
private
fun
getObjectKeySuffix
(
type
:
ObjectType
):
String
{
return
when
(
type
)
{
ObjectType
.
IMAGE
->
IMAGE_SUFFIX
ObjectType
.
VIDEO
->
VIDEO_SUFFIX
}
}
/**
* 本地生成ObjectKey
* 作为Object在云空间的唯一标识
*/
private
fun
getLocalObjectKey
(
name
:
String
,
type
:
ObjectType
):
String
{
return
MD5Util
.
md5Encrypt32Upper
(
name
+
FtDeviceFingerManager
.
getDeviceFinger
())
+
if
(
type
==
ObjectType
.
VIDEO
)
VIDEO_SUFFIX
else
IMAGE_SUFFIX
}
/**
* 调用金山云API后 SDK会回调此函数用于获取必要参数向AppServer请求token
*/
override
fun
onCalculateAuth
(
httpMethod
:
String
,
contentType
:
String
,
date
:
String
,
contentMD5
:
String
,
resource
:
String
,
headers
:
String
):
String
?
{
// 此处由APP端向业务服务器发送post请求返回Token
// 该回调方法运行在非主线程
Log
.
d
(
TAG
,
"KSYun calculate auth, httpMethod: $httpMethod, contentType: $contentType, date: $date, contentMD5: $contentMD5, resource: $resource, headers: $headers"
)
val
requestParams
=
HashMap
<
String
,
String
?>()
requestParams
[
"http_method"
]
=
httpMethod
requestParams
[
"date"
]
=
date
requestParams
[
"resource"
]
=
resource
requestParams
[
"content_md5"
]
=
contentMD5
requestParams
[
"content_type"
]
=
contentType
requestParams
[
"headers"
]
=
headers
return
CommonDataSource
.
getKSYunToken
(
requestParams
)
?.
result
?.
token
}
/**
* 业务监听
*/
interface
OnKS3TaskListener
{
fun
onTaskStart
()
fun
onTaskProgress
(
progress
:
Double
)
fun
onTaskFinish
()
fun
onTaskCancel
()
fun
onTaskSuccess
(
bucket
:
String
?,
objectKey
:
String
?)
fun
onTaskFailure
(
statesCode
:
Int
,
message
:
String
?)
}
/**
* 上传对象的类型
*/
enum
class
ObjectType
{
VIDEO
,
IMAGE
}
/**
* 业务场景的类型
*/
enum
class
ScenarioType
(
val
scenario
:
String
)
{
// 身份证
ID_CARD
(
"id_card"
),
// 活体数据
ALIVE_DETECT
(
"living_data"
),
// 营业执照
BUSINESS_LICENSE
(
"business_license"
),
// 商品
COMMODITY
(
"goods"
)
}
/**
* 金山云object上传handler
*/
class
KS3CorePutObjectResponseHandler
(
private
val
bucket
:
String
?,
private
val
objectKey
:
String
?,
val
listener
:
OnKS3TaskListener
)
:
PutObjectResponseHandler
()
{
override
fun
onTaskProgress
(
progress
:
Double
)
{
// work thread
listener
.
onTaskProgress
(
progress
)
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
error
:
Ks3Error
?,
responceHeaders
:
Array
<
out
Header
>?,
response
:
String
?,
throwable
:
Throwable
?
)
{
Log
.
e
(
TAG
,
"put object fail:, errorMsg: ${error?.errorMessage}"
)
listener
.
onTaskFailure
(
statesCode
,
error
?.
errorMessage
)
}
override
fun
onTaskSuccess
(
statesCode
:
Int
,
responceHeaders
:
Array
<
out
Header
>?)
{
Log
.
d
(
TAG
,
"put object success."
)
listener
.
onTaskSuccess
(
bucket
,
objectKey
)
}
override
fun
onTaskStart
()
{
listener
.
onTaskStart
()
}
override
fun
onTaskFinish
()
{
listener
.
onTaskFinish
()
}
override
fun
onTaskCancel
()
{
listener
.
onTaskCancel
()
}
}
}
CommonLib/BCommon/src/main/java/com/yidian/bcommon/utils/ShareUtils.kt
deleted
100644 → 0
View file @
60eb2874
package
com.yidian.bcommon.utils
import
android.content.Context
/**
* 分享工具类
*/
object
ShareUtils
{
}
CommonLib/BCommon/src/main/java/com/yidian/bcommon/utils/ViewHolderUtil.kt
deleted
100644 → 0
View file @
60eb2874
package
com.yidian.bcommon.utils
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.annotation.LayoutRes
import
androidx.recyclerview.widget.RecyclerView
class
ViewHolderUtil
{
companion
object
{
fun
RecyclerView
.
Adapter
<
out
RecyclerView
.
ViewHolder
>.
createItemView
(
parent
:
ViewGroup
,
@LayoutRes
layoutId
:
Int
):
View
{
return
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
layoutId
,
parent
,
false
)
}
}
}
Components/BGeneralBusiness/src/main/java/com/yidian/shenghuoquan/bgeneralbusiness/http/GeneralBusinessApiService.kt
View file @
672b2865
package
com.yidian.shenghuoquan.bgeneralbusiness.http
import
com.yidian.bcommon.http.*
import
com.yidian.bcommon.http.HttpResult
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
io.reactivex.rxjava3.core.Observable
import
retrofit2.http.GET
import
retrofit2.http.QueryMap
...
...
@@ -9,6 +10,7 @@ interface GeneralBusinessApiService {
private
companion
object
{
const
val
sendMsgCode
=
"/sms/sms/send_code"
const
val
getCommonConfig
=
"/api/resource"
}
/**
...
...
@@ -16,4 +18,10 @@ interface GeneralBusinessApiService {
*/
@GET
(
sendMsgCode
)
fun
sendMsgCode
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
params
:
Map
<
String
,
String
?
>):
Observable
<
HttpResult
<
Any
?
>>
/**
* TowerPro获取通用配置数据
*/
@GET
(
getCommonConfig
)
fun
getCommonConfig
(
@QueryMap
requestParams
:
Map
<
String
,
String
>):
Observable
<
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>>
}
Components/BGeneralBusiness/src/main/java/com/yidian/shenghuoquan/bgeneralbusiness/http/GeneralBusinessRemoteDataService.kt
View file @
672b2865
package
com.yidian.shenghuoquan.bgeneralbusiness.http
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.http.*
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.http.ServiceFactory
object
GeneralBusinessRemoteDataService
{
private
var
api
=
ServiceFactory
.
getInstance
().
createService
(
GeneralBusinessApiService
::
class
.
java
)
private
val
towerApi
by
lazy
{
ServiceFactory
.
getInstance
().
createService
(
GeneralBusinessApiService
::
class
.
java
,
if
(
RunConfig
.
TOWER_API_ENV
==
AppConfig
.
TowerApiEnvTest
)
{
AppConfig
.
TowerApiDomainTest
}
else
{
AppConfig
.
TowerApiDomainPro
}
)
}
// 获取短信验证码
fun
sendMsgCode
(
requestParams
:
HashMap
<
String
,
String
?
>,
callback
:
((
Boolean
)
->
Unit
)?
=
null
)
{
val
timeStamp
=
System
.
currentTimeMillis
()
...
...
@@ -23,4 +37,24 @@ object GeneralBusinessRemoteDataService {
}
})
}
// TowerPro 获取配置数据
fun
getCommonConfig
(
apiCallback
:
IGetCommonConfigCallback
,
requestParams
:
HashMap
<
String
,
String
>)
{
towerApi
.
getCommonConfig
(
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultObserver
<
GetCommonConfigBean
.
GetCommonConfigResponse
>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigSuccess
(
result
?.
result
)
}
override
fun
onFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
override
fun
onNetworkFailure
(
result
:
HttpResult
<
GetCommonConfigBean
.
GetCommonConfigResponse
>?)
{
apiCallback
.
getCommonConfigFailure
(
result
?.
status
)
}
})
}
}
Components/BGeneralBusiness/src/main/java/com/yidian/shenghuoquan/bgeneralbusiness/service/GeneralAbilityService.kt
View file @
672b2865
package
com.yidian.shenghuoquan.bgeneralbusiness.service
import
com.google.gson.Gson
import
com.yidian.bcommon.constant.AppConfig
import
com.yidian.bcommon.constant.RunConfig
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.bcommon.sdk.BCommonManager
import
com.yidian.bcommon.services.ZapServiceActionConstants
import
com.yidian.shenghuoquan.bgeneralbusiness.config.LazyInitConfig
import
com.yidian.shenghuoquan.bgeneralbusiness.http.GeneralBusinessRemoteDataService
...
...
@@ -13,14 +19,14 @@ import org.json.JSONObject
*/
class
GeneralAbilityService
:
ZapService
()
{
private
lateinit
var
resolver
:
ResultResolver
private
val
gson
by
lazy
{
Gson
()
}
override
fun
onAction
(
path
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
this
.
resolver
=
resolver
params
as
JSONObject
when
(
action
)
{
ZapServiceActionConstants
.
ActionRequestSmsCode
->
requestSmsCode
(
params
)
ZapServiceActionConstants
.
ActionRequestSmsCode
->
requestSmsCode
(
params
,
resolver
)
ZapServiceActionConstants
.
ActionLazyInit
->
lazyInit
()
ZapServiceActionConstants
.
ActionGetTowerProCommonConfig
->
getTowerProCommonConfig
(
resolver
)
}
}
...
...
@@ -33,7 +39,7 @@ class GeneralAbilityService : ZapService() {
/**
* 请求短信验证码
*/
private
fun
requestSmsCode
(
params
:
JSONObject
)
{
private
fun
requestSmsCode
(
params
:
JSONObject
,
resolver
:
ResultResolver
)
{
val
mobile
=
params
.
optString
(
"mobile"
)
val
scene
=
params
.
optString
(
"scene"
)
val
paramsMap
=
HashMap
<
String
,
String
?>()
...
...
@@ -53,4 +59,27 @@ class GeneralAbilityService : ZapService() {
// 初始化慧眼
LazyInitConfig
.
initXInsight
()
}
/**
* 获取TowerPro通用配置数据
*/
private
fun
getTowerProCommonConfig
(
resolver
:
ResultResolver
)
{
GeneralBusinessRemoteDataService
.
getCommonConfig
(
object
:
IGetCommonConfigCallback
{
override
fun
getCommonConfigSuccess
(
result
:
GetCommonConfigBean
.
GetCommonConfigResponse
?)
{
resolver
.
success
(
JSONObject
(
gson
.
toJson
(
result
)))
}
override
fun
getCommonConfigFailure
(
message
:
String
?)
{
resolver
.
fail
(-
1
,
message
,
"获取配置失败,请稍后重试"
)
}
},
hashMapOf
(
"appid"
to
BCommonManager
.
getAppId
(),
"env"
to
RunConfig
.
TOWER_API_ENV
.
toString
(),
"version"
to
AppConfig
.
TowerApiVersion
,
"os"
to
AppConfig
.
TowerApiOS
,
"keytag"
to
BCommonManager
.
getTowerProKeyTag
()
)
)
}
}
Components/BManagerCenter/src/main/java/com/yidian/shenghuoquan/bmanagercenter/constant/Constant.kt
View file @
672b2865
...
...
@@ -7,6 +7,8 @@ package com.yidian.shenghuoquan.bmanagercenter.constant
*/
object
Constant
{
const
val
LOG_TAG
=
"BManagerCenter"
const
val
LIFE_ACCOUNT_AUTH_TAG
=
"LifeAccountAuth"
// 认证类型
...
...
Components/BManagerCenter/src/main/java/com/yidian/shenghuoquan/bmanagercenter/ui/center/MerchantCenterActivity.kt
View file @
672b2865
...
...
@@ -6,16 +6,14 @@ import android.view.View
import
androidx.core.content.ContextCompat
import
androidx.core.view.isVisible
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.google.gson.Gson
import
com.scwang.smart.refresh.layout.api.RefreshLayout
import
com.scwang.smart.refresh.layout.listener.OnRefreshListener
import
com.yidian.bcommon.base.BaseActivity
import
com.yidian.bcommon.bean.HintOptionBean
import
com.yidian.bcommon.bean.LifeAccountItemBean
import
com.yidian.bcommon.constant.*
import
com.yidian.bcommon.http.CommonDataSource
import
com.yidian.bcommon.http.bean.GetCommonConfigBean
import
com.yidian.bcommon.http.callback.IGetCommonConfigCallback
import
com.yidian.bcommon.sdk.BCommonManager
import
com.yidian.bcommon.sdk.ClientType
import
com.yidian.bcommon.sdk.JudgeClientUtils
import
com.yidian.bcommon.services.ZapServiceActionConstants
...
...
@@ -44,6 +42,8 @@ import com.yidian.xpage.XPageManager
import
com.yidian.yac.core.zap.ZapTicket
import
org.greenrobot.eventbus.Subscribe
import
org.greenrobot.eventbus.ThreadMode
import
org.json.JSONObject
import
timber.log.Timber
/**
* author: yinjiacheng
...
...
@@ -53,7 +53,7 @@ import org.greenrobot.eventbus.ThreadMode
class
MerchantCenterActivity
:
BaseActivity
<
ActivityMerchantCenterBinding
>(),
MerchantSwitchDialog
.
OnMerchantSwitchCallback
,
LifeAccountLabelView
.
OnLifeAccountLabelCallback
,
MerchantCenterBottomHintDialog
.
OnMerchantCenterBottomHintCallback
,
IAuthMerchantCheckCallback
,
MerchantServiceFunctionAdapter
.
OnItemClickListener
,
CommonTopBarView
.
OnCommonTopBarActionCallback
,
OnRefreshListener
,
DialogInterface
.
OnShowListener
,
DialogInterface
.
OnDismissListener
,
IGetCommonConfigCallback
{
OnRefreshListener
,
DialogInterface
.
OnShowListener
,
DialogInterface
.
OnDismissListener
{
companion
object
{
const
val
PARAMS_LIFE_ACCOUNT_ID
=
"life_account_id"
...
...
@@ -79,6 +79,8 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), Me
*/
private
lateinit
var
functionPermissionList
:
ArrayList
<
Int
>
private
val
gson
by
lazy
{
Gson
()
}
override
fun
createViewBinding
():
ActivityMerchantCenterBinding
{
return
ActivityMerchantCenterBinding
.
inflate
(
layoutInflater
)
}
...
...
@@ -418,31 +420,16 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), Me
override
fun
onRefresh
(
refreshLayout
:
RefreshLayout
)
{
// 刷新数据
// 请求TowerPro通用配置
CommonDataSource
.
getCommonConfig
(
this
,
hashMapOf
(
"appid"
to
BCommonManager
.
getAppId
(),
"env"
to
RunConfig
.
TOWER_API_ENV
.
toString
(),
"version"
to
AppConfig
.
TowerApiVersion
,
"os"
to
AppConfig
.
TowerApiOS
,
"keytag"
to
BCommonManager
.
getTowerProKeyTag
()
)
)
}
override
fun
onShow
(
dialog
:
DialogInterface
?)
{
// 切换主体弹窗显示
// 更改页面标题背景色
viewBind
.
bvTopBar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
white
))
}
override
fun
onDismiss
(
dialog
:
DialogInterface
?)
{
// 切换主体弹窗消失
// 更改页面标题背景色
viewBind
.
bvTopBar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
transparent
))
ZapTicket
(
ZapServiceNameConstants
.
GeneralAbilityService
).
withAction
(
ZapServiceActionConstants
.
ActionGetTowerProCommonConfig
)
.
onResult
{
xResult
->
val
configResult
=
if
(
xResult
.
code
==
0
)
{
Timber
.
tag
(
Constant
.
LOG_TAG
).
i
(
"get common config success, result: ${xResult.result}"
)
gson
.
fromJson
((
xResult
.
result
as
JSONObject
).
toString
(),
GetCommonConfigBean
.
GetCommonConfigResponse
::
class
.
java
)
}
else
{
Timber
.
tag
(
Constant
.
LOG_TAG
).
e
(
"get common config fail, message: ${xResult.mesg}"
)
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
return
@onResult
}
override
fun
getCommonConfigSuccess
(
@Suppress
(
"PARAMETER_NAME_CHANGED_ON_OVERRIDE"
)
configResult
:
GetCommonConfigBean
.
GetCommonConfigResponse
?)
{
// 请求生活号列表
ApiService
.
getLifeAccountList
(
object
:
IGetLifeAccountListCallback
{
override
fun
getLifeAccountListSuccess
(
@Suppress
(
"PARAMETER_NAME_CHANGED_ON_OVERRIDE"
)
lifeAccountResult
:
ArrayList
<
LifeAccountItemBean
.
Response
>?)
{
...
...
@@ -482,10 +469,22 @@ class MerchantCenterActivity : BaseActivity<ActivityMerchantCenterBinding>(), Me
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
}
})
}.
onLost
{
Timber
.
tag
(
Constant
.
LOG_TAG
).
e
(
"get common config fail, message: ${it.mesg}"
)
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
}.
ship
()
}
override
fun
getCommonConfigFailure
(
message
:
String
?)
{
viewBind
.
rlRefresh
.
finishRefresh
(
false
)
override
fun
onShow
(
dialog
:
DialogInterface
?)
{
// 切换主体弹窗显示
// 更改页面标题背景色
viewBind
.
bvTopBar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
white
))
}
override
fun
onDismiss
(
dialog
:
DialogInterface
?)
{
// 切换主体弹窗消失
// 更改页面标题背景色
viewBind
.
bvTopBar
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
transparent
))
}
private
fun
requestLogout
()
{
...
...
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