This commit is contained in:
1
internal/handlers/registrasi/registrasih.go
Normal file
1
internal/handlers/registrasi/registrasih.go
Normal file
@@ -0,0 +1 @@
|
||||
package handlers
|
||||
170
internal/models/registrasi/registrasi.go
Normal file
170
internal/models/registrasi/registrasi.go
Normal file
@@ -0,0 +1,170 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"api-service/internal/models"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
type MsRegistrationCounter 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"`
|
||||
FKRefHealtcareTypeID models.NullableInt32 `json:"fk_ref_healtcare_type_id,omitempty" db:"fk_ref_healtcare_type_id"`
|
||||
FKRefServiceTypeID models.NullableInt32 `json:"fk_ref_service_type_id,omitempty" db:"fk_ref_service_type_id"`
|
||||
FKSdLocationID sql.NullString `json:"fk_sd_location_id,omitempty" db:"fk_sd_location_id"`
|
||||
DsSdLocation sql.NullString `json:"ds_sd_location,omitempty" db:"ds_sd_location"`
|
||||
}
|
||||
|
||||
|
||||
func (r MsRegistrationCounter) MarshalJSON() ([]byte, error) {
|
||||
type Alias MsRegistrationCounter
|
||||
aux := &struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Code *string `json:"code,omitempty"`
|
||||
Icon *string `json:"icon,omitempty"`
|
||||
Quota *int16 `json:"quota,omitempty"`
|
||||
Active *bool `json:"active,omitempty"`
|
||||
FKRefHealtcareTypeID *int32 `json:"fk_ref_healtcare_type_id,omitempty"`
|
||||
FKRefServiceTypeID *int32 `json:"fk_ref_service_type_id,omitempty"`
|
||||
FKSdLocationID *string `json:"fk_sd_location_id,omitempty"`
|
||||
DsSdLocation *string `json:"ds_sd_location,omitempty"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(&r),
|
||||
}
|
||||
|
||||
if r.Name.Valid {
|
||||
aux.Name = &r.Name.String
|
||||
}
|
||||
if r.Code.Valid {
|
||||
aux.Code = &r.Code.String
|
||||
}
|
||||
if r.Icon.Valid {
|
||||
aux.Icon = &r.Icon.String
|
||||
}
|
||||
if r.Quota.Valid {
|
||||
aux.Quota = &r.Quota.Int16
|
||||
}
|
||||
if r.Active.Valid {
|
||||
aux.Active = &r.Active.Bool
|
||||
}
|
||||
if r.FKRefHealtcareTypeID.Valid {
|
||||
fkrht := int32(r.FKRefHealtcareTypeID.Int32)
|
||||
aux.FKRefHealtcareTypeID = &fkrht
|
||||
}
|
||||
if r.FKRefServiceTypeID.Valid {
|
||||
fkrst := int32(r.FKRefServiceTypeID.Int32)
|
||||
aux.FKRefServiceTypeID = &fkrst
|
||||
}
|
||||
if r.FKSdLocationID.Valid {
|
||||
aux.FKSdLocationID = &r.FKSdLocationID.String
|
||||
}
|
||||
if r.DsSdLocation.Valid {
|
||||
aux.DsSdLocation = &r.DsSdLocation.String
|
||||
}
|
||||
|
||||
return json.Marshal(aux)
|
||||
}
|
||||
|
||||
// Helper methods untuk mendapatkan nilai yang aman
|
||||
func (r *MsRegistrationCounter) GetName() string {
|
||||
if r.Name.Valid {
|
||||
return r.Name.String
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (r *MsRegistrationCounter) GetCode() string {
|
||||
if r.Code.Valid {
|
||||
return r.Code.String
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (r *MsRegistrationCounter) GetIcon() string {
|
||||
if r.Icon.Valid {
|
||||
return r.Icon.String
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (r *MsRegistrationCounter) GetQuota() int16 {
|
||||
if r.Quota.Valid {
|
||||
return r.Quota.Int16
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (r *MsRegistrationCounter) GetActive() bool {
|
||||
if r.Active.Valid {
|
||||
return r.Active.Bool
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type MsRegistrationCounterGetByIDResponse struct {
|
||||
Message string `json:"message"`
|
||||
Data *MsRegistrationCounter `json:"data"`
|
||||
}
|
||||
|
||||
type MsRegistrationCounterGetResponse struct {
|
||||
Message string `json:"message"`
|
||||
Data []MsRegistrationCounter `json:"data"`
|
||||
Meta models.MetaResponse `json:"meta"`
|
||||
Summary *models.AggregateData `json:"summary,omitempty"`
|
||||
}
|
||||
|
||||
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"`
|
||||
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"`
|
||||
DsSdLocation string `json:"ds_sd_location" validate:"min=1,max=255"`
|
||||
}
|
||||
|
||||
type MsRegistrationCounterCreateResponse struct {
|
||||
Message string `json:"message"`
|
||||
Data *MsRegistrationCounter `json:"data"`
|
||||
}
|
||||
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
|
||||
type MsRegistrationCounterUpdateResponse struct {
|
||||
Message string `json:"message"`
|
||||
Data *MsRegistrationCounter `json:"data"`
|
||||
}
|
||||
|
||||
|
||||
type MsRegistrationCounterDeleteResponse struct {
|
||||
Message string `json:"message"`
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type MsRegistrationCounterFilter struct {
|
||||
Status *string `json:"status,omitempty" form:"status"`
|
||||
Search *string `json:"search,omitempty" form:"search"`
|
||||
DateFrom *time.Time `json:"date_from,omitempty" form:"date_from"`
|
||||
DateTo *time.Time `json:"date_to,omitempty" form:"date_to"`
|
||||
}
|
||||
Reference in New Issue
Block a user