mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 02:51:34 +00:00
This commit introduces the `MergeWork` command, a new feature to merge two `Work` entities, their associations, and their statistics. The entire operation is performed atomically within a database transaction to ensure data integrity. Key changes include: - A new `MergeWork` method in `internal/app/work/commands.go`. - An `Add` method on the `WorkStats` entity for combining statistics. - A new `GetWithAssociationsInTx` method on the `WorkRepository` to fetch entities within a transaction. - A comprehensive integration test using an in-memory SQLite database to validate the merge logic. This commit also consolidates all scattered TODOs and build issues from `TODO.md` and `BUILD_ISSUES.md` into a single, actionable `TASKS.md` file. The legacy documentation files have been removed to create a single source of truth for pending work.
21 lines
896 B
Go
21 lines
896 B
Go
package work
|
|
|
|
import (
|
|
"context"
|
|
"gorm.io/gorm"
|
|
"tercul/internal/domain"
|
|
)
|
|
|
|
// WorkRepository defines methods specific to Work.
|
|
type WorkRepository interface {
|
|
domain.BaseRepository[Work]
|
|
FindByTitle(ctx context.Context, title string) ([]Work, error)
|
|
FindByAuthor(ctx context.Context, authorID uint) ([]Work, error)
|
|
FindByCategory(ctx context.Context, categoryID uint) ([]Work, error)
|
|
FindByLanguage(ctx context.Context, language string, page, pageSize int) (*domain.PaginatedResult[Work], error)
|
|
GetWithTranslations(ctx context.Context, id uint) (*Work, error)
|
|
GetWithAssociations(ctx context.Context, id uint) (*Work, error)
|
|
GetWithAssociationsInTx(ctx context.Context, tx *gorm.DB, id uint) (*Work, error)
|
|
ListWithTranslations(ctx context.Context, page, pageSize int) (*domain.PaginatedResult[Work], error)
|
|
IsAuthor(ctx context.Context, workID uint, authorID uint) (bool, error)
|
|
} |