diff --git a/migrations/2405310815_create_friend_table.up.sql b/migrations/2405310815_create_friend_table.up.sql index baace5b..3057d02 100644 --- a/migrations/2405310815_create_friend_table.up.sql +++ b/migrations/2405310815_create_friend_table.up.sql @@ -12,8 +12,9 @@ CREATE TABLE friend_bill( friend_bill_id uuid PRIMARY KEY, relation_id uuid NOT NULL REFERENCES friend(relation_id), amount double precision NOT NULL, - title varchar(50) NOT NULL , + title varchar(50) NOT NULL, description varchar(100) NOT NULL default '', + in_debt varchar(30) NOT NULL, created_at timestamp NOT NULL default CURRENT_TIMESTAMP ) diff --git a/protobuf/friend_bill.proto b/protobuf/friend_bill.proto index 3d6c71a..54a86af 100644 --- a/protobuf/friend_bill.proto +++ b/protobuf/friend_bill.proto @@ -37,6 +37,7 @@ message CreateFriendBillRequest { double amount = 2; string title = 3; string description = 4; + string in_debt = 5; } message CreateFriendBillResponse { @@ -53,6 +54,7 @@ message ModifyFriendBillRequest { double amount = 3; string title = 4; string description = 5; + string in_debt = 6; } message ListFriendBillRequest { @@ -69,4 +71,5 @@ message FriendBill { double amount = 2; string title = 3; string description = 4; + string in_debt = 5; } \ No newline at end of file diff --git a/protobuf/gen/go/friend_bill.pb.go b/protobuf/gen/go/friend_bill.pb.go index d7816f5..4db574c 100644 --- a/protobuf/gen/go/friend_bill.pb.go +++ b/protobuf/gen/go/friend_bill.pb.go @@ -31,6 +31,7 @@ type CreateFriendBillRequest struct { Amount float64 `protobuf:"fixed64,2,opt,name=amount,proto3" json:"amount,omitempty"` Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + InDebt string `protobuf:"bytes,5,opt,name=in_debt,json=inDebt,proto3" json:"in_debt,omitempty"` } func (x *CreateFriendBillRequest) Reset() { @@ -93,6 +94,13 @@ func (x *CreateFriendBillRequest) GetDescription() string { return "" } +func (x *CreateFriendBillRequest) GetInDebt() string { + if x != nil { + return x.InDebt + } + return "" +} + type CreateFriendBillResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -197,6 +205,7 @@ type ModifyFriendBillRequest struct { Amount float64 `protobuf:"fixed64,3,opt,name=amount,proto3" json:"amount,omitempty"` Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` + InDebt string `protobuf:"bytes,6,opt,name=in_debt,json=inDebt,proto3" json:"in_debt,omitempty"` } func (x *ModifyFriendBillRequest) Reset() { @@ -266,6 +275,13 @@ func (x *ModifyFriendBillRequest) GetDescription() string { return "" } +func (x *ModifyFriendBillRequest) GetInDebt() string { + if x != nil { + return x.InDebt + } + return "" +} + type ListFriendBillRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -369,6 +385,7 @@ type FriendBill struct { Amount float64 `protobuf:"fixed64,2,opt,name=amount,proto3" json:"amount,omitempty"` Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + InDebt string `protobuf:"bytes,5,opt,name=in_debt,json=inDebt,proto3" json:"in_debt,omitempty"` } func (x *FriendBill) Reset() { @@ -431,6 +448,13 @@ func (x *FriendBill) GetDescription() string { return "" } +func (x *FriendBill) GetInDebt() string { + if x != nil { + return x.InDebt + } + return "" +} + var File_friend_bill_proto protoreflect.FileDescriptor var file_friend_bill_proto_rawDesc = []byte{ @@ -438,7 +462,7 @@ var file_friend_bill_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8a, + 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, @@ -447,71 +471,76 @@ var file_friend_bill_proto_rawDesc = []byte{ 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x40, 0x0a, 0x18, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, - 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x22, 0x3f, 0x0a, - 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, - 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x22, 0xb0, - 0x01, 0x0a, 0x17, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, - 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, - 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, - 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, - 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x22, 0x38, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, - 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x16, 0x4c, - 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, - 0x62, 0x69, 0x6c, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x0b, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, - 0x42, 0x69, 0x6c, 0x6c, 0x73, 0x22, 0x82, 0x01, 0x0a, 0x0a, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, - 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, - 0x69, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x69, + 0x6e, 0x5f, 0x64, 0x65, 0x62, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x6e, + 0x44, 0x65, 0x62, 0x74, 0x22, 0x40, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x22, 0xc9, 0x01, 0x0a, 0x17, 0x4d, 0x6f, 0x64, 0x69, + 0x66, 0x79, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, + 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x95, 0x03, 0x0a, 0x11, 0x46, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x63, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, - 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x18, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, - 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, - 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x14, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, - 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0x12, 0x5d, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x18, 0x2e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x17, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x11, 0x2a, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, - 0x62, 0x69, 0x6c, 0x6c, 0x12, 0x60, 0x0a, 0x10, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x18, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, - 0x79, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x14, 0x1a, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, - 0x69, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, 0x12, 0x5a, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x16, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x17, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, - 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x11, 0x12, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, - 0x6c, 0x6c, 0x42, 0x1e, 0x5a, 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x53, 0x70, 0x65, 0x65, 0x64, 0x52, 0x65, 0x61, 0x63, 0x68, 0x2f, 0x6d, 0x6f, 0x6e, 0x69, - 0x66, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x69, 0x6e, + 0x5f, 0x64, 0x65, 0x62, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, 0x6e, 0x44, + 0x65, 0x62, 0x74, 0x22, 0x38, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x48, 0x0a, + 0x16, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x0b, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x73, 0x22, 0x9b, 0x01, 0x0a, 0x0a, 0x46, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, + 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x06, 0x61, 0x6d, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x07, + 0x69, 0x6e, 0x5f, 0x64, 0x65, 0x62, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x69, + 0x6e, 0x44, 0x65, 0x62, 0x74, 0x32, 0x95, 0x03, 0x0a, 0x11, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x42, 0x69, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x63, 0x0a, 0x10, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x12, + 0x18, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, + 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x22, 0x0f, 0x2f, 0x76, + 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x3a, 0x01, 0x2a, + 0x12, 0x5d, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x42, 0x69, 0x6c, 0x6c, 0x12, 0x18, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x2a, 0x0f, + 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x12, + 0x60, 0x0a, 0x10, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, + 0x69, 0x6c, 0x6c, 0x12, 0x18, 0x2e, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x46, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x1a, 0x0f, 0x2f, + 0x76, 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x3a, 0x01, + 0x2a, 0x12, 0x5a, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, + 0x69, 0x6c, 0x6c, 0x12, 0x16, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x76, + 0x31, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x62, 0x69, 0x6c, 0x6c, 0x42, 0x1e, 0x5a, + 0x1c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x70, 0x65, 0x65, + 0x64, 0x52, 0x65, 0x61, 0x63, 0x68, 0x2f, 0x6d, 0x6f, 0x6e, 0x69, 0x66, 0x79, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/services/api/controllers/friend_bill/create.go b/services/api/controllers/friend_bill/create.go index 74042c7..744f09c 100644 --- a/services/api/controllers/friend_bill/create.go +++ b/services/api/controllers/friend_bill/create.go @@ -20,6 +20,9 @@ func (s Service) CreateFriendBill(ctx context.Context, req *monify.CreateFriendB if req.Amount == 0 { return nil, status.Error(codes.InvalidArgument, "Amount should not be zero") } + if req.InDebt == "" { + return nil, status.Error(codes.InvalidArgument, "InDebt person is required") + } _, ok := ctx.Value(lib.UserIdContextKey{}).(uuid.UUID) if !ok { return nil, status.Error(codes.Unauthenticated, "Unauthorized") @@ -29,9 +32,9 @@ func (s Service) CreateFriendBill(ctx context.Context, req *monify.CreateFriendB friend_billId := uuid.New() db := ctx.Value(lib.DatabaseContextKey{}).(*sql.DB) _, err := db.ExecContext(ctx, ` - INSERT INTO friend_bill (friend_bill_id, relation_id, amount, title, description) - VALUES ($1, $2, $3, $4, $5) - `, friend_billId, req.RelationId, req.Amount, req.Title, req.Description) + INSERT INTO friend_bill (friend_bill_id, relation_id, amount, title, description, in_debt) + VALUES ($1, $2, $3, $4, $5, $6) + `, friend_billId, req.RelationId, req.Amount, req.Title, req.Description, req.InDebt) if err != nil { logger.Error("Insert values into friend_bill error.", zap.Error(err)) return nil, status.Error(codes.Internal, "") diff --git a/services/api/controllers/friend_bill/list_friend_bill.go b/services/api/controllers/friend_bill/list_friend_bill.go index 0a7f031..2424ee2 100644 --- a/services/api/controllers/friend_bill/list_friend_bill.go +++ b/services/api/controllers/friend_bill/list_friend_bill.go @@ -20,7 +20,7 @@ func (s Service) ListFriendBill(ctx context.Context, req *monify.ListFriendBillR } db := ctx.Value(lib.DatabaseContextKey{}).(*sql.DB) query, err := db.QueryContext(ctx, ` - SELECT friend_bill_id, amount, title, description + SELECT friend_bill_id, amount, title, description, in_debt FROM friend_bill WHERE relation_id = $1`, req.RelationId) if err != nil { @@ -35,7 +35,7 @@ func (s Service) ListFriendBill(ctx context.Context, req *monify.ListFriendBillR break } var friend_bill monify.FriendBill - if err = query.Scan(&friend_bill.FriendBillId, &friend_bill.Amount, &friend_bill.Title, &friend_bill.Description); err != nil { + if err = query.Scan(&friend_bill.FriendBillId, &friend_bill.Amount, &friend_bill.Title, &friend_bill.Description, &friend_bill.InDebt); err != nil { logger.Error("Scan friend bill information error.", zap.Error(err)) return nil, status.Error(codes.Internal, "") } diff --git a/services/api/controllers/friend_bill/modify.go b/services/api/controllers/friend_bill/modify.go index 57c3ffe..1829db1 100644 --- a/services/api/controllers/friend_bill/modify.go +++ b/services/api/controllers/friend_bill/modify.go @@ -38,9 +38,9 @@ func (s Service) ModifyFriendBill(ctx context.Context, req *monify.ModifyFriendB // Insert _, err = tx.ExecContext(ctx, ` - INSERT INTO friend_bill (friend_bill_id, relation_id, amount, title, description) - VALUES ($1, $2, $3, $4, $5) - `, req.FriendBillId, req.RelationId, req.Amount, req.Title, req.Description) + INSERT INTO friend_bill (friend_bill_id, relation_id, amount, title, description, in_debt) + VALUES ($1, $2, $3, $4, $5, $6) + `, req.FriendBillId, req.RelationId, req.Amount, req.Title, req.Description, req.InDebt) if err != nil { logger.Error("Insert values into friend_bill error. (Modify)", zap.Error(err)) return nil, status.Error(codes.Internal, "") diff --git a/services/api/test/friend_bill_test.go b/services/api/test/friend_bill_test.go index 12ada65..891e7fc 100644 --- a/services/api/test/friend_bill_test.go +++ b/services/api/test/friend_bill_test.go @@ -36,12 +36,14 @@ func TestFriendBill(t *testing.T) { Amount: 300, Title: "test1", Description: "test1", + InDebt: "friend_bill_nickId1", }) _, err = client.CreateFriendBill(context.TODO(), &monify.CreateFriendBillRequest{ RelationId: friendS_relationId[0], Amount: 500, Title: "test2", Description: "test2", + InDebt: "friend_bill_nickId1", }) assert.NoError(t, err) _, err = client.CreateFriendBill(context.TODO(), &monify.CreateFriendBillRequest{ @@ -49,6 +51,7 @@ func TestFriendBill(t *testing.T) { Amount: 0, Title: "test2", Description: "test2", + InDebt: "friend_bill_nickId1", }) assert.Error(t, err) // Amount must not be zero @@ -59,9 +62,11 @@ func TestFriendBill(t *testing.T) { assert.Equal(t, 300.0, res1.FriendBills[0].Amount) assert.Equal(t, "test1", res1.FriendBills[0].Title) assert.Equal(t, "test1", res1.FriendBills[0].Description) + assert.Equal(t, "friend_bill_nickId1", res1.FriendBills[0].InDebt) assert.Equal(t, 500.0, res1.FriendBills[1].Amount) assert.Equal(t, "test2", res1.FriendBills[1].Title) assert.Equal(t, "test2", res1.FriendBills[1].Description) + assert.Equal(t, "friend_bill_nickId1", res1.FriendBills[1].InDebt) // Test delete friend bill _, err = client.DeleteFriendBill(context.TODO(), &monify.DeleteFriendBillRequest{FriendBillId: res1.FriendBills[0].FriendBillId}) @@ -71,6 +76,7 @@ func TestFriendBill(t *testing.T) { assert.Equal(t, 500.0, res2.FriendBills[0].Amount) assert.Equal(t, "test2", res2.FriendBills[0].Title) assert.Equal(t, "test2", res2.FriendBills[0].Description) + assert.Equal(t, "friend_bill_nickId1", res2.FriendBills[0].InDebt) // Test modify friend bill _, err = client.ModifyFriendBill(context.TODO(), &monify.ModifyFriendBillRequest{ @@ -79,10 +85,12 @@ func TestFriendBill(t *testing.T) { Amount: 1000, Title: "test3", Description: "test3", + InDebt: "friend_bill_nickId2", }) assert.NoError(t, err) res3, err := client.ListFriendBill(context.TODO(), &monify.ListFriendBillRequest{RelationId: friendS_relationId[0]}) assert.Equal(t, 1000.0, res3.FriendBills[0].Amount) assert.Equal(t, "test3", res3.FriendBills[0].Title) assert.Equal(t, "test3", res3.FriendBills[0].Description) + assert.Equal(t, "friend_bill_nickId2", res3.FriendBills[0].InDebt) }