-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
169 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
backend/src/main/scala/ru/vityaman/mylogistics/api/http/request/CreateTransferRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ru.vityaman.mylogistics.api.http.request | ||
|
||
import zio.json._ | ||
|
||
import ru.vityaman.mylogistics.logic.model.Transfer | ||
|
||
import java.time.Instant | ||
|
||
final case class CreateTransferRequest( | ||
sourceId: Int, | ||
targetId: Int, | ||
withdrawMoment: Instant, | ||
incomeMoment: Instant | ||
) { | ||
def asModel: Transfer.Request = | ||
Transfer.Request( | ||
sourceId = sourceId, | ||
targetId = targetId, | ||
withdrawMoment = withdrawMoment, | ||
incomeMoment = incomeMoment | ||
) | ||
} | ||
|
||
object CreateTransferRequest { | ||
implicit val decoder: JsonDecoder[CreateTransferRequest] = | ||
DeriveJsonDecoder.gen[CreateTransferRequest] | ||
implicit val encoder: JsonEncoder[CreateTransferRequest] = | ||
DeriveJsonEncoder.gen[CreateTransferRequest] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...rc/main/scala/ru/vityaman/mylogistics/logic/service/logged/LoggedTransactionService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ru.vityaman.mylogistics.logic.service.logged | ||
|
||
import zio.RLayer | ||
import zio.Task | ||
import zio.ZIO | ||
import zio.ZLayer | ||
|
||
import ru.vityaman.mylogistics.logic.model.DetailedTransaction | ||
import ru.vityaman.mylogistics.logic.model.Transfer | ||
import ru.vityaman.mylogistics.logic.service.TransactionService | ||
|
||
final class LoggedTransactionService(origin: TransactionService) | ||
extends TransactionService { | ||
|
||
override def getAll(): Task[List[DetailedTransaction]] = | ||
origin.getAll() | ||
|
||
override def getTransfers(): Task[List[Transfer.Equipped]] = | ||
origin | ||
.getTransfers() | ||
.tapErrorCause(ZIO.logCause(_)) | ||
|
||
override def create(transfer: Transfer.Request): Task[Transfer.Id] = | ||
origin | ||
.create(transfer) | ||
.tapErrorCause(ZIO.logCause(_)) | ||
} | ||
|
||
object LoggedTransactionService { | ||
val layer: RLayer[TransactionService, TransactionService] = | ||
ZLayer.fromFunction(new LoggedTransactionService(_)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters