|
@@ -72,7 +72,7 @@ func (t tagRepository) GetByURL(ctx context.Context, tag string) (*models.Tag, e
|
|
|
return &res, nil
|
|
|
}
|
|
|
|
|
|
-func (t tagRepository) GetByID(ctx context.Context, ID int) (*models.Tag, error) {
|
|
|
+func (t tagRepository) GetByID(ctx context.Context, id int) (*models.Tag, error) {
|
|
|
var res models.Tag
|
|
|
|
|
|
query := "SELECT id, url, tag " +
|
|
@@ -80,7 +80,7 @@ func (t tagRepository) GetByID(ctx context.Context, ID int) (*models.Tag, error)
|
|
|
"WHERE id = ? " +
|
|
|
"LIMIT 1"
|
|
|
|
|
|
- err := t.db.QueryRowContext(ctx, query, ID).
|
|
|
+ err := t.db.QueryRowContext(ctx, query, id).
|
|
|
Scan(&res.ID, &res.URL, &res.Tag)
|
|
|
|
|
|
if err != nil {
|
|
@@ -124,14 +124,14 @@ func (t tagRepository) GetAll(ctx context.Context) ([]models.Tag, error) {
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
-func (t tagRepository) GetByArticleID(ctx context.Context, ID int) ([]models.Tag, error) {
|
|
|
+func (t tagRepository) GetByArticleID(ctx context.Context, id int) ([]models.Tag, error) {
|
|
|
var res []models.Tag
|
|
|
|
|
|
query := "SELECT t.id, t.url, t.tag " +
|
|
|
"FROM " + articleTagTableName + " at, " + tagTableName + " t " +
|
|
|
"WHERE t.id = at.tag_id AND at.article_id = ?"
|
|
|
|
|
|
- rows, err := t.db.QueryContext(ctx, query, ID)
|
|
|
+ rows, err := t.db.QueryContext(ctx, query, id)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
@@ -160,12 +160,12 @@ func (t tagRepository) GetByArticleID(ctx context.Context, ID int) ([]models.Tag
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
-func (t tagRepository) IsUsed(ctx context.Context, ID int) (bool, error) {
|
|
|
+func (t tagRepository) IsUsed(ctx context.Context, id int) (bool, error) {
|
|
|
var count int
|
|
|
|
|
|
query := "SELECT COUNT(tag_id) FROM " + articleTagTableName + " WHERE tag_id = ?"
|
|
|
|
|
|
- if err := t.db.QueryRowContext(ctx, query, ID).Scan(&count); err != nil {
|
|
|
+ if err := t.db.QueryRowContext(ctx, query, id).Scan(&count); err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
|
|
@@ -188,10 +188,10 @@ func (t tagRepository) Update(ctx context.Context, m models.Tag) error {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-func (t tagRepository) Delete(ctx context.Context, ID int) error {
|
|
|
+func (t tagRepository) Delete(ctx context.Context, id int) error {
|
|
|
query := "DELETE FROM " + tagTableName + " WHERE id = ?"
|
|
|
|
|
|
- _, err := t.db.ExecContext(ctx, query, ID)
|
|
|
+ _, err := t.db.ExecContext(ctx, query, id)
|
|
|
|
|
|
return err
|
|
|
}
|