Spaces:
Configuration error
Configuration error
Commit ·
f3f5b2d
1
Parent(s): 1cea019
Deploy files from GitHub repository
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- main.go-6
- models/database_orm_model.go+8-6
- models/request_model.go+8-6
- router/router.go-1
- router/server.go-4
- services/partner_criteria_service.go+4-2
- space/pkg/validation/validation.go+16-155
- space/response/validation.go+19-2
- space/services/marriage_readiness_profile_service.go+4-3
- space/services/partner_criteria_service.go+4-3
- space/space/controller/partner_criteria/partner_criteria_controller.goAdded+66
- space/space/main.go+9-3
- space/space/models/database_orm_model.go+54-20
- space/space/models/request_model.go+112-77
- space/space/pkg/validation/custom_rules.go+236-116
- space/space/repositories/partner_criteria_repository.goAdded+38
- space/space/router/partner_criteria_route.goAdded+11
- space/space/router/router.go+1
- space/space/router/server.go+4
- space/space/services/cv_service.go+16-13
- space/space/services/partner_criteria_service.goAdded+77
- space/space/space/config/database_connection_config.go+13-2
- space/space/space/models/sequence.goAdded+25
- space/space/space/repositories/account_repository.go+18
- space/space/space/repositories/cv_repository.go+162-146
- space/space/space/services/cv_service.go+33-7
- space/space/space/services/user_profile_service.go+36-8
- space/space/space/space/models/database_orm_model.go+50-50
- space/space/space/space/models/field_counter.go+4-19
- space/space/space/space/space/config/database_connection_config.go+1
- space/space/space/space/space/controller/marriage_readiness_profile/marriage_readiness_profile_controller.goAdded+66
- space/space/space/space/space/main.go+12-5
- space/space/space/space/space/repositories/marriage_readiness_profile_repository.goAdded+38
- space/space/space/space/space/router/marriage_readiness_profile_route.goAdded+11
- space/space/space/space/space/services/marriage_readiness_profile_service.goAdded+90
- space/space/space/space/space/space/controller/cv/cv_controller.go+171-47
- space/space/space/space/space/space/models/database_orm_model.go+95-43
- space/space/space/space/space/space/models/request_model.go+199-45
- space/space/space/space/space/space/pkg/validation/validation.go+10-1
- space/space/space/space/space/space/pkg/worker/task_send_forgot_password_email.go+8-6
- space/space/space/space/space/space/pkg/worker/task_send_verify_email.go+8-5
- space/space/space/space/space/space/router/cv_route.go+1-1
- space/space/space/space/space/space/router/router.go+1
- space/space/space/space/space/space/router/server.go+11-7
- space/space/space/space/space/space/services/cv_service.go+188-181
- space/space/space/space/space/space/space/services/academy_quiz_answer_service.go+3
- space/space/space/space/space/space/space/services/academy_quiz_question_service.go+6
- space/space/space/space/space/space/space/space/controller/quiz/result_quiz_controller.goAdded+24
- space/space/space/space/space/space/space/space/controller/quiz/submit_quiz_controller.go+4-3
- space/space/space/space/space/space/space/space/models/database_orm_model.go+4-3
6 unmodified lines7891011121341 unmodified lines5556575859606162636413 unmodified lines787980818283846 unmodified lines"api.qobiltu.id/config"cv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""api.qobiltu.id/mail"41 unmodified linesworker.AsyncTaskDistributor = taskDistributor// setup repo, service, and controllerhealthCheckRepository := repositories.NewHealthCheckRepository(config.DB)healthCheckService := services.NewHealthCheckService(healthCheckRepository)healthCheckController := health_check_controller.NewHealthCheckController(healthCheckService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage, validator)cvController := cv_controller.NewCVController(cvService)13 unmodified lines// create servers, err := router.NewServer(healthCheckController,cvController,marriageReadinessProfileController,partnerCriteriaController,6 unmodified lines78910111241 unmodified lines54555657585913 unmodified lines7374757677786 unmodified lines"api.qobiltu.id/config"cv_controller "api.qobiltu.id/controller/cv"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""api.qobiltu.id/mail"41 unmodified linesworker.AsyncTaskDistributor = taskDistributor// setup repo, service, and controllercvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage, validator)cvController := cv_controller.NewCVController(cvService)13 unmodified lines// create servers, err := router.NewServer(cvController,marriageReadinessProfileController,partnerCriteriaController,
395 unmodified lines3963973983994004014022 unmodified lines405406407408409410411412413414415395 unmodified linesAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`// Kriteria UmumExpectedAgeLimit *int `gorm:"column:expected_age_limit" json:"expected_age_limit"` // batas usia pasangan yang diharapkanExpectedDomicile *string `gorm:"column:expected_domicile" json:"expected_domicile"` // domisili pasangan yang diharapkanAcceptedMaritalStatus *pq.StringArray `gorm:"column:accepted_marital_status;type:varchar(255)[]" json:"accepted_marital_status"` // status pernikahan yang diterimaPartnerFamilyReligion *string `gorm:"column:partner_family_religion" json:"partner_family_religion"` // agama yang dianut keluarga pasangan2 unmodified linesPartnerCanCook *string `gorm:"column:partner_can_cook" json:"partner_can_cook"` // apakah pasangan diharapkan bisa memasak// Kriteria FisikExpectedBodyShapes *pq.StringArray `gorm:"column:expected_body_shapes;type:varchar(255)[]" json:"expected_body_shapes"` // bentuk tubuh yang diharapkanExpectedSkinColors *pq.StringArray `gorm:"column:expected_skin_colors;type:varchar(255)[]" json:"expected_skin_colors"` // warna kulit yang diharapkanExpectedHairTypes *pq.StringArray `gorm:"column:expected_hair_types;type:varchar(255)[]" json:"expected_hair_types"` // tipe rambut yang diharapkanExpectedHairThickness *pq.StringArray `gorm:"column:expected_hair_thickness;type:varchar(255)[]" json:"expected_hair_thickness"` // jenis rambut yang diharapkanExpectedHeight *int `gorm:"column:expected_height" json:"expected_height"` // tinggi badan yang diharapkan// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkan395 unmodified lines3963973983994004014024032 unmodified lines406407408409410411412413414415416417395 unmodified linesAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`// Kriteria UmumExpecteMinAgeLimit *int `gorm:"column:expected_min_age_limit" json:"expected_min_age_limit"` // batas usia pasangan yang diharapkanExpecteMaxAgeLimit *int `gorm:"column:expected_max_age_limit" json:"expected_max_age_limit"` // batas usia pasangan yang diharapkanExpectedDomicile *string `gorm:"column:expected_domicile" json:"expected_domicile"` // domisili pasangan yang diharapkanAcceptedMaritalStatus *pq.StringArray `gorm:"column:accepted_marital_status;type:varchar(255)[]" json:"accepted_marital_status"` // status pernikahan yang diterimaPartnerFamilyReligion *string `gorm:"column:partner_family_religion" json:"partner_family_religion"` // agama yang dianut keluarga pasangan2 unmodified linesPartnerCanCook *string `gorm:"column:partner_can_cook" json:"partner_can_cook"` // apakah pasangan diharapkan bisa memasak// Kriteria FisikExpectedBodyShapes *pq.StringArray `gorm:"column:expected_body_shapes;type:varchar(255)[]" json:"expected_body_shapes"` // bentuk tubuh yang diharapkanExpectedSkinColors *pq.StringArray `gorm:"column:expected_skin_colors;type:varchar(255)[]" json:"expected_skin_colors"` // warna kulit yang diharapkanExpectedHairTypes *pq.StringArray `gorm:"column:expected_hair_types;type:varchar(255)[]" json:"expected_hair_types"` // tipe rambut yang diharapkanExpectedHairThickness *pq.StringArray `gorm:"column:expected_hair_thickness;type:varchar(255)[]" json:"expected_hair_thickness"` // jenis rambut yang diharapkanExpectedMinHeightLimit *int `gorm:"column:expected_min_height_limit" json:"expected_min_height_limit"` // tinggi badan yang diharapkanExpectedMaxHeightLimit *int `gorm:"column:expected_max_height_limit" json:"expected_max_height_limit"` // tinggi badan yang diharapkan// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkan
335 unmodified lines3363373383393403413422 unmodified lines345346347348349350351352353354355335 unmodified linesSavePartnerCriteriaRequest struct {AccountID int64 `json:"account_id"`ExpectedAgeLimit *int `gorm:"column:expected_age_limit" json:"expected_age_limit"` // batas usia pasangan yang diharapkanExpectedDomicile *string `gorm:"column:expected_domicile" json:"expected_domicile"` // domisili pasangan yang diharapkanAcceptedMaritalStatus *pq.StringArray `gorm:"column:accepted_marital_status;type:varchar(255)[]" json:"accepted_marital_status"` // status pernikahan yang diterimaPartnerFamilyReligion *string `gorm:"column:partner_family_religion" json:"partner_family_religion"` // agama yang dianut keluarga pasangan2 unmodified linesPartnerCanCook *string `gorm:"column:partner_can_cook" json:"partner_can_cook"` // apakah pasangan diharapkan bisa memasak// Kriteria FisikExpectedBodyShapes *pq.StringArray `gorm:"column:expected_body_shapes;type:varchar(255)[]" json:"expected_body_shapes"` // bentuk tubuh yang diharapkanExpectedSkinColors *pq.StringArray `gorm:"column:expected_skin_colors;type:varchar(255)[]" json:"expected_skin_colors"` // warna kulit yang diharapkanExpectedHairTypes *pq.StringArray `gorm:"column:expected_hair_types;type:varchar(255)[]" json:"expected_hair_types"` // tipe rambut yang diharapkanExpectedHairThickness *pq.StringArray `gorm:"column:expected_hair_thickness;type:varchar(255)[]" json:"expected_hair_thickness"` // jenis rambut yang diharapkanExpectedHeight *int `gorm:"column:expected_height" json:"expected_height"` // tinggi badan yang diharapkan// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkan335 unmodified lines3363373383393403413423432 unmodified lines346347348349350351352353354355356357335 unmodified linesSavePartnerCriteriaRequest struct {AccountID int64 `json:"account_id"`ExpecteMinAgeLimit *int `gorm:"column:expected_min_age_limit" json:"expected_min_age_limit"` // batas usia pasangan yang diharapkanExpecteMaxAgeLimit *int `gorm:"column:expected_max_age_limit" json:"expected_max_age_limit"` // batas usia pasangan yang diharapkanExpectedDomicile *string `gorm:"column:expected_domicile" json:"expected_domicile"` // domisili pasangan yang diharapkanAcceptedMaritalStatus *pq.StringArray `gorm:"column:accepted_marital_status;type:varchar(255)[]" json:"accepted_marital_status"` // status pernikahan yang diterimaPartnerFamilyReligion *string `gorm:"column:partner_family_religion" json:"partner_family_religion"` // agama yang dianut keluarga pasangan2 unmodified linesPartnerCanCook *string `gorm:"column:partner_can_cook" json:"partner_can_cook"` // apakah pasangan diharapkan bisa memasak// Kriteria FisikExpectedBodyShapes *pq.StringArray `gorm:"column:expected_body_shapes;type:varchar(255)[]" json:"expected_body_shapes"` // bentuk tubuh yang diharapkanExpectedSkinColors *pq.StringArray `gorm:"column:expected_skin_colors;type:varchar(255)[]" json:"expected_skin_colors"` // warna kulit yang diharapkanExpectedHairTypes *pq.StringArray `gorm:"column:expected_hair_types;type:varchar(255)[]" json:"expected_hair_types"` // tipe rambut yang diharapkanExpectedHairThickness *pq.StringArray `gorm:"column:expected_hair_thickness;type:varchar(255)[]" json:"expected_hair_thickness"` // jenis rambut yang diharapkanExpectedMinHeightLimit *int `gorm:"column:expected_min_height_limit" json:"expected_min_height_limit"` // tinggi badan yang diharapkanExpectedMaxHeightLimit *int `gorm:"column:expected_max_height_limit" json:"expected_max_height_limit"` // tinggi badan yang diharapkan// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkan
15 unmodified lines1617181920212215 unmodified linesQuizRoute(s.router)// another way to register routess.HealthCheckRoute()s.CVRoute()s.MarriageReadinessProfileRoute()s.PartnerCriteriaRoute()15 unmodified lines16171819202115 unmodified linesQuizRoute(s.router)// another way to register routess.CVRoute()s.MarriageReadinessProfileRoute()s.PartnerCriteriaRoute()
1 unmodified line23456781 unmodified line10111213141516171819202122233 unmodified lines272829303132331 unmodified lineimport (cv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""github.com/gin-gonic/gin"1 unmodified linetype Server struct {router *gin.EnginehealthCheckController health_check_controller.HealthCheckControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileControllerpartnerCriteriaController partner_criteria_controller.PartnerCriteriaController}func NewServer(healthCheckController health_check_controller.HealthCheckController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,3 unmodified linesrouter.Use(gin.Recovery())server := &Server{healthCheckController: healthCheckController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,1 unmodified line2345671 unmodified line910111213141516171819203 unmodified lines2425262728291 unmodified lineimport (cv_controller "api.qobiltu.id/controller/cv"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""github.com/gin-gonic/gin"1 unmodified linetype Server struct {router *gin.EnginecvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileControllerpartnerCriteriaController partner_criteria_controller.PartnerCriteriaController}func NewServer(cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,3 unmodified linesrouter.Use(gin.Recovery())server := &Server{cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,
41 unmodified lines424344454647485 unmodified lines5455565758596041 unmodified linespartnerCriteria.AccountID = req.AccountIDutils.AssignIfNotNil(&partnerCriteria.ExpectedAgeLimit, req.ExpectedAgeLimit)utils.AssignIfNotNil(&partnerCriteria.ExpectedDomicile, req.ExpectedDomicile)utils.AssignIfNotNil(&partnerCriteria.AcceptedMaritalStatus, req.AcceptedMaritalStatus)utils.AssignIfNotNil(&partnerCriteria.PartnerFamilyReligion, req.PartnerFamilyReligion)5 unmodified linesutils.AssignIfNotNil(&partnerCriteria.ExpectedSkinColors, req.ExpectedSkinColors)utils.AssignIfNotNil(&partnerCriteria.ExpectedHairTypes, req.ExpectedHairTypes)utils.AssignIfNotNil(&partnerCriteria.ExpectedHairThickness, req.ExpectedHairThickness)utils.AssignIfNotNil(&partnerCriteria.ExpectedHeight, req.ExpectedHeight)utils.AssignIfNotNil(&partnerCriteria.ExpectedPartnerIncome, req.ExpectedPartnerIncome)utils.AssignIfNotNil(&partnerCriteria.ExpectedIncomeSources, req.ExpectedIncomeSources)41 unmodified lines42434445464748495 unmodified lines555657585960616241 unmodified linespartnerCriteria.AccountID = req.AccountIDutils.AssignIfNotNil(&partnerCriteria.ExpecteMinAgeLimit, req.ExpecteMinAgeLimit)utils.AssignIfNotNil(&partnerCriteria.ExpecteMaxAgeLimit, req.ExpecteMaxAgeLimit)utils.AssignIfNotNil(&partnerCriteria.ExpectedDomicile, req.ExpectedDomicile)utils.AssignIfNotNil(&partnerCriteria.AcceptedMaritalStatus, req.AcceptedMaritalStatus)utils.AssignIfNotNil(&partnerCriteria.PartnerFamilyReligion, req.PartnerFamilyReligion)5 unmodified linesutils.AssignIfNotNil(&partnerCriteria.ExpectedSkinColors, req.ExpectedSkinColors)utils.AssignIfNotNil(&partnerCriteria.ExpectedHairTypes, req.ExpectedHairTypes)utils.AssignIfNotNil(&partnerCriteria.ExpectedHairThickness, req.ExpectedHairThickness)utils.AssignIfNotNil(&partnerCriteria.ExpectedMinHeightLimit, req.ExpectedMinHeightLimit)utils.AssignIfNotNil(&partnerCriteria.ExpectedMaxHeightLimit, req.ExpectedMaxHeightLimit)utils.AssignIfNotNil(&partnerCriteria.ExpectedPartnerIncome, req.ExpectedPartnerIncome)utils.AssignIfNotNil(&partnerCriteria.ExpectedIncomeSources, req.ExpectedIncomeSources)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174package validationimport ("errors""fmt""reflect""strings""github.com/go-playground/locales/en""github.com/go-playground/locales/id"ut "github.com/go-playground/universal-translator"v10 "github.com/go-playground/validator/v10"entranslations "github.com/go-playground/validator/v10/translations/en"idtranslations "github.com/go-playground/validator/v10/translations/id")// Constants for supported localesconst (LocaleID = "id"LocaleEN = "en")// ErrorMessage represents a validation error messagetype ErrorMessage struct {Field string `json:"field"`Message string `json:"-"`}type validator struct {validate *v10.Validatetranslator ut.Translator}// validatorInstance adalah instance global dari validator.var validatorInstance *validator// New creates a new validation instance with the specified locale// dan menginisialisasi instance global validatorInstance.func New(locale string) error {v := &validator{}parsedLocale := parseLocale(locale)uni := ut.New(en.New(), id.New(), en.New())translator, found := uni.GetTranslator(parsedLocale)if !found {return fmt.Errorf("translator not found for locale: %s", parsedLocale)}validate := v10.New()if err := setupValidations(validate); err != nil {return fmt.Errorf("failed to setup validations: %w", err)}if err := setupTranslations(validate, translator, parsedLocale); err != nil {return fmt.Errorf("failed to setup translations for locale %s: %w", parsedLocale, err)}v.validate = validatev.translator = translatorvalidatorInstance = v // Inisialisasi instance globalreturn nil}func parseLocale(locale string) string {switch strings.ToLower(locale) {case "id":return LocaleIDcase "en":return LocaleENdefault:return LocaleID // Default to Indonesian}}// setupValidations configures custom validation rules.func setupValidations(validate *v10.Validate) error {rules := NewValidatorRules(&InMemoryOptionSource{})if err := rules.RegisterAllCustomRules(validate); err != nil {return err}return nil}// setupTranslations configures translations for validation messages.func setupTranslations(validate *v10.Validate, translator ut.Translator, locale string) error {// Register default translations based on localeif err := registerDefaultTranslations(validate, translator, locale); err != nil {return fmt.Errorf("failed to register default translations for locale %s: %w", locale, err)}// Register custom password validation translationerr := validate.RegisterTranslation("password", translator,func(ut ut.Translator) error {return ut.Add("password", "harus mengandung minimal 8 karakter, huruf besar, huruf kecil, dan angka.", true)},func(ut ut.Translator, fe v10.FieldError) string {translated, err := ut.T(fe.Tag(), fe.Field())if err != nil {return fe.Field() + " is invalid"}return translated},)if err != nil {return fmt.Errorf("failed to register password translation: %w", err)}return nil}// registerDefaultTranslations sets up default translations for the specified locale.func registerDefaultTranslations(validate *v10.Validate, translator ut.Translator, locale string) error {switch locale {case LocaleID:return idtranslations.RegisterDefaultTranslations(validate, translator)case LocaleEN:return entranslations.RegisterDefaultTranslations(validate, translator)default:// Fallback to English if the locale is not supportedreturn entranslations.RegisterDefaultTranslations(validate, translator)}}// Validate validates a struct using the global validator instance// and returns a slice of ErrorMessage.func Validate(s any) []ErrorMessage {if validatorInstance == nil {return []ErrorMessage{{Field: "", Message: "Validator belum diinisialisasi. Panggil validation.New() terlebih dahulu."}}}err := validatorInstance.validate.Struct(s)if err != nil {return TranslateError(err)}return nil}// TranslateError takes a validation error and translates it using the global translator.func TranslateError(err error) []ErrorMessage {if validatorInstance == nil {return nil}var validationErrors v10.ValidationErrorsif !errors.As(err, &validationErrors) {return nil}var errorMessages []ErrorMessagefor _, e := range validationErrors {fieldLabel := e.Field()if e.Kind() == reflect.Ptr {continue}msg, err := validatorInstance.translator.T(e.Tag(), fieldLabel)if err != nil {msg = fieldLabel + " is Invalid"}errorMessages = append(errorMessages, ErrorMessage{Field: e.Tag(),Message: msg,})}return errorMessages}1234567891011121314151617181920212223242526272829303132333435package validationimport ("context""time""gorm.io/gorm")type ErrorMessage struct {Field string `json:"field"`Message string `json:"-"`}func New(db *gorm.DB) (*Validator, error) {// Create source with 5 minute cache expiryexpiry := 5 * time.MinutedbSource, err := NewDBOptionSource(db, expiry)if err != nil {return nil, err}// Start background refresh every 10 minutesctx := context.Background()dbSource.StartAutoRefresh(ctx, 10*time.Minute)// create validatorvalidator := NewValidator(dbSource)if err := validator.RegisterAllCustomRules(); err != nil {return nil, err}return validator, nil}
2 unmodified lines345678910111213142 unmodified linesimport ("api.qobiltu.id/models""api.qobiltu.id/pkg/validation")func HandleValidationError(validationErrors []validation.ErrorMessage) error {return models.Exception{ValidationError: true,Message: "Validation failed",ValidationErrorFields: validationErrors,}}2 unmodified lines3456789101112131415161718192021222324252627282930312 unmodified linesimport ("api.qobiltu.id/models""api.qobiltu.id/pkg/validation""github.com/go-playground/validator/v10")func HandleValidationError(err error) error {validationErrors, ok := err.(validator.ValidationErrors)if !ok {return models.Exception{ValidationError: true,Message: "Validation failed",}}validationErrorMessages := make([]validation.ErrorMessage, len(validationErrors))for i, err := range validationErrors {validationErrorMessages[i] = validation.ErrorMessage{Field: err.Field(),Message: err.Error(),}}return models.Exception{ValidationError: true,Message: "Validation failed",ValidationErrorFields: validationErrorMessages,}}
18 unmodified lines192021222324252627282930313218 unmodified linestype marriageReadinessProfileService struct {marriageReadinessProfileRepository repositories.MarriageReadinessProfileRepository}func NewMarriageReadinessProfileService(marriageReadinessProfileRepository repositories.MarriageReadinessProfileRepository) MarriageReadinessProfileService {return &marriageReadinessProfileService{marriageReadinessProfileRepository: marriageReadinessProfileRepository}}func (s *marriageReadinessProfileService) SaveMarriageReadinessProfile(ctx context.Context, req *models.SaveMarriageReadinessProfileRequest) (*models.MarriageReadinessProfile, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}18 unmodified lines19202122232425262728293031323318 unmodified linestype marriageReadinessProfileService struct {marriageReadinessProfileRepository repositories.MarriageReadinessProfileRepositoryvalidator *validation.Validator}func NewMarriageReadinessProfileService(marriageReadinessProfileRepository repositories.MarriageReadinessProfileRepository, validator *validation.Validator) MarriageReadinessProfileService {return &marriageReadinessProfileService{marriageReadinessProfileRepository: marriageReadinessProfileRepository, validator: validator}}func (s *marriageReadinessProfileService) SaveMarriageReadinessProfile(ctx context.Context, req *models.SaveMarriageReadinessProfileRequest) (*models.MarriageReadinessProfile, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}
18 unmodified lines192021222324252627282930313218 unmodified linestype partnerCriteriaService struct {partnerCriteriaRepository repositories.PartnerCriteriaRepository}func NewPartnerCriteriaService(partnerCriteriaRepository repositories.PartnerCriteriaRepository) PartnerCriteriaService {return &partnerCriteriaService{partnerCriteriaRepository: partnerCriteriaRepository}}func (s *partnerCriteriaService) SavePartnerCriteria(ctx context.Context, req *models.SavePartnerCriteriaRequest) (*models.PartnerCriteria, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}18 unmodified lines19202122232425262728293031323318 unmodified linestype partnerCriteriaService struct {partnerCriteriaRepository repositories.PartnerCriteriaRepositoryvalidator *validation.Validator}func NewPartnerCriteriaService(partnerCriteriaRepository repositories.PartnerCriteriaRepository, validator *validation.Validator) PartnerCriteriaService {return &partnerCriteriaService{partnerCriteriaRepository: partnerCriteriaRepository, validator: validator}}func (s *partnerCriteriaService) SavePartnerCriteria(ctx context.Context, req *models.SavePartnerCriteriaRequest) (*models.PartnerCriteria, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566package partner_criteria_controller
import ( "net/http"
"api.qobiltu.id/middleware" "api.qobiltu.id/models" "api.qobiltu.id/response" "api.qobiltu.id/services" "github.com/gin-gonic/gin")
type PartnerCriteriaController interface { SavePartnerCriteria(ctx *gin.Context) GetPartnerCriteria(ctx *gin.Context)}
type partnerCriteriaController struct { partnerCriteriaService services.PartnerCriteriaService}
func NewPartnerCriteriaController(partnerCriteriaService services.PartnerCriteriaService) PartnerCriteriaController { return &partnerCriteriaController{ partnerCriteriaService: partnerCriteriaService, }}
func (c *partnerCriteriaController) SavePartnerCriteria(ctx *gin.Context) { var req models.SavePartnerCriteriaRequest if err := ctx.ShouldBindJSON(&req); err != nil { response.HandleError(ctx, models.Exception{ Message: "Invalid body request", BadRequest: true, Err: err, }) return }
accountData := middleware.GetAccountData(ctx) req.AccountID = int64(accountData.UserID)
res, err := c.partnerCriteriaService.SavePartnerCriteria(ctx, &req) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Partner criteria saved", res, nil)}
func (c *partnerCriteriaController) GetPartnerCriteria(ctx *gin.Context) { accountData := middleware.GetAccountData(ctx) accountID := int64(accountData.UserID)
req := models.GetPartnerCriteriaRequest{ AccountID: accountID, }
res, err := c.partnerCriteriaService.GetPartnerCriteria(ctx, &req) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Get partner criteria success", res, nil)}8 unmodified lines910111213148 unmodified lines2324252627282929 unmodified lines596061626364656667686970714 unmodified lines7677787980818 unmodified linescv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile""api.qobiltu.id/mail""api.qobiltu.id/pkg/storage""api.qobiltu.id/pkg/validation"8 unmodified linesfunc main() {// setup validationerr := validation.New(validation.LocaleID)utils.FatalIfErr("failed to setup validator", err)// setup storage29 unmodified lineshealthCheckController := health_check_controller.NewHealthCheckController(healthCheckService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage)cvController := cv_controller.NewCVController(cvService)marriageReadinessProfileRepository := repositories.NewMarriageReadinessProfileRepository(config.DB)marriageReadinessProfileService := services.NewMarriageReadinessProfileService(marriageReadinessProfileRepository)marriageReadinessProfileController := marriage_readiness_profile_controller.NewMarriageReadinessProfileController(marriageReadinessProfileService)// start task processorerr = taskProcessor.Start()utils.FatalIfErr("failed to start task processor", err)4 unmodified lineshealthCheckController,cvController,marriageReadinessProfileController,)utils.FatalIfErr("failed to create server", err)8 unmodified lines91011121314158 unmodified lines2425262728293029 unmodified lines60616263646566676869707172737475764 unmodified lines818283848586878 unmodified linescv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""api.qobiltu.id/mail""api.qobiltu.id/pkg/storage""api.qobiltu.id/pkg/validation"8 unmodified linesfunc main() {// setup validationvalidator, err := validation.New(config.DB)utils.FatalIfErr("failed to setup validator", err)// setup storage29 unmodified lineshealthCheckController := health_check_controller.NewHealthCheckController(healthCheckService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage, validator)cvController := cv_controller.NewCVController(cvService)marriageReadinessProfileRepository := repositories.NewMarriageReadinessProfileRepository(config.DB)marriageReadinessProfileService := services.NewMarriageReadinessProfileService(marriageReadinessProfileRepository, validator)marriageReadinessProfileController := marriage_readiness_profile_controller.NewMarriageReadinessProfileController(marriageReadinessProfileService)partnerCriteriaRepository := repositories.NewPartnerCriteriaRepository(config.DB)partnerCriteriaService := services.NewPartnerCriteriaService(partnerCriteriaRepository, validator)partnerCriteriaController := partner_criteria_controller.NewPartnerCriteriaController(partnerCriteriaService)// start task processorerr = taskProcessor.Start()utils.FatalIfErr("failed to start task processor", err)4 unmodified lineshealthCheckController,cvController,marriageReadinessProfileController,partnerCriteriaController,)utils.FatalIfErr("failed to create server", err)
247 unmodified lines248249250251252253254255256257258259260261262263264265266267268269270271272273114 unmodified lines388389390391392393247 unmodified lines}WorshipAndReligiousUnderstandingCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`ObligatoryPrayer *string `gorm:"column:obligatory_prayer" json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `gorm:"column:congregational_prayer" json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `gorm:"column:tahajjud_prayer" json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `gorm:"column:dhuha_prayer" json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `gorm:"column:quran_memorization" json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `gorm:"column:quran_reading_ability" json:"quran_reading_ability"` // kemampuan_baca_alquranDaudFasting *string `gorm:"column:daud_fasting" json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `gorm:"column:ayyamul_bidh_fasting" json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah *pq.StringArray `gorm:"column:hajj_or_umrah;type:varchar(255)[]" json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `gorm:"column:listening_to_music" json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `gorm:"column:opinion_on_ikhtilat" json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `gorm:"column:opinion_on_touching_non_mahram" json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `gorm:"column:opinion_on_veil" json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `gorm:"column:weekly_religious_studies" json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `gorm:"column:followed_ustadz" json:"followed_ustadz"` // ustadz_yang_diikutiCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`FieldCounter}114 unmodified lines})// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }247 unmodified lines248249250251252253254255256257258259260261262263264265266267268269270271272273274114 unmodified lines389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427247 unmodified lines}WorshipAndReligiousUnderstandingCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`ObligatoryPrayer *string `gorm:"column:obligatory_prayer" json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `gorm:"column:congregational_prayer" json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `gorm:"column:tahajjud_prayer" json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `gorm:"column:dhuha_prayer" json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `gorm:"column:quran_memorization" json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `gorm:"column:quran_reading_ability" json:"quran_reading_ability"` // kemampuan_baca_alquranWeeklyReligiousStudyFrequency *string `gorm:"column:weekly_religious_study_frequency" json:"weekly_religious_study_frequency"` // kajian_yang_diikuti_dalam_sepekanDaudFasting *string `gorm:"column:daud_fasting" json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `gorm:"column:ayyamul_bidh_fasting" json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah *pq.StringArray `gorm:"column:hajj_or_umrah;type:varchar(255)[]" json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `gorm:"column:listening_to_music" json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `gorm:"column:opinion_on_ikhtilat" json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `gorm:"column:opinion_on_touching_non_mahram" json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `gorm:"column:opinion_on_veil" json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `gorm:"column:weekly_religious_studies" json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `gorm:"column:followed_ustadz" json:"followed_ustadz"` // ustadz_yang_diikutiCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`FieldCounter}114 unmodified lines})type (PartnerCriteria struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`// Kriteria UmumExpectedAgeLimit *int `gorm:"column:expected_age_limit" json:"expected_age_limit"` // batas usia pasangan yang diharapkanExpectedDomicile *string `gorm:"column:expected_domicile" json:"expected_domicile"` // domisili pasangan yang diharapkanAcceptedMaritalStatus *pq.StringArray `gorm:"column:accepted_marital_status;type:varchar(255)[]" json:"accepted_marital_status"` // status pernikahan yang diterimaPartnerFamilyReligion *string `gorm:"column:partner_family_religion" json:"partner_family_religion"` // agama yang dianut keluarga pasanganPartnerWeeklyReligiousStudyFrequency *string `gorm:"column:partner_weekly_religious_study_frequency" json:"partner_weekly_religious_study_frequency"` // rata-rata jumlah kajian yang diikuti pasangan per pekanPartnerMonthlySpendingEstimate *string `gorm:"column:partner_monthly_spending_estimate" json:"partner_monthly_spending_estimate"` // estimasi pengeluaran pasangan per bulanPartnerCanCook *string `gorm:"column:partner_can_cook" json:"partner_can_cook"` // apakah pasangan diharapkan bisa memasak// Kriteria FisikExpectedBodyShapes *pq.StringArray `gorm:"column:expected_body_shapes;type:varchar(255)[]" json:"expected_body_shapes"` // bentuk tubuh yang diharapkanExpectedSkinColors *pq.StringArray `gorm:"column:expected_skin_colors;type:varchar(255)[]" json:"expected_skin_colors"` // warna kulit yang diharapkanExpectedHairTypes *pq.StringArray `gorm:"column:expected_hair_types;type:varchar(255)[]" json:"expected_hair_types"` // tipe rambut yang diharapkanExpectedHairThickness *pq.StringArray `gorm:"column:expected_hair_thickness;type:varchar(255)[]" json:"expected_hair_thickness"` // jenis rambut yang diharapkanExpectedHeight *int `gorm:"column:expected_height" json:"expected_height"` // tinggi badan yang diharapkan// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkanExpectedIncomeSources *pq.StringArray `gorm:"column:expected_income_sources;type:varchar(255)[]" json:"expected_income_sources"` // sumber penghasilan pasanganExpectedLastEducation *pq.StringArray `gorm:"column:expected_last_education;type:varchar(255)[]" json:"expected_last_education"` // pendidikan terakhir yang diharapkanExpectedJobType *string `gorm:"column:expected_job_type" json:"expected_job_type"` // jenis pekerjaan pasangan yang diharapkanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`})// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }
73 unmodified lines747576777879803 unmodified lines84858687888990919293941 unmodified line9697989910010110210310410510613 unmodified lines12012112212312412512612712810 unmodified lines1391401411421431441451461471481 unmodified line1501511521531541551561571581591601611621631641651661671681691701712 unmodified lines1741751761771781791803 unmodified lines18418518618718818919017 unmodified lines2082092102112122132143 unmodified lines21821922022122222322458 unmodified lines28328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933073 unmodified linesFavoriteFoodAndDrinks *string `json:"favorite_food_and_drinks"` // makanan dan minuman favoritCanCook *bool `json:"can_cook"` // bisa memasakTypesOfDishesCooked *string `json:"types_of_dishes_cooked"` // jenis masakan yang bisa dimasakMonthlyExpenses *string `json:"monthly_expenses" validate:"monthly_expenses"` // pengeluaran per bulan}GetPersonalityAndPreferenceRequest struct {3 unmodified linesCreateFamilyMemberRequest struct {AccountID int64 `json:"-"`Role *string `json:"role" validate:"family_role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life_status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // AgamaJob *string `json:"job"` // PekerjaanLastEducation *string `json:"last_education" validate:"last_education"` // Pendidikan terakhirAge *int `json:"age"` // Usia}1 unmodified lineID int64 `json:"-"`AccountID int64 `json:"-"`Role *string `json:"role" validate:"family_role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life_status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // AgamaJob *string `json:"job"` // PekerjaanLastEducation *string `json:"last_education" validate:"last_education"` // Pendidikan terakhirAge *int `json:"age"` // Usia}13 unmodified linesAccountID int64 `json:"-"`HeightInCm *int `json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `json:"body_shape" validate:"body_shape"` // Bentuk tubuhSkinColor *string `json:"skin_color" validate:"skin_color"` // Warna kulitHairType *string `json:"hair_type" validate:"hair_type"` // Tipe rambutMedicalHistory *pq.StringArray `json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `json:"physical_traits"` // Ciri khas fisik10 unmodified linesDateOfBirth *time.Time `json:"date_of_birth"`PlaceOfBirth *string `json:"place_of_birth"`Domicile *string `json:"domicile"`MaritalStatus *string `json:"marital_status" validate:"marital_status"`LastEducation *string `json:"last_education" validate:"last_education"`LastJob *string `json:"last_job"`PhoneNumber *string `json:"phone_number" validate:"phone_number"`}GetAccountDetailsRequest struct {1 unmodified line}SaveWorshipAndReligiousUnderstandingRequest struct {AccountID int64 `json:"-"`ObligatoryPrayer *string `json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `json:"quran_reading_ability" validate:"quran_reading_ability"` // kemampuan_baca_alquranDaudFasting *string `json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah *pq.StringArray `json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `json:"followed_ustadz"` // ustadz_yang_diikuti}GetWorshipAndReligiousUnderstandingRequest struct {2 unmodified linesCreateEducationRequest struct {AccountID int64 `json:"-"`LastEducation *string `json:"last_education" validate:"last_education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikanYearStart *int `json:"year_start"` // tahun masuk3 unmodified linesUpdateEducationRequest struct {ID int64 `json:"-"`AccountID int64 `json:"-"`LastEducation *string `json:"last_education" validate:"last_education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikanYearStart *int `json:"year_start"` // tahun masuk17 unmodified linesInstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `json:"income_sources"` // sumber penghasilan}3 unmodified linesInstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `json:"income_sources"` // sumber penghasilan}58 unmodified lines})type SaveMarriageReadinessProfileRequest struct {AccountID int64 `json:"account_id"`// Visi Misi Rumah TanggaMarriageVision *string `gorm:"column:marriage_vision" json:"marriage_vision"` // Apa visi dan tujuan utama kamu dalam membangun rumah tangga?LivingPlan *string `gorm:"column:living_plan" json:"living_plan"` // Setelah menikah, kamu berencana tinggal di mana?SpouseRoles *string `gorm:"column:spouse_roles" json:"spouse_roles"` // Menurutmu, apa peran utama suami dan istri dalam rumah tangga?SpouseRights *string `gorm:"column:spouse_rights" json:"spouse_rights"` // Apa saja hak suami dan istri menurutmu?ConflictResolution *string `gorm:"column:conflict_resolution" json:"conflict_resolution"` // Jika terjadi konflik, bagaimana kamu menyikapinya?ParentingStyle *string `gorm:"column:parenting_style" json:"parenting_style"` // Setelah punya anak, pola pengasuhan seperti apa yang kamu inginkan?// Konsep Acara PernikahanReadyToMarryDuration *string `gorm:"column:ready_to_marry_duration" json:"ready_to_marry_duration"` // Setelah taaruf dimulai, berapa lama kamu butuh untuk siap menikah?WeddingConcept *string `gorm:"column:wedding_concept" json:"wedding_concept"` // Seperti apa konsep pernikahan yang kamu harapkan?WeddingFunding *string `gorm:"column:wedding_funding" json:"wedding_funding"` // Apakah kamu sudah mempersiapkan dana pernikahan? Dari mana sumbernya?// Karir KedepannyaCareerAfterMarriage *string `gorm:"column:career_after_marriage" json:"career_after_marriage"` // Apakah kamu ingin tetap bekerja setelah menikah?TimeManagement *string `gorm:"column:time_management" json:"time_management"` // Bagaimana kamu membagi waktu antara keluarga, ibadah, dan pekerjaan?CareerGoals *string `gorm:"column:career_goals" json:"career_goals"` // Apa impian karier atau cita-cita kamu dalam 5 sampai 10 tahun ke depan?SelfDevelopment *string `gorm:"column:self_development" json:"self_development"` // Apa usaha kamu untuk terus mengembangkan diri dan skill?// Pendidikan KeluargaDelayChildren *string `gorm:"column:delay_children" json:"delay_children"` // Apakah kamu berencana menunda memiliki anak?ChildEducationPlan *string `gorm:"column:child_education_plan" json:"child_education_plan"` // Apakah kamu sudah punya rencana pendidikan anak?ReligiousEmotionalBond *string `gorm:"column:religious_emotional_bond" json:"religious_emotional_bond"` // Bagaimana cara menjaga nilai agama & kedekatan emosional dengan anak?ParentingChallenges *string `gorm:"column:parenting_challenges" json:"parenting_challenges"` // Saat menghadapi tantangan pengasuhan, bagaimana kamu menyikapinya?// Finansial KeluargaMonthlyFinance *string `gorm:"column:monthly_finance" json:"monthly_finance"` // Bagaimana kamu mengelola keuangan bulanan?FamilyResponsibility *string `gorm:"column:family_responsibility" json:"family_responsibility"` // Apakah kamu masih punya tanggungan keluarga setelah menikah?DebtStatus *string `gorm:"column:debt_status" json:"debt_status"` // Apakah kamu punya cicilan/utang setelah menikah?FinanceSharing *string `gorm:"column:finance_sharing" json:"finance_sharing"` // Setelah menikah, bagaimana pembagian tanggung jawab keuangan?IncomeGapView *string `gorm:"column:income_gap_view" json:"income_gap_view"` // Pandangan kamu jika istri berpenghasilan lebih besar dari suami?// Keputusan dan KomunikasiDecisionMaking *string `gorm:"column:decision_making" json:"decision_making"` // Dalam mengambil keputusan, kamu lebih mempertimbangkan pasangan atau sendiri?GrowthTogether *string `gorm:"column:growth_together" json:"growth_together"` // Apakah kamu siap berjuang bersama pasangan? Apa saja yang ingin diperjuangkan?ParentIntervention *string `gorm:"column:parent_intervention" json:"parent_intervention"` // Sejauh mana orang tua/mertua boleh ikut campur dalam rumah tangga?HabitResponse *string `gorm:"column:habit_response" json:"habit_response"` // Bagaimana kamu menyikapi kebiasaan pasangan yang kurang kamu sukai?}type GetMarriageReadinessProfileRequest struct {AccountID int64 `json:"-"`}73 unmodified lines747576777879803 unmodified lines84858687888990919293941 unmodified line9697989910010110210310410510613 unmodified lines12012112212312412512612712810 unmodified lines1391401411421431441451461471481 unmodified line1501511521531541551561571581591601611621631641651661671681691701711722 unmodified lines1751761771781791801813 unmodified lines18518618718818919019117 unmodified lines2092102112122132142153 unmodified lines21922022122222322422558 unmodified lines28428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436573 unmodified linesFavoriteFoodAndDrinks *string `json:"favorite_food_and_drinks"` // makanan dan minuman favoritCanCook *bool `json:"can_cook"` // bisa memasakTypesOfDishesCooked *string `json:"types_of_dishes_cooked"` // jenis masakan yang bisa dimasakMonthlyExpenses *string `json:"monthly_expenses" validate:"monthly-expenses"` // pengeluaran per bulan}GetPersonalityAndPreferenceRequest struct {3 unmodified linesCreateFamilyMemberRequest struct {AccountID int64 `json:"-"`Role *string `json:"role" validate:"family-role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life-status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // AgamaJob *string `json:"job"` // PekerjaanLastEducation *string `json:"last_education" validate:"last-education"` // Pendidikan terakhirAge *int `json:"age"` // Usia}1 unmodified lineID int64 `json:"-"`AccountID int64 `json:"-"`Role *string `json:"role" validate:"family-role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life-status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // AgamaJob *string `json:"job"` // PekerjaanLastEducation *string `json:"last_education" validate:"last-education"` // Pendidikan terakhirAge *int `json:"age"` // Usia}13 unmodified linesAccountID int64 `json:"-"`HeightInCm *int `json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `json:"body_shape" validate:"body-shape"` // Bentuk tubuhSkinColor *string `json:"skin_color" validate:"skin-color"` // Warna kulitHairType *string `json:"hair_type" validate:"hair-type"` // Tipe rambutMedicalHistory *pq.StringArray `json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `json:"physical_traits"` // Ciri khas fisik10 unmodified linesDateOfBirth *time.Time `json:"date_of_birth"`PlaceOfBirth *string `json:"place_of_birth"`Domicile *string `json:"domicile"`MaritalStatus *string `json:"marital_status" validate:"marital-status"`LastEducation *string `json:"last_education" validate:"last-education"`LastJob *string `json:"last_job"`PhoneNumber *string `json:"phone_number" validate:"phone-number"`}GetAccountDetailsRequest struct {1 unmodified line}SaveWorshipAndReligiousUnderstandingRequest struct {AccountID int64 `json:"-"`ObligatoryPrayer *string `json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `json:"quran_reading_ability" validate:"quran-reading-ability"` // kemampuan_baca_alquranWeeklyReligiousStudyFrequency *string `json:"weekly_religious_study_frequency" validate:"weekly-religious-study-frequency"` // kajian_yang_diikuti_dalam_sepekanDaudFasting *string `json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah *pq.StringArray `json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `json:"followed_ustadz"` // ustadz_yang_diikuti}GetWorshipAndReligiousUnderstandingRequest struct {2 unmodified linesCreateEducationRequest struct {AccountID int64 `json:"-"`LastEducation *string `json:"last_education" validate:"last-education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikanYearStart *int `json:"year_start"` // tahun masuk3 unmodified linesUpdateEducationRequest struct {ID int64 `json:"-"`AccountID int64 `json:"-"`LastEducation *string `json:"last_education" validate:"last-education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikanYearStart *int `json:"year_start"` // tahun masuk17 unmodified linesInstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly-income"` // penghasilan per bulanIncomeSources *pq.StringArray `json:"income_sources"` // sumber penghasilan}3 unmodified linesInstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly-income"` // penghasilan per bulanIncomeSources *pq.StringArray `json:"income_sources"` // sumber penghasilan}58 unmodified lines})type (SaveMarriageReadinessProfileRequest struct {AccountID int64 `json:"account_id"`// Visi Misi Rumah TanggaMarriageVision *string `gorm:"column:marriage_vision" json:"marriage_vision"` // Apa visi dan tujuan utama kamu dalam membangun rumah tangga?LivingPlan *string `gorm:"column:living_plan" json:"living_plan"` // Setelah menikah, kamu berencana tinggal di mana?SpouseRoles *string `gorm:"column:spouse_roles" json:"spouse_roles"` // Menurutmu, apa peran utama suami dan istri dalam rumah tangga?SpouseRights *string `gorm:"column:spouse_rights" json:"spouse_rights"` // Apa saja hak suami dan istri menurutmu?ConflictResolution *string `gorm:"column:conflict_resolution" json:"conflict_resolution"` // Jika terjadi konflik, bagaimana kamu menyikapinya?ParentingStyle *string `gorm:"column:parenting_style" json:"parenting_style"` // Setelah punya anak, pola pengasuhan seperti apa yang kamu inginkan?// Konsep Acara PernikahanReadyToMarryDuration *string `gorm:"column:ready_to_marry_duration" json:"ready_to_marry_duration"` // Setelah taaruf dimulai, berapa lama kamu butuh untuk siap menikah?WeddingConcept *string `gorm:"column:wedding_concept" json:"wedding_concept"` // Seperti apa konsep pernikahan yang kamu harapkan?WeddingFunding *string `gorm:"column:wedding_funding" json:"wedding_funding"` // Apakah kamu sudah mempersiapkan dana pernikahan? Dari mana sumbernya?// Karir KedepannyaCareerAfterMarriage *string `gorm:"column:career_after_marriage" json:"career_after_marriage"` // Apakah kamu ingin tetap bekerja setelah menikah?TimeManagement *string `gorm:"column:time_management" json:"time_management"` // Bagaimana kamu membagi waktu antara keluarga, ibadah, dan pekerjaan?CareerGoals *string `gorm:"column:career_goals" json:"career_goals"` // Apa impian karier atau cita-cita kamu dalam 5 sampai 10 tahun ke depan?SelfDevelopment *string `gorm:"column:self_development" json:"self_development"` // Apa usaha kamu untuk terus mengembangkan diri dan skill?// Pendidikan KeluargaDelayChildren *string `gorm:"column:delay_children" json:"delay_children"` // Apakah kamu berencana menunda memiliki anak?ChildEducationPlan *string `gorm:"column:child_education_plan" json:"child_education_plan"` // Apakah kamu sudah punya rencana pendidikan anak?ReligiousEmotionalBond *string `gorm:"column:religious_emotional_bond" json:"religious_emotional_bond"` // Bagaimana cara menjaga nilai agama & kedekatan emosional dengan anak?ParentingChallenges *string `gorm:"column:parenting_challenges" json:"parenting_challenges"` // Saat menghadapi tantangan pengasuhan, bagaimana kamu menyikapinya?// Finansial KeluargaMonthlyFinance *string `gorm:"column:monthly_finance" json:"monthly_finance"` // Bagaimana kamu mengelola keuangan bulanan?FamilyResponsibility *string `gorm:"column:family_responsibility" json:"family_responsibility"` // Apakah kamu masih punya tanggungan keluarga setelah menikah?DebtStatus *string `gorm:"column:debt_status" json:"debt_status"` // Apakah kamu punya cicilan/utang setelah menikah?FinanceSharing *string `gorm:"column:finance_sharing" json:"finance_sharing"` // Setelah menikah, bagaimana pembagian tanggung jawab keuangan?IncomeGapView *string `gorm:"column:income_gap_view" json:"income_gap_view"` // Pandangan kamu jika istri berpenghasilan lebih besar dari suami?// Keputusan dan KomunikasiDecisionMaking *string `gorm:"column:decision_making" json:"decision_making"` // Dalam mengambil keputusan, kamu lebih mempertimbangkan pasangan atau sendiri?GrowthTogether *string `gorm:"column:growth_together" json:"growth_together"` // Apakah kamu siap berjuang bersama pasangan? Apa saja yang ingin diperjuangkan?ParentIntervention *string `gorm:"column:parent_intervention" json:"parent_intervention"` // Sejauh mana orang tua/mertua boleh ikut campur dalam rumah tangga?HabitResponse *string `gorm:"column:habit_response" json:"habit_response"` // Bagaimana kamu menyikapi kebiasaan pasangan yang kurang kamu sukai?}GetMarriageReadinessProfileRequest struct {AccountID int64 `json:"-"`})type (SavePartnerCriteriaRequest struct {AccountID int64 `json:"account_id"`ExpectedAgeLimit *int `gorm:"column:expected_age_limit" json:"expected_age_limit"` // batas usia pasangan yang diharapkanExpectedDomicile *string `gorm:"column:expected_domicile" json:"expected_domicile"` // domisili pasangan yang diharapkanAcceptedMaritalStatus *pq.StringArray `gorm:"column:accepted_marital_status;type:varchar(255)[]" json:"accepted_marital_status"` // status pernikahan yang diterimaPartnerFamilyReligion *string `gorm:"column:partner_family_religion" json:"partner_family_religion"` // agama yang dianut keluarga pasanganPartnerWeeklyReligiousStudyFrequency *string `gorm:"column:partner_weekly_religious_study_frequency" json:"partner_weekly_religious_study_frequency"` // rata-rata jumlah kajian yang diikuti pasangan per pekanPartnerMonthlySpendingEstimate *string `gorm:"column:partner_monthly_spending_estimate" json:"partner_monthly_spending_estimate"` // estimasi pengeluaran pasangan per bulanPartnerCanCook *string `gorm:"column:partner_can_cook" json:"partner_can_cook"` // apakah pasangan diharapkan bisa memasak// Kriteria FisikExpectedBodyShapes *pq.StringArray `gorm:"column:expected_body_shapes;type:varchar(255)[]" json:"expected_body_shapes"` // bentuk tubuh yang diharapkanExpectedSkinColors *pq.StringArray `gorm:"column:expected_skin_colors;type:varchar(255)[]" json:"expected_skin_colors"` // warna kulit yang diharapkanExpectedHairTypes *pq.StringArray `gorm:"column:expected_hair_types;type:varchar(255)[]" json:"expected_hair_types"` // tipe rambut yang diharapkanExpectedHairThickness *pq.StringArray `gorm:"column:expected_hair_thickness;type:varchar(255)[]" json:"expected_hair_thickness"` // jenis rambut yang diharapkanExpectedHeight *int `gorm:"column:expected_height" json:"expected_height"` // tinggi badan yang diharapkan// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkanExpectedIncomeSources *pq.StringArray `gorm:"column:expected_income_sources;type:varchar(255)[]" json:"expected_income_sources"` // sumber penghasilan pasanganExpectedLastEducation *pq.StringArray `gorm:"column:expected_last_education;type:varchar(255)[]" json:"expected_last_education"` // pendidikan terakhir yang diharapkanExpectedJobType *string `gorm:"column:expected_job_type" json:"expected_job_type"` // jenis pekerjaan pasangan yang diharapkan}GetPartnerCriteriaRequest struct {AccountID int64 `json:"-"`})
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041052 unmodified lines1081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651 unmodified line167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204package validationimport ("regexp""strings""sync"v10 "github.com/go-playground/validator/v10""gorm.io/gorm")type ValidOptionSource interface {GetValidOptions(key string) ([]string, error)GetValidKeys() []string}// --------------------// InMemoryOptionSource// --------------------type InMemoryOptionSource struct{}var inMemoryOptions = map[string][]string{"last_education": {"SD", "SMP", "SMA", "D1", "D2", "D3", "D4", "D5", "S1", "S2", "S3"},"marital_status": {"Belum Menikah", "Duda", "Janda"},"gender": {"Laki-laki", "Perempuan"},"monthly_expenses": {"< 2 Juta", "2-5 Juta", "5-20 Juta", "> 10 Juta"},"monthly_income": {"< 3 Juta", "3-5 Juta", "5-10 Juta", "> 10 Juta"},"religion": {"Islam", "Non-Islam"},"family_role": {"Ayah", "Ibu", "Kakak", "Adik", "Anak"},"life_status": {"Hidup", "Wafat"},"body_shape": {"Ideal", "Kurus", "Berisi", "Gemuk"},"skin_color": {"Putih", "Kuning Langsat", "Sawo Matang"},"hair_type": {"Lurus", "Bergelombang", "Keriting"},"frequently": {"Selalu", "Sering", "Kadang", "Jarang", "Tidak Pernah"},"quran_reading_ability": {"Lancar", "Menengah", "Perlu Bimbingan"},}func (s *InMemoryOptionSource) GetValidOptions(key string) ([]string, error) {return inMemoryOptions[key], nil}func (s *InMemoryOptionSource) GetValidKeys() []string {keys := make([]string, 0, len(inMemoryOptions))for k := range inMemoryOptions {keys = append(keys, k)}return keys}// --------------------// DBOptionSource// --------------------type DBOptionSource struct {options map[string][]stringmu sync.RWMutex}type (OptionCategory struct {ID int64 `gorm:"primaryKey" json:"id"`OptionName string `json:"option_name"`OptionSlug string `json:"option_slug" gorm:"uniqueIndex"`}OptionValues struct {ID int64 `gorm:"primaryKey" json:"id"`OptionCategoryID int64 `json:"option_category_id"`OptionValue string `json:"option_value"`})func NewDBOptionSource(db *gorm.DB) (*DBOptionSource, error) {var categories []OptionCategoryif err := db.Find(&categories).Error; err != nil {return nil, err}options := make(map[string][]string)for _, cat := range categories {var values []OptionValuesif err := db.Where("option_category_id = ?", cat.ID).Find(&values).Error; err != nil {return nil, err}for _, val := range values {options[cat.OptionSlug] = append(options[cat.OptionSlug], val.OptionValue)}}return &DBOptionSource{options: options}, nil}func (s *DBOptionSource) GetValidOptions(key string) ([]string, error) {s.mu.RLock()defer s.mu.RUnlock()return s.options[key], nil}func (s *DBOptionSource) GetValidKeys() []string {s.mu.RLock()defer s.mu.RUnlock()keys := make([]string, 0, len(s.options))for k := range s.options {keys = append(keys, k)2 unmodified lines}// --------------------// Validator// --------------------type Validator struct {source ValidOptionSource}func NewValidatorRules(source ValidOptionSource) *Validator {return &Validator{source: source}}func (v *Validator) GenericOptionRule(key string) func(fl v10.FieldLevel) bool {return func(fl v10.FieldLevel) bool {value := fl.Field().String()if value == "" {return true}validOptions, err := v.source.GetValidOptions(key)if err != nil {return false}for _, opt := range validOptions {if opt == value {return true}}return false}}func (v *Validator) RegisterAllCustomRules(validate *v10.Validate) error {for _, key := range v.source.GetValidKeys() {err := validate.RegisterValidation(key, v.GenericOptionRule(key))if err != nil {return err}}err := validate.RegisterValidation("password", v.PasswordRule)if err != nil {return err}err = validate.RegisterValidation("phone_number", v.PhoneNumberRule)if err != nil {return err}return nil}func (v *Validator) PasswordRule(fl v10.FieldLevel) bool {password := fl.Field().String()return len(password) >= 8 &&strings.ContainsAny(password, "abcdefghijklmnopqrstuvwxyz") &&1 unmodified linestrings.ContainsAny(password, "0123456789")}func (v *Validator) PhoneNumberRule(fl v10.FieldLevel) bool {phone := SanitizePhoneNumber(fl.Field().String())return strings.HasPrefix(phone, "+62")}func SanitizePhoneNumber(input string) string {// Hilangkan semua spasi dan stripinput = strings.ReplaceAll(input, " ", "")input = strings.ReplaceAll(input, "-", "")input = strings.ReplaceAll(input, "(", "")input = strings.ReplaceAll(input, ")", "")// Hilangkan semua karakter non-digit kecuali +re := regexp.MustCompile(`[^0-9\+]`)input = re.ReplaceAllString(input, "")// Handle nomor diawali 0 (contoh: 0812...) menjadi +62812...if strings.HasPrefix(input, "0") {input = "+62" + input[1:]}// Handle jika diawali dengan 62 tanpa + (contoh: 62812...)if strings.HasPrefix(input, "62") && !strings.HasPrefix(input, "+62") {input = "+" + input}// Handle jika tidak ada awalan +62 sama sekali (contoh: 8123456789)if !strings.HasPrefix(input, "+62") {if strings.HasPrefix(input, "8") {input = "+62" + input}}return input}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531542 unmodified lines1571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993001 unmodified line302303304305306307308309310311312313314315316317318319320321322323324package validationimport ("context""fmt""reflect""regexp""strings""sync""time"v10 "github.com/go-playground/validator/v10""gorm.io/gorm")type ValidatorOptionSource interface {GetValidOptions(key string) ([]string, error)GetValidKeys() []stringRefresh() errorStartAutoRefresh(ctx context.Context, interval time.Duration)HasKey(key string) bool}// --------------------// DBOptionSource with Safe Handling// --------------------type DBOptionSource struct {db *gorm.DBoptions map[string][]stringmu sync.RWMutexlastUpdate time.Timeexpiry time.DurationstopChan chan struct{}}func NewDBOptionSource(db *gorm.DB, expiry time.Duration) (*DBOptionSource, error) {source := &DBOptionSource{db: db,expiry: expiry,stopChan: make(chan struct{}),}if err := source.Refresh(); err != nil {return nil, fmt.Errorf("failed to initialize DB option source: %w", err)}return source, nil}func (s *DBOptionSource) Refresh() error {s.mu.Lock()defer s.mu.Unlock()// Buat session baru tanpa transactiontx := s.db.Session(&gorm.Session{SkipDefaultTransaction: true})var results []struct {Slug string `gorm:"column:slug"`Value string `gorm:"column:value"`}err := tx.Raw(`SELECTc.option_slug AS slug,v.option_value AS valueFROM option_categories cJOIN option_values v ON c.id = v.option_category_idORDER BY c.id, v.id`).Scan(&results).Errorif err != nil {return fmt.Errorf("failed to refresh options: %w", err)}newOptions := make(map[string][]string)for _, r := range results {newOptions[r.Slug] = append(newOptions[r.Slug], r.Value)}s.options = newOptionss.lastUpdate = time.Now()fmt.Println("options refreshed")return nil}func (s *DBOptionSource) StartAutoRefresh(ctx context.Context, interval time.Duration) {ticker := time.NewTicker(interval)go func() {for {select {case <-ticker.C:s.mu.Lock()needsRefresh := time.Since(s.lastUpdate) > s.expirys.mu.Unlock()if needsRefresh {if err := s.Refresh(); err != nil {fmt.Printf("failed to auto-refresh options: %v\n", err)}}case <-ctx.Done():ticker.Stop()returncase <-s.stopChan:ticker.Stop()return}}}()}func (s *DBOptionSource) StopAutoRefresh() {close(s.stopChan)}func (s *DBOptionSource) HasKey(key string) bool {s.mu.RLock()defer s.mu.RUnlock()_, exists := s.options[key]return exists}func (s *DBOptionSource) GetValidOptions(key string) ([]string, error) {s.mu.RLock()needsRefresh := time.Since(s.lastUpdate) > s.expirys.mu.RUnlock()if needsRefresh {if err := s.Refresh(); err != nil {return nil, fmt.Errorf("failed to refresh options: %w", err)}}s.mu.RLock()defer s.mu.RUnlock()options, exists := s.options[key]if !exists {return nil, nil // Return nil instead of error for missing keys}copied := make([]string, len(options))copy(copied, options)return copied, nil}func (s *DBOptionSource) GetValidKeys() []string {s.mu.RLock()defer s.mu.RUnlock()keys := make([]string, 0, len(s.options))for k := range s.options {keys = append(keys, k)2 unmodified lines}// --------------------// Validator with Safe Rule Handling// --------------------type Validator struct {source ValidatorOptionSourcevalidate *v10.Validate}func NewValidator(source ValidatorOptionSource) *Validator {validate := v10.New()return &Validator{source: source,validate: validate,}}func (v *Validator) RegisterAllCustomRules() error {// First register static validation rulesstaticRules := map[string]func(v10.FieldLevel) bool{"password": v.validatePassword,"phone-number": v.validatePhoneNumber,}for name, fn := range staticRules {if err := v.validate.RegisterValidation(name, fn); err != nil {return fmt.Errorf("failed to register %s validation: %w", name, err)}}// Then register dynamic option rulesfor _, key := range v.source.GetValidKeys() {if !v.source.HasKey(key) {continue // Skip if key doesn't exist}if err := v.validate.RegisterValidation(key, v.createOptionRule(key)); err != nil {return fmt.Errorf("failed to register validation for %s: %w", key, err)}}return nil}func (v *Validator) Validate(input interface{}) error {if input == nil {return nil}val := reflect.ValueOf(input)if val.Kind() == reflect.Ptr {if val.IsNil() {return nil}val = val.Elem() // Dereference the pointer}err := v.validate.Struct(input)if err == nil {return nil}// Filter out errors for nil/empty fieldsif ve, ok := err.(v10.ValidationErrors); ok {var filteredErrors v10.ValidationErrorsfor _, fe := range ve {fieldValue := val.FieldByName(fe.StructField())if !fieldValue.IsValid() {continue}if !isEmpty(fieldValue) {filteredErrors = append(filteredErrors, fe)} else {fmt.Printf("Ignoring validation error for empty field: %s\n", fe.Field())}}if len(filteredErrors) > 0 {return filteredErrors}return nil}return err}// isEmpty checks if a value is nil or emptyfunc isEmpty(v reflect.Value) bool {switch v.Kind() {case reflect.String:return v.Len() == 0case reflect.Ptr, reflect.Interface:return v.IsNil()case reflect.Slice, reflect.Map, reflect.Array:return v.Len() == 0case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:return v.Int() == 0case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:return v.Uint() == 0case reflect.Float32, reflect.Float64:return v.Float() == 0case reflect.Bool:return !v.Bool()case reflect.Struct:if t, ok := v.Interface().(time.Time); ok {return t.IsZero()}// Consider non-time structs as non-emptyreturn falsedefault:return false}}// createOptionRule remains the same as previous versionfunc (v *Validator) createOptionRule(key string) func(v10.FieldLevel) bool {return func(fl v10.FieldLevel) bool {field := fl.Field()if isEmpty(field) {return true}value := field.String()validOptions, err := v.source.GetValidOptions(key)if err != nil || validOptions == nil {return true}for _, opt := range validOptions {if opt == value {return true}}return false}}func (v *Validator) validatePassword(fl v10.FieldLevel) bool {password := fl.Field().String()return len(password) >= 8 &&strings.ContainsAny(password, "abcdefghijklmnopqrstuvwxyz") &&1 unmodified linestrings.ContainsAny(password, "0123456789")}func (v *Validator) validatePhoneNumber(fl v10.FieldLevel) bool {phone := NormalizePhoneNumber(fl.Field().String())return strings.HasPrefix(phone, "+62")}func NormalizePhoneNumber(input string) string {re := regexp.MustCompile(`[^0-9\+]`)input = re.ReplaceAllString(input, "")switch {case strings.HasPrefix(input, "0"):return "+62" + input[1:]case strings.HasPrefix(input, "62") && !strings.HasPrefix(input, "+62"):return "+" + inputcase strings.HasPrefix(input, "8"):return "+62" + inputdefault:return input}}
1234567891011121314151617181920212223242526272829303132333435363738package repositories
import ( "context"
"api.qobiltu.id/models" "gorm.io/gorm")
type PartnerCriteriaRepository interface { SavePartnerCriteria(ctx context.Context, req *models.PartnerCriteria) (*models.PartnerCriteria, error) GetPartnerCriteria(ctx context.Context, accountID int64) (*models.PartnerCriteria, error)}
type partnerCriteriaRepository struct { db *gorm.DB}
func NewPartnerCriteriaRepository(db *gorm.DB) PartnerCriteriaRepository { return &partnerCriteriaRepository{ db: db, }}
func (r *partnerCriteriaRepository) SavePartnerCriteria(ctx context.Context, req *models.PartnerCriteria) (*models.PartnerCriteria, error) { if err := r.db.WithContext(ctx).Save(req).Error; err != nil { return req, err } return req, nil}
func (r *partnerCriteriaRepository) GetPartnerCriteria(ctx context.Context, accountID int64) (*models.PartnerCriteria, error) { var partnerCriteria models.PartnerCriteria if err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&partnerCriteria).Error; err != nil { return nil, err } return &partnerCriteria, nil}1234567891011package router
import "api.qobiltu.id/middleware"
func (s *Server) PartnerCriteriaRoute() { routerGroup := s.router.Group("/api/v1/partner-criteria").Use(middleware.AuthUser) { routerGroup.POST("", s.partnerCriteriaController.SavePartnerCriteria) routerGroup.GET("", s.partnerCriteriaController.GetPartnerCriteria) }}18 unmodified lines192021222318 unmodified liness.HealthCheckRoute()s.CVRoute()s.MarriageReadinessProfileRoute()s.StorageRoute()}18 unmodified lines19202122232418 unmodified liness.HealthCheckRoute()s.CVRoute()s.MarriageReadinessProfileRoute()s.PartnerCriteriaRoute()s.StorageRoute()}
3 unmodified lines4567892 unmodified lines1213141516171819202122233 unmodified lines2728293031323 unmodified linescv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile""github.com/gin-gonic/gin")2 unmodified lineshealthCheckController health_check_controller.HealthCheckControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController}func NewServer(healthCheckController health_check_controller.HealthCheckController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,) (*Server, error) {router := gin.Default()3 unmodified lineshealthCheckController: healthCheckController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,router: router,}3 unmodified lines456789102 unmodified lines13141516171819202122232425263 unmodified lines303132333435363 unmodified linescv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""github.com/gin-gonic/gin")2 unmodified lineshealthCheckController health_check_controller.HealthCheckControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileControllerpartnerCriteriaController partner_criteria_controller.PartnerCriteriaController}func NewServer(healthCheckController health_check_controller.HealthCheckController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,) (*Server, error) {router := gin.Default()3 unmodified lineshealthCheckController: healthCheckController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,router: router,}
59 unmodified lines606162636465666768697071727374757647 unmodified lines12412512612712812913013114 unmodified lines14614714814915015115243 unmodified lines19619719819920020120242 unmodified lines24524624724824925025118 unmodified lines27027127227327427527638 unmodified lines31531631731831932032117 unmodified lines33934034134234334422 unmodified lines36736836937037137237315 unmodified lines38939039139239339439532 unmodified lines42842943043143243343413 unmodified lines44844945045145245345459 unmodified linestype cvService struct {cvRepository repositories.CVRepositorystorage storage.Storage}func NewCVService(cvRepository repositories.CVRepository, storage storage.Storage) CVService {return &cvService{cvRepository: cvRepository,storage: storage,}}func (s *cvService) SaveAccountDetails(ctx context.Context, req *models.SaveAccountDetailsRequest) (*models.AccountDetails, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}47 unmodified linesutils.AssignIfNotNil(&accountDetails.LastJob, req.LastJob)if req.PhoneNumber != nil {sanitizedPhone := validation.SanitizePhoneNumber(*req.PhoneNumber)accountDetails.PhoneNumber = &sanitizedPhone}// Simpan ke database14 unmodified lines}func (s *cvService) SavePersonalityAndPreference(ctx context.Context, req *models.SavePersonalityAndPreferenceRequest) (*models.PersonalityAndPreferenceCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}43 unmodified lines}func (s *cvService) CreateFamilyMember(ctx context.Context, req *models.CreateFamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}42 unmodified lines}func (s *cvService) UpdateFamilyMember(ctx context.Context, req *models.UpdateFamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}18 unmodified lines}func (s *cvService) SavePhysicalAndHealth(ctx context.Context, req *models.SavePhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}38 unmodified lines}func (s *cvService) SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.SaveWorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}17 unmodified linesutils.AssignIfNotNil(&worshipAndReligiousUnderstanding.DhuhaPrayer, req.DhuhaPrayer)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.QuranMemorization, req.QuranMemorization)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.QuranReadingAbility, req.QuranReadingAbility)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.DaudFasting, req.DaudFasting)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.AyyamulBidhFasting, req.AyyamulBidhFasting)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.HajjOrUmrah, req.HajjOrUmrah)22 unmodified lines}func (s *cvService) CreateEducation(ctx context.Context, req *models.CreateEducationRequest) (*models.EducationCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}15 unmodified lines}func (s *cvService) UpdateEducation(ctx context.Context, req *models.UpdateEducationRequest) (*models.EducationCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}32 unmodified lines}func (s *cvService) CreateJob(ctx context.Context, req *models.CreateJobRequest) (*models.JobCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}13 unmodified lines}func (s *cvService) UpdateJob(ctx context.Context, req *models.UpdateJobRequest) (*models.JobCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}59 unmodified lines6061626364656667686970717273747576777847 unmodified lines12612712812913013113213314 unmodified lines14814915015115215315443 unmodified lines19819920020120220320442 unmodified lines24724824925025125225318 unmodified lines27227327427527627727838 unmodified lines31731831932032132232317 unmodified lines34134234334434534634722 unmodified lines37037137237337437537615 unmodified lines39239339439539639739832 unmodified lines43143243343443543643713 unmodified lines45145245345445545645759 unmodified linestype cvService struct {cvRepository repositories.CVRepositorystorage storage.Storagevalidator *validation.Validator}func NewCVService(cvRepository repositories.CVRepository, storage storage.Storage, validator *validation.Validator) CVService {return &cvService{cvRepository: cvRepository,storage: storage,validator: validator,}}func (s *cvService) SaveAccountDetails(ctx context.Context, req *models.SaveAccountDetailsRequest) (*models.AccountDetails, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}47 unmodified linesutils.AssignIfNotNil(&accountDetails.LastJob, req.LastJob)if req.PhoneNumber != nil {normalizedPhoneNumber := validation.NormalizePhoneNumber(*req.PhoneNumber)accountDetails.PhoneNumber = &normalizedPhoneNumber}// Simpan ke database14 unmodified lines}func (s *cvService) SavePersonalityAndPreference(ctx context.Context, req *models.SavePersonalityAndPreferenceRequest) (*models.PersonalityAndPreferenceCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}43 unmodified lines}func (s *cvService) CreateFamilyMember(ctx context.Context, req *models.CreateFamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}42 unmodified lines}func (s *cvService) UpdateFamilyMember(ctx context.Context, req *models.UpdateFamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}18 unmodified lines}func (s *cvService) SavePhysicalAndHealth(ctx context.Context, req *models.SavePhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}38 unmodified lines}func (s *cvService) SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.SaveWorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}17 unmodified linesutils.AssignIfNotNil(&worshipAndReligiousUnderstanding.DhuhaPrayer, req.DhuhaPrayer)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.QuranMemorization, req.QuranMemorization)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.QuranReadingAbility, req.QuranReadingAbility)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.WeeklyReligiousStudyFrequency, req.WeeklyReligiousStudyFrequency)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.DaudFasting, req.DaudFasting)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.AyyamulBidhFasting, req.AyyamulBidhFasting)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.HajjOrUmrah, req.HajjOrUmrah)22 unmodified lines}func (s *cvService) CreateEducation(ctx context.Context, req *models.CreateEducationRequest) (*models.EducationCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}15 unmodified lines}func (s *cvService) UpdateEducation(ctx context.Context, req *models.UpdateEducationRequest) (*models.EducationCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}32 unmodified lines}func (s *cvService) CreateJob(ctx context.Context, req *models.CreateJobRequest) (*models.JobCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}13 unmodified lines}func (s *cvService) UpdateJob(ctx context.Context, req *models.UpdateJobRequest) (*models.JobCV, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677package services
import ( "context" "errors"
"api.qobiltu.id/models" "api.qobiltu.id/pkg/validation" "api.qobiltu.id/repositories" "api.qobiltu.id/response" "api.qobiltu.id/utils" "gorm.io/gorm")
type PartnerCriteriaService interface { SavePartnerCriteria(ctx context.Context, req *models.SavePartnerCriteriaRequest) (*models.PartnerCriteria, error) GetPartnerCriteria(ctx context.Context, req *models.GetPartnerCriteriaRequest) (*models.PartnerCriteria, error)}
type partnerCriteriaService struct { partnerCriteriaRepository repositories.PartnerCriteriaRepository}
func NewPartnerCriteriaService(partnerCriteriaRepository repositories.PartnerCriteriaRepository) PartnerCriteriaService { return &partnerCriteriaService{partnerCriteriaRepository: partnerCriteriaRepository}}
func (s *partnerCriteriaService) SavePartnerCriteria(ctx context.Context, req *models.SavePartnerCriteriaRequest) (*models.PartnerCriteria, error) { if err := validation.Validate(req); err != nil { return nil, response.HandleValidationError(err) }
partnerCriteria, err := s.partnerCriteriaRepository.GetPartnerCriteria(ctx, req.AccountID) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { return nil, response.HandleGormError(err, "Internal Server Error") }
if partnerCriteria == nil { partnerCriteria = &models.PartnerCriteria{} }
partnerCriteria.AccountID = req.AccountID
utils.AssignIfNotNil(&partnerCriteria.ExpectedAgeLimit, req.ExpectedAgeLimit) utils.AssignIfNotNil(&partnerCriteria.ExpectedDomicile, req.ExpectedDomicile) utils.AssignIfNotNil(&partnerCriteria.AcceptedMaritalStatus, req.AcceptedMaritalStatus) utils.AssignIfNotNil(&partnerCriteria.PartnerFamilyReligion, req.PartnerFamilyReligion) utils.AssignIfNotNil(&partnerCriteria.PartnerWeeklyReligiousStudyFrequency, req.PartnerWeeklyReligiousStudyFrequency) utils.AssignIfNotNil(&partnerCriteria.PartnerMonthlySpendingEstimate, req.PartnerMonthlySpendingEstimate) utils.AssignIfNotNil(&partnerCriteria.PartnerCanCook, req.PartnerCanCook)
utils.AssignIfNotNil(&partnerCriteria.ExpectedBodyShapes, req.ExpectedBodyShapes) utils.AssignIfNotNil(&partnerCriteria.ExpectedSkinColors, req.ExpectedSkinColors) utils.AssignIfNotNil(&partnerCriteria.ExpectedHairTypes, req.ExpectedHairTypes) utils.AssignIfNotNil(&partnerCriteria.ExpectedHairThickness, req.ExpectedHairThickness) utils.AssignIfNotNil(&partnerCriteria.ExpectedHeight, req.ExpectedHeight)
utils.AssignIfNotNil(&partnerCriteria.ExpectedPartnerIncome, req.ExpectedPartnerIncome) utils.AssignIfNotNil(&partnerCriteria.ExpectedIncomeSources, req.ExpectedIncomeSources) utils.AssignIfNotNil(&partnerCriteria.ExpectedLastEducation, req.ExpectedLastEducation) utils.AssignIfNotNil(&partnerCriteria.ExpectedJobType, req.ExpectedJobType)
res, err := s.partnerCriteriaRepository.SavePartnerCriteria(ctx, partnerCriteria) if err != nil { return nil, response.HandleGormError(err, "Internal Server Error") }
return res, nil}
func (s *partnerCriteriaService) GetPartnerCriteria(ctx context.Context, req *models.GetPartnerCriteriaRequest) (*models.PartnerCriteria, error) { res, err := s.partnerCriteriaRepository.GetPartnerCriteria(ctx, req.AccountID) if err != nil { return nil, response.HandleGormError(err, "Internal Server Error") } return res, nil}2 unmodified lines345678968 unmodified lines78798081828384858687882 unmodified linesimport ("fmt""log""log/slog""os""gorm.io/driver/postgres"68 unmodified lines&models.JobCV{},&models.AchievementCV{},&models.MarriageReadinessProfile{},)if err != nil {log.Fatal(err)}slog.Info("Auto-migration completed successfully")}2 unmodified lines34567868 unmodified lines77787980818283848586878889909192939495969798992 unmodified linesimport ("fmt""log""os""gorm.io/driver/postgres"68 unmodified lines&models.JobCV{},&models.AchievementCV{},&models.MarriageReadinessProfile{},&models.PartnerCriteria{},)if err != nil {log.Fatal(err)}sequences := []string{`CREATE SEQUENCE IF NOT EXISTS seq_ikh_counter START 1 INCREMENT 1 MINVALUE 1;`,`CREATE SEQUENCE IF NOT EXISTS seq_akh_counter START 1 INCREMENT 1 MINVALUE 1;`,}for _, seq := range sequences {if err := db.Exec(seq).Error; err != nil {fmt.Printf("Gagal membuat sequence: %v", err)}}fmt.Println("Auto-migration sequence check completed successfully")}
12345678910111213141516171819202122232425package models
import ( "fmt" "strings")
const ( SeqIkhCounter = "seq_ikh_counter" SeqAkhCounter = "seq_akh_counter")
func GetSequenceName(gender string) string { if strings.ToLower(gender) == "laki-laki" { return SeqIkhCounter } return SeqAkhCounter}
func BuildInitialName(gender string, number int64) string { if strings.ToLower(gender) == "laki-laki" { return fmt.Sprintf("IKH_%d", number) } return fmt.Sprintf("AKH_%d", number)}84 unmodified lines85868784 unmodified linesrepo.Result = accountDetailsreturn *repo}84 unmodified lines85868788899091929394959697989910010110210310410584 unmodified linesrepo.Result = accountDetailsreturn *repo}func GetNextInitialNameNumber(gender string) Repository[string, int] {repo := Construct[string, int](gender)sequenceName := models.GetSequenceName(gender)repo.Transaction.Raw("SELECT nextval('" + sequenceName + "')").Scan(&repo.Result)return *repo}func GetAccountDetailsByAccountID(accountID uint) Repository[models.AccountDetails, models.AccountDetails] {repo := Construct[models.AccountDetails, models.AccountDetails](models.AccountDetails{AccountID: accountID},)repo.Transactions(WhereGivenConstructor[models.AccountDetails, models.AccountDetails],Find[models.AccountDetails, models.AccountDetails],)return *repo}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243package repositoriesimport ("api.qobiltu.id/models""context""gorm.io/gorm")type CVRepository interface {SaveAccountDetails(ctx context.Context, req *models.AccountDetails) (*models.AccountDetails, error)GetAccountDetailsByAccountID(ctx context.Context, accountID int64) (*models.AccountDetails, error)SavePersonalityAndPreference(ctx context.Context, req *models.PersonalityAndPreferenceCV) (*models.PersonalityAndPreferenceCV, error)GetPersonalityAndPreferenceByAccountID(ctx context.Context, accountID int64) (*models.PersonalityAndPreferenceCV, error)SaveFamilyMember(ctx context.Context, req *models.FamilyMemberCV) (*models.FamilyMemberCV, error)ListFamilyMember(ctx context.Context, accountID int64) ([]models.FamilyMemberCV, error)GetFamilyMember(ctx context.Context, id int64) (*models.FamilyMemberCV, error)DeleteFamilyMember(ctx context.Context, id int64) errorSavePhysicalAndHealth(ctx context.Context, req *models.PhysicalAndHealthCV) (*models.PhysicalAndHealthCV, error)GetPhysicalAndHealthByAccountID(ctx context.Context, accountID int64) (*models.PhysicalAndHealthCV, error)SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.WorshipAndReligiousUnderstandingCV) (*models.WorshipAndReligiousUnderstandingCV, error)GetWorshipAndReligiousUnderstandingByAccountID(ctx context.Context, accountID int64) (*models.WorshipAndReligiousUnderstandingCV, error)SaveEducation(ctx context.Context, req *models.EducationCV) (*models.EducationCV, error)ListEducation(ctx context.Context, accountID int64) ([]models.EducationCV, error)GetEducation(ctx context.Context, id int64) (*models.EducationCV, error)DeleteEducation(ctx context.Context, id int64) errorSaveJob(ctx context.Context, req *models.JobCV) (*models.JobCV, error)ListJob(ctx context.Context, accountID int64) ([]models.JobCV, error)GetJob(ctx context.Context, id int64) (*models.JobCV, error)DeleteJob(ctx context.Context, id int64) errorSaveAchievement(ctx context.Context, req *models.AchievementCV) (*models.AchievementCV, error)ListAchievement(ctx context.Context, accountID int64) ([]models.AchievementCV, error)GetAchievement(ctx context.Context, id int64) (*models.AchievementCV, error)DeleteAchievement(ctx context.Context, id int64) error}type cvRepository struct {db *gorm.DB}func NewCVRepository(db *gorm.DB) CVRepository {return &cvRepository{db: db,}}func (r *cvRepository) SaveAccountDetails(ctx context.Context, req *models.AccountDetails) (*models.AccountDetails, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetAccountDetailsByAccountID(ctx context.Context, accountID int64) (*models.AccountDetails, error) {var accountDetails models.AccountDetailsif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&accountDetails).Error; err != nil {return nil, err}return &accountDetails, nil}func (r *cvRepository) SavePersonalityAndPreference(ctx context.Context, req *models.PersonalityAndPreferenceCV) (*models.PersonalityAndPreferenceCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetPersonalityAndPreferenceByAccountID(ctx context.Context, accountID int64) (*models.PersonalityAndPreferenceCV, error) {var personalityAndPreference models.PersonalityAndPreferenceCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&personalityAndPreference).Error; err != nil {return nil, err}return &personalityAndPreference, nil}func (r *cvRepository) SaveFamilyMember(ctx context.Context, req *models.FamilyMemberCV) (*models.FamilyMemberCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetFamilyMember(ctx context.Context, id int64) (*models.FamilyMemberCV, error) {var familyMember models.FamilyMemberCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&familyMember).Error; err != nil {return nil, err}return &familyMember, nil}func (r *cvRepository) DeleteFamilyMember(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.FamilyMemberCV{}).Error; err != nil {return err}return nil}func (r *cvRepository) ListFamilyMember(ctx context.Context, accountID int64) ([]models.FamilyMemberCV, error) {familyMembers := make([]models.FamilyMemberCV, 0)if err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&familyMembers).Error; err != nil {return nil, err}return familyMembers, nil}func (r *cvRepository) SavePhysicalAndHealth(ctx context.Context, req *models.PhysicalAndHealthCV) (*models.PhysicalAndHealthCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetPhysicalAndHealthByAccountID(ctx context.Context, accountID int64) (*models.PhysicalAndHealthCV, error) {var physicalAndHealth models.PhysicalAndHealthCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&physicalAndHealth).Error; err != nil {return nil, err}return &physicalAndHealth, nil}func (r *cvRepository) SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.WorshipAndReligiousUnderstandingCV) (*models.WorshipAndReligiousUnderstandingCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetWorshipAndReligiousUnderstandingByAccountID(ctx context.Context, accountID int64) (*models.WorshipAndReligiousUnderstandingCV, error) {var worshipAndReligiousUnderstanding models.WorshipAndReligiousUnderstandingCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&worshipAndReligiousUnderstanding).Error; err != nil {return nil, err}return &worshipAndReligiousUnderstanding, nil}// SaveEducation menyimpan atau memperbarui data pendidikan ke databasefunc (r *cvRepository) SaveEducation(ctx context.Context, req *models.EducationCV) (*models.EducationCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}// ListEducation mengambil daftar data pendidikan berdasarkan account_idfunc (r *cvRepository) ListEducation(ctx context.Context, accountID int64) ([]models.EducationCV, error) {var educations []models.EducationCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&educations).Error; err != nil {return nil, err}return educations, nil}// GetEducation mengambil satu data pendidikan berdasarkan idfunc (r *cvRepository) GetEducation(ctx context.Context, id int64) (*models.EducationCV, error) {var education models.EducationCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&education).Error; err != nil {return nil, err}return &education, nil}// DeleteEducation menghapus data pendidikan berdasarkan idfunc (r *cvRepository) DeleteEducation(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.EducationCV{}).Error; err != nil {return err}return nil}// SaveJob menyimpan atau memperbarui data pekerjaan ke databasefunc (r *cvRepository) SaveJob(ctx context.Context, req *models.JobCV) (*models.JobCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}// ListJob mengambil daftar data pekerjaan berdasarkan account_idfunc (r *cvRepository) ListJob(ctx context.Context, accountID int64) ([]models.JobCV, error) {var jobs []models.JobCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&jobs).Error; err != nil {return nil, err}return jobs, nil}// GetJob mengambil satu data pekerjaan berdasarkan idfunc (r *cvRepository) GetJob(ctx context.Context, id int64) (*models.JobCV, error) {var job models.JobCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&job).Error; err != nil {return nil, err}return &job, nil}// DeleteJob menghapus data pekerjaan berdasarkan idfunc (r *cvRepository) DeleteJob(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.JobCV{}).Error; err != nil {return err}return nil}// SaveAchievement menyimpan atau memperbarui data prestasi ke databasefunc (r *cvRepository) SaveAchievement(ctx context.Context, req *models.AchievementCV) (*models.AchievementCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}// ListAchievement mengambil daftar data prestasi berdasarkan account_idfunc (r *cvRepository) ListAchievement(ctx context.Context, accountID int64) ([]models.AchievementCV, error) {var achievements []models.AchievementCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&achievements).Error; err != nil {return nil, err}return achievements, nil}// GetAchievement mengambil satu data prestasi berdasarkan idfunc (r *cvRepository) GetAchievement(ctx context.Context, id int64) (*models.AchievementCV, error) {var achievement models.AchievementCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&achievement).Error; err != nil {return nil, err}return &achievement, nil}// DeleteAchievement menghapus data prestasi berdasarkan idfunc (r *cvRepository) DeleteAchievement(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.AchievementCV{}).Error; err != nil {return err}return nil}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259package repositoriesimport ("context""fmt""api.qobiltu.id/models""gorm.io/gorm")type CVRepository interface {SaveAccountDetails(ctx context.Context, req *models.AccountDetails) (*models.AccountDetails, error)GetAccountDetailsByAccountID(ctx context.Context, accountID int64) (*models.AccountDetails, error)GetNextInitialNameNumber(ctx context.Context, gender string) (int64, error)SavePersonalityAndPreference(ctx context.Context, req *models.PersonalityAndPreferenceCV) (*models.PersonalityAndPreferenceCV, error)GetPersonalityAndPreferenceByAccountID(ctx context.Context, accountID int64) (*models.PersonalityAndPreferenceCV, error)SaveFamilyMember(ctx context.Context, req *models.FamilyMemberCV) (*models.FamilyMemberCV, error)ListFamilyMember(ctx context.Context, accountID int64) ([]models.FamilyMemberCV, error)GetFamilyMember(ctx context.Context, id int64) (*models.FamilyMemberCV, error)DeleteFamilyMember(ctx context.Context, id int64) errorSavePhysicalAndHealth(ctx context.Context, req *models.PhysicalAndHealthCV) (*models.PhysicalAndHealthCV, error)GetPhysicalAndHealthByAccountID(ctx context.Context, accountID int64) (*models.PhysicalAndHealthCV, error)SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.WorshipAndReligiousUnderstandingCV) (*models.WorshipAndReligiousUnderstandingCV, error)GetWorshipAndReligiousUnderstandingByAccountID(ctx context.Context, accountID int64) (*models.WorshipAndReligiousUnderstandingCV, error)SaveEducation(ctx context.Context, req *models.EducationCV) (*models.EducationCV, error)ListEducation(ctx context.Context, accountID int64) ([]models.EducationCV, error)GetEducation(ctx context.Context, id int64) (*models.EducationCV, error)DeleteEducation(ctx context.Context, id int64) errorSaveJob(ctx context.Context, req *models.JobCV) (*models.JobCV, error)ListJob(ctx context.Context, accountID int64) ([]models.JobCV, error)GetJob(ctx context.Context, id int64) (*models.JobCV, error)DeleteJob(ctx context.Context, id int64) errorSaveAchievement(ctx context.Context, req *models.AchievementCV) (*models.AchievementCV, error)ListAchievement(ctx context.Context, accountID int64) ([]models.AchievementCV, error)GetAchievement(ctx context.Context, id int64) (*models.AchievementCV, error)DeleteAchievement(ctx context.Context, id int64) error}type cvRepository struct {db *gorm.DB}func NewCVRepository(db *gorm.DB) CVRepository {return &cvRepository{db: db,}}func (r *cvRepository) SaveAccountDetails(ctx context.Context, req *models.AccountDetails) (*models.AccountDetails, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetAccountDetailsByAccountID(ctx context.Context, accountID int64) (*models.AccountDetails, error) {var accountDetails models.AccountDetailsif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&accountDetails).Error; err != nil {return nil, err}return &accountDetails, nil}func (r *cvRepository) GetNextInitialNameNumber(ctx context.Context, gender string) (int64, error) {sequenceName := models.GetSequenceName(gender)var number int64query := fmt.Sprintf("SELECT nextval('%s')", sequenceName)err := r.db.WithContext(ctx).Raw(query).Scan(&number).Errorif err != nil {return 0, err}return number, nil}func (r *cvRepository) SavePersonalityAndPreference(ctx context.Context, req *models.PersonalityAndPreferenceCV) (*models.PersonalityAndPreferenceCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetPersonalityAndPreferenceByAccountID(ctx context.Context, accountID int64) (*models.PersonalityAndPreferenceCV, error) {var personalityAndPreference models.PersonalityAndPreferenceCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&personalityAndPreference).Error; err != nil {return nil, err}return &personalityAndPreference, nil}func (r *cvRepository) SaveFamilyMember(ctx context.Context, req *models.FamilyMemberCV) (*models.FamilyMemberCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetFamilyMember(ctx context.Context, id int64) (*models.FamilyMemberCV, error) {var familyMember models.FamilyMemberCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&familyMember).Error; err != nil {return nil, err}return &familyMember, nil}func (r *cvRepository) DeleteFamilyMember(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.FamilyMemberCV{}).Error; err != nil {return err}return nil}func (r *cvRepository) ListFamilyMember(ctx context.Context, accountID int64) ([]models.FamilyMemberCV, error) {familyMembers := make([]models.FamilyMemberCV, 0)if err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&familyMembers).Error; err != nil {return nil, err}return familyMembers, nil}func (r *cvRepository) SavePhysicalAndHealth(ctx context.Context, req *models.PhysicalAndHealthCV) (*models.PhysicalAndHealthCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetPhysicalAndHealthByAccountID(ctx context.Context, accountID int64) (*models.PhysicalAndHealthCV, error) {var physicalAndHealth models.PhysicalAndHealthCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&physicalAndHealth).Error; err != nil {return nil, err}return &physicalAndHealth, nil}func (r *cvRepository) SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.WorshipAndReligiousUnderstandingCV) (*models.WorshipAndReligiousUnderstandingCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}func (r *cvRepository) GetWorshipAndReligiousUnderstandingByAccountID(ctx context.Context, accountID int64) (*models.WorshipAndReligiousUnderstandingCV, error) {var worshipAndReligiousUnderstanding models.WorshipAndReligiousUnderstandingCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&worshipAndReligiousUnderstanding).Error; err != nil {return nil, err}return &worshipAndReligiousUnderstanding, nil}// SaveEducation menyimpan atau memperbarui data pendidikan ke databasefunc (r *cvRepository) SaveEducation(ctx context.Context, req *models.EducationCV) (*models.EducationCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}// ListEducation mengambil daftar data pendidikan berdasarkan account_idfunc (r *cvRepository) ListEducation(ctx context.Context, accountID int64) ([]models.EducationCV, error) {var educations []models.EducationCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&educations).Error; err != nil {return nil, err}return educations, nil}// GetEducation mengambil satu data pendidikan berdasarkan idfunc (r *cvRepository) GetEducation(ctx context.Context, id int64) (*models.EducationCV, error) {var education models.EducationCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&education).Error; err != nil {return nil, err}return &education, nil}// DeleteEducation menghapus data pendidikan berdasarkan idfunc (r *cvRepository) DeleteEducation(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.EducationCV{}).Error; err != nil {return err}return nil}// SaveJob menyimpan atau memperbarui data pekerjaan ke databasefunc (r *cvRepository) SaveJob(ctx context.Context, req *models.JobCV) (*models.JobCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}// ListJob mengambil daftar data pekerjaan berdasarkan account_idfunc (r *cvRepository) ListJob(ctx context.Context, accountID int64) ([]models.JobCV, error) {var jobs []models.JobCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&jobs).Error; err != nil {return nil, err}return jobs, nil}// GetJob mengambil satu data pekerjaan berdasarkan idfunc (r *cvRepository) GetJob(ctx context.Context, id int64) (*models.JobCV, error) {var job models.JobCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&job).Error; err != nil {return nil, err}return &job, nil}// DeleteJob menghapus data pekerjaan berdasarkan idfunc (r *cvRepository) DeleteJob(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.JobCV{}).Error; err != nil {return err}return nil}// SaveAchievement menyimpan atau memperbarui data prestasi ke databasefunc (r *cvRepository) SaveAchievement(ctx context.Context, req *models.AchievementCV) (*models.AchievementCV, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return req, err}return req, nil}// ListAchievement mengambil daftar data prestasi berdasarkan account_idfunc (r *cvRepository) ListAchievement(ctx context.Context, accountID int64) ([]models.AchievementCV, error) {var achievements []models.AchievementCVif err := r.db.WithContext(ctx).Where("account_id = ?", accountID).Find(&achievements).Error; err != nil {return nil, err}return achievements, nil}// GetAchievement mengambil satu data prestasi berdasarkan idfunc (r *cvRepository) GetAchievement(ctx context.Context, id int64) (*models.AchievementCV, error) {var achievement models.AchievementCVif err := r.db.WithContext(ctx).Where("id = ?", id).First(&achievement).Error; err != nil {return nil, err}return &achievement, nil}// DeleteAchievement menghapus data prestasi berdasarkan idfunc (r *cvRepository) DeleteAchievement(ctx context.Context, id int64) error {if err := r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.AchievementCV{}).Error; err != nil {return err}return nil}
4 unmodified lines567891058 unmodified lines69707172737475764 unmodified lines8182838485868788899091929394956 unmodified lines1021031041051061071084 unmodified lines"errors""math""strconv""api.qobiltu.id/models""api.qobiltu.id/pkg/storage"58 unmodified lines}func (s *cvService) SaveAccountDetails(ctx context.Context, req *models.SaveAccountDetailsRequest) (*models.AccountDetails, error) {// notes// jika ingin mengubah value wajib kirimkan field beserta value nyaif err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}4 unmodified linesreturn nil, response.HandleGormError(err, "Internal Server Error")}// Apply perubahanif accountDetails == nil {accountDetails = &models.AccountDetails{}}accountDetails.AccountID = uint(req.AccountID)utils.AssignIfNotNil(&accountDetails.FullName, req.FullName)utils.AssignIfNotNil(&accountDetails.Gender, req.Gender)utils.AssignIfNotNil(&accountDetails.DateOfBirth, req.DateOfBirth)utils.AssignIfNotNil(&accountDetails.PlaceOfBirth, req.PlaceOfBirth)utils.AssignIfNotNil(&accountDetails.Domicile, req.Domicile)6 unmodified linesaccountDetails.PhoneNumber = &sanitizedPhone}// Simpan datares, err := s.cvRepository.SaveAccountDetails(ctx, accountDetails)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")4 unmodified lines56789101158 unmodified lines7071727374754 unmodified lines80818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201216 unmodified lines1281291301311321331344 unmodified lines"errors""math""strconv""strings""api.qobiltu.id/models""api.qobiltu.id/pkg/storage"58 unmodified lines}func (s *cvService) SaveAccountDetails(ctx context.Context, req *models.SaveAccountDetailsRequest) (*models.AccountDetails, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}4 unmodified linesreturn nil, response.HandleGormError(err, "Internal Server Error")}// Cek apakah accountDetails baru atau existingisNew := accountDetails == nilif isNew {accountDetails = &models.AccountDetails{}accountDetails.AccountID = uint(req.AccountID)}// Simpan gender lama jika adaoldGender := ""if accountDetails.Gender != nil {oldGender = strings.ToLower(*accountDetails.Gender)}// Update gender jika dikirim dari requestvar genderChanged boolif req.Gender != nil {newGender := strings.ToLower(*req.Gender)if oldGender != newGender {genderChanged = trueaccountDetails.Gender = req.Gender}}// Jika gender baru atau gender berubah, generate InitialName baru via sequenceif isNew || genderChanged {if accountDetails.Gender != nil {number, err := s.cvRepository.GetNextInitialNameNumber(ctx, *accountDetails.Gender)if err != nil {return nil, response.HandleGormError(err, "Gagal generate initial name")}accountDetails.InitialName = models.BuildInitialName(*accountDetails.Gender, number)}}// Apply perubahan field lainnyautils.AssignIfNotNil(&accountDetails.FullName, req.FullName)utils.AssignIfNotNil(&accountDetails.DateOfBirth, req.DateOfBirth)utils.AssignIfNotNil(&accountDetails.PlaceOfBirth, req.PlaceOfBirth)utils.AssignIfNotNil(&accountDetails.Domicile, req.Domicile)6 unmodified linesaccountDetails.PhoneNumber = &sanitizedPhone}// Simpan ke databaseres, err := s.cvRepository.SaveAccountDetails(ctx, accountDetails)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")
1 unmodified line234567864 unmodified lines737475767778798081828384858687888990919293941 unmodified line969798991001015 unmodified lines1071081091101111121131141151 unmodified lineimport ("regexp""strconv""strings""api.qobiltu.id/models"64 unmodified lines}func (s *UserProfileService) Update() {if s.Constructor.PhoneNumber != nil {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)}usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif s.Constructor.Gender != nil {if strings.ToLower(*s.Constructor.Gender) == "laki-laki" {initialName = "IKH_"} else {initialName = "AKH_"}}initialName += strconv.Itoa(usersCount)s.Constructor.InitialName = initialNameuserProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified lines.Exception.Message = "There is no account with given credentials!"return}account := repositories.GetAccountById(uint(s.Constructor.AccountID))account.Result.IsDetailCompleted = (userProfile.Result.InitialName != "" &&userProfile.Result.FullName != nil &&5 unmodified linesuserProfile.Result.LastEducation != nil &&userProfile.Result.MaritalStatus != nil)repositories.UpdateAccount(account.Result)s.Result = models.UserProfileResponse{Account: account.Result,Details: userProfile.Result,}s.Result.Account.Password = "SECRET"}1 unmodified line23456764 unmodified lines727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181 unmodified line1201211221231241251261275 unmodified lines1331341351361371381391401411421431 unmodified lineimport ("regexp""strings""api.qobiltu.id/models"64 unmodified lines}func (s *UserProfileService) Update() {// Sanitize phone numberif s.Constructor.PhoneNumber != nil {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)}// Ambil data account details dari DBexistingDetails := repositories.GetAccountDetailsByAccountID(uint(s.Constructor.AccountID))if existingDetails.RowsError != nil {s.Error = existingDetails.RowsErrorreturn}if existingDetails.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "Account details not found"return}// Update initial name jika gender berubahvar initialName stringshouldUpdateInitialName := falseif s.Constructor.Gender != nil {newGender := strings.ToLower(*s.Constructor.Gender)oldGender := ""if existingDetails.Result.Gender != nil {oldGender = strings.ToLower(*existingDetails.Result.Gender)}if newGender != oldGender {initialNameNumber := repositories.GetNextInitialNameNumber(*s.Constructor.Gender)initialName = models.BuildInitialName(*s.Constructor.Gender, int64(initialNameNumber.Result))s.Constructor.InitialName = initialNameshouldUpdateInitialName = true}}// Update ke databaseif !shouldUpdateInitialName {s.Constructor.InitialName = existingDetails.Result.InitialName}userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified lines.Exception.Message = "There is no account with given credentials!"return}// Update flag isDetailCompleted di accountaccount := repositories.GetAccountById(uint(s.Constructor.AccountID))account.Result.IsDetailCompleted = (userProfile.Result.InitialName != "" &&userProfile.Result.FullName != nil &&5 unmodified linesuserProfile.Result.LastEducation != nil &&userProfile.Result.MaritalStatus != nil)repositories.UpdateAccount(account.Result)s.Result = models.UserProfileResponse{Account: account.Result,Details: userProfile.Result,}s.Result.Account.Password = "SECRET"}
18 unmodified lines19202122232425265 unmodified lines3233343536373839153 unmodified lines1931941951961971981992002018 unmodified lines2102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392 unmodified lines2422432442452462472482492502512522532542552569 unmodified lines26626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830918 unmodified lines}type AccountDetails struct {ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID uint `gorm:"column:account_id;not null;unique" json:"account_id"`InitialName string `gorm:"column:initial_name;not null" json:"initial_name"`FullName *string `gorm:"column:full_name" json:"full_name"`DateOfBirth *time.Time `gorm:"column:date_of_birth" json:"date_of_birth"`5 unmodified linesMaritalStatus *string `gorm:"column:marital_status" json:"marital_status"`Avatar *string `gorm:"column:avatar" json:"avatar"`PhoneNumber *string `gorm:"column:phone_number" json:"phone_number"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`FieldCounter}153 unmodified linestype (PersonalityAndPreferenceCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`PositiveTraits *string `gorm:"column:positive_traits" json:"positive_traits"` // sifat positifNegativeTraits *string `gorm:"column:negative_traits" json:"negative_traits"` // sifat negatifHobbies *string `gorm:"column:hobbies" json:"hobbies"` // hobi8 unmodified linesCanCook *bool `gorm:"column:can_cook" json:"can_cook"` // bisa memasakTypesOfDishesCooked *string `gorm:"column:types_of_dishes_cooked" json:"types_of_dishes_cooked"` // jenis masakan yang bisa dimasakMonthlyExpenses *string `gorm:"column:monthly_expenses" json:"monthly_expenses"` // pengeluaran per bulanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`FieldCounter}FamilyMemberCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`Role *string `gorm:"column:role" json:"role"` // Peran dalam keluargaStatus *string `gorm:"column:status" json:"status"` // Status (Hidup, Wafat)Religion *string `gorm:"column:religion" json:"religion"` // AgamaJob *string `gorm:"column:job" json:"job"` // PekerjaanLastEducation *string `gorm:"column:last_education" json:"last_education"` // Pendidikan terakhirAge *int `gorm:"column:age" json:"age"` // UsiaCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`FieldCounter}PhysicalAndHealthCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`HeightInCm *int `gorm:"column:height_cm" json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `gorm:"column:weight_kg" json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `gorm:"column:body_shape" json:"body_shape"` // Bentuk tubuh2 unmodified linesMedicalHistory *pq.StringArray `gorm:"column:medical_history;type:varchar(255)[]" json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `gorm:"column:physical_disorder" json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `gorm:"column:physical_traits" json:"physical_traits"` // Ciri khas fisikCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // Waktu data dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // Waktu data terakhir diperbaruiFieldCounter}WorshipAndReligiousUnderstandingCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`ObligatoryPrayer *string `gorm:"column:obligatory_prayer" json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `gorm:"column:congregational_prayer" json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `gorm:"column:tahajjud_prayer" json:"tahajjud_prayer"` // sholat_tahajud9 unmodified linesOpinionOnVeil *string `gorm:"column:opinion_on_veil" json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `gorm:"column:weekly_religious_studies" json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `gorm:"column:followed_ustadz" json:"followed_ustadz"` // ustadz_yang_diikutiCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`FieldCounter}EducationCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunLastEducation *string `gorm:"column:last_education" json:"last_education"` // pendidikan terakhirEducationInstitute *string `gorm:"column:education_institute" json:"education_institute"` // institusi pendidikanEducationMajor *string `gorm:"column:education_major" json:"education_major"` // jurusan pendidikanYearStart *int `gorm:"column:year_start" json:"year_start"` // tahun masukYearGraduate *int `gorm:"column:year_graduate" json:"year_graduate"` // tahun lulusCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // tanggal diperbarui}JobCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunInstitutionName *string `gorm:"column:institution_name" json:"institution_name"` // nama instansiCurrentJob *string `gorm:"column:current_job" json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `gorm:"column:year_started_working" json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `gorm:"column:monthly_income" json:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `gorm:"column:income_sources;type:varchar(255)[]" json:"income_sources"` // sumber penghasilanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // tanggal diperbarui}AchievementCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunAchievementOrAward *string `gorm:"column:achievement_or_award" json:"achievement_or_award"` // prestasi atau penghargaanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // tanggal diperbarui})18 unmodified lines19202122232425265 unmodified lines3233343536373839153 unmodified lines1931941951961971981992002018 unmodified lines2102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392 unmodified lines2422432442452462472482492502512522532542552569 unmodified lines26626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830918 unmodified lines}type AccountDetails struct {ID uint64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID uint `gorm:"column:account_id;not null;unique" json:"account_id" counter:"skip"`InitialName string `gorm:"column:initial_name;not null" json:"initial_name"`FullName *string `gorm:"column:full_name" json:"full_name"`DateOfBirth *time.Time `gorm:"column:date_of_birth" json:"date_of_birth"`5 unmodified linesMaritalStatus *string `gorm:"column:marital_status" json:"marital_status"`Avatar *string `gorm:"column:avatar" json:"avatar"`PhoneNumber *string `gorm:"column:phone_number" json:"phone_number"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`FieldCounter}153 unmodified linestype (PersonalityAndPreferenceCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`PositiveTraits *string `gorm:"column:positive_traits" json:"positive_traits"` // sifat positifNegativeTraits *string `gorm:"column:negative_traits" json:"negative_traits"` // sifat negatifHobbies *string `gorm:"column:hobbies" json:"hobbies"` // hobi8 unmodified linesCanCook *bool `gorm:"column:can_cook" json:"can_cook"` // bisa memasakTypesOfDishesCooked *string `gorm:"column:types_of_dishes_cooked" json:"types_of_dishes_cooked"` // jenis masakan yang bisa dimasakMonthlyExpenses *string `gorm:"column:monthly_expenses" json:"monthly_expenses"` // pengeluaran per bulanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`FieldCounter}FamilyMemberCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID int64 `gorm:"column:account_id;not null" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`Role *string `gorm:"column:role" json:"role"` // Peran dalam keluargaStatus *string `gorm:"column:status" json:"status"` // Status (Hidup, Wafat)Religion *string `gorm:"column:religion" json:"religion"` // AgamaJob *string `gorm:"column:job" json:"job"` // PekerjaanLastEducation *string `gorm:"column:last_education" json:"last_education"` // Pendidikan terakhirAge *int `gorm:"column:age" json:"age"` // UsiaCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`FieldCounter}PhysicalAndHealthCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`HeightInCm *int `gorm:"column:height_cm" json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `gorm:"column:weight_kg" json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `gorm:"column:body_shape" json:"body_shape"` // Bentuk tubuh2 unmodified linesMedicalHistory *pq.StringArray `gorm:"column:medical_history;type:varchar(255)[]" json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `gorm:"column:physical_disorder" json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `gorm:"column:physical_traits" json:"physical_traits"` // Ciri khas fisikCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"` // Waktu data dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"` // Waktu data terakhir diperbaruiFieldCounter}WorshipAndReligiousUnderstandingCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`ObligatoryPrayer *string `gorm:"column:obligatory_prayer" json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `gorm:"column:congregational_prayer" json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `gorm:"column:tahajjud_prayer" json:"tahajjud_prayer"` // sholat_tahajud9 unmodified linesOpinionOnVeil *string `gorm:"column:opinion_on_veil" json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `gorm:"column:weekly_religious_studies" json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `gorm:"column:followed_ustadz" json:"followed_ustadz"` // ustadz_yang_diikutiCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`FieldCounter}EducationCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id" counter:"skip"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"` // relasi ke akunLastEducation *string `gorm:"column:last_education" json:"last_education"` // pendidikan terakhirEducationInstitute *string `gorm:"column:education_institute" json:"education_institute"` // institusi pendidikanEducationMajor *string `gorm:"column:education_major" json:"education_major"` // jurusan pendidikanYearStart *int `gorm:"column:year_start" json:"year_start"` // tahun masukYearGraduate *int `gorm:"column:year_graduate" json:"year_graduate"` // tahun lulusCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"` // tanggal diperbarui}JobCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id" counter:"skip"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"` // relasi ke akunInstitutionName *string `gorm:"column:institution_name" json:"institution_name"` // nama instansiCurrentJob *string `gorm:"column:current_job" json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `gorm:"column:year_started_working" json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `gorm:"column:monthly_income" json:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `gorm:"column:income_sources;type:varchar(255)[]" json:"income_sources"` // sumber penghasilanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"` // tanggal diperbarui}AchievementCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id" counter:"skip"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id" counter:"skip"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"` // relasi ke akunAchievementOrAward *string `gorm:"column:achievement_or_award" json:"achievement_or_award"` // prestasi atau penghargaanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"` // tanggal diperbarui})
12345610 unmodified lines1718192021222324252627282930313233343536373839404142434445package modelsimport ("reflect""time")10 unmodified lines// shouldSkipField menentukan apakah field harus dilewati dalam penghitunganfunc shouldSkipField(field reflect.StructField) bool {// Skip field dengan nama FieldCounter (embedded type)if field.Name == "FieldCounter" {return true}// Skip field yang berasal dari GORM atau standard fields// seperti ID, timestamps, dan foreign keysif field.Name == "ID" || field.Name == "CreatedAt" || field.Name == "UpdatedAt" || field.Name == "DeletedAt" ||field.Name == "AccountID" || field.Name == "Account" {return true}// Periksa tag gorm untuk auto fieldsgormTag := field.Tag.Get("gorm")if len(gormTag) > 0 {// Skip kolom yang auto-increment atau auto-timestampif gormTag == "primaryKey" || gormTag == "autoIncrement" ||gormTag == "autoCreateTime" || gormTag == "autoUpdateTime" {return true}}return false}// TotalFields menghitung jumlah total field dalam struct123456710 unmodified lines18192021222324252627282930package modelsimport ("fmt""reflect""time")10 unmodified lines// shouldSkipField menentukan apakah field harus dilewati dalam penghitunganfunc shouldSkipField(field reflect.StructField) bool {if field.Name == "FieldCounter" {return true}counterTag := field.Tag.Get("counter")fmt.Println(field.Name, "=", counterTag)return counterTag == "skip"}// TotalFields menghitung jumlah total field dalam struct
76 unmodified lines77787980818276 unmodified lines&models.EducationCV{},&models.JobCV{},&models.AchievementCV{},)if err != nil {76 unmodified lines7778798081828376 unmodified lines&models.EducationCV{},&models.JobCV{},&models.AchievementCV{},&models.MarriageReadinessProfile{},)if err != nil {
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566package cv_controller
import ( "net/http"
"api.qobiltu.id/middleware" "api.qobiltu.id/models" "api.qobiltu.id/response" "api.qobiltu.id/services" "github.com/gin-gonic/gin")
type MarriageReadinessProfileController interface { SaveMarriageReadinessProfile(ctx *gin.Context) GetMarriageReadinessProfile(ctx *gin.Context)}
type marriageReadinessProfileController struct { marriageReadinessProfileService services.MarriageReadinessProfileService}
func NewMarriageReadinessProfileController(marriageReadinessProfileService services.MarriageReadinessProfileService) MarriageReadinessProfileController { return &marriageReadinessProfileController{ marriageReadinessProfileService: marriageReadinessProfileService, }}
func (c *marriageReadinessProfileController) SaveMarriageReadinessProfile(ctx *gin.Context) { var req models.SaveMarriageReadinessProfileRequest if err := ctx.ShouldBindJSON(&req); err != nil { response.HandleError(ctx, models.Exception{ Message: "Invalid body request", BadRequest: true, Err: err, }) return }
accountData := middleware.GetAccountData(ctx) req.AccountID = int64(accountData.UserID)
res, err := c.marriageReadinessProfileService.SaveMarriageReadinessProfile(ctx, &req) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Marriage readiness profile saved", res, nil)}
func (c *marriageReadinessProfileController) GetMarriageReadinessProfile(ctx *gin.Context) { accountData := middleware.GetAccountData(ctx) accountID := int64(accountData.UserID)
req := models.GetMarriageReadinessProfileRequest{ AccountID: accountID, }
res, err := c.marriageReadinessProfileService.GetMarriageReadinessProfile(ctx, &req) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Get marriage readiness profile success", res, nil)}1234567893 unmodified lines13141516171819202138 unmodified lines6061626364653 unmodified lines697071727374package mainimport ("api.qobiltu.id/config""api.qobiltu.id/controller/cv""api.qobiltu.id/controller/health_check""api.qobiltu.id/mail""api.qobiltu.id/pkg/storage""api.qobiltu.id/pkg/validation"3 unmodified lines"api.qobiltu.id/services""api.qobiltu.id/utils""github.com/hibiken/asynq""log/slog""net""strconv")func main() {38 unmodified linescvService := services.NewCVService(cvRepository, localStorage)cvController := cv_controller.NewCVController(cvService)// start task processorerr = taskProcessor.Start()utils.FatalIfErr("failed to start task processor", err)3 unmodified liness, err := router.NewServer(healthCheckController,cvController,)utils.FatalIfErr("failed to create server", err)12345678910111213143 unmodified lines18192021222338 unmodified lines626364656667686970713 unmodified lines75767778798081package mainimport ("log/slog""net""strconv""api.qobiltu.id/config"cv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile""api.qobiltu.id/mail""api.qobiltu.id/pkg/storage""api.qobiltu.id/pkg/validation"3 unmodified lines"api.qobiltu.id/services""api.qobiltu.id/utils""github.com/hibiken/asynq")func main() {38 unmodified linescvService := services.NewCVService(cvRepository, localStorage)cvController := cv_controller.NewCVController(cvService)marriageReadinessProfileRepository := repositories.NewMarriageReadinessProfileRepository(config.DB)marriageReadinessProfileService := services.NewMarriageReadinessProfileService(marriageReadinessProfileRepository)marriageReadinessProfileController := marriage_readiness_profile_controller.NewMarriageReadinessProfileController(marriageReadinessProfileService)// start task processorerr = taskProcessor.Start()utils.FatalIfErr("failed to start task processor", err)3 unmodified liness, err := router.NewServer(healthCheckController,cvController,marriageReadinessProfileController,)utils.FatalIfErr("failed to create server", err)
1234567891011121314151617181920212223242526272829303132333435363738package repositories
import ( "context"
"api.qobiltu.id/models" "gorm.io/gorm")
type MarriageReadinessProfileRepository interface { SaveMarriageReadinessProfile(ctx context.Context, req *models.MarriageReadinessProfile) (*models.MarriageReadinessProfile, error) GetMarriageReadinessProfile(ctx context.Context, accountID int64) (*models.MarriageReadinessProfile, error)}
type marriageReadinessProfileRepository struct { db *gorm.DB}
func NewMarriageReadinessProfileRepository(db *gorm.DB) MarriageReadinessProfileRepository { return &marriageReadinessProfileRepository{ db: db, }}
func (r *marriageReadinessProfileRepository) SaveMarriageReadinessProfile(ctx context.Context, req *models.MarriageReadinessProfile) (*models.MarriageReadinessProfile, error) { if err := r.db.WithContext(ctx).Save(req).Error; err != nil { return req, err } return req, nil}
func (r *marriageReadinessProfileRepository) GetMarriageReadinessProfile(ctx context.Context, accountID int64) (*models.MarriageReadinessProfile, error) { var marriageReadinessProfile models.MarriageReadinessProfile if err := r.db.WithContext(ctx).Where("account_id = ?", accountID).First(&marriageReadinessProfile).Error; err != nil { return nil, err } return &marriageReadinessProfile, nil}1234567891011package router
import "api.qobiltu.id/middleware"
func (s *Server) MarriageReadinessProfileRoute() { routerGroup := s.router.Group("/api/v1/marriage-readiness-profile").Use(middleware.AuthUser) { routerGroup.POST("", s.marriageReadinessProfileController.SaveMarriageReadinessProfile) routerGroup.GET("", s.marriageReadinessProfileController.GetMarriageReadinessProfile) }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990package services
import ( "context" "errors"
"api.qobiltu.id/models" "api.qobiltu.id/pkg/validation" "api.qobiltu.id/repositories" "api.qobiltu.id/response" "api.qobiltu.id/utils" "gorm.io/gorm")
type MarriageReadinessProfileService interface { SaveMarriageReadinessProfile(ctx context.Context, req *models.SaveMarriageReadinessProfileRequest) (*models.MarriageReadinessProfile, error) GetMarriageReadinessProfile(ctx context.Context, req *models.GetMarriageReadinessProfileRequest) (*models.MarriageReadinessProfile, error)}
type marriageReadinessProfileService struct { marriageReadinessProfileRepository repositories.MarriageReadinessProfileRepository}
func NewMarriageReadinessProfileService(marriageReadinessProfileRepository repositories.MarriageReadinessProfileRepository) MarriageReadinessProfileService { return &marriageReadinessProfileService{marriageReadinessProfileRepository: marriageReadinessProfileRepository}}
func (s *marriageReadinessProfileService) SaveMarriageReadinessProfile(ctx context.Context, req *models.SaveMarriageReadinessProfileRequest) (*models.MarriageReadinessProfile, error) { if err := validation.Validate(req); err != nil { return nil, response.HandleValidationError(err) }
marriageReadinessProfile, err := s.marriageReadinessProfileRepository.GetMarriageReadinessProfile(ctx, req.AccountID) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { return nil, response.HandleGormError(err, "Internal Server Error") }
if marriageReadinessProfile == nil { marriageReadinessProfile = &models.MarriageReadinessProfile{} }
marriageReadinessProfile.AccountID = req.AccountID
utils.AssignIfNotNil(&marriageReadinessProfile.MarriageVision, req.MarriageVision) utils.AssignIfNotNil(&marriageReadinessProfile.LivingPlan, req.LivingPlan) utils.AssignIfNotNil(&marriageReadinessProfile.SpouseRoles, req.SpouseRoles) utils.AssignIfNotNil(&marriageReadinessProfile.SpouseRights, req.SpouseRights) utils.AssignIfNotNil(&marriageReadinessProfile.ConflictResolution, req.ConflictResolution) utils.AssignIfNotNil(&marriageReadinessProfile.ParentingStyle, req.ParentingStyle)
utils.AssignIfNotNil(&marriageReadinessProfile.ReadyToMarryDuration, req.ReadyToMarryDuration) utils.AssignIfNotNil(&marriageReadinessProfile.WeddingConcept, req.WeddingConcept) utils.AssignIfNotNil(&marriageReadinessProfile.WeddingFunding, req.WeddingFunding)
utils.AssignIfNotNil(&marriageReadinessProfile.CareerAfterMarriage, req.CareerAfterMarriage) utils.AssignIfNotNil(&marriageReadinessProfile.TimeManagement, req.TimeManagement) utils.AssignIfNotNil(&marriageReadinessProfile.CareerGoals, req.CareerGoals) utils.AssignIfNotNil(&marriageReadinessProfile.SelfDevelopment, req.SelfDevelopment)
utils.AssignIfNotNil(&marriageReadinessProfile.DelayChildren, req.DelayChildren) utils.AssignIfNotNil(&marriageReadinessProfile.ChildEducationPlan, req.ChildEducationPlan) utils.AssignIfNotNil(&marriageReadinessProfile.ReligiousEmotionalBond, req.ReligiousEmotionalBond) utils.AssignIfNotNil(&marriageReadinessProfile.ParentingChallenges, req.ParentingChallenges)
utils.AssignIfNotNil(&marriageReadinessProfile.MonthlyFinance, req.MonthlyFinance) utils.AssignIfNotNil(&marriageReadinessProfile.FamilyResponsibility, req.FamilyResponsibility) utils.AssignIfNotNil(&marriageReadinessProfile.DebtStatus, req.DebtStatus) utils.AssignIfNotNil(&marriageReadinessProfile.FinanceSharing, req.FinanceSharing) utils.AssignIfNotNil(&marriageReadinessProfile.IncomeGapView, req.IncomeGapView)
utils.AssignIfNotNil(&marriageReadinessProfile.DecisionMaking, req.DecisionMaking) utils.AssignIfNotNil(&marriageReadinessProfile.GrowthTogether, req.GrowthTogether) utils.AssignIfNotNil(&marriageReadinessProfile.ParentIntervention, req.ParentIntervention) utils.AssignIfNotNil(&marriageReadinessProfile.HabitResponse, req.HabitResponse)
res, err := s.marriageReadinessProfileRepository.SaveMarriageReadinessProfile(ctx, marriageReadinessProfile) if err != nil { return nil, response.HandleGormError(err, "Internal Server Error") }
return res, nil}
func (s *marriageReadinessProfileService) GetMarriageReadinessProfile(ctx context.Context, req *models.GetMarriageReadinessProfileRequest) (*models.MarriageReadinessProfile, error) { res, err := s.marriageReadinessProfileRepository.GetMarriageReadinessProfile(ctx, req.AccountID) if err != nil { return nil, response.HandleGormError(err, "Internal Server Error") } return res, nil}48 unmodified lines495051525354558 unmodified lines64656667686970717213 unmodified lines868788899091925 unmodified lines989910010110210310410510613 unmodified lines1201211221231241251265 unmodified lines13213313413513613713813914017 unmodified lines1581591601611621631641651661671681691706 unmodified lines17717817918018118218310 unmodified lines19419519619719819920010 unmodified lines2112122132142152162175 unmodified lines22322422522622722822923023113 unmodified lines2452462472482492502515 unmodified lines25725825926026126226326426513 unmodified lines2792802812822832842854 unmodified lines29029129229329429529629729817 unmodified lines3163173183193203213223233243253263273286 unmodified lines33533633733833934034110 unmodified lines35235335435535635735810 unmodified lines3693703713723733743754 unmodified lines38038138238338438538638738817 unmodified lines4064074084094104114124134144154164174186 unmodified lines42542642742842943043110 unmodified lines44244344444544644744810 unmodified lines4594604614624634644654 unmodified lines47047147247347447547647747817 unmodified lines4964974984995005015025035045055065075086 unmodified lines51551651751851952052110 unmodified lines53253353453553653753810 unmodified lines54955055155255355455520 unmodified lines57657757857958058158258358458558648 unmodified linesDeleteAchievement(ctx *gin.Context)UploadProfileImage(ctx *gin.Context)GetProgress(ctx *gin.Context)}type cvController struct {8 unmodified lines// --- Account Details ---func (c *cvController) SaveAccountDetails(ctx *gin.Context) {var req models.AccountDetailsRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.GetAccountDetails(ctx, accountID)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Personality & Preference ---func (c *cvController) SavePersonalityAndPreference(ctx *gin.Context) {var req models.PersonalityAndPreferenceCVRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.GetPersonalityAndPreference(ctx, accountID)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Family Member ---func (c *cvController) CreateFamilyMember(ctx *gin.Context) {var req models.FamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}17 unmodified linesreturn}var req models.FamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}res, err := c.cvService.UpdateFamilyMember(ctx, id, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)list, err := c.cvService.ListFamilyMember(ctx, accountID)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}res, err := c.cvService.GetFamilyMember(ctx, id)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}err = c.cvService.DeleteFamilyMember(ctx, id)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Physical and Health ---func (c *cvController) SavePhysicalAndHealth(ctx *gin.Context) {var req models.PhysicalAndHealthRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.GetPhysicalAndHealth(ctx, accountID)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Worship and Religious Understanding ---func (c *cvController) SaveWorshipAndReligiousUnderstanding(ctx *gin.Context) {var req models.WorshipAndReligiousUnderstandingRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.GetWorshipAndReligiousUnderstanding(ctx, accountID)if err != nil {response.HandleError(ctx, err)return4 unmodified lines// --- Education ---func (c *cvController) CreateEducation(ctx *gin.Context) {var req models.EducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}17 unmodified linesreturn}var req models.EducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}res, err := c.cvService.UpdateEducation(ctx, id, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.ListEducation(ctx, accountID)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}res, err := c.cvService.GetEducation(ctx, id)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}err = c.cvService.DeleteEducation(ctx, id)if err != nil {response.HandleError(ctx, err)return4 unmodified lines// --- Job ---func (c *cvController) CreateJob(ctx *gin.Context) {var req models.JobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}17 unmodified linesreturn}var req models.JobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}res, err := c.cvService.UpdateJob(ctx, id, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.ListJob(ctx, accountID)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}res, err := c.cvService.GetJob(ctx, id)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}err = c.cvService.DeleteJob(ctx, id)if err != nil {response.HandleError(ctx, err)return4 unmodified lines// --- Achievement ---func (c *cvController) CreateAchievement(ctx *gin.Context) {var req models.AchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}17 unmodified linesreturn}var req models.AchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}res, err := c.cvService.UpdateAchievement(ctx, id, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.ListAchievement(ctx, accountID)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}res, err := c.cvService.GetAchievement(ctx, id)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}err = c.cvService.DeleteAchievement(ctx, id)if err != nil {response.HandleError(ctx, err)return20 unmodified linesresponse.HandleSuccess(ctx, http.StatusOK, "Profile image uploaded successfully", res, nil)}func (c *cvController) GetProgress(ctx *gin.Context) {accountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.cvService.GetProgress(ctx, accountID)if err != nil {response.HandleError(ctx, err)return48 unmodified lines495051525354558 unmodified lines6465666768697071727374757613 unmodified lines909192939495969798991005 unmodified lines10610710810911011111211311411511611711813 unmodified lines1321331341351361371381391401411425 unmodified lines14814915015115215315415515615715815916017 unmodified lines1781791801811821831841851861871881891901911921931941951966 unmodified lines20320420520620720820921021121221310 unmodified lines22422522622722822923023123223323410 unmodified lines2452462472482492502512522532542555 unmodified lines26126226326426526626726826927027127227313 unmodified lines2872882892902912922932942952962975 unmodified lines30330430530630730830931031131231331431513 unmodified lines3293303313323333343353363373383394 unmodified lines34434534634734834935035135235335435535617 unmodified lines3743753763773783793803813823833843853863873883893903913926 unmodified lines39940040140240340440540640740840910 unmodified lines42042142242342442542642742842943010 unmodified lines4414424434444454464474484494504514 unmodified lines45645745845946046146246346446546646746817 unmodified lines4864874884894904914924934944954964974984995005015025035046 unmodified lines51151251351451551651751851952052110 unmodified lines53253353453553653753853954054154210 unmodified lines5535545555565575585595605615625634 unmodified lines56856957057157257357457557657757857958017 unmodified lines5985996006016026036046056066076086096106116126136146156166 unmodified lines62362462562662762862963063163263310 unmodified lines64464564664764864965065165265365410 unmodified lines66566666766866967067167267367467520 unmodified lines69669769869970070170270370470570670770870971048 unmodified linesDeleteAchievement(ctx *gin.Context)UploadProfileImage(ctx *gin.Context)GetProgressCV(ctx *gin.Context)}type cvController struct {8 unmodified lines// --- Account Details ---func (c *cvController) SaveAccountDetails(ctx *gin.Context) {var req models.SaveAccountDetailsRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.GetAccountDetailsRequest{AccountID: accountID,}res, err := c.cvService.GetAccountDetails(ctx, &req)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Personality & Preference ---func (c *cvController) SavePersonalityAndPreference(ctx *gin.Context) {var req models.SavePersonalityAndPreferenceRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.GetPersonalityAndPreferenceRequest{AccountID: accountID,}res, err := c.cvService.GetPersonalityAndPreference(ctx, &req)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Family Member ---func (c *cvController) CreateFamilyMember(ctx *gin.Context) {var req models.CreateFamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}17 unmodified linesreturn}var req models.UpdateFamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}req.ID = idres, err := c.cvService.UpdateFamilyMember(ctx, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.ListFamilyMemberRequest{AccountID: accountID,}list, err := c.cvService.ListFamilyMember(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.GetFamilyMemberRequest{ID: id,}res, err := c.cvService.GetFamilyMember(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.DeleteFamilyMemberRequest{ID: id,}err = c.cvService.DeleteFamilyMember(ctx, &req)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Physical and Health ---func (c *cvController) SavePhysicalAndHealth(ctx *gin.Context) {var req models.SavePhysicalAndHealthRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.GetPhysicalAndHealthRequest{AccountID: accountID,}res, err := c.cvService.GetPhysicalAndHealth(ctx, &req)if err != nil {response.HandleError(ctx, err)return5 unmodified lines// --- Worship and Religious Understanding ---func (c *cvController) SaveWorshipAndReligiousUnderstanding(ctx *gin.Context) {var req models.SaveWorshipAndReligiousUnderstandingRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}13 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.GetWorshipAndReligiousUnderstandingRequest{AccountID: accountID,}res, err := c.cvService.GetWorshipAndReligiousUnderstanding(ctx, &req)if err != nil {response.HandleError(ctx, err)return4 unmodified lines// --- Education ---func (c *cvController) CreateEducation(ctx *gin.Context) {var req models.CreateEducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}17 unmodified linesreturn}var req models.UpdateEducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}req.ID = idres, err := c.cvService.UpdateEducation(ctx, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.ListEducationRequest{AccountID: accountID,}res, err := c.cvService.ListEducation(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.GetEducationRequest{ID: id,}res, err := c.cvService.GetEducation(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.DeleteEducationRequest{ID: id,}err = c.cvService.DeleteEducation(ctx, &req)if err != nil {response.HandleError(ctx, err)return4 unmodified lines// --- Job ---func (c *cvController) CreateJob(ctx *gin.Context) {var req models.CreateJobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}17 unmodified linesreturn}var req models.UpdateJobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}req.ID = idres, err := c.cvService.UpdateJob(ctx, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.ListJobRequest{AccountID: accountID,}res, err := c.cvService.ListJob(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.GetJobRequest{ID: id,}res, err := c.cvService.GetJob(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.DeleteJobRequest{ID: id,}err = c.cvService.DeleteJob(ctx, &req)if err != nil {response.HandleError(ctx, err)return4 unmodified lines// --- Achievement ---func (c *cvController) CreateAchievement(ctx *gin.Context) {var req models.CreateAchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}17 unmodified linesreturn}var req models.UpdateAchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}req.ID = idres, err := c.cvService.UpdateAchievement(ctx, &req)if err != nil {response.HandleError(ctx, err)return6 unmodified linesaccountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.ListAchievementRequest{AccountID: accountID,}res, err := c.cvService.ListAchievement(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.GetAchievementRequest{ID: id,}res, err := c.cvService.GetAchievement(ctx, &req)if err != nil {response.HandleError(ctx, err)return10 unmodified linesreturn}req := models.DeleteAchievementRequest{ID: id,}err = c.cvService.DeleteAchievement(ctx, &req)if err != nil {response.HandleError(ctx, err)return20 unmodified linesresponse.HandleSuccess(ctx, http.StatusOK, "Profile image uploaded successfully", res, nil)}func (c *cvController) GetProgressCV(ctx *gin.Context) {accountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.GetProgressCVRequest{AccountID: accountID,}res, err := c.cvService.GetProgressCV(ctx, &req)if err != nil {response.HandleError(ctx, err)return
230 unmodified lines23123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227311 unmodified lines28528628728828929029129229329429529629729829930038 unmodified lines33934034134234334424 unmodified lines369370371230 unmodified lines}PhysicalAndHealthCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`HeightInCm *int `gorm:"column:height_cm" json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `gorm:"column:weight_kg" json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `gorm:"column:body_shape" json:"body_shape"` // Bentuk tubuhSkinColor *string `gorm:"column:skin_color" json:"skin_color"` // Warna kulitHairType *string `gorm:"column:hair_type" json:"hair_type"` // Tipe rambutMedicalHistory *string `gorm:"column:medical_history" json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `gorm:"column:physical_disorder" json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `gorm:"column:physical_traits" json:"physical_traits"` // Ciri khas fisikCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // Waktu data dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // Waktu data terakhir diperbaruiFieldCounter}WorshipAndReligiousUnderstandingCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`ObligatoryPrayer *string `gorm:"column:obligatory_prayer" json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `gorm:"column:congregational_prayer" json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `gorm:"column:tahajjud_prayer" json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `gorm:"column:dhuha_prayer" json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `gorm:"column:quran_memorization" json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `gorm:"column:quran_reading_ability" json:"quran_reading_ability"` // kemampuan_baca_alquranDaudFasting *string `gorm:"column:daud_fasting" json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `gorm:"column:ayyamul_bidh_fasting" json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah pq.StringArray `gorm:"column:hajj_or_umrah;type:varchar(255)[]" json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `gorm:"column:listening_to_music" json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `gorm:"column:opinion_on_ikhtilat" json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `gorm:"column:opinion_on_touching_non_mahram" json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `gorm:"column:opinion_on_veil" json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `gorm:"column:weekly_religious_studies" json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `gorm:"column:followed_ustadz" json:"followed_ustadz"` // ustadz_yang_diikutiCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`FieldCounter}11 unmodified lines}JobCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunInstitutionName *string `gorm:"column:institution_name" json:"institution_name"` // nama instansiCurrentJob *string `gorm:"column:current_job" json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `gorm:"column:year_started_working" json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `gorm:"column:monthly_income" json:"monthly_income"` // penghasilan per bulanIncomeSources pq.StringArray `gorm:"column:income_sources;type:varchar(255)[]" json:"income_sources"` // sumber penghasilanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // tanggal diperbarui}AchievementCV struct {38 unmodified linesreturn w.FieldCounter.GetFilledFields(w)}// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }24 unmodified linesfunc (EducationCV) TableName() string { return "education_cv" }func (JobCV) TableName() string { return "job_cv" }func (AchievementCV) TableName() string { return "achievement_cv" }230 unmodified lines23123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227311 unmodified lines28528628728828929029129229329429529629729829930038 unmodified lines33934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239324 unmodified lines418419420421422423230 unmodified lines}PhysicalAndHealthCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`HeightInCm *int `gorm:"column:height_cm" json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `gorm:"column:weight_kg" json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `gorm:"column:body_shape" json:"body_shape"` // Bentuk tubuhSkinColor *string `gorm:"column:skin_color" json:"skin_color"` // Warna kulitHairType *string `gorm:"column:hair_type" json:"hair_type"` // Tipe rambutMedicalHistory *pq.StringArray `gorm:"column:medical_history;type:varchar(255)[]" json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `gorm:"column:physical_disorder" json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `gorm:"column:physical_traits" json:"physical_traits"` // Ciri khas fisikCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // Waktu data dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // Waktu data terakhir diperbaruiFieldCounter}WorshipAndReligiousUnderstandingCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`ObligatoryPrayer *string `gorm:"column:obligatory_prayer" json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `gorm:"column:congregational_prayer" json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `gorm:"column:tahajjud_prayer" json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `gorm:"column:dhuha_prayer" json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `gorm:"column:quran_memorization" json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `gorm:"column:quran_reading_ability" json:"quran_reading_ability"` // kemampuan_baca_alquranDaudFasting *string `gorm:"column:daud_fasting" json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `gorm:"column:ayyamul_bidh_fasting" json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah *pq.StringArray `gorm:"column:hajj_or_umrah;type:varchar(255)[]" json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `gorm:"column:listening_to_music" json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `gorm:"column:opinion_on_ikhtilat" json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `gorm:"column:opinion_on_touching_non_mahram" json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `gorm:"column:opinion_on_veil" json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `gorm:"column:weekly_religious_studies" json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `gorm:"column:followed_ustadz" json:"followed_ustadz"` // ustadz_yang_diikutiCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`FieldCounter}11 unmodified lines}JobCV struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunInstitutionName *string `gorm:"column:institution_name" json:"institution_name"` // nama instansiCurrentJob *string `gorm:"column:current_job" json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `gorm:"column:year_started_working" json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `gorm:"column:monthly_income" json:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `gorm:"column:income_sources;type:varchar(255)[]" json:"income_sources"` // sumber penghasilanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"` // tanggal dibuatUpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"` // tanggal diperbarui}AchievementCV struct {38 unmodified linesreturn w.FieldCounter.GetFilledFields(w)}type (MarriageReadinessProfile struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AccountID int64 `gorm:"column:account_id;not null;unique" json:"account_id"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"`// Visi Misi Rumah TanggaMarriageVision *string `gorm:"column:marriage_vision" json:"marriage_vision"` // Apa visi dan tujuan utama kamu dalam membangun rumah tangga?LivingPlan *string `gorm:"column:living_plan" json:"living_plan"` // Setelah menikah, kamu berencana tinggal di mana?SpouseRoles *string `gorm:"column:spouse_roles" json:"spouse_roles"` // Menurutmu, apa peran utama suami dan istri dalam rumah tangga?SpouseRights *string `gorm:"column:spouse_rights" json:"spouse_rights"` // Apa saja hak suami dan istri menurutmu?ConflictResolution *string `gorm:"column:conflict_resolution" json:"conflict_resolution"` // Jika terjadi konflik, bagaimana kamu menyikapinya?ParentingStyle *string `gorm:"column:parenting_style" json:"parenting_style"` // Setelah punya anak, pola pengasuhan seperti apa yang kamu inginkan?// Konsep Acara PernikahanReadyToMarryDuration *string `gorm:"column:ready_to_marry_duration" json:"ready_to_marry_duration"` // Setelah taaruf dimulai, berapa lama kamu butuh untuk siap menikah?WeddingConcept *string `gorm:"column:wedding_concept" json:"wedding_concept"` // Seperti apa konsep pernikahan yang kamu harapkan?WeddingFunding *string `gorm:"column:wedding_funding" json:"wedding_funding"` // Apakah kamu sudah mempersiapkan dana pernikahan? Dari mana sumbernya?// Karir KedepannyaCareerAfterMarriage *string `gorm:"column:career_after_marriage" json:"career_after_marriage"` // Apakah kamu ingin tetap bekerja setelah menikah?TimeManagement *string `gorm:"column:time_management" json:"time_management"` // Bagaimana kamu membagi waktu antara keluarga, ibadah, dan pekerjaan?CareerGoals *string `gorm:"column:career_goals" json:"career_goals"` // Apa impian karier atau cita-cita kamu dalam 5 sampai 10 tahun ke depan?SelfDevelopment *string `gorm:"column:self_development" json:"self_development"` // Apa usaha kamu untuk terus mengembangkan diri dan skill?// Pendidikan KeluargaDelayChildren *string `gorm:"column:delay_children" json:"delay_children"` // Apakah kamu berencana menunda memiliki anak?ChildEducationPlan *string `gorm:"column:child_education_plan" json:"child_education_plan"` // Apakah kamu sudah punya rencana pendidikan anak?ReligiousEmotionalBond *string `gorm:"column:religious_emotional_bond" json:"religious_emotional_bond"` // Bagaimana cara menjaga nilai agama & kedekatan emosional dengan anak?ParentingChallenges *string `gorm:"column:parenting_challenges" json:"parenting_challenges"` // Saat menghadapi tantangan pengasuhan, bagaimana kamu menyikapinya?// Finansial KeluargaMonthlyFinance *string `gorm:"column:monthly_finance" json:"monthly_finance"` // Bagaimana kamu mengelola keuangan bulanan?FamilyResponsibility *string `gorm:"column:family_responsibility" json:"family_responsibility"` // Apakah kamu masih punya tanggungan keluarga setelah menikah?DebtStatus *string `gorm:"column:debt_status" json:"debt_status"` // Apakah kamu punya cicilan/utang setelah menikah?FinanceSharing *string `gorm:"column:finance_sharing" json:"finance_sharing"` // Setelah menikah, bagaimana pembagian tanggung jawab keuangan?IncomeGapView *string `gorm:"column:income_gap_view" json:"income_gap_view"` // Pandangan kamu jika istri berpenghasilan lebih besar dari suami?// Keputusan dan KomunikasiDecisionMaking *string `gorm:"column:decision_making" json:"decision_making"` // Dalam mengambil keputusan, kamu lebih mempertimbangkan pasangan atau sendiri?GrowthTogether *string `gorm:"column:growth_together" json:"growth_together"` // Apakah kamu siap berjuang bersama pasangan? Apa saja yang ingin diperjuangkan?ParentIntervention *string `gorm:"column:parent_intervention" json:"parent_intervention"` // Sejauh mana orang tua/mertua boleh ikut campur dalam rumah tangga?HabitResponse *string `gorm:"column:habit_response" json:"habit_response"` // Bagaimana kamu menyikapi kebiasaan pasangan yang kurang kamu sukai?CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`})// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }24 unmodified linesfunc (EducationCV) TableName() string { return "education_cv" }func (JobCV) TableName() string { return "job_cv" }func (AchievementCV) TableName() string { return "achievement_cv" }func (MarriageReadinessProfile) TableName() string {return "marriage_readiness_profile"}
57 unmodified lines585960616263646510 unmodified lines76777879808182832 unmodified lines86878889909192939495969798991001011021031046 unmodified lines1111121131141151161171181191201211221231241251261271281291301311321331341351361371 unmodified line1391401411421431441451461471481491501511521531541551561571583 unmodified lines1621631641651661671685 unmodified lines17417517657 unmodified lines}type (PersonalityAndPreferenceCVRequest struct {AccountID int64 `json:"-"`PositiveTraits *string `json:"positive_traits"` // sifat positifNegativeTraits *string `json:"negative_traits"` // sifat negatifHobbies *string `json:"hobbies"` // hobi10 unmodified linesMonthlyExpenses *string `json:"monthly_expenses" validate:"monthly_expenses"` // pengeluaran per bulan}FamilyMemberRequest struct {AccountID int64 `json:"-"`Role *string `json:"role" validate:"family_role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life_status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // Agama2 unmodified linesAge *int `json:"age"` // Usia}PhysicalAndHealthRequest struct {AccountID int64 `json:"-"`HeightInCm *int `json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `json:"body_shape" validate:"body_shape"` // Bentuk tubuhSkinColor *string `json:"skin_color" validate:"skin_color"` // Warna kulitHairType *string `json:"hair_type" validate:"hair_type"` // Tipe rambutMedicalHistory *string `json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `json:"physical_traits"` // Ciri khas fisik}AccountDetailsRequest struct {AccountID int64 `json:"-"`FullName *string `json:"full_name"`Gender *string `json:"gender" validate:"gender"`6 unmodified linesPhoneNumber *string `json:"phone_number" validate:"phone_number"`}WorshipAndReligiousUnderstandingRequest struct {AccountID int64 `json:"-"`ObligatoryPrayer *string `json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `json:"quran_reading_ability" validate:"quran_reading_ability"` // kemampuan_baca_alquranDaudFasting *string `json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah pq.StringArray `json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `json:"followed_ustadz"` // ustadz_yang_diikuti}EducationRequest struct {AccountID int64 `json:"account_id"`LastEducation *string `json:"last_education" validate:"last_education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikan1 unmodified lineYearGraduate *int `json:"year_graduate"` // tahun lulus}JobRequest struct {AccountID int64 `json:"account_id"`InstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly_income"` // penghasilan per bulanIncomeSources pq.StringArray `json:"income_sources"` // sumber penghasilan}AchievementRequest struct {AccountID int64 `json:"account_id"`AchievementOrAward *string `json:"achievement_or_award"` // prestasi atau penghargaan}UploadProfileImageRequest struct {AccountID int64File *multipart.FileHeader3 unmodified linesURL string `json:"url"`}ProgressResponse struct {AccountDetailsProgress float64 `json:"account_details_progress"`PersonalityAndPreferenceCVProgress float64 `json:"personality_and_preference_cv_progress"`FamilyMemberCVProgress float64 `json:"family_member_cv_progress"`5 unmodified linesTotalProgress float64 `json:"total_progress"`})57 unmodified lines58596061626364656610 unmodified lines77787980818283848586878889909192939495969798991001012 unmodified lines1041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371386 unmodified lines1451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891 unmodified line1911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612623 unmodified lines2662672682692702712722732742752765 unmodified lines28228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933057 unmodified lines}type (SavePersonalityAndPreferenceRequest struct {AccountID int64 `json:"-"`PositiveTraits *string `json:"positive_traits"` // sifat positifNegativeTraits *string `json:"negative_traits"` // sifat negatifHobbies *string `json:"hobbies"` // hobi10 unmodified linesMonthlyExpenses *string `json:"monthly_expenses" validate:"monthly_expenses"` // pengeluaran per bulan}GetPersonalityAndPreferenceRequest struct {AccountID int64 `json:"-"`}CreateFamilyMemberRequest struct {AccountID int64 `json:"-"`Role *string `json:"role" validate:"family_role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life_status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // AgamaJob *string `json:"job"` // PekerjaanLastEducation *string `json:"last_education" validate:"last_education"` // Pendidikan terakhirAge *int `json:"age"` // Usia}UpdateFamilyMemberRequest struct {ID int64 `json:"-"`AccountID int64 `json:"-"`Role *string `json:"role" validate:"family_role"` // Peran dalam keluargaStatus *string `json:"status" validate:"life_status"` // Status (Hidup, Wafat)Religion *string `json:"religion" validate:"religion"` // Agama2 unmodified linesAge *int `json:"age"` // Usia}ListFamilyMemberRequest struct {AccountID int64 `json:"-"`}GetFamilyMemberRequest struct {ID int64 `json:"-"`}DeleteFamilyMemberRequest struct {ID int64 `json:"-"`}SavePhysicalAndHealthRequest struct {AccountID int64 `json:"-"`HeightInCm *int `json:"height_cm"` // Tinggi badan dalam satuan sentimeterWeightInKg *int `json:"weight_kg"` // Berat badan dalam satuan kilogramBodyShape *string `json:"body_shape" validate:"body_shape"` // Bentuk tubuhSkinColor *string `json:"skin_color" validate:"skin_color"` // Warna kulitHairType *string `json:"hair_type" validate:"hair_type"` // Tipe rambutMedicalHistory *pq.StringArray `json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `json:"physical_traits"` // Ciri khas fisik}GetPhysicalAndHealthRequest struct {AccountID int64 `json:"-"`}SaveAccountDetailsRequest struct {AccountID int64 `json:"-"`FullName *string `json:"full_name"`Gender *string `json:"gender" validate:"gender"`6 unmodified linesPhoneNumber *string `json:"phone_number" validate:"phone_number"`}GetAccountDetailsRequest struct {AccountID int64 `json:"account_id"`}SaveWorshipAndReligiousUnderstandingRequest struct {AccountID int64 `json:"-"`ObligatoryPrayer *string `json:"obligatory_prayer"` // sholat_wajib_5_waktuCongregationalPrayer *string `json:"congregational_prayer"` // sholat_berjamaah_di_masjidTahajjudPrayer *string `json:"tahajjud_prayer"` // sholat_tahajudDhuhaPrayer *string `json:"dhuha_prayer"` // sholat_dhuhaQuranMemorization *string `json:"quran_memorization"` // hafalan_alquranQuranReadingAbility *string `json:"quran_reading_ability" validate:"quran_reading_ability"` // kemampuan_baca_alquranDaudFasting *string `json:"daud_fasting"` // puasa_daudAyyamulBidhFasting *string `json:"ayyamul_bidh_fasting"` // puasa_ayyamul_bidhHajjOrUmrah *pq.StringArray `json:"hajj_or_umrah"` // ibadah_haji_umrohListeningToMusic *string `json:"listening_to_music"` // mendengarkan_musikOpinionOnIkhtilat *string `json:"opinion_on_ikhtilat"` // pendapat_ikhtilatOpinionOnTouchingNonMahram *string `json:"opinion_on_touching_non_mahram"` // pendapat_menyentuh_non_mahramOpinionOnVeil *string `json:"opinion_on_veil"` // pendapat_tentang_cadarWeeklyReligiousStudies *string `json:"weekly_religious_studies"` // kajian_yang_diikuti_dalam_sepekanFollowedUstadz *string `json:"followed_ustadz"` // ustadz_yang_diikuti}GetWorshipAndReligiousUnderstandingRequest struct {AccountID int64 `json:"-"`}CreateEducationRequest struct {AccountID int64 `json:"-"`LastEducation *string `json:"last_education" validate:"last_education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikanYearStart *int `json:"year_start"` // tahun masukYearGraduate *int `json:"year_graduate"` // tahun lulus}UpdateEducationRequest struct {ID int64 `json:"-"`AccountID int64 `json:"-"`LastEducation *string `json:"last_education" validate:"last_education"` // pendidikan terakhirEducationInstitute *string `json:"education_institute"` // institusi pendidikanEducationMajor *string `json:"education_major"` // jurusan pendidikan1 unmodified lineYearGraduate *int `json:"year_graduate"` // tahun lulus}ListEducationRequest struct {AccountID int64 `json:"-"`}GetEducationRequest struct {ID int64 `json:"-"`}DeleteEducationRequest struct {ID int64 `json:"-"`}CreateJobRequest struct {AccountID int64 `json:"account_id"`InstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `json:"income_sources"` // sumber penghasilan}UpdateJobRequest struct {ID int64 `json:"-"`AccountID int64 `json:"-"`InstitutionName *string `json:"institution_name"` // nama instansiCurrentJob *string `json:"current_job"` // pekerjaan saat iniYearStartedWorking *int `json:"year_started_working"` // tahun mulai bekerjaMonthlyIncome *string `json:"monthly_income" validate:"monthly_income"` // penghasilan per bulanIncomeSources *pq.StringArray `json:"income_sources"` // sumber penghasilan}ListJobRequest struct {AccountID int64 `json:"-"`}GetJobRequest struct {ID int64 `json:"-"`}DeleteJobRequest struct {ID int64 `json:"-"`}CreateAchievementRequest struct {AccountID int64 `json:"account_id"`AchievementOrAward *string `json:"achievement_or_award"` // prestasi atau penghargaan}UpdateAchievementRequest struct {ID int64 `json:"-"`AccountID int64 `json:"-"`AchievementOrAward *string `json:"achievement_or_award"` // prestasi atau penghargaan}ListAchievementRequest struct {AccountID int64 `json:"-"`}GetAchievementRequest struct {ID int64 `json:"-"`}DeleteAchievementRequest struct {ID int64 `json:"-"`}UploadProfileImageRequest struct {AccountID int64File *multipart.FileHeader3 unmodified linesURL string `json:"url"`}GetProgressCVRequest struct {AccountID int64 `json:"-"`}GetProgressCVResponse struct {AccountDetailsProgress float64 `json:"account_details_progress"`PersonalityAndPreferenceCVProgress float64 `json:"personality_and_preference_cv_progress"`FamilyMemberCVProgress float64 `json:"family_member_cv_progress"`5 unmodified linesTotalProgress float64 `json:"total_progress"`})type SaveMarriageReadinessProfileRequest struct {AccountID int64 `json:"account_id"`// Visi Misi Rumah TanggaMarriageVision *string `gorm:"column:marriage_vision" json:"marriage_vision"` // Apa visi dan tujuan utama kamu dalam membangun rumah tangga?LivingPlan *string `gorm:"column:living_plan" json:"living_plan"` // Setelah menikah, kamu berencana tinggal di mana?SpouseRoles *string `gorm:"column:spouse_roles" json:"spouse_roles"` // Menurutmu, apa peran utama suami dan istri dalam rumah tangga?SpouseRights *string `gorm:"column:spouse_rights" json:"spouse_rights"` // Apa saja hak suami dan istri menurutmu?ConflictResolution *string `gorm:"column:conflict_resolution" json:"conflict_resolution"` // Jika terjadi konflik, bagaimana kamu menyikapinya?ParentingStyle *string `gorm:"column:parenting_style" json:"parenting_style"` // Setelah punya anak, pola pengasuhan seperti apa yang kamu inginkan?// Konsep Acara PernikahanReadyToMarryDuration *string `gorm:"column:ready_to_marry_duration" json:"ready_to_marry_duration"` // Setelah taaruf dimulai, berapa lama kamu butuh untuk siap menikah?WeddingConcept *string `gorm:"column:wedding_concept" json:"wedding_concept"` // Seperti apa konsep pernikahan yang kamu harapkan?WeddingFunding *string `gorm:"column:wedding_funding" json:"wedding_funding"` // Apakah kamu sudah mempersiapkan dana pernikahan? Dari mana sumbernya?// Karir KedepannyaCareerAfterMarriage *string `gorm:"column:career_after_marriage" json:"career_after_marriage"` // Apakah kamu ingin tetap bekerja setelah menikah?TimeManagement *string `gorm:"column:time_management" json:"time_management"` // Bagaimana kamu membagi waktu antara keluarga, ibadah, dan pekerjaan?CareerGoals *string `gorm:"column:career_goals" json:"career_goals"` // Apa impian karier atau cita-cita kamu dalam 5 sampai 10 tahun ke depan?SelfDevelopment *string `gorm:"column:self_development" json:"self_development"` // Apa usaha kamu untuk terus mengembangkan diri dan skill?// Pendidikan KeluargaDelayChildren *string `gorm:"column:delay_children" json:"delay_children"` // Apakah kamu berencana menunda memiliki anak?ChildEducationPlan *string `gorm:"column:child_education_plan" json:"child_education_plan"` // Apakah kamu sudah punya rencana pendidikan anak?ReligiousEmotionalBond *string `gorm:"column:religious_emotional_bond" json:"religious_emotional_bond"` // Bagaimana cara menjaga nilai agama & kedekatan emosional dengan anak?ParentingChallenges *string `gorm:"column:parenting_challenges" json:"parenting_challenges"` // Saat menghadapi tantangan pengasuhan, bagaimana kamu menyikapinya?// Finansial KeluargaMonthlyFinance *string `gorm:"column:monthly_finance" json:"monthly_finance"` // Bagaimana kamu mengelola keuangan bulanan?FamilyResponsibility *string `gorm:"column:family_responsibility" json:"family_responsibility"` // Apakah kamu masih punya tanggungan keluarga setelah menikah?DebtStatus *string `gorm:"column:debt_status" json:"debt_status"` // Apakah kamu punya cicilan/utang setelah menikah?FinanceSharing *string `gorm:"column:finance_sharing" json:"finance_sharing"` // Setelah menikah, bagaimana pembagian tanggung jawab keuangan?IncomeGapView *string `gorm:"column:income_gap_view" json:"income_gap_view"` // Pandangan kamu jika istri berpenghasilan lebih besar dari suami?// Keputusan dan KomunikasiDecisionMaking *string `gorm:"column:decision_making" json:"decision_making"` // Dalam mengambil keputusan, kamu lebih mempertimbangkan pasangan atau sendiri?GrowthTogether *string `gorm:"column:growth_together" json:"growth_together"` // Apakah kamu siap berjuang bersama pasangan? Apa saja yang ingin diperjuangkan?ParentIntervention *string `gorm:"column:parent_intervention" json:"parent_intervention"` // Sejauh mana orang tua/mertua boleh ikut campur dalam rumah tangga?HabitResponse *string `gorm:"column:habit_response" json:"habit_response"` // Bagaimana kamu menyikapi kebiasaan pasangan yang kurang kamu sukai?}type GetMarriageReadinessProfileRequest struct {AccountID int64 `json:"-"`}
2 unmodified lines345678120 unmodified lines1291301311321331341351361371388 unmodified lines1471481491501511521531541552 unmodified linesimport ("errors""fmt""strings""github.com/go-playground/locales/en"120 unmodified linesif validatorInstance == nil {return []ErrorMessage{{Field: "", Message: "Validator belum diinisialisasi. Panggil validation.New() terlebih dahulu."}}}err := validatorInstance.validate.Struct(s)if err != nil {return TranslateError(err)}return nil}8 unmodified linesreturn nil}errorMessages := make([]ErrorMessage, 0, len(validationErrors))for _, e := range validationErrors {fieldLabel := e.Field()msg, err := validatorInstance.translator.T(e.Tag(), fieldLabel)if err != nil {msg = fieldLabel + " is Invalid"2 unmodified lines3456789120 unmodified lines1301311321331341351361371381391401418 unmodified lines1501511521531541551561571581591601611621631642 unmodified linesimport ("errors""fmt""reflect""strings""github.com/go-playground/locales/en"120 unmodified linesif validatorInstance == nil {return []ErrorMessage{{Field: "", Message: "Validator belum diinisialisasi. Panggil validation.New() terlebih dahulu."}}}err := validatorInstance.validate.Struct(s)if err != nil {return TranslateError(err)}return nil}8 unmodified linesreturn nil}var errorMessages []ErrorMessagefor _, e := range validationErrors {fieldLabel := e.Field()if e.Kind() == reflect.Ptr {continue}msg, err := validatorInstance.translator.T(e.Tag(), fieldLabel)if err != nil {msg = fieldLabel + " is Invalid"
123456789101112131447 unmodified lines6263646566676869707172737475package workerimport ("api.qobiltu.id/assets""bytes""context""encoding/json""fmt""github.com/hibiken/asynq""html/template""log/slog")const (47 unmodified lines}htmlContent := body.String()slog.Info("Sending forgot password email", slog.String("email", payload.EmailAddress))err = p.emailSender.Send(payload.EmailAddress, payload.Subject, htmlContent, payload)if err != nil {return fmt.Errorf("failed to send forgot password email: %w", err)}slog.Info("Forgot password email sent successfully", slog.String("email", payload.EmailAddress))return nil}12345678910111213141547 unmodified lines636465666768697071727374757677package workerimport ("bytes""context""encoding/json""fmt""html/template""time""api.qobiltu.id/assets""github.com/hibiken/asynq")const (47 unmodified lines}htmlContent := body.String()fmt.Println("Sending forgot password email", payload.EmailAddress)start := time.Now()err = p.emailSender.Send(payload.EmailAddress, payload.Subject, htmlContent, payload)if err != nil {return fmt.Errorf("failed to send forgot password email: %w", err)}fmt.Println("Forgot password email sent successfully", payload.EmailAddress)fmt.Println("Time taken", time.Since(start))return nil}
123456789101112131447 unmodified lines6263646566676869707172737475package workerimport ("api.qobiltu.id/assets""bytes""context""encoding/json""fmt""github.com/hibiken/asynq""html/template""log/slog")const (47 unmodified lines}htmlContent := body.String()slog.Info("Sending verification email", slog.String("email", payload.EmailAddress))err = p.emailSender.Send(payload.EmailAddress, payload.Subject, htmlContent, payload)if err != nil {return fmt.Errorf("failed to send verify email: %w", err)}slog.Info("Verification email sent successfully", slog.String("email", payload.EmailAddress))return nil}12345678910111213141547 unmodified lines63646566676869707172737475767778package workerimport ("bytes""context""encoding/json""fmt""html/template""time""api.qobiltu.id/assets""github.com/hibiken/asynq")const (47 unmodified lines}htmlContent := body.String()fmt.Println("Sending verification email", payload.EmailAddress)start := time.Now()err = p.emailSender.Send(payload.EmailAddress, payload.Subject, htmlContent, payload)if err != nil {return fmt.Errorf("failed to send verify email: %w", err)}fmt.Println("Verification email sent successfully", payload.EmailAddress)fmt.Println("Time taken", time.Since(start))return nil}
41 unmodified lines42434445464741 unmodified linesrouterGroup.PUT("/achievements/:id", s.cvController.UpdateAchievement)routerGroup.DELETE("/achievements/:id", s.cvController.DeleteAchievement)routerGroup.GET("/progress", s.cvController.GetProgress)}}41 unmodified lines42434445464741 unmodified linesrouterGroup.PUT("/achievements/:id", s.cvController.UpdateAchievement)routerGroup.DELETE("/achievements/:id", s.cvController.DeleteAchievement)routerGroup.GET("/progress", s.cvController.GetProgressCV)}}
17 unmodified lines181920212217 unmodified lines// another way to register routess.HealthCheckRoute()s.CVRoute()s.StorageRoute()}17 unmodified lines18192021222317 unmodified lines// another way to register routess.HealthCheckRoute()s.CVRoute()s.MarriageReadinessProfileRoute()s.StorageRoute()}
1 unmodified line2345678910111213141516171819202122232425262728291 unmodified lineimport (cv_controller "api.qobiltu.id/controller/cv""api.qobiltu.id/controller/health_check""github.com/gin-gonic/gin")type Server struct {router *gin.EnginehealthCheckController health_check_controller.HealthCheckControllercvController cv_controller.CVController}func NewServer(healthCheckController health_check_controller.HealthCheckController,cvController cv_controller.CVController,) (*Server, error) {router := gin.Default()router.Use(gin.Recovery())server := &Server{healthCheckController: healthCheckController,cvController: cvController,router: router,}server.setupRoutes()1 unmodified line234567891011121314151617181920212223242526272829303132331 unmodified lineimport (cv_controller "api.qobiltu.id/controller/cv"health_check_controller "api.qobiltu.id/controller/health_check"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile""github.com/gin-gonic/gin")type Server struct {router *gin.EnginehealthCheckController health_check_controller.HealthCheckControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController}func NewServer(healthCheckController health_check_controller.HealthCheckController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,) (*Server, error) {router := gin.Default()router.Use(gin.Recovery())server := &Server{healthCheckController: healthCheckController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,router: router,}server.setupRoutes()
10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657588 unmodified lines6768697071727310 unmodified lines84858687888990919293949596979 unmodified lines10710810911011111211311411511611711811912012110 unmodified lines1321331341351361371381391401411421431441451461471481491501513 unmodified lines1551561571581591601611621 unmodified line16416516616716816917012 unmodified lines1831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432441 unmodified line2462472482492502512523 unmodified lines2562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872881 unmodified line2902912922932942952963 unmodified lines3003013023033043053063073083093103113123133143153163173183193204 unmodified lines3253263273283293303313323333343353363373383399 unmodified lines3493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994008 unmodified lines40941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050167 unmodified lines5695705715725735745755761 unmodified line5785795805815825835841 unmodified line5865875885895905915921 unmodified line5945955965975985996001 unmodified line60260360460560660760860961061161261361461561661761861962062162262321 unmodified lines64564664764864965065165265313 unmodified lines66766866967067167267310 unmodified lines"api.qobiltu.id/pkg/validation""api.qobiltu.id/repositories""api.qobiltu.id/response""gorm.io/gorm")type CVService interface {SaveAccountDetails(ctx context.Context, req *models.AccountDetailsRequest) (*models.AccountDetails, error)GetAccountDetails(ctx context.Context, id int64) (*models.AccountDetails, error)SavePersonalityAndPreference(ctx context.Context, req *models.PersonalityAndPreferenceCVRequest) (*models.PersonalityAndPreferenceCV, error)GetPersonalityAndPreference(ctx context.Context, id int64) (*models.PersonalityAndPreferenceCV, error)CreateFamilyMember(ctx context.Context, req *models.FamilyMemberRequest) (*models.FamilyMemberCV, error)UpdateFamilyMember(ctx context.Context, id int64, req *models.FamilyMemberRequest) (*models.FamilyMemberCV, error)ListFamilyMember(ctx context.Context, accountID int64) ([]models.FamilyMemberCV, error)GetFamilyMember(ctx context.Context, id int64) (*models.FamilyMemberCV, error)DeleteFamilyMember(ctx context.Context, id int64) errorSavePhysicalAndHealth(ctx context.Context, req *models.PhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error)GetPhysicalAndHealth(ctx context.Context, id int64) (*models.PhysicalAndHealthCV, error)SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.WorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error)GetWorshipAndReligiousUnderstanding(ctx context.Context, id int64) (*models.WorshipAndReligiousUnderstandingCV, error)CreateEducation(ctx context.Context, req *models.EducationRequest) (*models.EducationCV, error)UpdateEducation(ctx context.Context, id int64, req *models.EducationRequest) (*models.EducationCV, error)ListEducation(ctx context.Context, accountID int64) ([]models.EducationCV, error)GetEducation(ctx context.Context, id int64) (*models.EducationCV, error)DeleteEducation(ctx context.Context, id int64) errorCreateJob(ctx context.Context, req *models.JobRequest) (*models.JobCV, error)UpdateJob(ctx context.Context, id int64, req *models.JobRequest) (*models.JobCV, error)ListJob(ctx context.Context, accountID int64) ([]models.JobCV, error)GetJob(ctx context.Context, id int64) (*models.JobCV, error)DeleteJob(ctx context.Context, id int64) errorCreateAchievement(ctx context.Context, req *models.AchievementRequest) (*models.AchievementCV, error)UpdateAchievement(ctx context.Context, id int64, req *models.AchievementRequest) (*models.AchievementCV, error)ListAchievement(ctx context.Context, accountID int64) ([]models.AchievementCV, error)GetAchievement(ctx context.Context, id int64) (*models.AchievementCV, error)DeleteAchievement(ctx context.Context, id int64) errorUploadProfileImage(ctx context.Context, req *models.UploadProfileImageRequest) (*models.UploadProfileImageResponse, error)GetProgress(ctx context.Context, accountID int64) (*models.ProgressResponse, error)}type cvService struct {8 unmodified lines}}func (s *cvService) SaveAccountDetails(ctx context.Context, req *models.AccountDetailsRequest) (*models.AccountDetails, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}10 unmodified lines}accountDetails.AccountID = uint(req.AccountID)accountDetails.FullName = req.FullNameaccountDetails.Gender = req.GenderaccountDetails.DateOfBirth = req.DateOfBirthaccountDetails.PlaceOfBirth = req.PlaceOfBirthaccountDetails.Domicile = req.DomicileaccountDetails.MaritalStatus = req.MaritalStatusaccountDetails.LastEducation = req.LastEducationaccountDetails.LastJob = req.LastJobif req.PhoneNumber != nil {sanitizedPhone := validation.SanitizePhoneNumber(*req.PhoneNumber)9 unmodified linesreturn res, nil}func (s *cvService) GetAccountDetails(ctx context.Context, id int64) (*models.AccountDetails, error) {res, err := s.cvRepository.GetAccountDetailsByAccountID(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data diri tidak ditemukan")}return res, nil}func (s *cvService) SavePersonalityAndPreference(ctx context.Context, req *models.PersonalityAndPreferenceCVRequest) (*models.PersonalityAndPreferenceCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}10 unmodified lines}personalityAndPreference.AccountID = req.AccountIDpersonalityAndPreference.PositiveTraits = req.PositiveTraitspersonalityAndPreference.NegativeTraits = req.NegativeTraitspersonalityAndPreference.Hobbies = req.HobbiespersonalityAndPreference.LifeGoals = req.LifeGoalspersonalityAndPreference.DailyActivities = req.DailyActivitiespersonalityAndPreference.LeisureActivities = req.LeisureActivitiespersonalityAndPreference.Likes = req.LikespersonalityAndPreference.Dislikes = req.DislikespersonalityAndPreference.StressHandling = req.StressHandlingpersonalityAndPreference.AngerTriggers = req.AngerTriggerspersonalityAndPreference.FavoriteFoodAndDrinks = req.FavoriteFoodAndDrinkspersonalityAndPreference.CanCook = req.CanCookpersonalityAndPreference.TypesOfDishesCooked = req.TypesOfDishesCookedpersonalityAndPreference.MonthlyExpenses = req.MonthlyExpensesres, err := s.cvRepository.SavePersonalityAndPreference(ctx, personalityAndPreference)if err != nil {3 unmodified linesreturn res, nil}func (s *cvService) GetPersonalityAndPreference(ctx context.Context, id int64) (*models.PersonalityAndPreferenceCV, error) {res, err := s.cvRepository.GetPersonalityAndPreferenceByAccountID(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}1 unmodified linereturn res, nil}func (s *cvService) CreateFamilyMember(ctx context.Context, req *models.FamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}12 unmodified lines// Simpan ke repositoryres, err := s.cvRepository.SaveFamilyMember(ctx, familyMember)if err != nil {return nil, response.HandleGormError(err, "Gagal menyimpan anggota keluarga")}return res, nil}func (s *cvService) ListFamilyMember(ctx context.Context, accountID int64) ([]models.FamilyMemberCV, error) {list, err := s.cvRepository.ListFamilyMember(ctx, accountID)if err != nil {return nil, response.HandleGormError(err, "Gagal mengambil daftar anggota keluarga")}return list, nil}func (s *cvService) GetFamilyMember(ctx context.Context, id int64) (*models.FamilyMemberCV, error) {res, err := s.cvRepository.GetFamilyMember(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data anggota keluarga tidak ditemukan")}return res, nil}func (s *cvService) DeleteFamilyMember(ctx context.Context, id int64) error {err := s.cvRepository.DeleteFamilyMember(ctx, id)if err != nil {return response.HandleGormError(err, "Gagal menghapus anggota keluarga")}return nil}func (s *cvService) UpdateFamilyMember(ctx context.Context, id int64, req *models.FamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}existing, err := s.cvRepository.GetFamilyMember(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data anggota keluarga tidak ditemukan")}existing.Role = req.Roleexisting.Status = req.Statusexisting.Religion = req.Religionexisting.Job = req.Jobexisting.LastEducation = req.LastEducationexisting.Age = req.Ageupdated, err := s.cvRepository.SaveFamilyMember(ctx, existing)if err != nil {return nil, response.HandleGormError(err, "Gagal memperbarui anggota keluarga")}return updated, nil}func (s *cvService) SavePhysicalAndHealth(ctx context.Context, req *models.PhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}1 unmodified line// Cek apakah data sudah ada berdasarkan account_idexisting, err := s.cvRepository.GetPhysicalAndHealthByAccountID(ctx, req.AccountID)if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Terjadi kesalahan saat mengambil data fisik dan kesehatan")}// Jika belum ada, buat objek baru3 unmodified lines// Mapping field dari requestexisting.AccountID = req.AccountIDexisting.HeightInCm = req.HeightInCmexisting.WeightInKg = req.WeightInKgexisting.BodyShape = req.BodyShapeexisting.SkinColor = req.SkinColorexisting.HairType = req.HairTypeexisting.MedicalHistory = req.MedicalHistoryexisting.PhysicalDisorder = req.PhysicalDisorderexisting.PhysicalTraits = req.PhysicalTraits// Simpan datares, err := s.cvRepository.SavePhysicalAndHealth(ctx, existing)if err != nil {return nil, response.HandleGormError(err, "Gagal menyimpan data fisik dan kesehatan")}return res, nil}func (s *cvService) GetPhysicalAndHealth(ctx context.Context, id int64) (*models.PhysicalAndHealthCV, error) {res, err := s.cvRepository.GetPhysicalAndHealthByAccountID(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data fisik dan kesehatan tidak ditemukan")}return res, nil}func (s *cvService) SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.WorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}1 unmodified line// Cek apakah data sudah ada berdasarkan account_idworshipAndReligiousUnderstanding, err := s.cvRepository.GetWorshipAndReligiousUnderstandingByAccountID(ctx, req.AccountID)if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Terjadi kesalahan saat mengambil data agama dan pemahaman agama")}// Jika belum ada, buat objek baru3 unmodified lines// Mapping field dari requestworshipAndReligiousUnderstanding.AccountID = req.AccountIDworshipAndReligiousUnderstanding.ObligatoryPrayer = req.ObligatoryPrayerworshipAndReligiousUnderstanding.CongregationalPrayer = req.CongregationalPrayerworshipAndReligiousUnderstanding.TahajjudPrayer = req.TahajjudPrayerworshipAndReligiousUnderstanding.DhuhaPrayer = req.DhuhaPrayerworshipAndReligiousUnderstanding.QuranMemorization = req.QuranMemorizationworshipAndReligiousUnderstanding.QuranReadingAbility = req.QuranReadingAbilityworshipAndReligiousUnderstanding.DaudFasting = req.DaudFastingworshipAndReligiousUnderstanding.AyyamulBidhFasting = req.AyyamulBidhFastingworshipAndReligiousUnderstanding.HajjOrUmrah = req.HajjOrUmrahworshipAndReligiousUnderstanding.ListeningToMusic = req.ListeningToMusicworshipAndReligiousUnderstanding.OpinionOnIkhtilat = req.OpinionOnIkhtilatworshipAndReligiousUnderstanding.OpinionOnTouchingNonMahram = req.OpinionOnTouchingNonMahramworshipAndReligiousUnderstanding.OpinionOnVeil = req.OpinionOnVeilworshipAndReligiousUnderstanding.WeeklyReligiousStudies = req.WeeklyReligiousStudiesworshipAndReligiousUnderstanding.FollowedUstadz = req.FollowedUstadz// Simpan datares, err := s.cvRepository.SaveWorshipAndReligiousUnderstanding(ctx, worshipAndReligiousUnderstanding)4 unmodified linesreturn res, nil}func (s *cvService) GetWorshipAndReligiousUnderstanding(ctx context.Context, id int64) (*models.WorshipAndReligiousUnderstandingCV, error) {res, err := s.cvRepository.GetWorshipAndReligiousUnderstandingByAccountID(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data agama dan pemahaman agama tidak ditemukan")}return res, nil}func (s *cvService) CreateEducation(ctx context.Context, req *models.EducationRequest) (*models.EducationCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}9 unmodified linesres, err := s.cvRepository.SaveEducation(ctx, edu)if err != nil {return nil, response.HandleGormError(err, "Gagal menambahkan data pendidikan")}return res, nil}func (s *cvService) UpdateEducation(ctx context.Context, id int64, req *models.EducationRequest) (*models.EducationCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}edu, err := s.cvRepository.GetEducation(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data pendidikan tidak ditemukan")}edu.LastEducation = req.LastEducationedu.EducationInstitute = req.EducationInstituteedu.EducationMajor = req.EducationMajoredu.YearStart = req.YearStartedu.YearGraduate = req.YearGraduateres, err := s.cvRepository.SaveEducation(ctx, edu)if err != nil {return nil, response.HandleGormError(err, "Gagal memperbarui data pendidikan")}return res, nil}func (s *cvService) ListEducation(ctx context.Context, accountID int64) ([]models.EducationCV, error) {return s.cvRepository.ListEducation(ctx, accountID)}func (s *cvService) GetEducation(ctx context.Context, id int64) (*models.EducationCV, error) {edu, err := s.cvRepository.GetEducation(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data pendidikan tidak ditemukan")}return edu, nil}func (s *cvService) DeleteEducation(ctx context.Context, id int64) error {return s.cvRepository.DeleteEducation(ctx, id)}func (s *cvService) CreateJob(ctx context.Context, req *models.JobRequest) (*models.JobCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}8 unmodified lines}res, err := s.cvRepository.SaveJob(ctx, job)if err != nil {return nil, response.HandleGormError(err, "Gagal menambahkan data pekerjaan")}return res, nil}func (s *cvService) UpdateJob(ctx context.Context, id int64, req *models.JobRequest) (*models.JobCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}job, err := s.cvRepository.GetJob(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data pekerjaan tidak ditemukan")}job.InstitutionName = req.InstitutionNamejob.CurrentJob = req.CurrentJobjob.YearStartedWorking = req.YearStartedWorkingjob.MonthlyIncome = req.MonthlyIncomejob.IncomeSources = req.IncomeSourcesres, err := s.cvRepository.SaveJob(ctx, job)if err != nil {return nil, response.HandleGormError(err, "Gagal memperbarui data pekerjaan")}return res, nil}func (s *cvService) ListJob(ctx context.Context, accountID int64) ([]models.JobCV, error) {return s.cvRepository.ListJob(ctx, accountID)}func (s *cvService) GetJob(ctx context.Context, id int64) (*models.JobCV, error) {job, err := s.cvRepository.GetJob(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data pekerjaan tidak ditemukan")}return job, nil}func (s *cvService) DeleteJob(ctx context.Context, id int64) error {return s.cvRepository.DeleteJob(ctx, id)}func (s *cvService) CreateAchievement(ctx context.Context, req *models.AchievementRequest) (*models.AchievementCV, error) {ach := &models.AchievementCV{AccountID: req.AccountID,AchievementOrAward: req.AchievementOrAward,}res, err := s.cvRepository.SaveAchievement(ctx, ach)if err != nil {return nil, response.HandleGormError(err, "Gagal menambahkan data prestasi")}return res, nil}func (s *cvService) UpdateAchievement(ctx context.Context, id int64, req *models.AchievementRequest) (*models.AchievementCV, error) {ach, err := s.cvRepository.GetAchievement(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data prestasi tidak ditemukan")}ach.AchievementOrAward = req.AchievementOrAwardres, err := s.cvRepository.SaveAchievement(ctx, ach)if err != nil {return nil, response.HandleGormError(err, "Gagal memperbarui data prestasi")}return res, nil}func (s *cvService) ListAchievement(ctx context.Context, accountID int64) ([]models.AchievementCV, error) {return s.cvRepository.ListAchievement(ctx, accountID)}func (s *cvService) GetAchievement(ctx context.Context, id int64) (*models.AchievementCV, error) {ach, err := s.cvRepository.GetAchievement(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Data prestasi tidak ditemukan")}return ach, nil}func (s *cvService) DeleteAchievement(ctx context.Context, id int64) error {return s.cvRepository.DeleteAchievement(ctx, id)}func (s *cvService) UploadProfileImage(ctx context.Context, req *models.UploadProfileImageRequest) (*models.UploadProfileImageResponse, error) {67 unmodified lines}, nil}func (s *cvService) GetProgress(ctx context.Context, accountID int64) (*models.ProgressResponse, error) {accountDetails, err := s.cvRepository.GetAccountDetailsByAccountID(ctx, accountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified lineaccountDetails = &models.AccountDetails{}}personalityAndPreferenceCV, err := s.cvRepository.GetPersonalityAndPreferenceByAccountID(ctx, accountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified linepersonalityAndPreferenceCV = &models.PersonalityAndPreferenceCV{}}physicalAndHealthCV, err := s.cvRepository.GetPhysicalAndHealthByAccountID(ctx, accountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified linephysicalAndHealthCV = &models.PhysicalAndHealthCV{}}worshipAndReligiousUnderstandingCV, err := s.cvRepository.GetWorshipAndReligiousUnderstandingByAccountID(ctx, accountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified lineworshipAndReligiousUnderstandingCV = &models.WorshipAndReligiousUnderstandingCV{}}educationCV, err := s.cvRepository.ListEducation(ctx, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}familyMemberCV, err := s.cvRepository.ListFamilyMember(ctx, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}jobCV, err := s.cvRepository.ListJob(ctx, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}achievementCV, err := s.cvRepository.ListAchievement(ctx, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}21 unmodified linesfamilyMemberCV int,jobCV int,achievementCV int,) *models.ProgressResponse {// fullIfPresent returns 100 if the data is greater than 0, otherwise returns 0fullIfPresent := func(data int) float64 {if data > 0 {return 10013 unmodified linesoverallProgress := (accountDetailsPercentage + personalityAndPreferenceCVPercentage + physicalAndHealthCVPercentage + worshipAndReligiousUnderstandingCVPercentage + educationCVPercentage + familyMemberCVPercentage + jobCVPercentage + achievementCVPercentage) / 8return &models.ProgressResponse{AccountDetailsProgress: math.Round(accountDetailsPercentage*100) / 100,PersonalityAndPreferenceCVProgress: math.Round(personalityAndPreferenceCVPercentage*100) / 100,FamilyMemberCVProgress: math.Round(familyMemberCVPercentage*100) / 100,10 unmodified lines111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758598 unmodified lines68697071727374757610 unmodified lines878889909192939495969798991001019 unmodified lines11111211311411511611711811912012112212312412510 unmodified lines1361371381391401411421431441451461471481491501511521531541551563 unmodified lines1601611621631641651661671 unmodified line16917017117217317417512 unmodified lines1881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482491 unmodified line2512522532542552562573 unmodified lines2612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932941 unmodified line2962972982993003013023 unmodified lines3063073083093103113123133143153163173183193203213223233243253263274 unmodified lines3323333343353363373383393403413423433443453469 unmodified lines3563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064078 unmodified lines41641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750867 unmodified lines5765775785795805815825831 unmodified line5855865875885895905911 unmodified line5935945955965975985991 unmodified line6016026036046056066071 unmodified line60961061161261361461561661761861962062162262362462562662762862963021 unmodified lines65265365465565665765865966013 unmodified lines67467567667767867968010 unmodified lines"api.qobiltu.id/pkg/validation""api.qobiltu.id/repositories""api.qobiltu.id/response""api.qobiltu.id/utils""gorm.io/gorm")type CVService interface {SaveAccountDetails(ctx context.Context, req *models.SaveAccountDetailsRequest) (*models.AccountDetails, error)GetAccountDetails(ctx context.Context, req *models.GetAccountDetailsRequest) (*models.AccountDetails, error)SavePersonalityAndPreference(ctx context.Context, req *models.SavePersonalityAndPreferenceRequest) (*models.PersonalityAndPreferenceCV, error)GetPersonalityAndPreference(ctx context.Context, req *models.GetPersonalityAndPreferenceRequest) (*models.PersonalityAndPreferenceCV, error)CreateFamilyMember(ctx context.Context, req *models.CreateFamilyMemberRequest) (*models.FamilyMemberCV, error)UpdateFamilyMember(ctx context.Context, req *models.UpdateFamilyMemberRequest) (*models.FamilyMemberCV, error)ListFamilyMember(ctx context.Context, req *models.ListFamilyMemberRequest) ([]models.FamilyMemberCV, error)GetFamilyMember(ctx context.Context, req *models.GetFamilyMemberRequest) (*models.FamilyMemberCV, error)DeleteFamilyMember(ctx context.Context, req *models.DeleteFamilyMemberRequest) errorSavePhysicalAndHealth(ctx context.Context, req *models.SavePhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error)GetPhysicalAndHealth(ctx context.Context, req *models.GetPhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error)SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.SaveWorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error)GetWorshipAndReligiousUnderstanding(ctx context.Context, req *models.GetWorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error)CreateEducation(ctx context.Context, req *models.CreateEducationRequest) (*models.EducationCV, error)UpdateEducation(ctx context.Context, req *models.UpdateEducationRequest) (*models.EducationCV, error)ListEducation(ctx context.Context, req *models.ListEducationRequest) ([]models.EducationCV, error)GetEducation(ctx context.Context, req *models.GetEducationRequest) (*models.EducationCV, error)DeleteEducation(ctx context.Context, req *models.DeleteEducationRequest) errorCreateJob(ctx context.Context, req *models.CreateJobRequest) (*models.JobCV, error)UpdateJob(ctx context.Context, req *models.UpdateJobRequest) (*models.JobCV, error)ListJob(ctx context.Context, req *models.ListJobRequest) ([]models.JobCV, error)GetJob(ctx context.Context, req *models.GetJobRequest) (*models.JobCV, error)DeleteJob(ctx context.Context, req *models.DeleteJobRequest) errorCreateAchievement(ctx context.Context, req *models.CreateAchievementRequest) (*models.AchievementCV, error)UpdateAchievement(ctx context.Context, req *models.UpdateAchievementRequest) (*models.AchievementCV, error)ListAchievement(ctx context.Context, req *models.ListAchievementRequest) ([]models.AchievementCV, error)GetAchievement(ctx context.Context, req *models.GetAchievementRequest) (*models.AchievementCV, error)DeleteAchievement(ctx context.Context, req *models.DeleteAchievementRequest) errorUploadProfileImage(ctx context.Context, req *models.UploadProfileImageRequest) (*models.UploadProfileImageResponse, error)GetProgressCV(ctx context.Context, req *models.GetProgressCVRequest) (*models.GetProgressCVResponse, error)}type cvService struct {8 unmodified lines}}func (s *cvService) SaveAccountDetails(ctx context.Context, req *models.SaveAccountDetailsRequest) (*models.AccountDetails, error) {// notes// jika ingin mengubah value wajib kirimkan field beserta value nyaif err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}10 unmodified lines}accountDetails.AccountID = uint(req.AccountID)utils.AssignIfNotNil(&accountDetails.FullName, req.FullName)utils.AssignIfNotNil(&accountDetails.Gender, req.Gender)utils.AssignIfNotNil(&accountDetails.DateOfBirth, req.DateOfBirth)utils.AssignIfNotNil(&accountDetails.PlaceOfBirth, req.PlaceOfBirth)utils.AssignIfNotNil(&accountDetails.Domicile, req.Domicile)utils.AssignIfNotNil(&accountDetails.MaritalStatus, req.MaritalStatus)utils.AssignIfNotNil(&accountDetails.LastEducation, req.LastEducation)utils.AssignIfNotNil(&accountDetails.LastJob, req.LastJob)if req.PhoneNumber != nil {sanitizedPhone := validation.SanitizePhoneNumber(*req.PhoneNumber)9 unmodified linesreturn res, nil}func (s *cvService) GetAccountDetails(ctx context.Context, req *models.GetAccountDetailsRequest) (*models.AccountDetails, error) {res, err := s.cvRepository.GetAccountDetailsByAccountID(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) SavePersonalityAndPreference(ctx context.Context, req *models.SavePersonalityAndPreferenceRequest) (*models.PersonalityAndPreferenceCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}10 unmodified lines}personalityAndPreference.AccountID = req.AccountIDutils.AssignIfNotNil(&personalityAndPreference.PositiveTraits, req.PositiveTraits)utils.AssignIfNotNil(&personalityAndPreference.NegativeTraits, req.NegativeTraits)utils.AssignIfNotNil(&personalityAndPreference.Hobbies, req.Hobbies)utils.AssignIfNotNil(&personalityAndPreference.LifeGoals, req.LifeGoals)utils.AssignIfNotNil(&personalityAndPreference.DailyActivities, req.DailyActivities)utils.AssignIfNotNil(&personalityAndPreference.LeisureActivities, req.LeisureActivities)utils.AssignIfNotNil(&personalityAndPreference.Likes, req.Likes)utils.AssignIfNotNil(&personalityAndPreference.Dislikes, req.Dislikes)utils.AssignIfNotNil(&personalityAndPreference.StressHandling, req.StressHandling)utils.AssignIfNotNil(&personalityAndPreference.AngerTriggers, req.AngerTriggers)utils.AssignIfNotNil(&personalityAndPreference.FavoriteFoodAndDrinks, req.FavoriteFoodAndDrinks)utils.AssignIfNotNil(&personalityAndPreference.CanCook, req.CanCook)utils.AssignIfNotNil(&personalityAndPreference.TypesOfDishesCooked, req.TypesOfDishesCooked)utils.AssignIfNotNil(&personalityAndPreference.MonthlyExpenses, req.MonthlyExpenses)res, err := s.cvRepository.SavePersonalityAndPreference(ctx, personalityAndPreference)if err != nil {3 unmodified linesreturn res, nil}func (s *cvService) GetPersonalityAndPreference(ctx context.Context, req *models.GetPersonalityAndPreferenceRequest) (*models.PersonalityAndPreferenceCV, error) {res, err := s.cvRepository.GetPersonalityAndPreferenceByAccountID(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}1 unmodified linereturn res, nil}func (s *cvService) CreateFamilyMember(ctx context.Context, req *models.CreateFamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}12 unmodified lines// Simpan ke repositoryres, err := s.cvRepository.SaveFamilyMember(ctx, familyMember)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) ListFamilyMember(ctx context.Context, req *models.ListFamilyMemberRequest) ([]models.FamilyMemberCV, error) {list, err := s.cvRepository.ListFamilyMember(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return list, nil}func (s *cvService) GetFamilyMember(ctx context.Context, req *models.GetFamilyMemberRequest) (*models.FamilyMemberCV, error) {res, err := s.cvRepository.GetFamilyMember(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) DeleteFamilyMember(ctx context.Context, req *models.DeleteFamilyMemberRequest) error {err := s.cvRepository.DeleteFamilyMember(ctx, req.ID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}func (s *cvService) UpdateFamilyMember(ctx context.Context, req *models.UpdateFamilyMemberRequest) (*models.FamilyMemberCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}existing, err := s.cvRepository.GetFamilyMember(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}utils.AssignIfNotNil(&existing.Role, req.Role)utils.AssignIfNotNil(&existing.Status, req.Status)utils.AssignIfNotNil(&existing.Religion, req.Religion)utils.AssignIfNotNil(&existing.Job, req.Job)utils.AssignIfNotNil(&existing.LastEducation, req.LastEducation)utils.AssignIfNotNil(&existing.Age, req.Age)updated, err := s.cvRepository.SaveFamilyMember(ctx, existing)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return updated, nil}func (s *cvService) SavePhysicalAndHealth(ctx context.Context, req *models.SavePhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}1 unmodified line// Cek apakah data sudah ada berdasarkan account_idexisting, err := s.cvRepository.GetPhysicalAndHealthByAccountID(ctx, req.AccountID)if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")}// Jika belum ada, buat objek baru3 unmodified lines// Mapping field dari requestexisting.AccountID = req.AccountIDutils.AssignIfNotNil(&existing.HeightInCm, req.HeightInCm)utils.AssignIfNotNil(&existing.WeightInKg, req.WeightInKg)utils.AssignIfNotNil(&existing.BodyShape, req.BodyShape)utils.AssignIfNotNil(&existing.SkinColor, req.SkinColor)utils.AssignIfNotNil(&existing.HairType, req.HairType)utils.AssignIfNotNil(&existing.MedicalHistory, req.MedicalHistory)utils.AssignIfNotNil(&existing.PhysicalDisorder, req.PhysicalDisorder)utils.AssignIfNotNil(&existing.PhysicalTraits, req.PhysicalTraits)// Simpan datares, err := s.cvRepository.SavePhysicalAndHealth(ctx, existing)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) GetPhysicalAndHealth(ctx context.Context, req *models.GetPhysicalAndHealthRequest) (*models.PhysicalAndHealthCV, error) {res, err := s.cvRepository.GetPhysicalAndHealthByAccountID(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) SaveWorshipAndReligiousUnderstanding(ctx context.Context, req *models.SaveWorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}1 unmodified line// Cek apakah data sudah ada berdasarkan account_idworshipAndReligiousUnderstanding, err := s.cvRepository.GetWorshipAndReligiousUnderstandingByAccountID(ctx, req.AccountID)if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")}// Jika belum ada, buat objek baru3 unmodified lines// Mapping field dari requestworshipAndReligiousUnderstanding.AccountID = req.AccountIDutils.AssignIfNotNil(&worshipAndReligiousUnderstanding.ObligatoryPrayer, req.ObligatoryPrayer)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.CongregationalPrayer, req.CongregationalPrayer)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.TahajjudPrayer, req.TahajjudPrayer)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.DhuhaPrayer, req.DhuhaPrayer)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.QuranMemorization, req.QuranMemorization)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.QuranReadingAbility, req.QuranReadingAbility)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.DaudFasting, req.DaudFasting)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.AyyamulBidhFasting, req.AyyamulBidhFasting)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.HajjOrUmrah, req.HajjOrUmrah)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.ListeningToMusic, req.ListeningToMusic)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.OpinionOnIkhtilat, req.OpinionOnIkhtilat)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.OpinionOnTouchingNonMahram, req.OpinionOnTouchingNonMahram)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.OpinionOnVeil, req.OpinionOnVeil)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.WeeklyReligiousStudies, req.WeeklyReligiousStudies)utils.AssignIfNotNil(&worshipAndReligiousUnderstanding.FollowedUstadz, req.FollowedUstadz)// Simpan datares, err := s.cvRepository.SaveWorshipAndReligiousUnderstanding(ctx, worshipAndReligiousUnderstanding)4 unmodified linesreturn res, nil}func (s *cvService) GetWorshipAndReligiousUnderstanding(ctx context.Context, req *models.GetWorshipAndReligiousUnderstandingRequest) (*models.WorshipAndReligiousUnderstandingCV, error) {res, err := s.cvRepository.GetWorshipAndReligiousUnderstandingByAccountID(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) CreateEducation(ctx context.Context, req *models.CreateEducationRequest) (*models.EducationCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}9 unmodified linesres, err := s.cvRepository.SaveEducation(ctx, edu)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) UpdateEducation(ctx context.Context, req *models.UpdateEducationRequest) (*models.EducationCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}edu, err := s.cvRepository.GetEducation(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}utils.AssignIfNotNil(&edu.LastEducation, req.LastEducation)utils.AssignIfNotNil(&edu.EducationInstitute, req.EducationInstitute)utils.AssignIfNotNil(&edu.EducationMajor, req.EducationMajor)utils.AssignIfNotNil(&edu.YearStart, req.YearStart)utils.AssignIfNotNil(&edu.YearGraduate, req.YearGraduate)res, err := s.cvRepository.SaveEducation(ctx, edu)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) ListEducation(ctx context.Context, req *models.ListEducationRequest) ([]models.EducationCV, error) {return s.cvRepository.ListEducation(ctx, req.AccountID)}func (s *cvService) GetEducation(ctx context.Context, req *models.GetEducationRequest) (*models.EducationCV, error) {edu, err := s.cvRepository.GetEducation(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return edu, nil}func (s *cvService) DeleteEducation(ctx context.Context, req *models.DeleteEducationRequest) error {return s.cvRepository.DeleteEducation(ctx, req.ID)}func (s *cvService) CreateJob(ctx context.Context, req *models.CreateJobRequest) (*models.JobCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}8 unmodified lines}res, err := s.cvRepository.SaveJob(ctx, job)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) UpdateJob(ctx context.Context, req *models.UpdateJobRequest) (*models.JobCV, error) {if err := validation.Validate(req); err != nil {return nil, response.HandleValidationError(err)}job, err := s.cvRepository.GetJob(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}utils.AssignIfNotNil(&job.InstitutionName, req.InstitutionName)utils.AssignIfNotNil(&job.CurrentJob, req.CurrentJob)utils.AssignIfNotNil(&job.YearStartedWorking, req.YearStartedWorking)utils.AssignIfNotNil(&job.MonthlyIncome, req.MonthlyIncome)utils.AssignIfNotNil(&job.IncomeSources, req.IncomeSources)res, err := s.cvRepository.SaveJob(ctx, job)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) ListJob(ctx context.Context, req *models.ListJobRequest) ([]models.JobCV, error) {return s.cvRepository.ListJob(ctx, req.AccountID)}func (s *cvService) GetJob(ctx context.Context, req *models.GetJobRequest) (*models.JobCV, error) {job, err := s.cvRepository.GetJob(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return job, nil}func (s *cvService) DeleteJob(ctx context.Context, req *models.DeleteJobRequest) error {return s.cvRepository.DeleteJob(ctx, req.ID)}func (s *cvService) CreateAchievement(ctx context.Context, req *models.CreateAchievementRequest) (*models.AchievementCV, error) {ach := &models.AchievementCV{AccountID: req.AccountID,AchievementOrAward: req.AchievementOrAward,}res, err := s.cvRepository.SaveAchievement(ctx, ach)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) UpdateAchievement(ctx context.Context, req *models.UpdateAchievementRequest) (*models.AchievementCV, error) {ach, err := s.cvRepository.GetAchievement(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}ach.AchievementOrAward = req.AchievementOrAwardres, err := s.cvRepository.SaveAchievement(ctx, ach)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *cvService) ListAchievement(ctx context.Context, req *models.ListAchievementRequest) ([]models.AchievementCV, error) {return s.cvRepository.ListAchievement(ctx, req.AccountID)}func (s *cvService) GetAchievement(ctx context.Context, req *models.GetAchievementRequest) (*models.AchievementCV, error) {ach, err := s.cvRepository.GetAchievement(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return ach, nil}func (s *cvService) DeleteAchievement(ctx context.Context, req *models.DeleteAchievementRequest) error {return s.cvRepository.DeleteAchievement(ctx, req.ID)}func (s *cvService) UploadProfileImage(ctx context.Context, req *models.UploadProfileImageRequest) (*models.UploadProfileImageResponse, error) {67 unmodified lines}, nil}func (s *cvService) GetProgressCV(ctx context.Context, req *models.GetProgressCVRequest) (*models.GetProgressCVResponse, error) {accountDetails, err := s.cvRepository.GetAccountDetailsByAccountID(ctx, req.AccountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified lineaccountDetails = &models.AccountDetails{}}personalityAndPreferenceCV, err := s.cvRepository.GetPersonalityAndPreferenceByAccountID(ctx, req.AccountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified linepersonalityAndPreferenceCV = &models.PersonalityAndPreferenceCV{}}physicalAndHealthCV, err := s.cvRepository.GetPhysicalAndHealthByAccountID(ctx, req.AccountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified linephysicalAndHealthCV = &models.PhysicalAndHealthCV{}}worshipAndReligiousUnderstandingCV, err := s.cvRepository.GetWorshipAndReligiousUnderstandingByAccountID(ctx, req.AccountID)if err != nil {if !errors.Is(err, gorm.ErrRecordNotFound) {return nil, response.HandleGormError(err, "Internal Server Error")1 unmodified lineworshipAndReligiousUnderstandingCV = &models.WorshipAndReligiousUnderstandingCV{}}educationCV, err := s.cvRepository.ListEducation(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}familyMemberCV, err := s.cvRepository.ListFamilyMember(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}jobCV, err := s.cvRepository.ListJob(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}achievementCV, err := s.cvRepository.ListAchievement(ctx, req.AccountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}21 unmodified linesfamilyMemberCV int,jobCV int,achievementCV int,) *models.GetProgressCVResponse {// fullIfPresent mengembalikan 100 jika data lebih dari 0, jika tidak maka mengembalikan 0fullIfPresent := func(data int) float64 {if data > 0 {return 10013 unmodified linesoverallProgress := (accountDetailsPercentage + personalityAndPreferenceCVPercentage + physicalAndHealthCVPercentage + worshipAndReligiousUnderstandingCVPercentage + educationCVPercentage + familyMemberCVPercentage + jobCVPercentage + achievementCVPercentage) / 8return &models.GetProgressCVResponse{AccountDetailsProgress: math.Round(accountDetailsPercentage*100) / 100,PersonalityAndPreferenceCVProgress: math.Round(personalityAndPreferenceCVPercentage*100) / 100,FamilyMemberCVProgress: math.Round(familyMemberCVPercentage*100) / 100,
52 unmodified lines5354555652 unmodified lines}return})}52 unmodified lines5354555657585952 unmodified lines}return})s.Exception = QuizAttemptService.Exceptions.Error = errors.Join(s.Error, QuizAttemptService.Error)return}
12345632 unmodified lines39404142package servicesimport ("api.qobiltu.id/models""api.qobiltu.id/repositories")32 unmodified lines}return})}1234567832 unmodified lines4142434445464748package servicesimport ("errors""api.qobiltu.id/models""api.qobiltu.id/repositories")32 unmodified lines}return})s.Exception = QuizAttemptService.Exceptions.Error = errors.Join(s.Error, QuizAttemptService.Error)return}
123456789101112131415161718192021222324package controller
import (
"strconv"
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func Result(c *gin.Context) {
quizResult := services.QuizResultService{}
quizResultController := controller.Controller[any, models.QuizAttempt, []models.QuizResultResponse]{
Service: &quizResult.Service,
}
quizResultController.HeaderParse(c, func() {
academyId, _ := strconv.Atoi(c.Param("attempt_id"))
quizResult.Constructor.AccountID = uint(quizResultController.AccountData.UserID)
quizResult.Constructor.ID = uint(academyId) | 0
quizResult.Retrieve()
quizResultController.Response(c)
})
}14 unmodified lines15161718192021222314 unmodified linesService: &submitQuiz.Service,}submitQuizController.HeaderParse(c, func() {quizId, _ := strconv.Atoi(c.Param("attempt_id"))submitQuizController.Service.Constructor.ID = uint(quizId)submitQuiz.Create(submitQuizController.AccountData.UserID)submitQuizController.Response(c)})}14 unmodified lines1516171819202122232414 unmodified linesService: &submitQuiz.Service,}submitQuizController.HeaderParse(c, func() {attemptId, _ := strconv.Atoi(c.Param("attempt_id"))submitQuizController.Service.Constructor.ID = uint(attemptId)submitQuizController.Service.Constructor.AccountID = uint(submitQuizController.AccountData.UserID)submitQuiz.Create()submitQuizController.Response(c)})}
151 unmodified lines1521531541551561571581 unmodified line160161162163164165166107 unmodified lines274275276277278279280151 unmodified linesQuizID uint `json:"quiz_id"`Content string `json:"content"`Order int `json:"order"`CorrectAnswer uint `json:"-"`}type Quiz struct {ID uint `gorm:"primaryKey" json:"id"`1 unmodified lineSlug string `json:"slug" gorm:"uniqueIndex" `Title string `json:"title"`Description string `json:"description"`TotalQuestions string `json:"total_questions"`AttemptLimit int `json:"attempt_limit"`TimeLimit int `json:"time_limit"`MinScore int `json:"min_score"`107 unmodified linesID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunLastEducation *string `gorm:"column:last_education" json:"last_education" validate:""` // pendidikan terakhirEducationInstitute *string `gorm:"column:education_institute" json:"education_institute"` // institusi pendidikanEducationMajor *string `gorm:"column:education_major" json:"education_major"` // jurusan pendidikanYearStart *int `gorm:"column:year_start" json:"year_start"` // tahun masuk151 unmodified lines1521531541551561571581591 unmodified line161162163164165166167107 unmodified lines275276277278279280281151 unmodified linesQuizID uint `json:"quiz_id"`Content string `json:"content"`Order int `json:"order"`CorrectAnswer uint `json:"corrent_answer"`Review string `json:"reviews"`}type Quiz struct {ID uint `gorm:"primaryKey" json:"id"`1 unmodified lineSlug string `json:"slug" gorm:"uniqueIndex" `Title string `json:"title"`Description string `json:"description"`TotalQuestions int `json:"total_questions"`AttemptLimit int `json:"attempt_limit"`TimeLimit int `json:"time_limit"`MinScore int `json:"min_score"`107 unmodified linesID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"` // idAccountID int64 `gorm:"column:account_id;not null" json:"account_id"` // id akunAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty"` // relasi ke akunLastEducation *string `gorm:"column:last_education" json:"last_education"` // pendidikan terakhirEducationInstitute *string `gorm:"column:education_institute" json:"education_institute"` // institusi pendidikanEducationMajor *string `gorm:"column:education_major" json:"education_major"` // jurusan pendidikanYearStart *int `gorm:"column:year_start" json:"year_start"` // tahun masuk
main.go-6
models/database_orm_model.go+8-6
models/request_model.go+8-6
router/router.go-1
router/server.go-4
services/partner_criteria_service.go+4-2
space/pkg/validation/validation.go+16-155
space/response/validation.go+19-2
space/services/marriage_readiness_profile_service.go+4-3
space/services/partner_criteria_service.go+4-3
space/space/controller/partner_criteria/partner_criteria_controller.goAdded+66
space/space/main.go+9-3
space/space/models/database_orm_model.go+54-20
space/space/models/request_model.go+112-77
space/space/pkg/validation/custom_rules.go+236-116
space/space/repositories/partner_criteria_repository.goAdded+38
space/space/router/partner_criteria_route.goAdded+11
space/space/router/router.go+1
space/space/router/server.go+4
space/space/services/cv_service.go+16-13
space/space/services/partner_criteria_service.goAdded+77
space/space/space/config/database_connection_config.go+13-2
space/space/space/models/sequence.goAdded+25
space/space/space/repositories/account_repository.go+18
space/space/space/repositories/cv_repository.go+162-146
space/space/space/services/cv_service.go+33-7
space/space/space/services/user_profile_service.go+36-8
space/space/space/space/models/database_orm_model.go+50-50
space/space/space/space/models/field_counter.go+4-19
space/space/space/space/space/config/database_connection_config.go+1
space/space/space/space/space/controller/marriage_readiness_profile/marriage_readiness_profile_controller.goAdded+66
space/space/space/space/space/main.go+12-5
space/space/space/space/space/repositories/marriage_readiness_profile_repository.goAdded+38
space/space/space/space/space/router/marriage_readiness_profile_route.goAdded+11
space/space/space/space/space/services/marriage_readiness_profile_service.goAdded+90
space/space/space/space/space/space/controller/cv/cv_controller.go+171-47
space/space/space/space/space/space/models/database_orm_model.go+95-43
space/space/space/space/space/space/models/request_model.go+199-45
space/space/space/space/space/space/pkg/validation/validation.go+10-1
space/space/space/space/space/space/pkg/worker/task_send_forgot_password_email.go+8-6
space/space/space/space/space/space/pkg/worker/task_send_verify_email.go+8-5
space/space/space/space/space/space/router/cv_route.go+1-1
space/space/space/space/space/space/router/router.go+1
space/space/space/space/space/space/router/server.go+11-7
space/space/space/space/space/space/services/cv_service.go+188-181
space/space/space/space/space/space/space/services/academy_quiz_answer_service.go+3
space/space/space/space/space/space/space/services/academy_quiz_question_service.go+6
space/space/space/space/space/space/space/space/controller/quiz/result_quiz_controller.goAdded+24
space/space/space/space/space/space/space/space/controller/quiz/submit_quiz_controller.go+4-3
space/space/space/space/space/space/space/space/models/database_orm_model.go+4-3