new file structure & koneksi ke DB
This commit is contained in:
44
internal/api/repository/doctor.go
Normal file
44
internal/api/repository/doctor.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"devone.aplikasi.web.id/gitea/mario/go-ohif-proxy/internal/database"
|
||||
)
|
||||
|
||||
// DBDoctor represents a doctor from the database
|
||||
type DBDoctor struct {
|
||||
ID int `db:"id"`
|
||||
Doctor_UsersID string `db:"Doctor_UsersID"`
|
||||
DoctorID string `db:"DoctorID"`
|
||||
DoctorName string `db:"DoctorName"`
|
||||
DoctorCreatedAt time.Time `db:"DoctorCreatedAt"`
|
||||
DoctorLastUpdatedAt time.Time `db:"DoctorLastUpdatedAt"`
|
||||
}
|
||||
|
||||
// DoctorRepository handles database operations related to doctors
|
||||
type DoctorRepository struct {
|
||||
*Repository
|
||||
}
|
||||
|
||||
// NewDoctorRepository creates a new doctor repository
|
||||
func NewDoctorRepository() *DoctorRepository {
|
||||
return &DoctorRepository{
|
||||
Repository: NewRepository(),
|
||||
}
|
||||
}
|
||||
|
||||
// GetDoctorDetailsByUserID retrieves doctor details for a user
|
||||
func (r *DoctorRepository) GetDoctorDetailsByUserID(userID string) (*DBDoctor, error) {
|
||||
var dbDoctor DBDoctor
|
||||
|
||||
query := `SELECT * FROM doctor WHERE Doctor_UsersID = ?`
|
||||
err := database.DB.Get(&dbDoctor, query, userID)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("database error getting doctor details: %w", err)
|
||||
}
|
||||
|
||||
return &dbDoctor, nil
|
||||
}
|
||||
Reference in New Issue
Block a user