添加扩展、余量接口

This commit is contained in:
lzh 2025-06-13 14:23:06 +08:00
parent c22977816b
commit fd6d763431
5 changed files with 924 additions and 619 deletions

File diff suppressed because it is too large Load Diff

View File

@ -274,9 +274,19 @@ func (this *BundleExtendRecordsListResponse) Validate() error {
func (this *BundleExtendRecordItem) Validate() error {
return nil
}
func (this *SetBundleBalanceRequest) Validate() error {
func (this *GetBundleBalanceReq) Validate() error {
return nil
}
func (this *SetBundleBalanceResponse) Validate() error {
func (this *BundleBalanceItem) Validate() error {
return nil
}
func (this *GetBundleBalanceResp) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v4.24.0--rc1
// - protoc v3.20.3
// source: pb/bundle.proto
package bundle
@ -46,11 +46,11 @@ type BundleClient interface {
CreateOrderAddRecord(ctx context.Context, in *OrderAddRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
PackagePriceAndTime(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*PackagePriceAndTimeResponse, common.ErrorWithAttachment)
OrderRecordsListV2(ctx context.Context, in *OrderRecordsRequestV2, opts ...grpc_go.CallOption) (*OrderRecordsResponseV2, common.ErrorWithAttachment)
//增值套餐
// 增值套餐
CreateValueAddBundle(ctx context.Context, in *CreateValueAddBundleRequest, opts ...grpc_go.CallOption) (*CreateValueAddBundleResponse, common.ErrorWithAttachment)
ValueAddBundleList(ctx context.Context, in *ValueAddBundleListRequest, opts ...grpc_go.CallOption) (*ValueAddBundleListResponse, common.ErrorWithAttachment)
ValueAddBundleDetail(ctx context.Context, in *ValueAddBundleDetailRequest, opts ...grpc_go.CallOption) (*ValueAddBundleDetailResponse, common.ErrorWithAttachment)
//新增值服务
// 新增值服务
SaveValueAddService(ctx context.Context, in *ValueAddServiceLang, opts ...grpc_go.CallOption) (*SaveResponse, common.ErrorWithAttachment)
ValueAddServiceList(ctx context.Context, in *ValueAddServiceListRequest, opts ...grpc_go.CallOption) (*ValueAddServiceListResponse, common.ErrorWithAttachment)
ValueAddServiceDetail(ctx context.Context, in *ValueAddServiceDetailRequest, opts ...grpc_go.CallOption) (*ValueAddServiceDetailResponse, common.ErrorWithAttachment)
@ -58,6 +58,7 @@ type BundleClient interface {
// 余量管理
BundleExtend(ctx context.Context, in *BundleExtendRequest, opts ...grpc_go.CallOption) (*BundleExtendResponse, common.ErrorWithAttachment)
BundleExtendRecordsList(ctx context.Context, in *BundleExtendRecordsListRequest, opts ...grpc_go.CallOption) (*BundleExtendRecordsListResponse, common.ErrorWithAttachment)
GetBundleBalance(ctx context.Context, in *GetBundleBalanceReq, opts ...grpc_go.CallOption) (*GetBundleBalanceResp, common.ErrorWithAttachment)
}
type bundleClient struct {
@ -92,6 +93,7 @@ type BundleClientImpl struct {
ValueAddServiceLangByUuidAndLanguage func(ctx context.Context, in *ValueAddServiceDetailRequest) (*ValueAddServiceLang, error)
BundleExtend func(ctx context.Context, in *BundleExtendRequest) (*BundleExtendResponse, error)
BundleExtendRecordsList func(ctx context.Context, in *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
GetBundleBalance func(ctx context.Context, in *GetBundleBalanceReq) (*GetBundleBalanceResp, error)
}
func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient {
@ -268,6 +270,12 @@ func (c *bundleClient) BundleExtendRecordsList(ctx context.Context, in *BundleEx
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleExtendRecordsList", in, out)
}
func (c *bundleClient) GetBundleBalance(ctx context.Context, in *GetBundleBalanceReq, opts ...grpc_go.CallOption) (*GetBundleBalanceResp, common.ErrorWithAttachment) {
out := new(GetBundleBalanceResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetBundleBalance", in, out)
}
// BundleServer is the server API for Bundle service.
// All implementations must embed UnimplementedBundleServer
// for forward compatibility
@ -290,11 +298,11 @@ type BundleServer interface {
CreateOrderAddRecord(context.Context, *OrderAddRecord) (*CommonResponse, error)
PackagePriceAndTime(context.Context, *OrderRecord) (*PackagePriceAndTimeResponse, error)
OrderRecordsListV2(context.Context, *OrderRecordsRequestV2) (*OrderRecordsResponseV2, error)
//增值套餐
// 增值套餐
CreateValueAddBundle(context.Context, *CreateValueAddBundleRequest) (*CreateValueAddBundleResponse, error)
ValueAddBundleList(context.Context, *ValueAddBundleListRequest) (*ValueAddBundleListResponse, error)
ValueAddBundleDetail(context.Context, *ValueAddBundleDetailRequest) (*ValueAddBundleDetailResponse, error)
//新增值服务
// 新增值服务
SaveValueAddService(context.Context, *ValueAddServiceLang) (*SaveResponse, error)
ValueAddServiceList(context.Context, *ValueAddServiceListRequest) (*ValueAddServiceListResponse, error)
ValueAddServiceDetail(context.Context, *ValueAddServiceDetailRequest) (*ValueAddServiceDetailResponse, error)
@ -302,6 +310,7 @@ type BundleServer interface {
// 余量管理
BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error)
BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
GetBundleBalance(context.Context, *GetBundleBalanceReq) (*GetBundleBalanceResp, error)
mustEmbedUnimplementedBundleServer()
}
@ -391,6 +400,9 @@ func (UnimplementedBundleServer) BundleExtend(context.Context, *BundleExtendRequ
func (UnimplementedBundleServer) BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method BundleExtendRecordsList not implemented")
}
func (UnimplementedBundleServer) GetBundleBalance(context.Context, *GetBundleBalanceReq) (*GetBundleBalanceResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBundleBalance not implemented")
}
func (s *UnimplementedBundleServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
@ -1202,6 +1214,35 @@ func _Bundle_BundleExtendRecordsList_Handler(srv interface{}, ctx context.Contex
return interceptor(ctx, in, info, handler)
}
func _Bundle_GetBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBundleBalanceReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("GetBundleBalance", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
// Bundle_ServiceDesc is the grpc_go.ServiceDesc for Bundle service.
// It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -1317,6 +1358,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "BundleExtendRecordsList",
Handler: _Bundle_BundleExtendRecordsList_Handler,
},
{
MethodName: "GetBundleBalance",
Handler: _Bundle_GetBundleBalance_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "pb/bundle.proto",

View File

@ -39,6 +39,12 @@ func BundleRouter(r *gin.RouterGroup) {
bundleAppRouteV2.POST("bundle-detail", bundle.BundleDetailV2)
}
bundleExtend := bundleAppRoute.Group("extend")
{
bundleExtend.POST("", bundle.BundleExtend)
bundleExtend.POST("list", bundle.BundleExtendRecordsList)
bundleExtend.POST("balance", bundle.GetBundleBalance)
}
}
}

View File

@ -6,12 +6,11 @@ import (
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
func BundleExtend(c *gin.Context) {
var req bundle.BundleExtendRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
if err := c.ShouldBindJSON(&req); err != nil {
service.Error(c, err)
return
}
@ -25,7 +24,7 @@ func BundleExtend(c *gin.Context) {
func BundleExtendRecordsList(c *gin.Context) {
var req bundle.BundleExtendRecordsListRequest
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
if err := c.ShouldBindJSON(&req); err != nil {
service.Error(c, err)
return
}
@ -36,3 +35,17 @@ func BundleExtendRecordsList(c *gin.Context) {
}
service.Success(c, res)
}
func GetBundleBalance(c *gin.Context) {
var req bundle.GetBundleBalanceReq
if err := c.ShouldBindJSON(&req); err != nil {
service.Error(c, err)
return
}
res, err := service.BundleProvider.GetBundleBalance(context.Background(), &req)
if err != nil {
service.Error(c, err)
return
}
service.Success(c, res)
}