加上一个日志输出,看看回调内容
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m10s

This commit is contained in:
2026-07-28 09:21:54 +08:00
parent a8ca00e5f2
commit 7c5b6ee036
9 changed files with 294 additions and 3 deletions

View File

@@ -137,7 +137,7 @@ func initHandlers(svc *services, deps *Dependencies) *Handlers {
wecomInfra.NewSceneRepository(deps.DB), deps.SystemConfigAudit,
)
wecomApprovalCallback := callback.NewWeComApprovalHandler(wecomInfra.NewCallbackService(
wecomRepository, integrationlog.NewRepository(deps.DB), deps.QueueClient,
wecomRepository, integrationlog.NewRepository(deps.DB), deps.QueueClient, deps.Logger,
))
svc.Account.SetWeComMemberFinder(wecomMembers)

View File

@@ -11,6 +11,7 @@ import (
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/break/junhong_cmp_fiber/pkg/errors"
"github.com/break/junhong_cmp_fiber/pkg/queue"
"go.uber.org/zap"
)
type callbackIntegrationLog interface {
@@ -42,11 +43,12 @@ type CallbackService struct {
applications *ApplicationRepository
integration callbackIntegrationLog
queue *queue.Client
logger *zap.Logger
}
// NewCallbackService 创建企业微信审批回调服务。
func NewCallbackService(applications *ApplicationRepository, integration callbackIntegrationLog, queueClient *queue.Client) *CallbackService {
return &CallbackService{applications: applications, integration: integration, queue: queueClient}
func NewCallbackService(applications *ApplicationRepository, integration callbackIntegrationLog, queueClient *queue.Client, logger *zap.Logger) *CallbackService {
return &CallbackService{applications: applications, integration: integration, queue: queueClient, logger: logger}
}
// VerifyURL 校验企微回调 URL 并返回 echostr 明文。
@@ -75,6 +77,9 @@ func (s *CallbackService) Receive(ctx context.Context, applicationID uint, signa
if err != nil {
return err
}
if s.logger != nil {
s.logger.Info("企业微信审批回调解密成功", zap.Uint("application_id", applicationID), zap.ByteString("content", plaintext))
}
var event approvalChangeEvent
if err := xml.Unmarshal(plaintext, &event); err != nil || event.Event != "sys_approval_change" || strings.TrimSpace(event.SPNo) == "" {
return errors.New(errors.CodeInvalidParam, "企业微信审批回调事件无效")