package repoimpl import ( "context" "eino-project/internal/biz" "eino-project/internal/data" "github.com/go-kratos/kratos/v2/log" ) // CustomerRepo 智能客服数据仓库 type CustomerRepo struct { data *data.Data log *log.Helper } // NewCustomerRepo 创建智能客服数据仓库 func NewCustomerRepo(d *data.Data, logger log.Logger) biz.CustomerRepo { return &CustomerRepo{ data: d, log: log.NewHelper(logger), } } // CheckSystemHealth 检查系统健康状态 func (r *CustomerRepo) CheckSystemHealth(ctx context.Context) map[string]biz.ServiceStatus { status := make(map[string]biz.ServiceStatus) // 检查数据库连接 if r.data.DB != nil { if err := r.data.DB.Ping(); err != nil { status["database"] = biz.ServiceStatus{ Name: "Database", Status: false, Message: "Database connection failed: " + err.Error(), } } else { status["database"] = biz.ServiceStatus{ Name: "Database", Status: true, Message: "Database connection is healthy", } } } // 检查 Redis 连接 if r.data.RDB != nil { if err := r.data.RDB.Ping(ctx).Err(); err != nil { status["redis"] = biz.ServiceStatus{ Name: "Redis", Status: false, Message: "Redis connection failed: " + err.Error(), } } else { status["redis"] = biz.ServiceStatus{ Name: "Redis", Status: true, Message: "Redis connection is healthy", } } } return status }