2026-06-22 16:55:22 +08:00

98 lines
3.5 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
roomGuardClient client.RoomGuardClient
roomQueryClient client.RoomQueryClient
userIdentityClient client.UserIdentityClient
userProfileClient client.UserProfileClient
userHostClient client.UserHostClient
imGroupIDPrefix string
}
type Config struct {
WalletClient client.WalletClient
RoomGuardClient client.RoomGuardClient
RoomQueryClient client.RoomQueryClient
UserIdentityClient client.UserIdentityClient
UserProfileClient client.UserProfileClient
UserHostClient client.UserHostClient
IMGroupIDPrefix string
}
func New(config Config) *Handler {
return &Handler{
walletClient: config.WalletClient,
roomGuardClient: config.RoomGuardClient,
roomQueryClient: config.RoomQueryClient,
userIdentityClient: config.UserIdentityClient,
userProfileClient: config.UserProfileClient,
userHostClient: config.UserHostClient,
imGroupIDPrefix: config.IMGroupIDPrefix,
}
}
func (h *Handler) WalletHandlers() httproutes.WalletHandlers {
return httproutes.WalletHandlers{
GetWalletOverview: h.getWalletOverview,
GetMyBalances: h.getMyBalances,
ListRechargeProducts: h.listRechargeProducts,
GetH5RechargeContext: h.getH5RechargeContext,
ListH5RechargeOptions: h.listH5RechargeOptions,
CreateH5RechargeOrder: h.createH5RechargeOrder,
SubmitH5RechargeTx: h.submitH5RechargeTx,
GetH5RechargeOrder: h.getH5RechargeOrder,
HandleMifapayNotify: h.handleMifapayNotify,
HandleV5PayNotify: h.handleV5PayNotify,
ConfirmGooglePayment: h.confirmGooglePayment,
GetDiamondExchangeConfig: h.getDiamondExchangeConfig,
ListCoinTransactions: h.listCoinTransactions,
ListWalletTransactions: h.listWalletTransactions,
ListCoinSellers: h.listCoinSellers,
TransferCoinFromSeller: h.transferCoinFromSeller,
GetSalaryWalletOverview: h.getSalaryWalletOverview,
GetSalaryWalletHistory: h.getSalaryWalletHistory,
SearchSalaryWalletSeller: h.searchSalaryWalletSeller,
ExchangeSalaryToCoin: h.exchangeSalaryToCoin,
TransferSalaryToSeller: h.transferSalaryToCoinSeller,
GetRedPacketConfig: h.getRedPacketConfig,
ListRoomRedPackets: h.listRoomRedPackets,
CreateRoomRedPacket: h.createRoomRedPacket,
GetRedPacket: h.getRedPacket,
ClaimRedPacket: h.claimRedPacket,
GetCurrentRegionIMGroup: h.getCurrentRegionIMGroup,
GetRedPacketIMGroup: h.getCurrentRegionIMGroup,
SendVoiceRoomRedPacket: h.sendVoiceRoomRedPacket,
ListActiveRedPackets: h.listActiveRedPackets,
ClaimVoiceRoomRedPacket: h.claimVoiceRoomRedPacket,
GetVoiceRoomRedPacket: h.getVoiceRoomRedPacket,
ListRedPacketClaims: h.listRedPacketClaims,
ListSentRedPackets: h.listSentRedPackets,
}
}
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)
}
func (h *Handler) GetUserGiftWall(writer http.ResponseWriter, request *http.Request) {
h.getUserGiftWall(writer, request)
}