fixing crud registrasi, penambahan lokasi dan display lokasi
Some checks failed
Go-test / build (push) Has been cancelled
Some checks failed
Go-test / build (push) Has been cancelled
This commit is contained in:
@@ -21,23 +21,23 @@ type MsRegistrationCounter struct {
|
||||
DsSdLocation sql.NullString `json:"ds_sd_location,omitempty" db:"ds_sd_location"`
|
||||
}
|
||||
|
||||
type MsRegistrationCounterDetail struct {
|
||||
ID int64 `json:"id" db:"id"`
|
||||
Name sql.NullString `json:"name,omitempty" db:"name"`
|
||||
Code sql.NullString `json:"code,omitempty" db:"code"`
|
||||
Icon sql.NullString `json:"icon,omitempty" db:"icon"`
|
||||
Quota sql.NullInt16 `json:"quota,omitempty" db:"quota"`
|
||||
Active sql.NullBool `json:"active,omitempty" db:"active"`
|
||||
HealthCareType sql.NullString `json:"healthcaretype,omitempty" db:"healthcaretype"`
|
||||
ServiceType sql.NullString `json:"servicetype,omitempty" db:"fk_ref_service_type_id"`
|
||||
}
|
||||
type MsRegistrationCounterDetail struct {
|
||||
ID int64 `json:"id" db:"id"`
|
||||
Name sql.NullString `json:"name,omitempty" db:"name"`
|
||||
Code sql.NullString `json:"code,omitempty" db:"code"`
|
||||
Icon sql.NullString `json:"icon,omitempty" db:"icon"`
|
||||
Quota sql.NullInt16 `json:"quota,omitempty" db:"quota"`
|
||||
Active sql.NullBool `json:"active,omitempty" db:"active"`
|
||||
HealthCareType sql.NullString `json:"healthcaretype,omitempty" db:"healthcaretype"`
|
||||
ServiceType sql.NullString `json:"servicetype,omitempty" db:"servicetype"`
|
||||
Location sql.NullString `json:"location" db:"location"`
|
||||
DisplayLocation sql.NullString `json:"displaylocation" db:"displaylocation"`
|
||||
}
|
||||
|
||||
|
||||
func (m MsRegistrationCounterDetail) MarshalJSON() ([]byte, error) {
|
||||
// Buat alias untuk menghindari rekursi tak terbatas saat pemanggilan json.Marshal
|
||||
type Alias MsRegistrationCounterDetail
|
||||
|
||||
// Buat struct anonim dengan field pointer untuk menangani nilai NULL
|
||||
aux := &struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Code *string `json:"code,omitempty"`
|
||||
@@ -46,13 +46,13 @@ func (m MsRegistrationCounterDetail) MarshalJSON() ([]byte, error) {
|
||||
Active *bool `json:"active,omitempty"`
|
||||
HealthCareType *string `json:"healthcaretype,omitempty"`
|
||||
ServiceType *string `json:"servicetype,omitempty"`
|
||||
// Embed alias untuk menyertakan field non-nullable seperti 'id'
|
||||
Location *string `json:"location"`
|
||||
DisplayLocation *string `json:"displaylocation"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(&m),
|
||||
}
|
||||
|
||||
// Jika field asli valid, isi pointer di struct anonim
|
||||
if m.Name.Valid {
|
||||
aux.Name = &m.Name.String
|
||||
}
|
||||
@@ -68,6 +68,21 @@ func (m MsRegistrationCounterDetail) MarshalJSON() ([]byte, error) {
|
||||
if m.Active.Valid {
|
||||
aux.Active = &m.Active.Bool
|
||||
}
|
||||
|
||||
if m.Location.Valid {
|
||||
aux.Location = &m.Location.String
|
||||
} else {
|
||||
emptyStr := ""
|
||||
aux.Location = &emptyStr
|
||||
}
|
||||
|
||||
if m.DisplayLocation.Valid {
|
||||
aux.DisplayLocation = &m.DisplayLocation.String
|
||||
} else {
|
||||
emptyStr := ""
|
||||
aux.DisplayLocation = &emptyStr
|
||||
}
|
||||
|
||||
if m.HealthCareType.Valid {
|
||||
aux.HealthCareType = &m.HealthCareType.String
|
||||
}
|
||||
@@ -75,7 +90,6 @@ func (m MsRegistrationCounterDetail) MarshalJSON() ([]byte, error) {
|
||||
aux.ServiceType = &m.ServiceType.String
|
||||
}
|
||||
|
||||
// Marshal struct anonim yang sudah "bersih"
|
||||
return json.Marshal(aux)
|
||||
}
|
||||
|
||||
@@ -184,15 +198,15 @@ type MsRegistrationCounterGetResponse struct {
|
||||
}
|
||||
|
||||
type MsRegistrationCounterCreateRequest struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=20"`
|
||||
Code string `json:"code" validate:"required,min=1,max=3"`
|
||||
Icon string `json:"icon" validate:"min=1,max=20"`
|
||||
Name string `json:"name" validate:"required,min=1"`
|
||||
Code string `json:"code"`
|
||||
Icon string `json:"icon"`
|
||||
Quota int16 `json:"quota" validate:"min=0"`
|
||||
Active bool `json:"active"`
|
||||
FKRefHealtcareTypeID int32 `json:"fk_ref_healtcare_type_id" validate:"min=1"`
|
||||
FKRefServiceTypeID int32 `json:"fk_ref_service_type_id" validate:"min=1"`
|
||||
FKRefHealtcareTypeID int32 `json:"fk_ref_healtcare_type_id"`
|
||||
FKRefServiceTypeID int32 `json:"fk_ref_service_type_id"`
|
||||
FKSdLocationID string `json:"fk_sd_location_id"`
|
||||
DsSdLocation string `json:"ds_sd_location" validate:"min=1,max=255"`
|
||||
DsSdLocation string `json:"ds_sd_location"`
|
||||
}
|
||||
|
||||
type MsRegistrationCounterCreateResponse struct {
|
||||
@@ -202,15 +216,15 @@ type MsRegistrationCounterCreateResponse struct {
|
||||
|
||||
type MsRegistrationCounterUpdateRequest struct {
|
||||
ID int `json:"id" validate:"required,min=1"`
|
||||
Name string `json:"name" validate:"required,min=1,max=20"`
|
||||
Code string `json:"code" validate:"required,min=1,max=3"`
|
||||
Icon string `json:"icon" validate:"min=1,max=20"`
|
||||
Name string `json:"name" validate:"required,min=1"`
|
||||
Code string `json:"code" validate:"required,min=1"`
|
||||
Icon string `json:"icon" validate:"min=1"`
|
||||
Quota int16 `json:"quota" validate:"min=0"`
|
||||
Active bool `json:"active"`
|
||||
FKRefHealtcareTypeID int32 `json:"fk_ref_healtcare_type_id" validate:"min=1"`
|
||||
FKRefServiceTypeID int32 `json:"fk_ref_service_type_id" validate:"min=1"`
|
||||
FKSdLocationID string `json:"fk_sd_location_id" validate:"required"`
|
||||
DsSdLocation string `json:"ds_sd_location" validate:"required,min=1,max=255"`
|
||||
FKRefHealtcareTypeID int32 `json:"fk_ref_healtcare_type_id"`
|
||||
FKRefServiceTypeID int32 `json:"fk_ref_service_type_id"`
|
||||
FKSdLocationID string `json:"fk_sd_location_id"`
|
||||
DsSdLocation string `json:"ds_sd_location"`
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user