feat(BE-115,116,117): implement chickin CRUD, approve logic, and stock availabilit

This commit is contained in:
aguhh18
2025-10-20 06:01:16 +07:00
parent 68a670a2bd
commit 83c3e61113
34 changed files with 558 additions and 199 deletions
@@ -1,21 +0,0 @@
package repository
import (
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
"gorm.io/gorm"
)
type ChickinRepository interface {
repository.BaseRepository[entity.ProjectChickin]
}
type ChickinRepositoryImpl struct {
*repository.BaseRepositoryImpl[entity.ProjectChickin]
}
func NewChickinRepository(db *gorm.DB) ChickinRepository {
return &ChickinRepositoryImpl{
BaseRepositoryImpl: repository.NewBaseRepository[entity.ProjectChickin](db),
}
}
@@ -0,0 +1,36 @@
package repository
import (
"context"
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
"gorm.io/gorm"
)
type ProjectChickinRepository interface {
repository.BaseRepository[entity.ProjectChickin]
GetFirstByProjectFlockID(ctx context.Context, projectFlockID uint) (*entity.ProjectChickin, error)
}
type ChickinRepositoryImpl struct {
*repository.BaseRepositoryImpl[entity.ProjectChickin]
}
func NewChickinRepository(db *gorm.DB) ProjectChickinRepository {
return &ChickinRepositoryImpl{
BaseRepositoryImpl: repository.NewBaseRepository[entity.ProjectChickin](db),
}
}
func (r *ChickinRepositoryImpl) GetFirstByProjectFlockID(ctx context.Context, projectFlockID uint) (*entity.ProjectChickin, error) {
var chickin entity.ProjectChickin
err := r.DB().WithContext(ctx).
Where("project_floc_id = ?", projectFlockID).
Where("deleted_at IS NULL").
First(&chickin).Error
if err != nil {
return nil, err
}
return &chickin, nil
}