Update API

This commit is contained in:
2025-06-22 23:23:26 +07:00
parent b077ef9f06
commit 40705fbf3b
63 changed files with 1976 additions and 81 deletions
+25
View File
@@ -0,0 +1,25 @@
package repository
import (
"BE-MiniERP/modules/auth/models"
"gorm.io/gorm"
)
type UserRepository struct {
DB *gorm.DB
}
func NewUserRepository(db *gorm.DB) *UserRepository {
return &UserRepository{DB: db}
}
func (r *UserRepository) Create(user *models.User) error {
return r.DB.Create(user).Error
}
func (r *UserRepository) FindByUsername(username string) (*models.User, error) {
var user models.User
result := r.DB.Where("username = ?", username).First(&user)
return &user, result.Error
}