first commit
This commit is contained in:
50
services/person/person.store.go
Normal file
50
services/person/person.store.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user