Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
f3a7046d
Commit
f3a7046d
authored
Jul 14, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置渠道管理类,处理渠道配置所需api
parent
b004a9e3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
117 additions
and
40 deletions
+117
-40
channel.json
app/src/main/assets/channel.json
+2
-2
ChannelInfoBean.java
.../main/java/com/miya/fastcashier/bean/ChannelInfoBean.java
+59
-0
LFileParamBean.kt
...src/main/java/com/miya/fastcashier/bean/LFileParamBean.kt
+2
-6
LoginFormStateBean.kt
...main/java/com/miya/fastcashier/bean/LoginFormStateBean.kt
+1
-1
LFilePickerActivity.java
...ain/java/com/miya/fastcashier/ui/LFilePickerActivity.java
+3
-3
ChannelManageKit.java
...va/com/miya/fastcashier/util/manage/ChannelManageKit.java
+42
-20
LFilePickerManageKit.kt
.../miya/fastcashier/util/manage/log/LFilePickerManageKit.kt
+2
-2
LoginViewModel.kt
...ain/java/com/miya/fastcashier/viewmodel/LoginViewModel.kt
+6
-6
No files found.
app/src/main/assets/channel.json
View file @
f3a7046d
...
...
@@ -2,13 +2,13 @@
{
"ChannelId"
:
-1
,
"ChannelName"
:
"通用"
,
"ChannelName
Desc
"
:
"common"
,
"ChannelName
En
"
:
"common"
,
"ChannelAccountArray"
:
[]
},
{
"ChannelId"
:
1
,
"ChannelName"
:
"匡威"
,
"ChannelName
Desc
"
:
"converse"
,
"ChannelName
En
"
:
"converse"
,
"ChannelAccountArray"
:
[
"6011"
,
"6013"
,
"6014"
,
"6017"
,
"6021"
]
}
]
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/bean/ChannelInfoBean.java
0 → 100644
View file @
f3a7046d
package
com
.
miya
.
fastcashier
.
bean
;
import
com.fastcashier.lib_common.base.BaseBean
;
import
java.util.List
;
/**
* 类描述:渠道配置信息
* 创建人:zpxiang
* 创建时间:
* 修改人:
* 修改时间:
*/
public
class
ChannelInfoBean
extends
BaseBean
{
/**
* ChannelId : 1
* ChannelName : 匡威
* ChannelNameDesc : converse
* ChannelAccountArray : ["6011","6013","6014","6017","6021"]
*/
private
String
ChannelId
;
private
String
ChannelName
;
private
String
ChannelNameEn
;
private
List
<
String
>
ChannelAccountArray
;
public
void
setChannelId
(
String
channelId
)
{
ChannelId
=
channelId
;
}
public
String
getChannelId
()
{
return
ChannelId
;
}
public
String
getChannelName
()
{
return
ChannelName
;
}
public
void
setChannelName
(
String
channelName
)
{
ChannelName
=
channelName
;
}
public
String
getChannelNameEn
()
{
return
ChannelNameEn
;
}
public
void
setChannelNameEn
(
String
channelNameEn
)
{
ChannelNameEn
=
channelNameEn
;
}
public
List
<
String
>
getChannelAccountArray
()
{
return
ChannelAccountArray
;
}
public
void
setChannelAccountArray
(
List
<
String
>
channelAccountArray
)
{
ChannelAccountArray
=
channelAccountArray
;
}
}
app/src/main/java/com/miya/fastcashier/bean/LFileParam
Entity
.kt
→
app/src/main/java/com/miya/fastcashier/bean/LFileParam
Bean
.kt
View file @
f3a7046d
package
com.miya.fastcashier.bean
import
java.io.Serializable
import
com.fastcashier.lib_common.base.BaseBean
/**
* 作者:Leon
* 时间:2017/3/21 14:50
*/
class
LFileParamEntity
:
Serializable
{
class
LFileParamBean
:
BaseBean
()
{
var
title
:
String
?
=
null
@get
:
Deprecated
(
""
)
...
...
app/src/main/java/com/miya/fastcashier/bean/LoginFormState.kt
→
app/src/main/java/com/miya/fastcashier/bean/LoginFormState
Bean
.kt
View file @
f3a7046d
...
...
@@ -3,7 +3,7 @@ package com.miya.fastcashier.bean
/**
* Data validation state of the login form.
*/
data class
LoginFormState
(
data class
LoginFormState
Bean
(
val
usernameError
:
Int
?
=
null
,
val
passwordError
:
Int
?
=
null
,
val
isDataValid
:
Boolean
=
false
...
...
app/src/main/java/com/miya/fastcashier/ui/LFilePickerActivity.java
View file @
f3a7046d
...
...
@@ -23,7 +23,7 @@ import com.fastcashier.lib_common.net.CommonCallback;
import
com.fastcashier.lib_common.util.LogFileUtils
;
import
com.miya.fastcashier.R
;
import
com.miya.fastcashier.util.manage.log.LFileFilter
;
import
com.miya.fastcashier.bean.LFileParam
Entity
;
import
com.miya.fastcashier.bean.LFileParam
Bean
;
import
com.miya.fastcashier.net.MiyaApiRequest
;
import
com.miya.fastcashier.net.MiyaApi
;
import
com.miya.fastcashier.ui.adapter.PathAdapter
;
...
...
@@ -55,7 +55,7 @@ public class LFilePickerActivity extends BaseActivity {
private
String
mPath
;
private
PathAdapter
mPathAdapter
;
private
Toolbar
mToolbar
;
private
LFileParam
Entity
mParamEntity
;
private
LFileParam
Bean
mParamEntity
;
private
boolean
mIsAllSelected
=
false
;
private
Menu
mMenu
;
private
Toast
successToast
;
...
...
@@ -67,7 +67,7 @@ public class LFilePickerActivity extends BaseActivity {
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
mParamEntity
=
(
LFileParam
Entity
)
getIntent
().
getExtras
().
getSerializable
(
"param"
);
mParamEntity
=
(
LFileParam
Bean
)
getIntent
().
getExtras
().
getSerializable
(
"param"
);
setTheme
(
mParamEntity
.
getTheme
());
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_lfile_picker
);
...
...
app/src/main/java/com/miya/fastcashier/util/manage/ChannelManageKit.java
View file @
f3a7046d
...
...
@@ -4,11 +4,17 @@ import android.content.Context;
import
android.content.res.AssetManager
;
import
android.text.TextUtils
;
import
com.blankj.utilcode.util.GsonUtils
;
import
com.fastcashier.lib_common.function.account.AccountService
;
import
com.google.gson.reflect.TypeToken
;
import
com.miya.fastcashier.bean.ChannelInfoBean
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -21,14 +27,15 @@ import java.util.Map;
*/
public
class
ChannelManageKit
{
private
static
Map
<
String
,
String
>
channelMap
;
private
static
final
long
CHANNEL_OFFICIAL_ID
=
-
1
;
private
static
final
String
CHANNEL_OFFICIAL_NAME
=
"通用"
;
private
static
Map
<
String
,
ChannelInfoBean
>
channelMap
;
private
static
final
String
CHANNEL_OFFICIAL_ACCOUNT
=
"-1"
;
private
static
final
String
CHANNEL_OFFICIAL_
CHANNEL
NAME
=
"通用"
;
/**
* 初始化本地渠道数据
*/
public
static
void
initChannelRes
(
Context
context
)
{
clearChannelResData
();
if
(
null
==
context
)
{
initDefaultChannelRes
();
return
;
...
...
@@ -39,12 +46,32 @@ public class ChannelManageKit {
initDefaultChannelRes
();
return
;
}
// GsonUtils.fromJson(assetsJson);
ArrayList
<
ChannelInfoBean
>
channelInfoList
=
GsonUtils
.
fromJson
(
assetsJson
,
new
TypeToken
<
List
<
ChannelInfoBean
>>()
{}.
getType
());
channelMap
=
new
HashMap
<>();
if
(!
channelInfoList
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
channelInfoList
.
size
();
i
++)
{
ChannelInfoBean
channelInfoBean
=
channelInfoList
.
get
(
i
);
List
<
String
>
channelAccountArray
=
channelInfoBean
.
getChannelAccountArray
();
if
(
channelAccountArray
.
isEmpty
()){
initDefaultChannelRes
();
return
;
}
for
(
int
j
=
0
;
j
<
channelAccountArray
.
size
();
i
++)
{
String
account
=
channelAccountArray
.
get
(
j
);
channelMap
.
put
(
account
,
channelInfoBean
);
}
}
}
}
private
static
void
initDefaultChannelRes
()
{
channelMap
=
new
HashMap
<>();
ChannelInfoBean
commonChannel
=
new
ChannelInfoBean
();
commonChannel
.
setChannelId
(
"-1"
);
commonChannel
.
setChannelName
(
CHANNEL_OFFICIAL_CHANNELNAME
);
commonChannel
.
setChannelNameEn
(
CHANNEL_OFFICIAL_CHANNELNAME
);
channelMap
.
put
(
CHANNEL_OFFICIAL_ACCOUNT
,
commonChannel
);
}
/**
...
...
@@ -55,30 +82,29 @@ public class ChannelManageKit {
initChannelRes
(
context
);
}
String
channelName
=
channelMap
.
get
(
AccountService
.
INSTANCE
.
getUserName
());
if
(
TextUtils
.
isEmpty
(
channelName
)
)
{
return
CHANNEL_OFFICIAL_NAME
;
boolean
containsKey
=
channelMap
.
containsKey
(
AccountService
.
INSTANCE
.
getUserName
());
if
(
!
containsKey
)
{
return
CHANNEL_OFFICIAL_
CHANNEL
NAME
;
}
return
channel
Name
;
return
channel
Map
.
get
(
AccountService
.
INSTANCE
.
getUserName
()).
getChannelName
()
;
}
/**
* 获取App渠道编号
*/
public
static
lo
ng
getAppChannelId
(
Context
context
)
{
public
static
Stri
ng
getAppChannelId
(
Context
context
)
{
if
(
context
==
null
)
{
return
CHANNEL_OFFICIAL_
ID
;
return
CHANNEL_OFFICIAL_
ACCOUNT
;
}
if
(
channelMap
==
null
||
channelMap
.
isEmpty
())
{
initChannelRes
(
context
);
}
String
channelCode
=
channelMap
.
get
(
getAppChannelName
(
context
));
if
(
TextUtils
.
isEmpty
(
channelCode
))
{
return
CHANNEL_OFFICIAL_ID
;
if
(!
channelMap
.
containsKey
(
AccountService
.
INSTANCE
.
getUserName
()))
{
return
CHANNEL_OFFICIAL_ACCOUNT
;
}
return
Long
.
parseLong
(
channelCode
);
return
channelMap
.
get
(
AccountService
.
INSTANCE
.
getUserName
()).
getChannelId
(
);
}
public
static
void
clearChannelResData
()
{
...
...
@@ -92,10 +118,6 @@ public class ChannelManageKit {
/**
* 读取json文件
*
* @param context
* @param fileName
* @return
*/
private
static
String
getAssetsJson
(
Context
context
,
String
fileName
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
...
...
app/src/main/java/com/miya/fastcashier/util/manage/log/LFilePickerManageKit.kt
View file @
f3a7046d
...
...
@@ -6,7 +6,7 @@ import android.content.Intent
import
android.os.Bundle
import
androidx.annotation.StyleRes
import
com.miya.fastcashier.R
import
com.miya.fastcashier.bean.LFileParam
Entity
import
com.miya.fastcashier.bean.LFileParam
Bean
import
com.miya.fastcashier.ui.LFilePickerActivity
/**
...
...
@@ -277,7 +277,7 @@ class LFilePickerManageKit {
private
val
bundle
:
Bundle
private
get
()
{
val
paramEntity
=
LFileParam
Entity
()
val
paramEntity
=
LFileParam
Bean
()
paramEntity
.
title
=
mTitle
paramEntity
.
theme
=
theme
paramEntity
.
titleColor
=
mTitleColor
...
...
app/src/main/java/com/miya/fastcashier/viewmodel/LoginViewModel.kt
View file @
f3a7046d
...
...
@@ -7,7 +7,7 @@ import androidx.lifecycle.viewModelScope
import
com.fastcashier.lib_common.function.account.SelfCashierAccountInfo
import
com.fastcashier.lib_common.net.CommonCallback
import
com.miya.fastcashier.R
import
com.miya.fastcashier.bean.LoginFormState
import
com.miya.fastcashier.bean.LoginFormState
Bean
import
com.miya.fastcashier.net.param.LoginParams
import
com.miya.fastcashier.net.MiyaApiRequest
import
kotlinx.coroutines.Dispatchers
...
...
@@ -16,8 +16,8 @@ import kotlinx.coroutines.launch
class
LoginViewModel
:
ViewModel
()
{
val
loginLiveData
:
MutableLiveData
<
Result
<
SelfCashierAccountInfo
>>
=
MutableLiveData
()
val
_loginForm
=
MutableLiveData
<
LoginFormState
>()
val
loginFormState
:
LiveData
<
LoginFormState
>
=
_loginForm
val
_loginForm
=
MutableLiveData
<
LoginFormState
Bean
>()
val
loginFormState
:
LiveData
<
LoginFormState
Bean
>
=
_loginForm
fun
login
(
userName
:
String
,
passWord
:
String
)
{
...
...
@@ -43,11 +43,11 @@ class LoginViewModel : ViewModel() {
fun
loginDataChanged
(
username
:
String
,
password
:
String
)
{
if
(!
isUserNameValid
(
username
))
{
_loginForm
.
value
=
LoginFormState
(
usernameError
=
R
.
string
.
username_not_empty
)
_loginForm
.
value
=
LoginFormState
Bean
(
usernameError
=
R
.
string
.
username_not_empty
)
}
else
if
(!
isPasswordValid
(
password
))
{
_loginForm
.
value
=
LoginFormState
(
passwordError
=
R
.
string
.
password_not_empty
)
_loginForm
.
value
=
LoginFormState
Bean
(
passwordError
=
R
.
string
.
password_not_empty
)
}
else
{
_loginForm
.
value
=
LoginFormState
(
isDataValid
=
true
)
_loginForm
.
value
=
LoginFormState
Bean
(
isDataValid
=
true
)
}
}
...
...
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