first commit

This commit is contained in:
Sas Andy
2024-12-09 09:51:19 +07:00
commit ecc5dfd9c0
69 changed files with 5365 additions and 0 deletions

View 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
}