Skip to content

Fix/9 architecture#10

Open
tulashvili wants to merge 12 commits into
mainfrom
fix/9-architecture
Open

Fix/9 architecture#10
tulashvili wants to merge 12 commits into
mainfrom
fix/9-architecture

Conversation

@tulashvili

Copy link
Copy Markdown
Owner

No description provided.

Comment thread internal/domain/rules.go
import "errors"

// Validate user answer
func ValidateAnswer(answer int) error {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделать его методом для UserAnswer, вынести его в файл answer.go

"fmt"
"time"
type Question struct {
Category

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Category: Category


"github.com/tulashvili/MyDailyControlQuestions/internal/models"
)
type Category string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В отдельный файл

Comment on lines +21 to +24
query := `
INSERT INTO daily_log (category, question, answer, answeredAt)
VALUES (?, ?, ?, ?)
`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переписать под sqlx и почитай про sql инъекции

Comment on lines +1 to +8
package repo

import "github.com/tulashvili/MyDailyControlQuestions/internal/domain"

type AnswerRepository interface {
SaveAnswer(answer domain.UserAnswer) error
GetAnswers(period int) ([]domain.UserAnswer, error)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут это не нужно, за хорошую практику считается использовать интерфейсы в месте использования

"github.com/tulashvili/MyDailyControlQuestions/internal/usecase"
)

var listQuestionsCmd = &cobra.Command{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше в один файл вынести все команды

Comment thread internal/ui/cli/root.go
Long: ``,
}

func Execute(conn *sql.DB) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем сюда конект прокидываешь?

db *sql.DB
}

func NewSQLiteAnswerRepository(db *sql.DB) *SQLiteAnswerRepository {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убери из названия SQLite

Comment thread pkg/db/sqlitedb/sqlite.go

// ToDo: move this to migrate.go

func InitDB(path db.DataSource) (*sql.DB, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалить это все, переписать миграции под goose, конект вынести в db.go

Comment thread internal/app.go

if err := sqlitedb.CreateTable(app.DB); err != nil {
log.Fatal(err)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а где все остальное? слой репозитория, сервисный слой и т.д

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants