2026-05-26 03:40:01 +08:00

69 lines
2.2 KiB
Go

package walletapi
import (
"net/http"
"hyapp/services/gateway-service/internal/client"
"hyapp/services/gateway-service/internal/transport/http/httproutes"
)
// Handler owns wallet-facing HTTP endpoints.
// It keeps wallet semantics behind wallet-service and only handles HTTP protocol conversion.
type Handler struct {
walletClient client.WalletClient
roomQueryClient client.RoomQueryClient
userIdentityClient client.UserIdentityClient
userProfileClient client.UserProfileClient
userHostClient client.UserHostClient
}
type Config struct {
WalletClient client.WalletClient
RoomQueryClient client.RoomQueryClient
UserIdentityClient client.UserIdentityClient
UserProfileClient client.UserProfileClient
UserHostClient client.UserHostClient
}
func New(config Config) *Handler {
return &Handler{
walletClient: config.WalletClient,
roomQueryClient: config.RoomQueryClient,
userIdentityClient: config.UserIdentityClient,
userProfileClient: config.UserProfileClient,
userHostClient: config.UserHostClient,
}
}
func (h *Handler) WalletHandlers() httproutes.WalletHandlers {
return httproutes.WalletHandlers{
GetWalletOverview: h.getWalletOverview,
GetMyBalances: h.getMyBalances,
ListRechargeProducts: h.listRechargeProducts,
ConfirmGooglePayment: h.confirmGooglePayment,
GetDiamondExchangeConfig: h.getDiamondExchangeConfig,
ApplyWithdrawal: h.applyWithdrawal,
ListCoinTransactions: h.listCoinTransactions,
ListWalletTransactions: h.listWalletTransactions,
ListCoinSellers: h.listCoinSellers,
TransferCoinFromSeller: h.transferCoinFromSeller,
GetRedPacketConfig: h.getRedPacketConfig,
ListRoomRedPackets: h.listRoomRedPackets,
CreateRoomRedPacket: h.createRoomRedPacket,
GetRedPacket: h.getRedPacket,
ClaimRedPacket: h.claimRedPacket,
}
}
func (h *Handler) VIPHandlers() httproutes.VIPHandlers {
return httproutes.VIPHandlers{
GetMyVIP: h.getMyVIP,
ListVIPPackages: h.listVIPPackages,
PurchaseVIP: h.purchaseVIP,
}
}
func (h *Handler) GetMyGiftWall(writer http.ResponseWriter, request *http.Request) {
h.getMyGiftWall(writer, request)
}