feat(grpc): add gRPC server infrastructure and schedule sync service
Add gRPC server support with configurable TLS, environment-based settings, and Wire injection. Implement schedule synchronization service with task runner integration for external course data fetching. - Add gRPC configuration with env var overrides (APP_GRPC_ENABLED, APP_GRPC_PORT, etc.) - Create gRPC server infrastructure with runner task management - Implement ScheduleSyncService for course data synchronization - Add sync endpoint to schedule handler for external system integration - Update repository with context-aware batch delete operation - Wire all dependencies including zap logger for structured logging
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"carrot_bbs/internal/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -12,6 +14,7 @@ type ScheduleRepository interface {
|
||||
Create(course *model.ScheduleCourse) error
|
||||
Update(course *model.ScheduleCourse) error
|
||||
DeleteByID(id string) error
|
||||
DeleteByUserID(ctx context.Context, userID string) error
|
||||
ExistsColorByUser(userID, color, excludeID string) (bool, error)
|
||||
}
|
||||
|
||||
@@ -52,6 +55,10 @@ func (r *scheduleRepository) DeleteByID(id string) error {
|
||||
return r.db.Delete(&model.ScheduleCourse{}, "id = ?", id).Error
|
||||
}
|
||||
|
||||
func (r *scheduleRepository) DeleteByUserID(ctx context.Context, userID string) error {
|
||||
return r.db.WithContext(ctx).Delete(&model.ScheduleCourse{}, "user_id = ?", userID).Error
|
||||
}
|
||||
|
||||
func (r *scheduleRepository) ExistsColorByUser(userID, color, excludeID string) (bool, error) {
|
||||
var count int64
|
||||
query := r.db.Model(&model.ScheduleCourse{}).
|
||||
|
||||
Reference in New Issue
Block a user