package models import ( "api-service/internal/models" "database/sql" "encoding/json" ) type RefHealthcareType struct { ID int32 `json:"id" db:"id"` Name sql.NullString `json:"name,omitempty" db:"name"` Active sql.NullBool `json:"active,omitempty" db:"active"` } func (r RefHealthcareType) MarshalJSON() ([]byte, error) { // Buat alias untuk menghindari rekursi tak terbatas saat pemanggilan json.Marshal type Alias RefHealthcareType aux := &struct { Name *string `json:"name,omitempty"` Active *bool `json:"active,omitempty"` *Alias }{ Alias: (*Alias)(&r), } // Jika field Name valid, ambil nilainya if r.Name.Valid { aux.Name = &r.Name.String } // Jika field Active valid, ambil nilainya if r.Active.Valid { aux.Active = &r.Active.Bool } return json.Marshal(aux) } type RefHealthcareTypeGetResponse struct { Message string `json:"message"` Data *RefHealthcareType `json:"data"` } type RefHealthcareTypeGetListResponse struct { Message string `json:"message"` Data []RefHealthcareType `json:"data"` Meta models.MetaResponse `json:"meta"` } type RefServiceType struct { ID int32 `json:"id" db:"id"` Name sql.NullString `json:"name,omitempty" db:"name"` Active sql.NullBool `json:"active,omitempty" db:"active"` } func (r RefServiceType) MarshalJSON() ([]byte, error) { type Alias RefServiceType aux := &struct { Name *string `json:"name,omitempty"` Active *bool `json:"active,omitempty"` *Alias }{ Alias: (*Alias)(&r), } if r.Name.Valid { aux.Name = &r.Name.String } if r.Active.Valid { aux.Active = &r.Active.Bool } return json.Marshal(aux) } type RefServiceTypeGetResponse struct { Message string `json:"message"` Data *RefServiceType `json:"data"` } type RefServiceTypeGetListResponse struct { Message string `json:"message"` Data []RefServiceType `json:"data"` Meta models.MetaResponse `json:"meta"` } type RefServiceTypeFilter struct { Active *bool `json:"active,omitempty" form:"active"` // Digunakan untuk query parameter ?active=true Search *string `json:"search,omitempty" form:"search"` // Digunakan untuk query parameter ?search=lab }