From dc1e2fa5bb2551671be247ca9eb90d4f73e280ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B0=D1=82=D0=BE=D0=BB=D0=B8=D0=B9=20=D0=A2?= =?UTF-8?q?=D1=83=D1=85=D1=82=D0=B0=D1=80=D0=BE=D0=B2?= Date: Sun, 4 Feb 2024 16:43:13 +0500 Subject: [PATCH] v1.0.2 Albums --- sea.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sea.go b/sea.go index 3c7b8e9..72604c5 100644 --- a/sea.go +++ b/sea.go @@ -21,25 +21,30 @@ func Connect() (*Sea, error) { return &sea, nil } +func openDB() (*sqlx.DB, error) { + db, err := sqlx.Open("mysql", "itman:X753951x@(xigmanas:3306)/sea") + if err != nil { + return nil, err + } + return db, nil +} + // ============= ALBUM ============ + type Album struct { Seria string Cnt int Hash string } -// func getAlbums(db *sqlx.DB) []Album { -// cmd := "call getAlbums()" -// var albums []Album -// err := db.Select(&albums, cmd) -// return albums -// } - -func openDB() (*sqlx.DB, error) { - db, err := sqlx.Open("mysql", "itman:X753951x@(xigmanas:3306)/sea") +func (s *Sea) Albums(db *sqlx.DB) ([]Album, error) { + cmd := "call getAlbums()" + var albums []Album + err := db.Select(&albums, cmd) if err != nil { return nil, err } - return db, nil + return albums, nil } +