-
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.
feature: delete friend bill (without test)
- Loading branch information
1 parent
4af63e1
commit 1e90b85
Showing
2 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package friend_bill | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
"monify/lib" | ||
monify "monify/protobuf/gen/go" | ||
|
||
"github.com/google/uuid" | ||
"go.uber.org/zap" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
"google.golang.org/protobuf/types/known/emptypb" | ||
) | ||
|
||
func (s Service) DeleteFriendBill(ctx context.Context, req *monify.DeleteFriendBillRequest) (*emptypb.Empty, error) { | ||
logger := ctx.Value(lib.LoggerContextKey{}).(*zap.Logger) | ||
_, ok := ctx.Value(lib.UserIdContextKey{}).(uuid.UUID) | ||
if !ok { | ||
return nil, status.Error(codes.Unauthenticated, "Unauthorized.") | ||
} | ||
db := ctx.Value(lib.DatabaseContextKey{}).(*sql.DB) | ||
_, err := db.ExecContext(ctx, `DELETE FROM friend_bill WHERE friend_bill_id = $1`, req.FriendBillId) | ||
if err != nil { | ||
logger.Error("Delete friend bill error.", zap.Error(err)) | ||
return nil, status.Error(codes.Internal, "") | ||
} | ||
return &emptypb.Empty{}, nil | ||
} |
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