diff --git a/backend/api/handler/coze/public_product_service.go b/backend/api/handler/coze/public_product_service.go index 34bb812c0..e4d6e9829 100644 --- a/backend/api/handler/coze/public_product_service.go +++ b/backend/api/handler/coze/public_product_service.go @@ -362,3 +362,23 @@ func PublicGetProductCallInfo(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusOK, resp) } + +// PublicGetMarketPluginConfig . +// @router /api/marketplace/product/config [GET] +func PublicGetMarketPluginConfig(ctx context.Context, c *app.RequestContext) { + var err error + var req product_public_api.GetMarketPluginConfigRequest + err = c.BindAndValidate(&req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + + resp, err := plugin.PluginApplicationSVC.GetMarketPluginConfig(ctx, &req) + if err != nil { + internalServerErrorResponse(ctx, c, err) + return + } + + c.JSON(consts.StatusOK, resp) +} diff --git a/backend/api/model/marketplace/product_public_api/public_api.go b/backend/api/model/marketplace/product_public_api/public_api.go index 791b717ff..35800866f 100644 --- a/backend/api/model/marketplace/product_public_api/public_api.go +++ b/backend/api/model/marketplace/product_public_api/public_api.go @@ -353,6 +353,543 @@ func (p *UserLevel) Value() (driver.Value, error) { return int64(*p), nil } +type GetMarketPluginConfigRequest struct { +} + +func NewGetMarketPluginConfigRequest() *GetMarketPluginConfigRequest { + return &GetMarketPluginConfigRequest{} +} + +func (p *GetMarketPluginConfigRequest) InitDefault() { +} + +var fieldIDToName_GetMarketPluginConfigRequest = map[int16]string{} + +func (p *GetMarketPluginConfigRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *GetMarketPluginConfigRequest) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("GetMarketPluginConfigRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetMarketPluginConfigRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetMarketPluginConfigRequest(%+v)", *p) + +} + +type GetMarketPluginConfigResponse struct { + Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` + Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` + Data *Configuration `thrift:"Data,3,optional" form:"data" json:"data,omitempty"` + BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"BaseResp" json:"BaseResp,omitempty" query:"BaseResp"` +} + +func NewGetMarketPluginConfigResponse() *GetMarketPluginConfigResponse { + return &GetMarketPluginConfigResponse{} +} + +func (p *GetMarketPluginConfigResponse) InitDefault() { +} + +func (p *GetMarketPluginConfigResponse) GetCode() (v int32) { + return p.Code +} + +func (p *GetMarketPluginConfigResponse) GetMessage() (v string) { + return p.Message +} + +var GetMarketPluginConfigResponse_Data_DEFAULT *Configuration + +func (p *GetMarketPluginConfigResponse) GetData() (v *Configuration) { + if !p.IsSetData() { + return GetMarketPluginConfigResponse_Data_DEFAULT + } + return p.Data +} + +var GetMarketPluginConfigResponse_BaseResp_DEFAULT *base.BaseResp + +func (p *GetMarketPluginConfigResponse) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return GetMarketPluginConfigResponse_BaseResp_DEFAULT + } + return p.BaseResp +} + +var fieldIDToName_GetMarketPluginConfigResponse = map[int16]string{ + 1: "Code", + 2: "Message", + 3: "Data", + 255: "BaseResp", +} + +func (p *GetMarketPluginConfigResponse) IsSetData() bool { + return p.Data != nil +} + +func (p *GetMarketPluginConfigResponse) IsSetBaseResp() bool { + return p.BaseResp != nil +} + +func (p *GetMarketPluginConfigResponse) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetCode bool = false + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetCode = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetCode { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetMessage { + fieldId = 2 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetMarketPluginConfigResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_GetMarketPluginConfigResponse[fieldId])) +} + +func (p *GetMarketPluginConfigResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.Code = _field + return nil +} +func (p *GetMarketPluginConfigResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Message = _field + return nil +} +func (p *GetMarketPluginConfigResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewConfiguration() + if err := _field.Read(iprot); err != nil { + return err + } + p.Data = _field + return nil +} +func (p *GetMarketPluginConfigResponse) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.BaseResp = _field + return nil +} + +func (p *GetMarketPluginConfigResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetMarketPluginConfigResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetMarketPluginConfigResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.Code); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetMarketPluginConfigResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetMarketPluginConfigResponse) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetData() { + if err = oprot.WriteFieldBegin("Data", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.Data.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetMarketPluginConfigResponse) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBaseResp() { + if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.BaseResp.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *GetMarketPluginConfigResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetMarketPluginConfigResponse(%+v)", *p) + +} + +type Configuration struct { + EnableSaasPlugin *bool `thrift:"enable_saas_plugin,1,optional" form:"enable_saas_plugin" json:"enable_saas_plugin,omitempty" query:"enable_saas_plugin"` +} + +func NewConfiguration() *Configuration { + return &Configuration{} +} + +func (p *Configuration) InitDefault() { +} + +var Configuration_EnableSaasPlugin_DEFAULT bool + +func (p *Configuration) GetEnableSaasPlugin() (v bool) { + if !p.IsSetEnableSaasPlugin() { + return Configuration_EnableSaasPlugin_DEFAULT + } + return *p.EnableSaasPlugin +} + +var fieldIDToName_Configuration = map[int16]string{ + 1: "enable_saas_plugin", +} + +func (p *Configuration) IsSetEnableSaasPlugin() bool { + return p.EnableSaasPlugin != nil +} + +func (p *Configuration) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Configuration[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Configuration) ReadField1(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.EnableSaasPlugin = _field + return nil +} + +func (p *Configuration) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Configuration"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Configuration) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetEnableSaasPlugin() { + if err = oprot.WriteFieldBegin("enable_saas_plugin", thrift.BOOL, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.EnableSaasPlugin); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Configuration) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Configuration(%+v)", *p) + +} + type SearchProductRequest struct { Keyword string `thrift:"Keyword,1,required" json:"Keyword,required" query:"keyword,required"` PageNum int32 `thrift:"PageNum,2,required" json:"PageNum,required" query:"page_num,required"` @@ -29230,6 +29767,8 @@ type PublicProductService interface { PublicGetProductCategoryList(ctx context.Context, req *GetProductCategoryListRequest) (r *GetProductCategoryListResponse, err error) PublicGetProductCallInfo(ctx context.Context, req *GetProductCallInfoRequest) (r *GetProductCallInfoResponse, err error) + + PublicGetMarketPluginConfig(ctx context.Context, req *GetMarketPluginConfigRequest) (r *GetMarketPluginConfigResponse, err error) } type PublicProductServiceClient struct { @@ -29339,6 +29878,15 @@ func (p *PublicProductServiceClient) PublicGetProductCallInfo(ctx context.Contex } return _result.GetSuccess(), nil } +func (p *PublicProductServiceClient) PublicGetMarketPluginConfig(ctx context.Context, req *GetMarketPluginConfigRequest) (r *GetMarketPluginConfigResponse, err error) { + var _args PublicProductServicePublicGetMarketPluginConfigArgs + _args.Req = req + var _result PublicProductServicePublicGetMarketPluginConfigResult + if err = p.Client_().Call(ctx, "PublicGetMarketPluginConfig", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} type PublicProductServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction @@ -29369,6 +29917,7 @@ func NewPublicProductServiceProcessor(handler PublicProductService) *PublicProdu self.AddToProcessorMap("PublicSearchSuggest", &publicProductServiceProcessorPublicSearchSuggest{handler: handler}) self.AddToProcessorMap("PublicGetProductCategoryList", &publicProductServiceProcessorPublicGetProductCategoryList{handler: handler}) self.AddToProcessorMap("PublicGetProductCallInfo", &publicProductServiceProcessorPublicGetProductCallInfo{handler: handler}) + self.AddToProcessorMap("PublicGetMarketPluginConfig", &publicProductServiceProcessorPublicGetMarketPluginConfig{handler: handler}) return self } func (p *PublicProductServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -29821,6 +30370,54 @@ func (p *publicProductServiceProcessorPublicGetProductCallInfo) Process(ctx cont return true, err } +type publicProductServiceProcessorPublicGetMarketPluginConfig struct { + handler PublicProductService +} + +func (p *publicProductServiceProcessorPublicGetMarketPluginConfig) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PublicProductServicePublicGetMarketPluginConfigArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PublicGetMarketPluginConfig", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PublicProductServicePublicGetMarketPluginConfigResult{} + var retval *GetMarketPluginConfigResponse + if retval, err2 = p.handler.PublicGetMarketPluginConfig(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PublicGetMarketPluginConfig: "+err2.Error()) + oprot.WriteMessageBegin("PublicGetMarketPluginConfig", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PublicGetMarketPluginConfig", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + type PublicProductServicePublicGetProductListArgs struct { Req *GetProductListRequest `thrift:"req,1"` } @@ -32448,3 +33045,295 @@ func (p *PublicProductServicePublicGetProductCallInfoResult) String() string { return fmt.Sprintf("PublicProductServicePublicGetProductCallInfoResult(%+v)", *p) } + +type PublicProductServicePublicGetMarketPluginConfigArgs struct { + Req *GetMarketPluginConfigRequest `thrift:"req,1"` +} + +func NewPublicProductServicePublicGetMarketPluginConfigArgs() *PublicProductServicePublicGetMarketPluginConfigArgs { + return &PublicProductServicePublicGetMarketPluginConfigArgs{} +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) InitDefault() { +} + +var PublicProductServicePublicGetMarketPluginConfigArgs_Req_DEFAULT *GetMarketPluginConfigRequest + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) GetReq() (v *GetMarketPluginConfigRequest) { + if !p.IsSetReq() { + return PublicProductServicePublicGetMarketPluginConfigArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_PublicProductServicePublicGetMarketPluginConfigArgs = map[int16]string{ + 1: "req", +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetMarketPluginConfigArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewGetMarketPluginConfigRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetMarketPluginConfig_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetMarketPluginConfigArgs(%+v)", *p) + +} + +type PublicProductServicePublicGetMarketPluginConfigResult struct { + Success *GetMarketPluginConfigResponse `thrift:"success,0,optional"` +} + +func NewPublicProductServicePublicGetMarketPluginConfigResult() *PublicProductServicePublicGetMarketPluginConfigResult { + return &PublicProductServicePublicGetMarketPluginConfigResult{} +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) InitDefault() { +} + +var PublicProductServicePublicGetMarketPluginConfigResult_Success_DEFAULT *GetMarketPluginConfigResponse + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) GetSuccess() (v *GetMarketPluginConfigResponse) { + if !p.IsSetSuccess() { + return PublicProductServicePublicGetMarketPluginConfigResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_PublicProductServicePublicGetMarketPluginConfigResult = map[int16]string{ + 0: "success", +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetMarketPluginConfigResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewGetMarketPluginConfigResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetMarketPluginConfig_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetMarketPluginConfigResult(%+v)", *p) + +} diff --git a/backend/api/router/coze/api.go b/backend/api/router/coze/api.go index 0cebd03c3..f8d1a9b45 100644 --- a/backend/api/router/coze/api.go +++ b/backend/api/router/coze/api.go @@ -160,6 +160,7 @@ func Register(r *server.Hertz) { { _product := _marketplace.Group("/product", _productMw()...) _product.GET("/call_info", append(_publicgetproductcallinfoMw(), coze.PublicGetProductCallInfo)...) + _product.GET("/config", append(_publicgetmarketpluginconfigMw(), coze.PublicGetMarketPluginConfig)...) _product.GET("/detail", append(_publicgetproductdetailMw(), coze.PublicGetProductDetail)...) _product.POST("/duplicate", append(_publicduplicateproductMw(), coze.PublicDuplicateProduct)...) _product.POST("/favorite", append(_publicfavoriteproductMw(), coze.PublicFavoriteProduct)...) diff --git a/backend/api/router/coze/middleware.go b/backend/api/router/coze/middleware.go index e7c67916b..33ad5763f 100644 --- a/backend/api/router/coze/middleware.go +++ b/backend/api/router/coze/middleware.go @@ -1600,3 +1600,8 @@ func _publicgetproductcategorylistMw() []app.HandlerFunc { // your code... return nil } + +func _publicgetmarketpluginconfigMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/backend/application/plugin/plugin.go b/backend/application/plugin/plugin.go index bb170ef38..536cc1870 100644 --- a/backend/application/plugin/plugin.go +++ b/backend/application/plugin/plugin.go @@ -18,10 +18,13 @@ package plugin import ( "context" + "os" "strconv" "strings" "time" + typesConsts "github.com/coze-dev/coze-studio/backend/types/consts" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" productCommon "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_common" productAPI "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api" @@ -35,7 +38,6 @@ import ( "github.com/coze-dev/coze-studio/backend/domain/plugin/repository" "github.com/coze-dev/coze-studio/backend/domain/plugin/service" search "github.com/coze-dev/coze-studio/backend/domain/search/service" - entityUser "github.com/coze-dev/coze-studio/backend/domain/user/entity" user "github.com/coze-dev/coze-studio/backend/domain/user/service" "github.com/coze-dev/coze-studio/backend/infra/contract/storage" "github.com/coze-dev/coze-studio/backend/pkg/errorx" @@ -591,35 +593,24 @@ func (p *PluginApplicationService) GetSaasProductCategoryList(ctx context.Contex } func (p *PluginApplicationService) GetProductCallInfo(ctx context.Context, req *productAPI.GetProductCallInfoRequest) (resp *productAPI.GetProductCallInfoResponse, err error) { - // userInfo, err := p.userSVC.GetSaasUserInfo(ctx) - // if err != nil { - // logs.CtxErrorf(ctx, "GetSaasUserInfo failed: %v", err) - // return &productAPI.GetProductCallInfoResponse{ - // Code: -1, - // Message: "Failed to get user info", - // }, nil - // } - - // benefit, err := p.userSVC.GetUserBenefit(ctx) - // if err != nil { - // logs.CtxErrorf(ctx, "GetUserBenefit failed: %v", err) - // return &productAPI.GetProductCallInfoResponse{ - // Code: -1, - // Message: "Failed to get user benefit", - // }, nil - // } - - //todo:: need to move - userInfo := &entityUser.SaasUserData{ - UserName: "gigoo", - NickName: "gigoo", - AvatarURL: "https://p6-passport.byteacctimg.com/img/user-avatar/cae85f2778fc38b29f5930be8f954bed~300x300.image", + userInfo, err := p.userSVC.GetSaasUserInfo(ctx) + if err != nil { + logs.CtxErrorf(ctx, "GetSaasUserInfo failed: %v", err) + return &productAPI.GetProductCallInfoResponse{ + Code: -1, + Message: "Failed to get user info", + }, nil } - benefit := &entityUser.UserBenefit{ - UsedCount: 10, - TotalCount: 100, - IsUnlimited: false, + + benefit, err := p.userSVC.GetUserBenefit(ctx) + if err != nil { + logs.CtxErrorf(ctx, "GetUserBenefit failed: %v", err) + return &productAPI.GetProductCallInfoResponse{ + Code: -1, + Message: "Failed to get user benefit", + }, nil } + // Build response data data := &productAPI.GetProductCallInfoData{ UserLevel: productAPI.UserLevel_Free, @@ -642,3 +633,19 @@ func (p *PluginApplicationService) GetProductCallInfo(ctx context.Context, req * Data: data, }, nil } + +func (p *PluginApplicationService) GetMarketPluginConfig(ctx context.Context, req *productAPI.GetMarketPluginConfigRequest) (resp *productAPI.GetMarketPluginConfigResponse, err error) { + + enableSaasPluginEnv := os.Getenv(typesConsts.CozeSaasPluginEnabled) + enableSaasPlugin := enableSaasPluginEnv == "true" + + resp = &productAPI.GetMarketPluginConfigResponse{ + Code: 0, + Message: "success", + Data: &productAPI.Configuration{ + EnableSaasPlugin: &enableSaasPlugin, + }, + } + + return resp, nil +} diff --git a/backend/types/consts/consts.go b/backend/types/consts/consts.go index 0fc4cf0dd..4163fe07f 100644 --- a/backend/types/consts/consts.go +++ b/backend/types/consts/consts.go @@ -52,8 +52,9 @@ const ( S3Endpoint = "S3_ENDPOINT" S3BucketEndpoint = "S3_BUCKET_ENDPOINT" - CozeSaasAPIKey = "COZE_SAAS_API_KEY" - CozeSaasAPIBaseURL = "COZE_SAAS_API_BASE_URL" + CozeSaasPluginEnabled = "COZE_SAAS_PLUGIN_ENABLED" + CozeSaasAPIKey = "COZE_SAAS_API_KEY" + CozeSaasAPIBaseURL = "COZE_SAAS_API_BASE_URL" HostKeyInCtx = "HOST_KEY_IN_CTX" RequestSchemeKeyInCtx = "REQUEST_SCHEME_IN_CTX" diff --git a/docker/.env.debug.example b/docker/.env.debug.example index eaaf323fa..f886e4da9 100644 --- a/docker/.env.debug.example +++ b/docker/.env.debug.example @@ -275,5 +275,6 @@ export PLUGIN_AES_OAUTH_TOKEN_SECRET='cn+$PJ(HhJ[5d*z9' # Coze Saas API Configuration +export COZE_SAAS_PLUGIN_ENABLED="" # default "", if you want to enable, set to true export COZE_SAAS_API_BASE_URL="https://api.coze.cn" export COZE_SAAS_API_KEY="" diff --git a/docker/.env.example b/docker/.env.example index 7315bdf51..b9c62afd9 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -275,5 +275,6 @@ export PLUGIN_AES_STATE_SECRET='osj^kfhsd*(z!sno' export PLUGIN_AES_OAUTH_TOKEN_SECRET='cn+$PJ(HhJ[5d*z9' # Coze Saas API Configuration +export COZE_SAAS_PLUGIN_ENABLED="" # default "", if you want to enable, set to true export COZE_SAAS_API_BASE_URL="https://api.coze.cn" export COZE_SAAS_API_KEY="" diff --git a/docker/atlas/migrations/20250930034835_update.sql b/docker/atlas/migrations/20250930034835_update.sql deleted file mode 100644 index 0469afd47..000000000 --- a/docker/atlas/migrations/20250930034835_update.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Modify "plugin" table -ALTER TABLE `opencoze`.`plugin` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "plugin source 1 from saas 0 default" AFTER `openapi_doc`, ADD COLUMN `ext` json NULL COMMENT "extra "; --- Modify "plugin_version" table -ALTER TABLE `opencoze`.`plugin_version` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "plugin source 1 from saas 0 default" AFTER `openapi_doc`, ADD COLUMN `ext` json NULL COMMENT "extra "; --- Modify "tool" table -ALTER TABLE `opencoze`.`tool` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "tool source 1 coze saas 0 default" AFTER `activated_status`, ADD COLUMN `ext` json NULL COMMENT "extra"; --- Modify "tool_version" table -ALTER TABLE `opencoze`.`tool_version` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "tool source 1 coze saas 0 default" AFTER `deleted_at`, ADD COLUMN `ext` json NULL COMMENT "extra"; diff --git a/docker/atlas/migrations/20251014030825_update.sql b/docker/atlas/migrations/20251014030825_update.sql new file mode 100644 index 000000000..c19baec5e --- /dev/null +++ b/docker/atlas/migrations/20251014030825_update.sql @@ -0,0 +1,5 @@ +-- Modify "agent_tool_draft" table +ALTER TABLE `opencoze`.`agent_tool_draft` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "tool source 1 coze saas 0 default"; +-- Modify "agent_tool_version" table +ALTER TABLE `opencoze`.`agent_tool_version` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "tool source 1 coze saas 0 default"; + diff --git a/docker/atlas/migrations/atlas.sum b/docker/atlas/migrations/atlas.sum index c4a3e3b28..7ca6c7291 100644 --- a/docker/atlas/migrations/atlas.sum +++ b/docker/atlas/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:lmHhy0psjXX5nxglqxAu8GAdbWV+CFENuOc1AyPR0B8= +h1:7SU+cKf0EawKtMqGb8+KvPxxdkXd0t1RR0y5H2P56/o= 20250703095335_initial.sql h1:/joaeUTMhXqAEc0KwsSve5+bYM0qPOp+9OizJtsRc+U= 20250703115304_update.sql h1:cbYo6Q6Lh96hB4hu5KW2Nn/Mr0VDpg7a1WPgpIb1SOc= 20250704040445_update.sql h1:QWmoPY//oQ+GFZwET9w/oAWa8mM0KVaD5G8Yiu9bMqY= @@ -12,4 +12,4 @@ h1:lmHhy0psjXX5nxglqxAu8GAdbWV+CFENuOc1AyPR0B8= 20250812093734_update.sql h1:27fQaPt0LYi1dA7MABvERthVR4pj4MRWFgdRVR3cd6w= 20250813081543_update.sql h1:HyBPu1LVs8oiyABbZDU3fFW0n6MeC7qOpzcHWVkwNVc= 20250822060516_update.sql h1:KoL8FPXw5/JMsJMtJsoGFIc4wYHlngBudeYSz5o4iKU= -20250930034835_update.sql h1:VgI4ss8IylY7Y4LrOj9s9PFvC37YB0z4SlOlB+n++d0= +20251014030825_update.sql h1:G9+haJr3RHCstEJ2stl0PV6WoXf61s1m0bXaKH06xZE= diff --git a/idl/marketplace/public_api.thrift b/idl/marketplace/public_api.thrift index c02dfe5fa..1038ce29e 100644 --- a/idl/marketplace/public_api.thrift +++ b/idl/marketplace/public_api.thrift @@ -19,6 +19,21 @@ service PublicProductService { GetProductCallInfoResponse PublicGetProductCallInfo(1: GetProductCallInfoRequest req)(api.get = "/api/marketplace/product/call_info") + GetMarketPluginConfigResponse PublicGetMarketPluginConfig(1: GetMarketPluginConfigRequest req)(api.get = "/api/marketplace/product/config", api.category = "PublicAPI") +} + +struct GetMarketPluginConfigRequest{ +} + +struct GetMarketPluginConfigResponse{ + 1 : required i32 Code (agw.key = "code",api.body = "code") , + 2 : required string Message (agw.key = "message",api.body = "message"), + 3 : optional Configuration Data (agw.key = "data",api.body = "data") , + 255: optional base.BaseResp BaseResp , +} + +struct Configuration { + 1: optional bool enable_saas_plugin } struct SearchProductRequest{