修复麦位任务
This commit is contained in:
parent
c6ba03c407
commit
fbe9e922f8
@ -50,7 +50,7 @@ func (s *Service) ReceiveEvent(ctx context.Context, req EventRequest) (*EventRes
|
||||
return nil, NewAppError(http.StatusBadRequest, "invalid_event_type", "eventType is required")
|
||||
}
|
||||
if !isAllowedConditionType(eventType) {
|
||||
return &EventResponse{Processed: false, Updated: 0}, nil
|
||||
return &EventResponse{Processed: false, Updated: 0, Reason: "unsupported_condition_type"}, nil
|
||||
}
|
||||
userID := req.UserID.Int64()
|
||||
if userID <= 0 {
|
||||
@ -67,7 +67,7 @@ func (s *Service) ReceiveEvent(ctx context.Context, req EventRequest) (*EventRes
|
||||
return nil, err
|
||||
}
|
||||
if existingCount > 0 {
|
||||
return &EventResponse{Processed: false, Updated: 0}, nil
|
||||
return &EventResponse{Processed: false, Updated: 0, Reason: "duplicate_event"}, nil
|
||||
}
|
||||
|
||||
bundle, err := s.loadEnabledBundle(ctx, sysOrigin)
|
||||
@ -75,7 +75,7 @@ func (s *Service) ReceiveEvent(ctx context.Context, req EventRequest) (*EventRes
|
||||
return nil, err
|
||||
}
|
||||
if bundle == nil {
|
||||
return &EventResponse{Processed: false, Updated: 0}, nil
|
||||
return &EventResponse{Processed: false, Updated: 0, Reason: "task_center_disabled"}, nil
|
||||
}
|
||||
|
||||
matchedTasks := make([]model.TaskCenterTaskConfig, 0)
|
||||
@ -85,7 +85,7 @@ func (s *Service) ReceiveEvent(ctx context.Context, req EventRequest) (*EventRes
|
||||
}
|
||||
}
|
||||
if len(matchedTasks) == 0 {
|
||||
return &EventResponse{Processed: false, Updated: 0}, nil
|
||||
return &EventResponse{Processed: false, Updated: 0, Reason: "no_matched_task"}, nil
|
||||
}
|
||||
|
||||
occurredAt := parseOccurredAt(req.OccurredAt, time.Now())
|
||||
@ -160,7 +160,11 @@ func (s *Service) ReceiveEvent(ctx context.Context, req EventRequest) (*EventRes
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &EventResponse{Processed: updated > 0, Updated: updated}, nil
|
||||
reason := ""
|
||||
if updated == 0 {
|
||||
reason = "no_updated_task"
|
||||
}
|
||||
return &EventResponse{Processed: updated > 0, Updated: updated, Reason: reason}, nil
|
||||
}
|
||||
|
||||
func (s *Service) loadOrCreateProgressTx(tx *gorm.DB, sysOrigin string, userID int64, task model.TaskCenterTaskConfig, cycleKey string) (model.TaskCenterUserProgress, error) {
|
||||
|
||||
@ -193,8 +193,9 @@ type EventRequest struct {
|
||||
}
|
||||
|
||||
type EventResponse struct {
|
||||
Processed bool `json:"processed"`
|
||||
Updated int `json:"updated"`
|
||||
Processed bool `json:"processed"`
|
||||
Updated int `json:"updated"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
type PageResponse[T any] struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user