51 lines
906 B
Go
51 lines
906 B
Go
package person
|
|
|
|
import (
|
|
"github.com/jmoiron/sqlx"
|
|
"sismedika.com/sas/westone/types"
|
|
)
|
|
|
|
type Store struct {
|
|
db *sqlx.DB
|
|
}
|
|
|
|
func NewStore(db *sqlx.DB) *Store {
|
|
return &Store{db: db}
|
|
}
|
|
|
|
func (s *Store) GetPersonByID(id int) (*types.Person, error) {
|
|
person := new(types.Person)
|
|
|
|
qry := `
|
|
SELECT
|
|
PersonID,
|
|
PersonName,
|
|
PersonSalutation,
|
|
PersonPrefix,
|
|
PersonSuffix,
|
|
PersonGender,
|
|
PersonBirthPlace,
|
|
PersonBirthDate,
|
|
PersonReligionCode,
|
|
PersonReligionSystem,
|
|
PersonBloodTypeCode,
|
|
PersonBloodTypeSystem,
|
|
PersonRhesusCode,
|
|
PersonRhesusSystem,
|
|
PersonEducationCode,
|
|
PersonEducationSystem,
|
|
PersonJobClassCode,
|
|
PersonJobClassSystem,
|
|
PersonEtnicityCode,
|
|
PersonEtnicitySystem,
|
|
PersonMaritalBirth,
|
|
PersonMaritalStatus
|
|
FROM person WHERE PersonID = ?
|
|
`
|
|
if err := s.db.Get(person, qry, id); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return person, nil
|
|
}
|