Initial
This commit is contained in:
29
app/repository/fisk_log.go
Normal file
29
app/repository/fisk_log.go
Normal file
@ -0,0 +1,29 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"repo-pattern/app/lib/helpers"
|
||||
"repo-pattern/app/models"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FiskLogRepository struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func CreateFiskLogRepository(db *gorm.DB) *FiskLogRepository {
|
||||
return &FiskLogRepository{db}
|
||||
}
|
||||
|
||||
func (r *FiskLogRepository) New(model models.FiskLogItem) *models.FiskLogItem {
|
||||
now := helpers.UTCNow()
|
||||
model.CreatedAt = now
|
||||
model.UpdatedAt = now
|
||||
return &model
|
||||
}
|
||||
|
||||
func (r *FiskLogRepository) Save(model *models.FiskLogItem) error {
|
||||
model.UpdatedAt = helpers.UTCNow()
|
||||
result := r.db.Save(model)
|
||||
return result.Error
|
||||
}
|
||||
Reference in New Issue
Block a user