-
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.
- Loading branch information
Showing
6 changed files
with
96 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package controllers | ||
|
||
import ( | ||
"time" | ||
|
||
"golang.org/x/exp/constraints" | ||
) | ||
|
||
type Channel struct { | ||
Id uint `json:"id"` | ||
Identifier string `json:"identifier"` | ||
Name string `json:"name"` | ||
} | ||
|
||
type Currency struct { | ||
Id uint `json:"id"` | ||
Name string `json:"name"` | ||
Active bool `json:"active"` | ||
} | ||
|
||
type Payment struct { | ||
UID string `json:"uid" binding:"required"` | ||
Source Channel `json:"source" binding:"required"` | ||
Amount float64 `json:"amount" binding:"amount"` | ||
Currency Currency `json:"currency" binding:"currency"` | ||
Recipient Channel `json:"recipient" binding:"recipient"` | ||
Timestamp time.Time `json:"timeStamp" binding:"timestamp"` | ||
Remarks string `json:"remarks" binding:"remarks"` | ||
} | ||
|
||
func Add[T constraints.Ordered](a , b T) T { | ||
return a + b | ||
} | ||
|
||
func Subtract[T constraints.Ordered](a , b T) T { | ||
return a + b | ||
} | ||
|
||
func Multiply[T constraints.Ordered](a , b T) T { | ||
return a + b | ||
} | ||
|
||
func Divide[T constraints.Ordered](a , b T) T { | ||
return a + b | ||
} | ||
|
||
func Min[T constraints.Ordered](a , b T) T { | ||
if a > b { | ||
return b | ||
} | ||
return a | ||
} | ||
|
||
func Max[T constraints.Ordered](a , b T) T { | ||
if a > b { | ||
return a | ||
} | ||
return b | ||
} |
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,25 @@ | ||
package controllers | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAdd(t *testing.T) { | ||
got := Add[int](1, 3) | ||
|
||
want := 4 | ||
|
||
if got != want { | ||
t.Errorf("got %q, wanted %q", got, want) | ||
} | ||
} | ||
|
||
func TestMinus(t *testing.T) { | ||
got := Subtract[int](10, 4) | ||
|
||
want := 6 | ||
|
||
if got != want { | ||
t.Errorf("got %q, wanted %q", got, want) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
syntax = "proto3"; | ||
|
||
service ProductManagement { | ||
rpc GetProduct(ProductRequest) returns (ProductResponse); | ||
rpc UpdateStock(StockUpdateRequest) returns (StockUpdateResponse); | ||
service PaymentManagement { | ||
rpc GetPayments(PaymentRequest) returns (PaymentResponse); | ||
rpc UpdatePayment(PaymentUpdateRequest) returns (PaymentUpdateResponse); | ||
} |