management server listener (#17)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #17 Co-authored-by: David Ashby <delta.mu.alpha@gmail.com> Co-committed-by: David Ashby <delta.mu.alpha@gmail.com>
This commit is contained in:
@@ -153,9 +153,8 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) {
|
||||
}
|
||||
|
||||
allBooksQuery := fmt.Sprintf(`SELECT
|
||||
id, title, authors, sortauthor, isbn10, isbn13, format,
|
||||
genre, publisher, series, volume, year, signed,
|
||||
description, notes, coverurl, childrens
|
||||
id, title, authors, sortauthor, isbn10, isbn13, format, genre, publisher,
|
||||
series, volume, year, signed, description, notes, coverurl, childrens
|
||||
FROM %s`, m.tableName)
|
||||
|
||||
books := []media.Book{}
|
||||
@@ -169,12 +168,8 @@ func (m *MySQL) GetAllBooks(ctx context.Context) ([]media.Book, error) {
|
||||
b := media.Book{}
|
||||
var authors string
|
||||
err := rows.Scan(
|
||||
&b.ID, &b.Title, &authors,
|
||||
&b.SortAuthor, &b.ISBN10, &b.ISBN13,
|
||||
&b.Format, &b.Genre, &b.Publisher,
|
||||
&b.Series, &b.Volume, &b.Year,
|
||||
&b.Signed, &b.Description, &b.Notes,
|
||||
&b.CoverURL, &b.Childrens)
|
||||
&b.ID, &b.Title, &authors, &b.SortAuthor, &b.ISBN10, &b.ISBN13, &b.Format, &b.Genre, &b.Publisher,
|
||||
&b.Series, &b.Volume, &b.Year, &b.Signed, &b.Description, &b.Notes, &b.CoverURL, &b.Childrens)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -193,25 +188,14 @@ func (m *MySQL) AddBook(ctx context.Context, b *media.Book) error {
|
||||
|
||||
res, err := m.connection.ExecContext(ctx, `
|
||||
INSERT INTO `+m.tableName+`
|
||||
(title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series, volume, year, signed, description, notes, coverurl, childrens)
|
||||
(
|
||||
title, authors, sortauthor, isbn10, isbn13, format, genre, publisher, series,
|
||||
volume, year, signed, description, notes, coverurl, childrens
|
||||
)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
b.Title,
|
||||
strings.Join(b.Authors, ";"),
|
||||
b.SortAuthor,
|
||||
b.ISBN10,
|
||||
b.ISBN13,
|
||||
b.Format,
|
||||
b.Genre,
|
||||
b.Publisher,
|
||||
b.Series,
|
||||
b.Volume,
|
||||
b.Year,
|
||||
b.Signed,
|
||||
b.Description,
|
||||
b.Notes,
|
||||
b.CoverURL,
|
||||
b.Childrens,
|
||||
b.Title, strings.Join(b.Authors, ";"), b.SortAuthor, b.ISBN10, b.ISBN13, b.Format, b.Genre, b.Publisher, b.Series,
|
||||
b.Volume, b.Year, b.Signed, b.Description, b.Notes, b.CoverURL, b.Childrens,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -236,41 +220,13 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error {
|
||||
|
||||
res, err := m.connection.ExecContext(ctx, `
|
||||
UPDATE `+m.tableName+`
|
||||
SET id=?
|
||||
title=?
|
||||
authors=?
|
||||
sortauthor=?
|
||||
isbn10=?
|
||||
isbn13=?
|
||||
format=?
|
||||
genre=?
|
||||
publisher=?
|
||||
series=?
|
||||
volume=?
|
||||
year=?
|
||||
signed=?
|
||||
description=?
|
||||
notes=?
|
||||
coverurl=?
|
||||
childrens=?
|
||||
SET
|
||||
id=? title=? authors=? sortauthor=? isbn10=? isbn13=? format=? genre=? publisher=?
|
||||
series=? volume=? year=? signed=? description=? notes=? coverurl=? childrens=?
|
||||
WHERE id=?`,
|
||||
new.Title,
|
||||
strings.Join(new.Authors, ";"),
|
||||
new.SortAuthor,
|
||||
new.ISBN10,
|
||||
new.ISBN13,
|
||||
new.Format,
|
||||
new.Genre,
|
||||
new.Publisher,
|
||||
new.Series,
|
||||
new.Volume,
|
||||
new.Year,
|
||||
new.Signed,
|
||||
new.Description,
|
||||
new.Notes,
|
||||
new.CoverURL,
|
||||
new.Childrens,
|
||||
old.ID)
|
||||
new.Title, strings.Join(new.Authors, ";"), new.SortAuthor, new.ISBN10, new.ISBN13, new.Format, new.Genre, new.Publisher,
|
||||
new.Series, new.Volume, new.Year, new.Signed, new.Description, new.Notes, new.CoverURL, new.Childrens, old.ID,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -284,6 +240,10 @@ func (m *MySQL) UpdateBook(ctx context.Context, old, new *media.Book) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MySQL) DeleteBook(_ context.Context, b *media.Book) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseMigrationFileName(filename string) (int, string, error) {
|
||||
sp := strings.SplitN(filename, "-", 2)
|
||||
i, err := strconv.Atoi(sp[0])
|
||||
|
Reference in New Issue
Block a user