Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
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
Vladislav Bogdashkin
Room Park Android
Commits
38f8b251
Commit
38f8b251
authored
Jan 14, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deals user dependencies workaround
parent
1bd9f768
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
149 additions
and
30 deletions
+149
-30
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+45
-0
Deal.kt
.../visual/roompark/data/repository/db/requrey/model/Deal.kt
+4
-4
User.kt
.../visual/roompark/data/repository/db/requrey/model/User.kt
+7
-4
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+27
-0
DealContract.kt
...m/biganto/visual/roompark/domain/contract/DealContract.kt
+2
-1
deal.kt
...ava/com/biganto/visual/roompark/domain/interactor/deal.kt
+12
-7
deals.kt
...va/com/biganto/visual/roompark/domain/interactor/deals.kt
+15
-7
deals.kt
...in/java/com/biganto/visual/roompark/domain/model/deals.kt
+14
-2
dealUseCase.kt
...om/biganto/visual/roompark/domain/use_case/dealUseCase.kt
+17
-0
ScreenController.kt
...ual/roompark/presentation/screen/deal/ScreenController.kt
+3
-2
ScreenDI.kt
...anto/visual/roompark/presentation/screen/deal/ScreenDI.kt
+1
-1
ScreenPresenter.kt
...sual/roompark/presentation/screen/deal/ScreenPresenter.kt
+1
-1
ScreenContract.kt
...sual/roompark/presentation/screen/deals/ScreenContract.kt
+1
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
38f8b251
...
...
@@ -4,12 +4,14 @@ import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import
com.biganto.visual.roompark.data.local.UserState
import
com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.domain.model.fromEntity
...
...
@@ -23,6 +25,8 @@ import javax.inject.Inject
*/
//
const
val
TEST_DEAL_TOKEN
=
"185|_Zs1k17uO_Ezn7wqZ8ostl8XJ5_G2rDez3x9F4qxj-do4wV1bxiUfLgOZZMUvc5guXScNN3Dr9yfNEBVvxGkQw=="
class
EstateRepository
@Inject
constructor
(
private
val
local
:
ILocalStore
,
...
...
@@ -189,4 +193,45 @@ class EstateRepository @Inject constructor(
// , electric:Boolean
// ) = api.getDirectPlan(estateId,planId,furniture,sizes,electric).
private
val
getDealsApi
:
Observable
<
List
<
DealEntity
>>
=
local
.
recentUser
()
.
flatMap
{
when
(
it
)
{
is
UserState
.
Authenticated
->
db
.
fetchUser
(
it
.
uuid
.
toInt
())
else
->
throw
CustomApiException
.
NotAuthorizedException
()
}
}
.
flatMap
{
user
->
api
.
getDeals
(
TEST_DEAL_TOKEN
)
//api.getDeals(user.authToken)
.
doOnError
(
Timber
::
e
)
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
doOnNext
{
it
.
forEach
{
deal
->
deal
.
user
=
user
}
}
.
doOnNext
(
db
::
blockingUpsert
)
}
private
val
getDealsDb
:
Observable
<
List
<
DealEntity
>>
=
local
.
recentUser
()
.
flatMap
{
when
(
it
)
{
is
UserState
.
Authenticated
->
db
.
fetchUser
(
it
.
uuid
.
toInt
()).
take
(
1
)
else
->
throw
CustomApiException
.
NotAuthorizedException
()
}
}
.
map
{
it
.
deals
?.
map
{
deal
->
deal
as
DealEntity
}
}
override
fun
getDeals
():
Observable
<
List
<
DealModel
>>
{
return
Observable
.
mergeDelayError
(
arrayListOf
(
getDealsDb
,
getDealsApi
)
).
map
{
fromEntity
(
it
,
::
fromEntity
)
}
.
doOnError
(
Timber
::
e
)
}
}
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/Deal.kt
View file @
38f8b251
...
...
@@ -10,19 +10,19 @@ import io.requery.*
interface
Deal
:
Persistable
{
@get
:
Key
val
id
:
String
val
estateCrmId
:
String
val
id
:
Int
val
estateCrmId
:
Int
val
opportunitySum
:
Int
val
paymentSum
:
Int
val
amountPaySum
:
Int
val
statusId
:
Int
val
managerName
:
String
@get
:
ForeignKey
(
references
=
Estate
::
class
)
@get
:
OneToOne
(
cascade
=
[
CascadeAction
.
NON
E
])
@get
:
OneToOne
(
cascade
=
[
CascadeAction
.
SAV
E
])
var
estate
:
Estate
@get
:
Nullable
@get
:
Column
(
name
=
"UserContainer"
)
@get
:
ForeignKey
(
references
=
User
::
class
)
@get
:
OneToOne
(
mappedBy
=
"uuid"
,
cascade
=
[
CascadeAction
.
NONE
])
@get
:
ManyToOne
(
cascade
=
[
CascadeAction
.
NONE
])
var
user
:
User
?
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/User.kt
View file @
38f8b251
package
com.biganto.visual.roompark.data.repository.db.requrey.model
import
io.requery.Entity
import
io.requery.Key
import
io.requery.Persistable
import
io.requery.Table
import
io.requery.*
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
...
...
@@ -21,5 +18,11 @@ interface User : Persistable {
val
authToken
:
String
val
targetResolution
:
Int
// @get:ForeignKey(references = Deal::class )
@get
:
Nullable
@get
:
OneToMany
(
cascade
=
[
CascadeAction
.
DELETE
])
val
deals
:
List
<
Deal
>?
}
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
38f8b251
...
...
@@ -93,6 +93,33 @@ fun fromRaw(raw:ResolutionRaw) =
fun
fromRaw
(
raw
:
DealRaw
,
uuid
:
Int
):
DealEntity
{
val
user
=
UserEntity
()
user
.
setUuid
(
uuid
)
return
fromRaw
(
raw
,
user
)
}
fun
fromRaw
(
raw
:
DealRaw
):
DealEntity
{
val
entity
=
DealEntity
()
entity
.
setId
(
raw
.
id
)
entity
.
setEstateCrmId
(
raw
.
estate_id
)
entity
.
setOpportunitySum
(
raw
.
opportunity_sum
)
entity
.
setPaymentSum
(
raw
.
payment_sum
)
entity
.
setAmountPaySum
(
raw
.
amount_pay_sum
)
entity
.
setStatusId
(
raw
.
status_id
)
entity
.
setManagerName
(
raw
.
manager
)
return
entity
}
fun
fromRaw
(
raw
:
DealRaw
,
user
:
UserEntity
):
DealEntity
{
val
entity
=
fromRaw
(
raw
)
entity
.
estate
=
fromRaw
(
raw
.
estate
)
entity
.
user
=
user
return
entity
}
fun
fromRaw
(
raw
:
EstateRaw
):
EstateEntity
{
val
entity
=
EstateEntity
()
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DealContract.kt
View file @
38f8b251
package
com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
io.reactivex.Observable
...
...
@@ -24,5 +25,5 @@ interface DealContract{
,
electric
:
Boolean
?):
Observable
<
String
>
fun
getDeals
():
Observable
<
List
<
DealModel
>>
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/deal.kt
View file @
38f8b251
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.model.*
import
io.reactivex.
Sing
le
import
io.reactivex.
Observab
le
import
javax.inject.Inject
/**
...
...
@@ -9,10 +10,14 @@ import javax.inject.Inject
*/
class
DealInteractor
@Inject
constructor
(
val
useCase
:
DealContract
){
fun
getDeal
(
id
:
String
)
=
Single
.
just
(
dealFlat
)
fun
getStatusList
()
=
Single
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
fun
getDeal
(
id
:
Int
):
Observable
<
DealModel
>
=
useCase
.
getDeals
()
.
map
{
it
.
first
{
it
.
id
==
id
}
}
fun
getStatusList
()
=
Observable
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
companion
object
{
...
...
@@ -193,8 +198,8 @@ class DealInteractor @Inject constructor(
type
=
"flat"
,
url
=
"https://stage.room-park.ru:38386/choose/flat/1/14/1086/"
),
estate_id
=
"20dfe300-b85c-e711-80d7-00155d0a0a0e"
,
id
=
"9abdcb37-306a-e811-80e6-00155d0a0a0e"
,
estate_id
=
2156
,
id
=
1562623
,
managerName
=
"\u0411\u043e\u0441\u043e\u0432\u0430, \u0418\u0440\u0438\u043d\u0430"
,
opportunitySum
=
5035860
,
paymentSum
=
500000
,
...
...
@@ -302,8 +307,8 @@ class DealInteractor @Inject constructor(
type
=
"flat"
,
url
=
"https://stage.room-park.ru:38386/choose/flat/1/2/88/"
),
estate_id
=
"54d7e300-b85c-e711-80d7-00155d0a0a0e"
,
id
=
"2419877b-2d6a-e811-80e6-00155d0a0a0e"
,
estate_id
=
6222
,
id
=
42341
,
managerName
=
"Босова, Ирина"
,
opportunitySum
=
5618160
,
paymentSum
=
500000
,
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/deals.kt
View file @
38f8b251
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.*
import
io.reactivex.Single
import
com.biganto.visual.roompark.domain.use_case.DealseUseCase
import
io.reactivex.Observable
import
javax.inject.Inject
/**
...
...
@@ -9,10 +10,12 @@ import javax.inject.Inject
*/
class
DealsInteractor
@Inject
constructor
(
val
useCase
:
DealseUseCase
){
fun
fetchDeals
()
=
Single
.
just
(
arrayListOf
(
dealFlat
,
dealParkign
))
fun
getStatusList
()
=
Single
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
fun
fetchDeals
()
=
useCase
.
getDeals
()
// Single.just(arrayListOf(dealFlat, dealParkign))
fun
getStatusList
()
=
Observable
.
just
(
statusList
.
sortedBy
{
it
.
orderId
})
companion
object
{
...
...
@@ -67,6 +70,11 @@ class DealsInteractor @Inject constructor(
10
,
"Договор находится в офисе продаж. Вы можете забрать его в любое время"
,
"Договор готов к выдаче"
),
StatusModel
(
11
,
"AAAA aa a a aAA a a"
,
"AAAA"
)
)
...
...
@@ -187,8 +195,8 @@ class DealsInteractor @Inject constructor(
type
=
"flat"
,
url
=
"https://stage.room-park.ru:38386/choose/flat/1/14/1086/"
),
estate_id
=
"20dfe300-b85c-e711-80d7-00155d0a0a0e"
,
id
=
"9abdcb37-306a-e811-80e6-00155d0a0a0e"
,
estate_id
=
1425
,
id
=
4621213
,
managerName
=
"\u0411\u043e\u0441\u043e\u0432\u0430, \u0418\u0440\u0438\u043d\u0430"
,
opportunitySum
=
5035860
,
paymentSum
=
500000
,
...
...
@@ -296,8 +304,8 @@ class DealsInteractor @Inject constructor(
type
=
"flat"
,
url
=
"https://stage.room-park.ru:38386/choose/flat/1/2/88/"
),
estate_id
=
"54d7e300-b85c-e711-80d7-00155d0a0a0e"
,
id
=
"2419877b-2d6a-e811-80e6-00155d0a0a0e"
,
estate_id
=
1231
,
id
=
42342342
,
managerName
=
"Босова, Ирина"
,
opportunitySum
=
5618160
,
paymentSum
=
500000
,
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/deals.kt
View file @
38f8b251
package
com.biganto.visual.roompark.domain.model
import
com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ExplicationEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.PlanPreset
...
...
@@ -20,8 +21,8 @@ data class StatusModel(
)
data class
DealModel
(
val
id
:
String
,
val
estate_id
:
String
,
val
id
:
Int
,
val
estate_id
:
Int
,
val
opportunitySum
:
Int
,
val
paymentSum
:
Int
,
val
amount_pay_sum
:
Int
,
...
...
@@ -30,6 +31,17 @@ data class DealModel(
val
estate
:
EstateModel
)
fun
fromEntity
(
entity
:
DealEntity
)
=
DealModel
(
id
=
entity
.
id
,
estate_id
=
entity
.
estateCrmId
,
opportunitySum
=
entity
.
opportunitySum
,
paymentSum
=
entity
.
paymentSum
,
amount_pay_sum
=
entity
.
amountPaySum
,
statusId
=
entity
.
statusId
,
managerName
=
entity
.
managerName
,
estate
=
fromEntity
(
entity
.
estate
as
EstateEntity
)
)
data class
EstateModel
(
val
id
:
Int
,
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/dealUseCase.kt
0 → 100644
View file @
38f8b251
package
com.biganto.visual.roompark.domain.use_case
import
com.biganto.visual.roompark.domain.contract.DealContract
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
class
DealseUseCase
@Inject
constructor
(
private
val
contract
:
DealContract
)
{
fun
getDeals
()
=
contract
.
getDeals
()
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenController.kt
View file @
38f8b251
...
...
@@ -33,7 +33,7 @@ class DealScreenController :
constructor
(
args
:
Bundle
):
super
(
args
)
constructor
(
id
:
String
)
:
super
(
bundleOf
(
SELECTED_DEAL_ID_KEY
to
id
))
constructor
(
id
:
Int
)
:
super
(
bundleOf
(
SELECTED_DEAL_ID_KEY
to
id
))
override
fun
injectDependencies
()
{
getComponent
()
...
...
@@ -161,7 +161,8 @@ class DealScreenController :
private
fun
getComponent
()
=
DaggerDealScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
,
args
.
getString
(
SELECTED_DEAL_ID_KEY
)
?:
error
(
"Deal Id is empty!"
))
,
args
.
getInt
(
SELECTED_DEAL_ID_KEY
)
)
.
inject
(
this
)
override
fun
getLayoutId
():
Int
=
R
.
layout
.
deal_screen
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenDI.kt
View file @
38f8b251
...
...
@@ -22,7 +22,7 @@ interface DealScreenComponent {
fun
create
(
appComponent
:
AppComponent
,
@BindsInstance
activity
:
RoomParkMainActivity
,
@BindsInstance
@Named
(
SELECTED_DEAL_ID_KEY
)
selectedDealId
:
String
,
@BindsInstance
@Named
(
SELECTED_DEAL_ID_KEY
)
selectedDealId
:
Int
):
DealScreenComponent
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenPresenter.kt
View file @
38f8b251
...
...
@@ -22,7 +22,7 @@ import javax.inject.Named
class
DealScreenPresenter
@Inject
constructor
(
private
val
interactor
:
DealInteractor
,
private
val
context
:
Context
,
@Named
(
SELECTED_DEAL_ID_KEY
)
private
val
dealId
:
String
@Named
(
SELECTED_DEAL_ID_KEY
)
private
val
dealId
:
Int
)
:
BigantoBasePresenter
<
DealScreen
,
DealScreenViewState
>()
{
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenContract.kt
View file @
38f8b251
...
...
@@ -13,7 +13,7 @@ interface DealsScreen : BigantoBaseContract<DealsScreenViewState> {
data class
DealPreviewModel
(
val
id
:
String
,
val
id
:
Int
,
val
type
:
String
,
val
name
:
String
,
val
building
:
Int
?,
...
...
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