|
@@ -37,7 +37,7 @@ func (a articleRepository) GetAllPreview(ctx context.Context) ([]models.ArticleP
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
- rows, err := a.db.QueryContext(ctx, query, args)
|
|
|
|
|
|
+ rows, err := a.db.QueryContext(ctx, query, args...)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
@@ -69,7 +69,7 @@ func (a articleRepository) GetAll(ctx context.Context) ([]models.Article, error)
|
|
OrderBy("publish_time DESC").
|
|
OrderBy("publish_time DESC").
|
|
ToSql()
|
|
ToSql()
|
|
|
|
|
|
- rows, err := a.db.QueryContext(ctx, query, args)
|
|
|
|
|
|
+ rows, err := a.db.QueryContext(ctx, query, args...)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
@@ -98,7 +98,7 @@ func (a articleRepository) GetPreviewByTagID(ctx context.Context, tagID int) ([]
|
|
|
|
|
|
query := "SELECT a.id, a.url, a.publish_time, a.title, a.preview_text, a.image " +
|
|
query := "SELECT a.id, a.url, a.publish_time, a.title, a.preview_text, a.image " +
|
|
"FROM " + articleTableName + " a, " + articleTagTableName + " at " +
|
|
"FROM " + articleTableName + " a, " + articleTagTableName + " at " +
|
|
- "WHERE a.is_active = true AND at.article_id = a.id AND at.tag_id = ? " +
|
|
|
|
|
|
+ "WHERE a.is_active = true AND at.article_id = a.id AND at.tag_id = $1 " +
|
|
"ORDER BY a.publish_time DESC"
|
|
"ORDER BY a.publish_time DESC"
|
|
|
|
|
|
rows, err := a.db.QueryContext(ctx, query, tagID)
|
|
rows, err := a.db.QueryContext(ctx, query, tagID)
|
|
@@ -129,7 +129,7 @@ func (a articleRepository) GetByURL(ctx context.Context, url string) (*models.Ar
|
|
var res models.Article
|
|
var res models.Article
|
|
|
|
|
|
query, args, err := sq.Select("id", "url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
|
|
query, args, err := sq.Select("id", "url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
|
|
- From(tagTableName).
|
|
|
|
|
|
+ From(articleTableName).
|
|
PlaceholderFormat(sq.Dollar).
|
|
PlaceholderFormat(sq.Dollar).
|
|
Where(sq.Eq{"url": url}).
|
|
Where(sq.Eq{"url": url}).
|
|
Limit(1).
|
|
Limit(1).
|
|
@@ -153,7 +153,7 @@ func (a articleRepository) GetByID(ctx context.Context, id int) (*models.Article
|
|
var res models.Article
|
|
var res models.Article
|
|
|
|
|
|
query, args, err := sq.Select("id", "url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
|
|
query, args, err := sq.Select("id", "url", "publish_time", "title", "image", "text", "preview_text", "meta_keywords", "meta_desc", "is_active").
|
|
- From(tagTableName).
|
|
|
|
|
|
+ From(articleTableName).
|
|
PlaceholderFormat(sq.Dollar).
|
|
PlaceholderFormat(sq.Dollar).
|
|
Where(sq.Eq{"id": id}).
|
|
Where(sq.Eq{"id": id}).
|
|
Limit(1).
|
|
Limit(1).
|