feat(tag): make private things private
This commit is contained in:
@@ -10,11 +10,11 @@ import (
|
||||
)
|
||||
|
||||
type Db interface {
|
||||
Insert(ctx context.Context, tag Tag) (*Tag, error)
|
||||
Update(ctx context.Context, tag Tag) (*Tag, error)
|
||||
Delete(ctx context.Context, userId uuid.UUID, id uuid.UUID) error
|
||||
Get(ctx context.Context, userId uuid.UUID, id uuid.UUID) (*Tag, error)
|
||||
GetAll(ctx context.Context, userId uuid.UUID) ([]Tag, error)
|
||||
insert(ctx context.Context, tag Tag) (*Tag, error)
|
||||
update(ctx context.Context, tag Tag) (*Tag, error)
|
||||
delete(ctx context.Context, userId uuid.UUID, id uuid.UUID) error
|
||||
get(ctx context.Context, userId uuid.UUID, id uuid.UUID) (*Tag, error)
|
||||
getAll(ctx context.Context, userId uuid.UUID) ([]Tag, error)
|
||||
}
|
||||
|
||||
type DbSqlite struct {
|
||||
@@ -25,7 +25,7 @@ func NewDbSqlite(db *sqlx.DB) *DbSqlite {
|
||||
return &DbSqlite{db: db}
|
||||
}
|
||||
|
||||
func (db DbSqlite) Insert(ctx context.Context, tag Tag) (*Tag, error) {
|
||||
func (db DbSqlite) insert(ctx context.Context, tag Tag) (*Tag, error) {
|
||||
r, err := db.db.ExecContext(ctx, `
|
||||
INSERT INTO tag (id, user_id, name, created_at, created_by, updated_at, updated_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
@@ -36,10 +36,10 @@ func (db DbSqlite) Insert(ctx context.Context, tag Tag) (*Tag, error) {
|
||||
return nil, core.ErrInternal
|
||||
}
|
||||
|
||||
return db.Get(ctx, tag.UserId, tag.Id)
|
||||
return db.get(ctx, tag.UserId, tag.Id)
|
||||
}
|
||||
|
||||
func (db DbSqlite) Update(ctx context.Context, tag Tag) (*Tag, error) {
|
||||
func (db DbSqlite) update(ctx context.Context, tag Tag) (*Tag, error) {
|
||||
_, err := db.db.ExecContext(ctx, `
|
||||
UPDATE tag
|
||||
SET name = ?,
|
||||
@@ -54,10 +54,10 @@ func (db DbSqlite) Update(ctx context.Context, tag Tag) (*Tag, error) {
|
||||
return nil, core.ErrInternal
|
||||
}
|
||||
|
||||
return db.Get(ctx, tag.UserId, tag.Id)
|
||||
return db.get(ctx, tag.UserId, tag.Id)
|
||||
}
|
||||
|
||||
func (db DbSqlite) Delete(ctx context.Context, userId uuid.UUID, id uuid.UUID) error {
|
||||
func (db DbSqlite) delete(ctx context.Context, userId uuid.UUID, id uuid.UUID) error {
|
||||
r, err := db.db.ExecContext(
|
||||
ctx,
|
||||
"DELETE FROM tag WHERE user_id = ? AND id = ?",
|
||||
@@ -71,7 +71,7 @@ func (db DbSqlite) Delete(ctx context.Context, userId uuid.UUID, id uuid.UUID) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db DbSqlite) Get(ctx context.Context, userId uuid.UUID, id uuid.UUID) (*Tag, error) {
|
||||
func (db DbSqlite) get(ctx context.Context, userId uuid.UUID, id uuid.UUID) (*Tag, error) {
|
||||
var tag Tag
|
||||
err := db.db.Get(&tag, "SELECT * FROM tag WHERE id = ? AND user_id = ?", id, userId)
|
||||
|
||||
@@ -83,7 +83,7 @@ func (db DbSqlite) Get(ctx context.Context, userId uuid.UUID, id uuid.UUID) (*Ta
|
||||
return &tag, nil
|
||||
}
|
||||
|
||||
func (db DbSqlite) GetAll(ctx context.Context, userId uuid.UUID) ([]Tag, error) {
|
||||
func (db DbSqlite) getAll(ctx context.Context, userId uuid.UUID) ([]Tag, error) {
|
||||
var tags []Tag
|
||||
err := db.db.Select(&tags, "SELECT * FROM tag WHERE user_id = ?", userId)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user