diff --git a/internal/filter/domain.go b/internal/filter/domain.go new file mode 100644 index 0000000..a1f63df --- /dev/null +++ b/internal/filter/domain.go @@ -0,0 +1,44 @@ +package filter + +import ( + "context" + appconfig "github.com/exhibition-main/internal/config" + "reflect" +) + +import ( + "dubbo.apache.org/dubbo-go/v3/common/extension" + "dubbo.apache.org/dubbo-go/v3/filter" + "dubbo.apache.org/dubbo-go/v3/protocol" +) + +func init() { + extension.SetFilter("fonDomainFilter", NewDomainFonFilter) +} + +func NewDomainFonFilter() filter.Filter { + return &DomainFonFilter{} +} + +type DomainFonFilter struct { +} + +func (f *DomainFonFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { + if len(invocation.Arguments()) > 0 { + req := invocation.Arguments()[0] + pp := reflect.ValueOf(req) + field := pp.Elem().FieldByName("Domain") + + if field.IsValid() { + if field.IsZero() { + field.SetString(appconfig.Data.System.Domain) + } + } + } + + return invoker.Invoke(ctx, invocation) +} + +func (f *DomainFonFilter) OnResponse(ctx context.Context, result protocol.Result, invoker protocol.Invoker, protocol protocol.Invocation) protocol.Result { + return result +} diff --git a/pkg/service/account.go b/pkg/service/account.go index 4d9a0d1..4751192 100644 --- a/pkg/service/account.go +++ b/pkg/service/account.go @@ -2,6 +2,7 @@ package service import ( "github.com/exhibition-main/api/account" + appconfig "github.com/exhibition-main/internal/config" "github.com/exhibition-main/internal/msg" "github.com/exhibition-main/internal/response" "github.com/gin-gonic/gin" @@ -17,10 +18,10 @@ func OnlySend(c *gin.Context) { response.ResponseQuickMsg(c, msg.Fail, msg.INVALID_PARAMS, nil) return } - //req.Domain = appconfig.Data.System.Domain - //req.Scope = "exhibition" + req.Domain = appconfig.Data.System.Domain + req.Scope = "exhibition" - res, err := AccountProvider.SendMsg(c, &req) + res, err := AccountProvider.OnlySendMsg(c, &req) if err != nil { response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil) return @@ -39,9 +40,9 @@ func OnlyCheck(c *gin.Context) { response.ResponseQuickMsg(c, msg.Fail, msg.INVALID_PARAMS, nil) return } - // - //req.Domain = appconfig.Data.System.Domain - //req.Scope = "exhibition" + + req.Domain = appconfig.Data.System.Domain + req.Scope = "exhibition" res, err := AccountProvider.OnlyCheckMsg(c, &req) if err != nil {