2017-07-30 18:14:20 +00:00
|
|
|
package bouquins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2017-08-02 17:54:09 +00:00
|
|
|
"errors"
|
|
|
|
"fmt"
|
2017-07-31 17:37:52 +00:00
|
|
|
"log"
|
2017-07-30 18:14:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
STMT_PAGE = " LIMIT ? OFFSET ?"
|
|
|
|
STMT_BOOKS0 = `SELECT books.id AS id,title,series_index,name as series_name,series.id AS series_id
|
|
|
|
FROM books LEFT OUTER JOIN books_series_link ON books.id = books_series_link.book
|
|
|
|
LEFT OUTER JOIN series ON series.id = books_series_link.series `
|
|
|
|
STMT_BOOKS_TAGS0 = `SELECT name, books_tags_link.book as book FROM tags, books_tags_link
|
|
|
|
WHERE tags.id = books_tags_link.tag AND books_tags_link.book IN ( SELECT id FROM books `
|
|
|
|
STMT_BOOKS_AUTHORS0 = `SELECT authors.id, authors.name, books_authors_link.book as book
|
|
|
|
FROM authors, books_authors_link WHERE books_authors_link.author = authors.id
|
|
|
|
AND books_authors_link.book IN ( SELECT id FROM books `
|
|
|
|
STMT_WHERE = " WHERE "
|
|
|
|
STMT_SEARCH_TERM = " books.sort like ? "
|
|
|
|
STMT_BOOL_AND = " AND "
|
|
|
|
STMT_BOOL_OR = " OR "
|
|
|
|
STMT_SEARCH_ORDER = " ORDER BY books.sort"
|
|
|
|
|
|
|
|
STMT_BOOKS_COUNT = "SELECT count(id) FROM books"
|
|
|
|
STMT_BOOK = `SELECT books.id AS id,title, series_index, series.name AS series_name, series.id AS series_id,
|
|
|
|
strftime('%s', timestamp), strftime('%Y', pubdate), isbn,lccn,path,uuid,has_cover,
|
|
|
|
languages.lang_code, publishers.name AS pubname FROM books
|
|
|
|
LEFT OUTER JOIN books_languages_link ON books_languages_link.book = books.id
|
|
|
|
LEFT OUTER JOIN languages ON languages.id = books_languages_link.lang_code
|
|
|
|
LEFT OUTER JOIN data ON data.book = books.id
|
|
|
|
LEFT OUTER JOIN books_series_link ON books.id = books_series_link.book
|
|
|
|
LEFT OUTER JOIN series ON series.id = books_series_link.series
|
|
|
|
LEFT OUTER JOIN books_publishers_link ON books.id = books_publishers_link.book
|
|
|
|
LEFT OUTER JOIN publishers ON publishers.id = books_publishers_link.publisher
|
|
|
|
WHERE books.id = ?`
|
|
|
|
STMT_BOOK_TAGS = "SELECT name FROM tags, books_tags_link WHERE tags.id = books_tags_link.tag AND books_tags_link.book = ?"
|
|
|
|
STMT_BOOK_AUTHORS = `SELECT authors.id, authors.name, books_authors_link.book as book
|
|
|
|
FROM authors, books_authors_link WHERE books_authors_link.author = authors.id
|
|
|
|
AND books_authors_link.book = ?`
|
|
|
|
STMT_BOOK_DATA = "SELECT data.name, data.format, data.uncompressed_size FROM data WHERE data.book = ?"
|
|
|
|
STMT_BOOKS_ID_ASC = STMT_BOOKS0 + " ORDER BY id" + STMT_PAGE
|
|
|
|
STMT_BOOKS_ID_DESC = STMT_BOOKS0 + "ORDER BY id DESC" + STMT_PAGE
|
|
|
|
STMT_BOOKS_TITLE_ASC = STMT_BOOKS0 + "ORDER BY books.sort" + STMT_PAGE
|
|
|
|
STMT_BOOKS_TITLE_DESC = STMT_BOOKS0 + "ORDER BY books.sort DESC" + STMT_PAGE
|
|
|
|
STMT_BOOKS_TAGS_ID_ASC = STMT_BOOKS_TAGS0 + "ORDER BY id" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_TAGS_ID_DESC = STMT_BOOKS_TAGS0 + "ORDER BY id DESC" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_TAGS_TITLE_ASC = STMT_BOOKS_TAGS0 + "ORDER BY books.sort" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_TAGS_TITLE_DESC = STMT_BOOKS_TAGS0 + "ORDER BY books.sort DESC" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_AUTHORS_ID_ASC = STMT_BOOKS_AUTHORS0 + "ORDER BY id" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_AUTHORS_ID_DESC = STMT_BOOKS_AUTHORS0 + "ORDER BY id DESC" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_AUTHORS_TITLE_ASC = STMT_BOOKS_AUTHORS0 + "ORDER BY books.sort" + STMT_PAGE + ")"
|
|
|
|
STMT_BOOKS_AUTHORS_TITLE_DESC = STMT_BOOKS_AUTHORS0 + "ORDER BY books.sort DESC" + STMT_PAGE + ")"
|
|
|
|
|
|
|
|
DEF_LIM = 10
|
2017-07-31 17:37:52 +00:00
|
|
|
|
2017-08-01 18:00:20 +00:00
|
|
|
BOOKS QueryType = iota
|
|
|
|
BOOKS_TAGS QueryType = iota
|
|
|
|
BOOKS_AUTHORS QueryType = iota
|
2017-08-02 17:54:09 +00:00
|
|
|
BOOK QueryType = iota
|
|
|
|
BOOK_TAGS QueryType = iota
|
|
|
|
BOOK_DATA QueryType = iota
|
2017-08-02 18:00:42 +00:00
|
|
|
BOOK_AUTHORS QueryType = iota
|
2017-08-02 17:54:09 +00:00
|
|
|
BOOKS_COUNT QueryType = iota
|
2017-07-30 18:14:20 +00:00
|
|
|
)
|
|
|
|
|
2017-07-31 17:37:52 +00:00
|
|
|
var QUERIES = map[Query]string{
|
2017-08-01 18:00:20 +00:00
|
|
|
Query{BOOKS, true, true}: STMT_BOOKS_TITLE_DESC,
|
|
|
|
Query{BOOKS, true, false}: STMT_BOOKS_TITLE_ASC,
|
|
|
|
Query{BOOKS, false, true}: STMT_BOOKS_ID_DESC,
|
|
|
|
Query{BOOKS, false, false}: STMT_BOOKS_ID_ASC,
|
|
|
|
Query{BOOKS_TAGS, true, true}: STMT_BOOKS_TAGS_TITLE_DESC,
|
|
|
|
Query{BOOKS_TAGS, true, false}: STMT_BOOKS_TAGS_TITLE_ASC,
|
|
|
|
Query{BOOKS_TAGS, false, true}: STMT_BOOKS_TAGS_ID_DESC,
|
|
|
|
Query{BOOKS_TAGS, false, false}: STMT_BOOKS_TAGS_ID_ASC,
|
2017-07-31 17:37:52 +00:00
|
|
|
Query{BOOKS_AUTHORS, true, true}: STMT_BOOKS_AUTHORS_TITLE_DESC,
|
|
|
|
Query{BOOKS_AUTHORS, true, false}: STMT_BOOKS_AUTHORS_TITLE_ASC,
|
|
|
|
Query{BOOKS_AUTHORS, false, true}: STMT_BOOKS_AUTHORS_ID_DESC,
|
|
|
|
Query{BOOKS_AUTHORS, false, false}: STMT_BOOKS_AUTHORS_ID_ASC,
|
2017-08-02 17:54:09 +00:00
|
|
|
Query{BOOK, false, false}: STMT_BOOK,
|
|
|
|
Query{BOOK_TAGS, false, false}: STMT_BOOK_TAGS,
|
|
|
|
Query{BOOK_DATA, false, false}: STMT_BOOK_DATA,
|
2017-08-02 18:00:42 +00:00
|
|
|
Query{BOOK_AUTHORS, false, false}: STMT_BOOK_AUTHORS,
|
2017-08-02 17:54:09 +00:00
|
|
|
Query{BOOKS_COUNT, false, false}: STMT_BOOKS_COUNT,
|
2017-07-31 17:37:52 +00:00
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
var STMTS = make(map[Query]*sql.Stmt)
|
2017-07-31 17:37:52 +00:00
|
|
|
|
|
|
|
type QueryType uint
|
|
|
|
type Query struct {
|
|
|
|
Type QueryType
|
|
|
|
Title bool
|
|
|
|
Desc bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// PREPARED STATEMENTS //
|
2017-08-02 17:54:09 +00:00
|
|
|
func (app *Bouquins) PrepareAll() error {
|
|
|
|
errcount := 0
|
|
|
|
for q, v := range QUERIES {
|
|
|
|
stmt, err := app.DB.Prepare(v)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err, v)
|
|
|
|
errcount++
|
|
|
|
}
|
|
|
|
STMTS[q] = stmt
|
|
|
|
}
|
|
|
|
if errcount > 0 {
|
|
|
|
return errors.New(fmt.Sprintf("%d errors on queries, see logs", errcount))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// prepared statement with sort on books
|
|
|
|
func (app *Bouquins) psSortBooks(qt QueryType, sort, order string) (*sql.Stmt, error) {
|
|
|
|
q := Query{qt, sort == "title", order == "desc"}
|
|
|
|
query := QUERIES[q]
|
2017-07-31 17:37:52 +00:00
|
|
|
log.Println(query)
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt := STMTS[q]
|
|
|
|
if stmt == nil {
|
|
|
|
log.Println("Missing statement for ", q)
|
|
|
|
var err error
|
|
|
|
stmt, err = app.DB.Prepare(query)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stmt, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// prepared statement without sort
|
|
|
|
func (app *Bouquins) ps(qt QueryType) (*sql.Stmt, error) {
|
|
|
|
return app.psSortBooks(qt, "", "")
|
2017-07-31 17:37:52 +00:00
|
|
|
}
|
|
|
|
|
2017-07-30 18:14:20 +00:00
|
|
|
// MERGE SUB QUERIES //
|
|
|
|
func assignAuthorsTagsBooks(books []*BookAdv, authors map[int64][]*Author, tags map[int64][]string) {
|
|
|
|
for _, b := range books {
|
|
|
|
b.Authors = authors[b.Id]
|
|
|
|
b.Tags = tags[b.Id]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SUB QUERIES //
|
|
|
|
|
2017-07-31 17:37:52 +00:00
|
|
|
func (app *Bouquins) queryBooks(limit, offset int, sort, order string) ([]*BookAdv, error) {
|
2017-07-30 18:14:20 +00:00
|
|
|
books := make([]*BookAdv, 0, limit)
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt, err := app.psSortBooks(BOOKS, sort, order)
|
2017-07-30 18:14:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
rows, err := stmt.Query(limit, offset)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
defer rows.Close()
|
2017-07-30 18:14:20 +00:00
|
|
|
for rows.Next() {
|
|
|
|
book := new(BookAdv)
|
|
|
|
var series_name sql.NullString
|
|
|
|
var series_id sql.NullInt64
|
|
|
|
if err := rows.Scan(&book.Id, &book.Title, &book.SeriesIndex, &series_name, &series_id); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if series_name.Valid && series_id.Valid {
|
|
|
|
book.Series = &Series{
|
|
|
|
series_id.Int64,
|
|
|
|
series_name.String,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
books = append(books, book)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return books, nil
|
|
|
|
}
|
|
|
|
|
2017-07-31 17:37:52 +00:00
|
|
|
func (app *Bouquins) queryBooksAuthors(limit, offset int, sort, order string) (map[int64][]*Author, error) {
|
2017-07-30 18:14:20 +00:00
|
|
|
authors := make(map[int64][]*Author)
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt, err := app.psSortBooks(BOOKS_AUTHORS, sort, order)
|
2017-07-30 18:14:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
rows, err := stmt.Query(limit, offset)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
defer rows.Close()
|
2017-07-30 18:14:20 +00:00
|
|
|
for rows.Next() {
|
|
|
|
author := new(Author)
|
|
|
|
var book int64
|
|
|
|
if err := rows.Scan(&author.Id, &author.Name, &book); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if authors[book] == nil {
|
|
|
|
authors[book] = append(make([]*Author, 0), author)
|
|
|
|
} else {
|
|
|
|
authors[book] = append(authors[book], author)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return authors, nil
|
|
|
|
}
|
|
|
|
|
2017-07-31 17:37:52 +00:00
|
|
|
func (app *Bouquins) queryBooksTags(limit, offset int, sort, order string) (map[int64][]string, error) {
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt, err := app.psSortBooks(BOOKS_TAGS, sort, order)
|
2017-07-30 18:14:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
rows, err := stmt.Query(limit, offset)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
defer rows.Close()
|
2017-08-01 18:00:20 +00:00
|
|
|
tags := make(map[int64][]string)
|
2017-07-30 18:14:20 +00:00
|
|
|
for rows.Next() {
|
|
|
|
var tag string
|
|
|
|
var book int64
|
|
|
|
if err := rows.Scan(&tag, &book); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
bookTags := tags[book]
|
|
|
|
if bookTags == nil {
|
2017-07-31 18:49:12 +00:00
|
|
|
bookTags = make([]string, 0)
|
2017-07-30 18:14:20 +00:00
|
|
|
tags[book] = bookTags
|
|
|
|
}
|
|
|
|
tags[book] = append(bookTags, tag)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return tags, nil
|
|
|
|
}
|
2017-08-01 18:00:20 +00:00
|
|
|
func (app *Bouquins) queryBook(id int64) (*BookFull, error) {
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt, err := app.ps(BOOK)
|
2017-08-01 18:00:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
book := new(BookFull)
|
|
|
|
var seriesIdx sql.NullFloat64
|
|
|
|
var seriesId, timestamp, pubdate sql.NullInt64
|
|
|
|
var seriesName, isbn, lccn, uuid, lang, publisher sql.NullString
|
|
|
|
var cover sql.NullBool
|
|
|
|
err = stmt.QueryRow(id).Scan(&book.Id, &book.Title, &seriesIdx, &seriesName, &seriesId,
|
|
|
|
×tamp, &pubdate, &isbn, &lccn, &book.Path, &uuid, &cover, &lang, &publisher)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if seriesId.Valid && seriesName.Valid && seriesIdx.Valid {
|
|
|
|
book.SeriesIndex = seriesIdx.Float64
|
|
|
|
book.Series = &Series{seriesId.Int64, seriesName.String}
|
|
|
|
}
|
|
|
|
if timestamp.Valid {
|
|
|
|
book.Timestamp = timestamp.Int64
|
|
|
|
}
|
|
|
|
if pubdate.Valid {
|
|
|
|
book.Pubdate = pubdate.Int64
|
|
|
|
}
|
|
|
|
if isbn.Valid {
|
|
|
|
book.Isbn = isbn.String
|
|
|
|
}
|
|
|
|
if lccn.Valid {
|
|
|
|
book.Lccn = lccn.String
|
|
|
|
}
|
|
|
|
if uuid.Valid {
|
|
|
|
book.Uuid = uuid.String
|
|
|
|
}
|
|
|
|
if lang.Valid {
|
|
|
|
book.Lang = lang.String
|
|
|
|
}
|
|
|
|
if publisher.Valid {
|
|
|
|
book.Publisher = publisher.String
|
|
|
|
}
|
|
|
|
if cover.Valid {
|
|
|
|
book.Has_cover = cover.Bool
|
|
|
|
}
|
|
|
|
return book, nil
|
|
|
|
}
|
|
|
|
func (app *Bouquins) queryBookTags(book *BookFull) error {
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt, err := app.ps(BOOK_TAGS)
|
2017-08-01 18:00:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
rows, err := stmt.Query(book.Id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
defer rows.Close()
|
2017-08-01 18:00:20 +00:00
|
|
|
for rows.Next() {
|
|
|
|
var tag string
|
|
|
|
if err = rows.Scan(&tag); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
book.Tags = append(book.Tags, tag)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
func (app *Bouquins) queryBookData(book *BookFull) error {
|
|
|
|
stmt, err := app.ps(BOOK_DATA)
|
2017-08-01 18:00:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
rows, err := stmt.Query(book.Id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
defer rows.Close()
|
2017-08-01 18:00:20 +00:00
|
|
|
for rows.Next() {
|
|
|
|
data := new(BookData)
|
|
|
|
if err = rows.Scan(&data.Name, &data.Format, &data.Size); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
book.Data = append(book.Data, data)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-08-02 17:54:09 +00:00
|
|
|
func (app *Bouquins) queryBookAuthors(book *BookFull) error {
|
2017-08-02 18:00:42 +00:00
|
|
|
stmt, err := app.ps(BOOK_AUTHORS)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
rows, err := stmt.Query(book.Id)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer rows.Close()
|
|
|
|
for rows.Next() {
|
|
|
|
author := new(Author)
|
|
|
|
var bookId int64
|
|
|
|
if err = rows.Scan(&author.Id, &author.Name, &bookId); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
book.Authors = append(book.Authors, author)
|
|
|
|
}
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-01 18:00:20 +00:00
|
|
|
return nil
|
|
|
|
}
|
2017-07-30 18:14:20 +00:00
|
|
|
|
|
|
|
// DB LOADS //
|
|
|
|
|
|
|
|
func (app *Bouquins) BookCount() (int64, error) {
|
|
|
|
var count int64
|
2017-08-02 17:54:09 +00:00
|
|
|
stmt, err := app.ps(BOOKS_COUNT)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
row := stmt.QueryRow()
|
|
|
|
err = row.Scan(&count)
|
2017-07-30 18:14:20 +00:00
|
|
|
return count, err
|
|
|
|
}
|
2017-07-31 18:14:57 +00:00
|
|
|
func (app *Bouquins) SeriesAdv(limit, offset int, sort, order string) ([]*SeriesAdv, error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
func (app *Bouquins) AuthorsAdv(limit, offset int, sort, order string) ([]*AuthorAdv, error) {
|
|
|
|
panic("not implemented")
|
|
|
|
}
|
2017-07-30 18:14:20 +00:00
|
|
|
|
2017-08-01 13:38:23 +00:00
|
|
|
func (app *Bouquins) BookFull(id int64) (*BookFull, error) {
|
2017-08-01 18:00:20 +00:00
|
|
|
book, err := app.queryBook(id)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = app.queryBookTags(book)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = app.queryBookAuthors(book)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = app.queryBookData(book)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return book, nil
|
2017-08-01 13:38:23 +00:00
|
|
|
}
|
|
|
|
|
2017-07-31 17:37:52 +00:00
|
|
|
func (app *Bouquins) BooksAdv(limit, offset int, sort, order string) ([]*BookAdv, error) {
|
2017-07-30 18:14:20 +00:00
|
|
|
if limit == 0 {
|
|
|
|
limit = DEF_LIM
|
|
|
|
}
|
2017-07-31 17:37:52 +00:00
|
|
|
books, err := app.queryBooks(limit, offset, sort, order)
|
2017-07-30 18:14:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-07-31 17:37:52 +00:00
|
|
|
authors, err := app.queryBooksAuthors(limit, offset, sort, order)
|
2017-07-30 18:14:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2017-07-31 17:37:52 +00:00
|
|
|
tags, err := app.queryBooksTags(limit, offset, sort, order)
|
2017-07-30 18:14:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
assignAuthorsTagsBooks(books, authors, tags)
|
|
|
|
return books, nil
|
|
|
|
}
|