Spaces:
Configuration error
Configuration error
Commit ·
1301478
1
Parent(s): 58a3ab8
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)
- config/database_connection_config.go+1
- controller/marriage_readiness_profile/marriage_readiness_profile_controller.goAdded+66
- main.go+12-5
- models/database_orm_model.go+65-13
- models/request_model.go+55-9
- pkg/worker/task_send_forgot_password_email.go+8-6
- pkg/worker/task_send_verify_email.go+8-5
- repositories/marriage_readiness_profile_repository.goAdded+38
- router/marriage_readiness_profile_route.goAdded+11
- router/router.go+1
- router/server.go+11-7
- services/marriage_readiness_profile_service.goAdded+90
- space/controller/cv/cv_controller.go+171-47
- space/models/database_orm_model.go+95-43
- space/models/request_model.go+199-45
- space/pkg/validation/validation.go+10-1
- space/router/cv_route.go+1-1
- space/services/cv_service.go+188-181
- space/space/repositories/quiz_repository.go+1-1
- space/space/services/academy_quiz_answer_service.go+3
- space/space/services/academy_quiz_question_service.go+6
- space/space/services/academy_quiz_service.go+13-3
- space/space/space/controller/quiz/result_quiz_controller.goAdded+24
- space/space/space/controller/quiz/submit_quiz_controller.go+4-3
- space/space/space/models/database_orm_model.go+4-3
- space/space/space/repositories/academy_repository.go+10
- space/space/space/repositories/quiz_repository.go+12
- space/space/space/router/quiz_route.go+2
- space/space/space/services/academy_quiz_service.go+64-2
- space/space/space/services/academy_service.go+13
- space/space/space/space/.env.example+26-9
- space/space/space/space/space/pkg/validation/custom_rules.go+1-1
- space/space/space/space/space/space/services/cv_service.go+11-13
- space/space/space/space/space/space/space/controller/cv/cv_controller.go+17-2
- space/space/space/space/space/space/space/models/field_counter.goAdded+163
- space/space/space/space/space/space/space/models/request_model.go+12
- space/space/space/space/space/space/space/router/cv_route.go+2
- space/space/space/space/space/space/space/services/cv_service.go+115
- space/space/space/space/space/space/space/space/models/database_orm_model.go+47-9
- space/space/space/space/space/space/space/space/repositories/quiz_repository.go+5-2
- space/space/space/space/space/space/space/space/services/academy_quiz_service.go+1-1
- space/space/space/space/space/space/space/space/space/pkg/validation/custom_rules.go+42
- space/space/space/space/space/space/space/space/space/pkg/validation/validation.go+1
- space/space/space/space/space/space/space/space/space/space/Makefile+9-1
- space/space/space/space/space/space/space/space/space/space/config/config.go+3
- space/space/space/space/space/space/space/space/space/space/controller/cv/cv_controller.go+20
- space/space/space/space/space/space/space/space/space/space/docker-compose.yml+4-7
- space/space/space/space/space/space/space/space/space/space/go.mod+1-1
- space/space/space/space/space/space/space/space/space/space/main.go+8-4
- space/space/space/space/space/space/space/space/space/space/models/exception_model.go+3-1
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)
230 unmodified lines23123223323423523623723823924024124224324424524624724824989 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}89 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 lines23123223323423523623723823924024124224324424524624724824989 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}89 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"}
116 unmodified lines117118119120121122123124125126127128129130131150 unmodified lines282283284116 unmodified lines}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 *string `json:"medical_history"` // Riwayat penyakitPhysicalDisorder *string `json:"physical_disorder"` // Cacat fisikPhysicalTraits *string `json:"physical_traits"` // Ciri khas fisik}GetPhysicalAndHealthRequest struct {150 unmodified linesTotalProgress float64 `json:"total_progress"`})116 unmodified lines117118119120121122123124125126127128129130131150 unmodified lines282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330116 unmodified lines}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 {150 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:"-"`}
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}
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) }}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()
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"
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)}}
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,
128 unmodified lines129130131132133134128 unmodified lines)repo.Transaction.Model(&repo.Constructor).Raw("SELECT quiz_attempt_id,COUNT(*) AS total_questions,SUM(CASE WHEN is_correct = true THEN 1 ELSE 0 END) AS correct_answers,CAST(SUM(CASE WHEN is_correct = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) AS average_score FROM user_answers WHERE quiz_attempt_id = ? GROUP BY quiz_attempt_id", attemptId).Scan(&repo.Result)repo.RowsError = repo.Transaction.Errorrepo.NoRecord = truereturn *repo}128 unmodified lines129130131132133134128 unmodified lines)repo.Transaction.Model(&repo.Constructor).Raw("SELECT quiz_attempt_id,COUNT(*) AS total_questions,SUM(CASE WHEN is_correct = true THEN 1 ELSE 0 END) AS correct_answers,CAST(SUM(CASE WHEN is_correct = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) AS average_score FROM user_answers WHERE quiz_attempt_id = ? GROUP BY quiz_attempt_id", attemptId).Scan(&repo.Result)repo.RowsError = repo.Transaction.Errorrepo.NoRecord = falsereturn *repo}
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}
1 unmodified line23456744 unmodified lines5253545556575868 unmodified lines1271281291301311321331341351361371381391401413 unmodified lines1451461471481491501511 unmodified lineimport ("errors""time""api.qobiltu.id/models"44 unmodified linesfunc CheckUserLatestAttempt(s *AttemptQuizService, latestAttemptRepo repositories.Repository[models.QuizAttempt, models.QuizAttempt], quizRepo repositories.Repository[models.Quiz, models.Quiz], userID uint, next func()) {currentTime := time.Now()if currentTime.After(latestAttemptRepo.Result.DueAt) {s.Exception.IsTimeOut = trues.Exception.Message = "Your latest attempt is timeout!"// Submit68 unmodified linesfunc (s *AttemptQuizService) Create(userID uint) {s.Validate(userID, func(latestAttemptRepo repositories.Repository[models.QuizAttempt, models.QuizAttempt], quizRepo repositories.Repository[models.Quiz, models.Quiz]) {if latestAttemptRepo.Result.FinishedAt != nil {Attempt(s, quizRepo, userID)} else {s.Result = latestAttemptRepo.Result}})}func (s *SubmitQuizService) Create() {quizAttemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.ID, s.Constructor.AccountID)if quizAttemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"3 unmodified linescountScoreRepo := repositories.CountUserAttemptScore(s.Constructor.ID)if countScoreRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"}s.Error = errors.Join(s.Error, countScoreRepo.RowsError)1 unmodified line234567844 unmodified lines5354555657585968 unmodified lines1281291301311321331341351361371381391401411421431441451461471481491501513 unmodified lines1551561571581591601611 unmodified lineimport ("errors""fmt""time""api.qobiltu.id/models"44 unmodified linesfunc CheckUserLatestAttempt(s *AttemptQuizService, latestAttemptRepo repositories.Repository[models.QuizAttempt, models.QuizAttempt], quizRepo repositories.Repository[models.Quiz, models.Quiz], userID uint, next func()) {currentTime := time.Now()if currentTime.After(latestAttemptRepo.Result.DueAt) && latestAttemptRepo.Result.FinishedAt == nil {s.Exception.IsTimeOut = trues.Exception.Message = "Your latest attempt is timeout!"// Submit68 unmodified linesfunc (s *AttemptQuizService) Create(userID uint) {s.Validate(userID, func(latestAttemptRepo repositories.Repository[models.QuizAttempt, models.QuizAttempt], quizRepo repositories.Repository[models.Quiz, models.Quiz]) {if latestAttemptRepo.Result.FinishedAt != nil {if latestAttemptRepo.Result.Score < float64(quizRepo.Result.MinScore) {Attempt(s, quizRepo, userID)} else {s.Result = latestAttemptRepo.Resultreturn}} else {s.Result = latestAttemptRepo.Resultreturn}})}func (s *SubmitQuizService) Create() {fmt.Println(s.Constructor.ID)fmt.Println(s.Constructor.AccountID)quizAttemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.ID, s.Constructor.AccountID)fmt.Println(quizAttemptRepo.Result)if quizAttemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"3 unmodified linescountScoreRepo := repositories.CountUserAttemptScore(s.Constructor.ID)if countScoreRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt result with given user!"}s.Error = errors.Join(s.Error, countScoreRepo.RowsError)
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
92 unmodified lines93949592 unmodified lines)return *repo}92 unmodified lines9394959697989910010110210310410592 unmodified lines)return *repo}func UpdateAcademyMaterialCompletedById(id_material uint) Repository[models.AcademyMaterial, models.AcademyMaterial] {repo := Construct[models.AcademyMaterial, models.AcademyMaterial](models.AcademyMaterial{ID: id_material, IsCompleted: true},)Update(repo)return *repo}// func UpdateAcademyProgressById(id_academy uint)
62 unmodified lines63646566676862 unmodified linesreturn *repo}func CreateAttempt(quizAttempt models.QuizAttempt) Repository[models.QuizAttempt, models.QuizAttempt] {repo := Construct[models.QuizAttempt, models.QuizAttempt](quizAttempt,62 unmodified lines63646566676869707172737475767778798062 unmodified linesreturn *repo}func GetAttemptByUserId(userId uint) Repository[models.QuizAttempt, []models.QuizAttempt] {repo := Construct[models.QuizAttempt, []models.QuizAttempt](models.QuizAttempt{AccountID: userId,},)repo.Transactions(WhereGivenConstructor[models.QuizAttempt, []models.QuizAttempt],Find[models.QuizAttempt, []models.QuizAttempt],)return *repo}func CreateAttempt(quizAttempt models.QuizAttempt) Repository[models.QuizAttempt, models.QuizAttempt] {repo := Construct[models.QuizAttempt, models.QuizAttempt](quizAttempt,
12 unmodified lines13141516171812 unmodified linesrouterGroup.POST("/:academy_id/:quiz_id/attempt", middleware.AuthUser, QuizController.Attempt)routerGroup.GET("/:academy_id/:quiz_id/question", middleware.AuthUser, QuizController.Question)routerGroup.PUT("/:academy_id/:quiz_id/choose-answer", middleware.AuthUser, QuizController.Answer)routerGroup.POST("/submit-attempt/:attempt_id", middleware.AuthUser, QuizController.Submit)}}12 unmodified lines131415161718192012 unmodified linesrouterGroup.POST("/:academy_id/:quiz_id/attempt", middleware.AuthUser, QuizController.Attempt)routerGroup.GET("/:academy_id/:quiz_id/question", middleware.AuthUser, QuizController.Question)routerGroup.PUT("/:academy_id/:quiz_id/choose-answer", middleware.AuthUser, QuizController.Answer)routerGroup.GET("result/:attempt_id", middleware.AuthUser, QuizController.Result)routerGroup.GET("result/", middleware.AuthUser, QuizController.Result)routerGroup.POST("/submit-attempt/:attempt_id", middleware.AuthUser, QuizController.Submit)}}
19 unmodified lines202122232425104 unmodified lines1301311321331341351361371 unmodified line13914014114214314423 unmodified lines16816917019 unmodified linesService[models.Academy, []models.Quiz]}func AuthorizeQuizwithAcademy(s *AttemptQuizService, next func()) {academyRepo := repositories.GetAcademyByID(s.Constructor.AcademyID)s.Error = academyRepo.RowsError104 unmodified lines})}func (s *SubmitQuizService) Create(userID uint) {quizAttemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.ID, userID)if quizAttemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"1 unmodified line}s.Error = errors.Join(s.Error, quizAttemptRepo.RowsError)countScoreRepo := repositories.CountUserAttemptScore(s.Constructor.ID)s.Error = errors.Join(s.Error, countScoreRepo.RowsError)if quizAttemptRepo.Result.FinishedAt == nil {23 unmodified liness.Result = quizRepo.Resultreturn}19 unmodified lines20212223242526272829104 unmodified lines1341351361371381391401411 unmodified line14314414514614714814915015115223 unmodified lines17617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123219 unmodified linesService[models.Academy, []models.Quiz]}type QuizResultService struct {Service[models.QuizAttempt, []models.QuizResultResponse]}func AuthorizeQuizwithAcademy(s *AttemptQuizService, next func()) {academyRepo := repositories.GetAcademyByID(s.Constructor.AcademyID)s.Error = academyRepo.RowsError104 unmodified lines})}func (s *SubmitQuizService) Create() {quizAttemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.ID, s.Constructor.AccountID)if quizAttemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"1 unmodified line}s.Error = errors.Join(s.Error, quizAttemptRepo.RowsError)countScoreRepo := repositories.CountUserAttemptScore(s.Constructor.ID)if countScoreRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"}s.Error = errors.Join(s.Error, countScoreRepo.RowsError)if quizAttemptRepo.Result.FinishedAt == nil {23 unmodified liness.Result = quizRepo.Resultreturn}func (s *QuizResultService) Retrieve() {if s.Constructor.ID != 0 {attemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.ID, s.Constructor.AccountID)s.Error = attemptRepo.RowsErrorif attemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no attempt with given user id"return}if attemptRepo.Result.FinishedAt == nil {s.Exception.Forbidden = trues.Exception.Message = "You have to submit the exam first to see the result!"return}countScoreRepo := repositories.CountUserAttemptScore(s.Constructor.ID)s.Error = errors.Join(s.Error, countScoreRepo.RowsError)if countScoreRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"}s.Result = []models.QuizResultResponse{models.QuizResultResponse{QuizAttempt: attemptRepo.Result,Result: countScoreRepo.Result,},}return} else {allAttemptsRepo := repositories.GetAttemptByUserId(s.Constructor.AccountID)if allAttemptsRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no attempt with given user id!"return}s.Error = allAttemptsRepo.RowsErrorvar arrResult []models.QuizResultResponsefor _, attempt := range allAttemptsRepo.Result {if attempt.FinishedAt != nil {countScoreRepo := repositories.CountUserAttemptScore(attempt.ID)s.Error = errors.Join(s.Error, countScoreRepo.RowsError)if countScoreRepo.NoRecord {continue}arrResult = append(arrResult, models.QuizResultResponse{QuizAttempt: attempt,Result: countScoreRepo.Result,})}}s.Result = arrResultreturn}}
24 unmodified lines252627282930104 unmodified lines13513613724 unmodified linesService[models.AcademyMaterial, models.AcademyContent]}func castAcademyMaterials(academyId uint) []models.AcademyMaterialResponse {var ArrMaterials []models.AcademyMaterialResponseacademyMaterialsRepo := repositories.GetAllAcademyMaterialsByAcademyID(academyId)104 unmodified lines}s.Result = academyContentRepo.Result}24 unmodified lines25262728293031323334104 unmodified lines13914014114214314414514614714814915024 unmodified linesService[models.AcademyMaterial, models.AcademyContent]}type AcademyMarkReadService struct {Service[models.AcademyMaterial, models.Academy]}func castAcademyMaterials(academyId uint) []models.AcademyMaterialResponse {var ArrMaterials []models.AcademyMaterialResponseacademyMaterialsRepo := repositories.GetAllAcademyMaterialsByAcademyID(academyId)104 unmodified lines}s.Result = academyContentRepo.Result}func (s *AcademyMarkReadService) Update() {markReadRepo := repositories.UpdateAcademyMaterialCompletedById(s.Constructor.ID)if markReadRepo.NoRecord {s.Exception.DataNotFound = trues.Error = markReadRepo.RowsErrorreturn}}
123456789DB_HOST =DB_USER =DB_PASSWORD =DB_PORT =DB_NAME =SALT =HOST_ADDRESS =HOST_PORT =LOG_PATH = logs1234567891011121314151617181920212223242526APP_URL=https://api.qobiltu.idENV=productionDB_HOST=dbDB_USER=qobiltuDB_PASSWORD=DB_PORT=DB_NAME=SALT=HOST_ADDRESS=HOST_PORT=LOG_PATH=logsSMTP_SENDER_EMAIL=SMTP_SENDER_PASSWORD=SMTP_HOST=SMTP_PORT=EMAIL_VERIFICATION_DURATION=REDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=REDIS_DB=0REDIS_MIN_IDLE_CONNS=10REDIS_POOL_SIZE=10REDIS_POOL_TIMEOUT=30s
31 unmodified lines3233343536373831 unmodified lines"body_shape": {"Ideal", "Kurus", "Berisi", "Gemuk"},"skin_color": {"Putih", "Kuning Langsat", "Sawo Matang"},"hair_type": {"Lurus", "Bergelombang", "Keriting"},"frequently": {"Selalu", "Sering", "Kadang", "Jarang"},"quran_reading_ability": {"Lancar", "Menengah", "Perlu Bimbingan"},}31 unmodified lines3233343536373831 unmodified lines"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"},}
2 unmodified lines3456789638 unmodified lines6486496506516526536546556566576586596606616626636646656666676686696706716726731 unmodified line6756766776786796806816826832 unmodified linesimport ("context""errors""fmt""math""strconv"638 unmodified linesachievementCV int,) *models.ProgressResponse {exists := func(data int) float64 {if data > 0 {return 100}return 0}fmt.Println("accountDetails", accountDetails.GetFilledFields())fmt.Println("accountDetailsTotal", accountDetails.TotalFields())accountDetailsPercentage := float64(len(accountDetails.GetFilledFields())) / float64(accountDetails.TotalFields()) * 100personalityAndPreferenceCVPercentage := float64(len(personalityAndPreferenceCV.GetFilledFields())) / float64(personalityAndPreferenceCV.TotalFields()) * 100physicalAndHealthCVPercentage := float64(len(physicalAndHealthCV.GetFilledFields())) / float64(physicalAndHealthCV.TotalFields()) * 100worshipAndReligiousUnderstandingCVPercentage := float64(len(worshipAndReligiousUnderstandingCV.GetFilledFields())) / float64(worshipAndReligiousUnderstandingCV.TotalFields()) * 100edicationCVPercentage := exists(educationCV)familyMemberCVPercentage := exists(familyMemberCV)jobCVPercentage := exists(jobCV)achievementCVPercentage := exists(achievementCV)overallProgress := (accountDetailsPercentage + personalityAndPreferenceCVPercentage + physicalAndHealthCVPercentage + worshipAndReligiousUnderstandingCVPercentage + edicationCVPercentage + familyMemberCVPercentage + jobCVPercentage + achievementCVPercentage) / 8return &models.ProgressResponse{AccountDetailsProgress: math.Round(accountDetailsPercentage*100) / 100,1 unmodified lineFamilyMemberCVProgress: math.Round(familyMemberCVPercentage*100) / 100,PhysicalAndHealthCVProgress: math.Round(physicalAndHealthCVPercentage*100) / 100,WorshipAndReligiousUnderstandingCVProgress: math.Round(worshipAndReligiousUnderstandingCVPercentage*100) / 100,EducationCVProgress: math.Round(edicationCVPercentage*100) / 100,JobCVProgress: jobCVPercentage,AchievementCVProgress: achievementCVPercentage,TotalProgress: math.Round(overallProgress*100) / 100,}}2 unmodified lines345678638 unmodified lines6476486496506516526536546556566576586596606616626636646656666676686696706711 unmodified line6736746756766776786796806812 unmodified linesimport ("context""errors""math""strconv"638 unmodified linesachievementCV int,) *models.ProgressResponse {// fullIfPresent returns 100 if the data is greater than 0, otherwise returns 0fullIfPresent := func(data int) float64 {if data > 0 {return 100}return 0}accountDetailsPercentage := float64(len(accountDetails.GetFilledFields())) / float64(accountDetails.TotalFields()) * 100personalityAndPreferenceCVPercentage := float64(len(personalityAndPreferenceCV.GetFilledFields())) / float64(personalityAndPreferenceCV.TotalFields()) * 100physicalAndHealthCVPercentage := float64(len(physicalAndHealthCV.GetFilledFields())) / float64(physicalAndHealthCV.TotalFields()) * 100worshipAndReligiousUnderstandingCVPercentage := float64(len(worshipAndReligiousUnderstandingCV.GetFilledFields())) / float64(worshipAndReligiousUnderstandingCV.TotalFields()) * 100educationCVPercentage := fullIfPresent(educationCV)familyMemberCVPercentage := fullIfPresent(familyMemberCV)jobCVPercentage := fullIfPresent(jobCV)achievementCVPercentage := fullIfPresent(achievementCV)overallProgress := (accountDetailsPercentage + personalityAndPreferenceCVPercentage + physicalAndHealthCVPercentage + worshipAndReligiousUnderstandingCVPercentage + educationCVPercentage + familyMemberCVPercentage + jobCVPercentage + achievementCVPercentage) / 8return &models.ProgressResponse{AccountDetailsProgress: math.Round(accountDetailsPercentage*100) / 100,1 unmodified lineFamilyMemberCVProgress: math.Round(familyMemberCVPercentage*100) / 100,PhysicalAndHealthCVProgress: math.Round(physicalAndHealthCVPercentage*100) / 100,WorshipAndReligiousUnderstandingCVProgress: math.Round(worshipAndReligiousUnderstandingCVPercentage*100) / 100,EducationCVProgress: math.Round(educationCVPercentage*100) / 100,JobCVProgress: math.Round(jobCVPercentage*100) / 100,AchievementCVProgress: math.Round(achievementCVPercentage*100) / 100,TotalProgress: math.Round(overallProgress*100) / 100,}}
1234567891011121334 unmodified lines484950515253519 unmodified lines573574575package cv_controllerimport ("api.qobiltu.id/middleware""api.qobiltu.id/models""api.qobiltu.id/response""api.qobiltu.id/services""github.com/gin-gonic/gin""net/http""strconv")type CVController interface {34 unmodified linesDeleteAchievement(ctx *gin.Context)UploadProfileImage(ctx *gin.Context)}type cvController struct {519 unmodified linesresponse.HandleSuccess(ctx, http.StatusOK, "Profile image uploaded successfully", res, nil)}123456789101112131434 unmodified lines49505152535455519 unmodified lines575576577578579580581582583584585586587588589590package cv_controllerimport ("net/http""strconv""api.qobiltu.id/middleware""api.qobiltu.id/models""api.qobiltu.id/response""api.qobiltu.id/services""github.com/gin-gonic/gin")type CVController interface {34 unmodified linesDeleteAchievement(ctx *gin.Context)UploadProfileImage(ctx *gin.Context)GetProgress(ctx *gin.Context)}type cvController struct {519 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)return}response.HandleSuccess(ctx, http.StatusOK, "Progress retrieved successfully", res, nil)}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163package models
import ( "reflect" "time")
// CounterGetter adalah interface yang menyediakan method untuk menghitung dan mendapatkan fieldtype CounterGetter interface { TotalFields() int GetFilledFields() []string}
// FieldCounter menyediakan fungsionalitas generik penghitungan dan pengecekan field// untuk diembed ke dalam struct laintype FieldCounter struct{}
// 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 keys if 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 fields gormTag := field.Tag.Get("gorm") if len(gormTag) > 0 { // Skip kolom yang auto-increment atau auto-timestamp if gormTag == "primaryKey" || gormTag == "autoIncrement" || gormTag == "autoCreateTime" || gormTag == "autoUpdateTime" { return true } }
return false}
// TotalFields menghitung jumlah total field dalam struct// dengan mengecualikan field internal, metadata, dan embedded FieldCounterfunc (fc FieldCounter) TotalFields(s any) int { t := reflect.TypeOf(s) count := 0
// Jika s adalah pointer, dapatkan elemen yang ditunjuknya if t.Kind() == reflect.Ptr { t = t.Elem() }
// Pastikan kita berurusan dengan struct if t.Kind() != reflect.Struct { return 0 }
// Hitung field yang sesuai dengan kriteria for i := 0; i < t.NumField(); i++ { field := t.Field(i)
// Skip field yang memenuhi kriteria yang ditentukan if shouldSkipField(field) { continue }
count++ }
return count}
// GetFilledFields mengembalikan slice berisi nama field yang telah diisi dengan nilai// (tidak nil, string tidak kosong, int/float tidak 0, dll)func (fc FieldCounter) GetFilledFields(s any) []string { var filledFields []string v := reflect.ValueOf(s)
// Jika s adalah pointer, dapatkan elemen yang ditunjuknya if v.Kind() == reflect.Ptr { if v.IsNil() { return filledFields } v = v.Elem() }
// Pastikan kita berurusan dengan struct if v.Kind() != reflect.Struct { return filledFields }
t := v.Type()
// Loop melalui semua field for i := 0; i < v.NumField(); i++ { field := v.Field(i) fieldType := t.Field(i) fieldName := fieldType.Name
// Skip field yang memenuhi kriteria yang ditentukan if shouldSkipField(fieldType) { continue }
// Cek apakah field diisi berdasarkan tipenya if isFieldFilled(field) { filledFields = append(filledFields, fieldName) } }
return filledFields}
// isFieldFilled memeriksa apakah field memiliki nilai non-zerofunc isFieldFilled(field reflect.Value) bool { // Jika field tidak dapat di-address atau diakses, anggap kosong if !field.IsValid() || !field.CanInterface() { return false }
// Handle untuk pointer if field.Kind() == reflect.Ptr { if field.IsNil() { return false } // Untuk pointer, periksa nilai yang ditunjuk return isFieldFilled(field.Elem()) }
// Cek berdasarkan tipe data switch field.Kind() { case reflect.String: return field.String() != "" case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return field.Int() != 0 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return field.Uint() != 0 case reflect.Float32, reflect.Float64: return field.Float() != 0 case reflect.Bool: return field.Bool() case reflect.Slice, reflect.Map, reflect.Array: return !field.IsNil() && field.Len() > 0 case reflect.Struct: // Perlakuan khusus untuk time.Time if field.Type() == reflect.TypeOf(time.Time{}) { // Anggap time.Time kosong jika zero value atau tahun sangat awal timeVal := field.Interface().(time.Time) return !timeVal.IsZero() && timeVal.Year() > 1 }
// Untuk struct lain, bandingkan dengan zero value return !reflect.DeepEqual(field.Interface(), reflect.Zero(field.Type()).Interface()) case reflect.Interface: return !field.IsNil() default: // Untuk tipe lain, gunakan perbandingan dengan zero value return !field.IsZero() }}160 unmodified lines161162163164160 unmodified linesUploadProfileImageResponse struct {URL string `json:"url"`})160 unmodified lines161162163164165166167168169170171172173174175176160 unmodified linesUploadProfileImageResponse struct {URL 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"`PhysicalAndHealthCVProgress float64 `json:"physical_and_health_cv_progress"`WorshipAndReligiousUnderstandingCVProgress float64 `json:"worship_and_religious_understanding_cv_progress"`EducationCVProgress float64 `json:"education_cv_progress"`JobCVProgress float64 `json:"job_cv_progress"`AchievementCVProgress float64 `json:"achievement_cv_progress"`TotalProgress float64 `json:"total_progress"`})
40 unmodified lines414243444540 unmodified linesrouterGroup.GET("/achievements/:id", s.cvController.GetAchievement)routerGroup.PUT("/achievements/:id", s.cvController.UpdateAchievement)routerGroup.DELETE("/achievements/:id", s.cvController.DeleteAchievement)}}40 unmodified lines4142434445464740 unmodified linesrouterGroup.GET("/achievements/:id", s.cvController.GetAchievement)routerGroup.PUT("/achievements/:id", s.cvController.UpdateAchievement)routerGroup.DELETE("/achievements/:id", s.cvController.DeleteAchievement)routerGroup.GET("/progress", s.cvController.GetProgress)}}
2 unmodified lines34567842 unmodified lines515253545556509 unmodified lines5665675682 unmodified linesimport ("context""errors""strconv""api.qobiltu.id/models"42 unmodified linesDeleteAchievement(ctx context.Context, id int64) errorUploadProfileImage(ctx context.Context, req *models.UploadProfileImageRequest) (*models.UploadProfileImageResponse, error)}type cvService struct {509 unmodified linesURL: url,}, nil}2 unmodified lines34567891042 unmodified lines53545556575859509 unmodified lines5695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826832 unmodified linesimport ("context""errors""fmt""math""strconv""api.qobiltu.id/models"42 unmodified linesDeleteAchievement(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 {509 unmodified linesURL: url,}, 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")}accountDetails = &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")}personalityAndPreferenceCV = &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")}physicalAndHealthCV = &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")}worshipAndReligiousUnderstandingCV = &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")}progressDetails := calculateProgress(accountDetails,personalityAndPreferenceCV,physicalAndHealthCV,worshipAndReligiousUnderstandingCV,len(educationCV),len(familyMemberCV),len(jobCV),len(achievementCV),)return progressDetails, nil}func calculateProgress(accountDetails *models.AccountDetails,personalityAndPreferenceCV *models.PersonalityAndPreferenceCV,physicalAndHealthCV *models.PhysicalAndHealthCV,worshipAndReligiousUnderstandingCV *models.WorshipAndReligiousUnderstandingCV,educationCV int,familyMemberCV int,jobCV int,achievementCV int,) *models.ProgressResponse {exists := func(data int) float64 {if data > 0 {return 100}return 0}fmt.Println("accountDetails", accountDetails.GetFilledFields())fmt.Println("accountDetailsTotal", accountDetails.TotalFields())accountDetailsPercentage := float64(len(accountDetails.GetFilledFields())) / float64(accountDetails.TotalFields()) * 100personalityAndPreferenceCVPercentage := float64(len(personalityAndPreferenceCV.GetFilledFields())) / float64(personalityAndPreferenceCV.TotalFields()) * 100physicalAndHealthCVPercentage := float64(len(physicalAndHealthCV.GetFilledFields())) / float64(physicalAndHealthCV.TotalFields()) * 100worshipAndReligiousUnderstandingCVPercentage := float64(len(worshipAndReligiousUnderstandingCV.GetFilledFields())) / float64(worshipAndReligiousUnderstandingCV.TotalFields()) * 100edicationCVPercentage := exists(educationCV)familyMemberCVPercentage := exists(familyMemberCV)jobCVPercentage := exists(jobCV)achievementCVPercentage := exists(achievementCV)overallProgress := (accountDetailsPercentage + personalityAndPreferenceCVPercentage + physicalAndHealthCVPercentage + worshipAndReligiousUnderstandingCVPercentage + edicationCVPercentage + familyMemberCVPercentage + jobCVPercentage + achievementCVPercentage) / 8return &models.ProgressResponse{AccountDetailsProgress: math.Round(accountDetailsPercentage*100) / 100,PersonalityAndPreferenceCVProgress: math.Round(personalityAndPreferenceCVPercentage*100) / 100,FamilyMemberCVProgress: math.Round(familyMemberCVPercentage*100) / 100,PhysicalAndHealthCVProgress: math.Round(physicalAndHealthCVPercentage*100) / 100,WorshipAndReligiousUnderstandingCVProgress: math.Round(worshipAndReligiousUnderstandingCVPercentage*100) / 100,EducationCVProgress: math.Round(edicationCVPercentage*100) / 100,JobCVProgress: jobCVPercentage,AchievementCVProgress: achievementCVPercentage,TotalProgress: math.Round(overallProgress*100) / 100,}}
33 unmodified lines343536373839114 unmodified lines15415515615715815916016116216316416516616716840 unmodified lines2092102112122132148 unmodified lines22322422522622722810 unmodified lines23924024124224324417 unmodified lines26226326426526626732 unmodified lines30030130230330430533 unmodified linesPhoneNumber *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"`}type EmailVerification struct {114 unmodified linesCorrectAnswer uint `json:"-"`}type Quiz struct {ID uint `gorm:"primaryKey" json:"id"`AcademyID uint `json:"academy_id"`Slug string `json:"slug" gorm:"uniqueIndex" `Title string `json:"title"`Description string `json:"description"`AttemptLimit int `json:"attempt_limit"`TimeLimit int `json:"time_limit"`MinScore int `json:"min_score"`CreatedAt time.Time `json:"created_at"`}type QuizAttempt struct {40 unmodified linesMonthlyExpenses *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"`}FamilyMemberCV struct {8 unmodified linesAge *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"`}PhysicalAndHealthCV struct {10 unmodified linesPhysicalTraits *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 diperbarui}WorshipAndReligiousUnderstandingCV struct {17 unmodified linesFollowedUstadz *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"`}EducationCV struct {32 unmodified lines})// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }33 unmodified lines34353637383940114 unmodified lines15515615715815916016116216316416516616716816917040 unmodified lines2112122132142152162178 unmodified lines22622722822923023123210 unmodified lines24324424524624724824917 unmodified lines26726826927027127227332 unmodified lines30630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234333 unmodified linesPhoneNumber *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}type EmailVerification struct {114 unmodified linesCorrectAnswer uint `json:"-"`}type Quiz struct {ID uint `gorm:"primaryKey" json:"id"`AcademyID uint `json:"academy_id"`Slug 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"`CreatedAt time.Time `json:"created_at"`}type QuizAttempt struct {40 unmodified linesMonthlyExpenses *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 {8 unmodified linesAge *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 {10 unmodified linesPhysicalTraits *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 {17 unmodified linesFollowedUstadz *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 {32 unmodified lines})func (a AccountDetails) TotalFields() int {return a.FieldCounter.TotalFields(a)}func (a AccountDetails) GetFilledFields() []string {return a.FieldCounter.GetFilledFields(a)}func (p PersonalityAndPreferenceCV) TotalFields() int {return p.FieldCounter.TotalFields(p)}func (p PersonalityAndPreferenceCV) GetFilledFields() []string {return p.FieldCounter.GetFilledFields(p)}func (p PhysicalAndHealthCV) TotalFields() int {return p.FieldCounter.TotalFields(p)}func (p PhysicalAndHealthCV) GetFilledFields() []string {return p.FieldCounter.GetFilledFields(p)}func (w WorshipAndReligiousUnderstandingCV) TotalFields() int {return w.FieldCounter.TotalFields(w)}func (w WorshipAndReligiousUnderstandingCV) GetFilledFields() []string {return w.FieldCounter.GetFilledFields(w)}// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }
48 unmodified lines49505152535455565748 unmodified linesreturn *repo}func GetAttemptById(attemptId uint) Repository[models.QuizAttempt, models.QuizAttempt] {repo := Construct[models.QuizAttempt, models.QuizAttempt](models.QuizAttempt{ID: attemptId},)repo.Transactions(WhereGivenConstructor[models.QuizAttempt, models.QuizAttempt],48 unmodified lines49505152535455565758596048 unmodified linesreturn *repo}func GetAttemptByIdandUserId(attemptId uint, userId uint) Repository[models.QuizAttempt, models.QuizAttempt] {repo := Construct[models.QuizAttempt, models.QuizAttempt](models.QuizAttempt{ID: attemptId,AccountID: userId,},)repo.Transactions(WhereGivenConstructor[models.QuizAttempt, models.QuizAttempt],
130 unmodified lines131132133134135136137130 unmodified lines}func (s *SubmitQuizService) Create(userID uint) {quizAttemptRepo := repositories.GetAttemptById(s.Constructor.ID)if quizAttemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"130 unmodified lines131132133134135136137130 unmodified lines}func (s *SubmitQuizService) Create(userID uint) {quizAttemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.ID, userID)if quizAttemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no quiz attempt with given user!"
123456143 unmodified lines1501511521531541554 unmodified lines160161162package validationimport ("strings""sync"143 unmodified linesreturn err}return nil}4 unmodified linesstrings.ContainsAny(password, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") &&strings.ContainsAny(password, "0123456789")}1234567143 unmodified lines1511521531541551561571581591601614 unmodified lines166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204package validationimport ("regexp""strings""sync"143 unmodified linesreturn err}err = validate.RegisterValidation("phone_number", v.PhoneNumberRule)if err != nil {return err}return nil}4 unmodified linesstrings.ContainsAny(password, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") &&strings.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}
78 unmodified lines79808182838478 unmodified linesif err := rules.RegisterAllCustomRules(validate); err != nil {return err}return nil}78 unmodified lines7980818283848578 unmodified linesif err := rules.RegisterAllCustomRules(validate); err != nil {return err}return nil}
1234567up-dev:docker compose -f docker-compose.dev.yml up -drun-dev:go run main.go.PHONY : up-dev run-dev123456789101112131415up-dev:docker compose -f docker-compose.dev.yml up -ddown-dev:docker compose -f docker-compose.dev.yml downup:docker compose up -d --builddown:docker compose downrun-dev:go run main.go.PHONY : up-dev run-dev down-dev up down
28 unmodified lines29303132333414 unmodified lines49505152535428 unmodified linesvar REDIS_POOL_SIZE intvar REDIS_POOL_TIMEOUT time.Durationfunc init() {godotenv.Load()ENV = os.Getenv("ENV")14 unmodified linesREDIS_POOL_SIZE = getValue(os.Getenv("REDIS_POOL_SIZE"), 10, func(s string) (int, error) { return strconv.Atoi(s) })REDIS_MIN_IDLE_CONNS = getValue(os.Getenv("REDIS_MIN_IDLE_CONNS"), 10, func(s string) (int, error) { return strconv.Atoi(s) })REDIS_POOL_TIMEOUT = getValue(os.Getenv("REDIS_POOL_TIMEOUT"), time.Second*30, func(s string) (time.Duration, error) { return time.ParseDuration(s) })}func getValue[T any](value string, defaultValue T, convert func(string) (T, error)) T {28 unmodified lines293031323334353614 unmodified lines5152535455565728 unmodified linesvar REDIS_POOL_SIZE intvar REDIS_POOL_TIMEOUT time.Durationvar APP_URL stringfunc init() {godotenv.Load()ENV = os.Getenv("ENV")14 unmodified linesREDIS_POOL_SIZE = getValue(os.Getenv("REDIS_POOL_SIZE"), 10, func(s string) (int, error) { return strconv.Atoi(s) })REDIS_MIN_IDLE_CONNS = getValue(os.Getenv("REDIS_MIN_IDLE_CONNS"), 10, func(s string) (int, error) { return strconv.Atoi(s) })REDIS_POOL_TIMEOUT = getValue(os.Getenv("REDIS_POOL_TIMEOUT"), time.Second*30, func(s string) (time.Duration, error) { return time.ParseDuration(s) })APP_URL = getValue(os.Getenv("APP_URL"), "http://localhost:3000", func(s string) (string, error) { return s, nil })}func getValue[T any](value string, defaultValue T, convert func(string) (T, error)) T {
45 unmodified lines464748495051501 unmodified lines55355455545 unmodified linesListAchievement(ctx *gin.Context)GetAchievement(ctx *gin.Context)DeleteAchievement(ctx *gin.Context)}type cvController struct {501 unmodified linesresponse.HandleSuccess(ctx, http.StatusOK, "Achievement deleted successfully", nil, nil)}45 unmodified lines4647484950515253501 unmodified lines55555655755855956056156256356456556656756856957057157257357457545 unmodified linesListAchievement(ctx *gin.Context)GetAchievement(ctx *gin.Context)DeleteAchievement(ctx *gin.Context)UploadProfileImage(ctx *gin.Context)}type cvController struct {501 unmodified linesresponse.HandleSuccess(ctx, http.StatusOK, "Achievement deleted successfully", nil, nil)}func (c *cvController) UploadProfileImage(ctx *gin.Context) {accountData := middleware.GetAccountData(ctx)avatarFile, _ := ctx.FormFile("avatar")req := models.UploadProfileImageRequest{AccountID: int64(accountData.UserID),File: avatarFile,}res, err := c.cvService.UploadProfileImage(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Profile image uploaded successfully", res, nil)}
5 unmodified lines67891011121314151617181925 unmodified lines454647484950515253545 unmodified linesbuild: .depends_on:- dbenv_file: .envports:- "8080:8080"networks:- qobiltu-network# volumes:# - ./logs:/app/logs# - /home/qobiltu/api-qobiltu:/apprestart: unless-stoppeddb:25 unmodified lines- qobiltu-networkrestart: alwaysvolumes:db-data:redis-data:networks:qobiltu-network:driver: bridge5 unmodified lines6789101112131415161718192025 unmodified lines4647484950515 unmodified linesbuild: .depends_on:- db- redisenv_file: .envports:- "8080:8080"volumes:- ./logs:/app/logs- ./uploads:/app/uploadsnetworks:- qobiltu-networkrestart: unless-stoppeddb:25 unmodified lines- qobiltu-networkrestart: alwaysnetworks:qobiltu-network:driver: bridge
7 unmodified lines891011121323 unmodified lines373839404142437 unmodified linesgithub.com/go-playground/universal-translator v0.18.1github.com/go-playground/validator/v10 v10.25.0github.com/golang-jwt/jwt/v5 v5.2.1github.com/gosimple/slug v1.15.0github.com/hibiken/asynq v0.25.1github.com/joho/godotenv v1.5.123 unmodified linesgithub.com/go-logr/stdr v1.2.2 // indirectgithub.com/goccy/go-json v0.10.5 // indirectgithub.com/google/s2a-go v0.1.9 // indirectgithub.com/google/uuid v1.6.0 // indirectgithub.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirectgithub.com/googleapis/gax-go/v2 v2.14.1 // indirectgithub.com/gosimple/unidecode v1.0.1 // indirect7 unmodified lines89101112131423 unmodified lines3839404142437 unmodified linesgithub.com/go-playground/universal-translator v0.18.1github.com/go-playground/validator/v10 v10.25.0github.com/golang-jwt/jwt/v5 v5.2.1github.com/google/uuid v1.6.0github.com/gosimple/slug v1.15.0github.com/hibiken/asynq v0.25.1github.com/joho/godotenv v1.5.123 unmodified linesgithub.com/go-logr/stdr v1.2.2 // indirectgithub.com/goccy/go-json v0.10.5 // indirectgithub.com/google/s2a-go v0.1.9 // indirectgithub.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirectgithub.com/googleapis/gax-go/v2 v2.14.1 // indirectgithub.com/gosimple/unidecode v1.0.1 // indirect
1 unmodified line23456789101112131415166 unmodified lines23242526272824 unmodified lines535455565758591 unmodified lineimport ("api.qobiltu.id/config"cv_controller "api.qobiltu.id/controller/cv""api.qobiltu.id/controller/health_check""api.qobiltu.id/mail""api.qobiltu.id/repositories""api.qobiltu.id/router""api.qobiltu.id/services""api.qobiltu.id/utils""api.qobiltu.id/validation""api.qobiltu.id/worker""github.com/hibiken/asynq""log/slog""net"6 unmodified lineserr := validation.New(validation.LocaleID)utils.FatalIfErr("failed to setup validator", err)// setup email senderemailConfig := mail.Config{Host: config.SMTP_HOST,24 unmodified lineshealthCheckController := health_check_controller.NewHealthCheckController(healthCheckService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository)cvController := cv_controller.NewCVController(cvService)// start task processor1 unmodified line2345678910111213141516176 unmodified lines24252627282930313224 unmodified lines575859606162631 unmodified lineimport ("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""api.qobiltu.id/pkg/worker""api.qobiltu.id/repositories""api.qobiltu.id/router""api.qobiltu.id/services""api.qobiltu.id/utils""github.com/hibiken/asynq""log/slog""net"6 unmodified lineserr := validation.New(validation.LocaleID)utils.FatalIfErr("failed to setup validator", err)// setup storagelocalStorage := storage.NewLocalStorage("uploads", config.APP_URL+"/storage/")// setup email senderemailConfig := mail.Config{Host: config.SMTP_HOST,24 unmodified lineshealthCheckController := health_check_controller.NewHealthCheckController(healthCheckService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage)cvController := cv_controller.NewCVController(cvService)// start task processor
123456package modelsimport "api.qobiltu.id/validation"type Exception struct {Unauthorized bool `json:"unauthorized,omitempty"`12345678package modelsimport ("api.qobiltu.id/pkg/validation")type Exception struct {Unauthorized bool `json:"unauthorized,omitempty"`
config/database_connection_config.go+1
controller/marriage_readiness_profile/marriage_readiness_profile_controller.goAdded+66
main.go+12-5
models/database_orm_model.go+65-13
models/request_model.go+55-9
pkg/worker/task_send_forgot_password_email.go+8-6
pkg/worker/task_send_verify_email.go+8-5
repositories/marriage_readiness_profile_repository.goAdded+38
router/marriage_readiness_profile_route.goAdded+11
router/router.go+1
router/server.go+11-7
services/marriage_readiness_profile_service.goAdded+90
space/controller/cv/cv_controller.go+171-47
space/models/database_orm_model.go+95-43
space/models/request_model.go+199-45
space/pkg/validation/validation.go+10-1
space/router/cv_route.go+1-1
space/services/cv_service.go+188-181
space/space/repositories/quiz_repository.go+1-1
space/space/services/academy_quiz_answer_service.go+3
space/space/services/academy_quiz_question_service.go+6
space/space/services/academy_quiz_service.go+13-3
space/space/space/controller/quiz/result_quiz_controller.goAdded+24
space/space/space/controller/quiz/submit_quiz_controller.go+4-3
space/space/space/models/database_orm_model.go+4-3
space/space/space/repositories/academy_repository.go+10
space/space/space/repositories/quiz_repository.go+12
space/space/space/router/quiz_route.go+2
space/space/space/services/academy_quiz_service.go+64-2
space/space/space/services/academy_service.go+13
space/space/space/space/.env.example+26-9
space/space/space/space/space/pkg/validation/custom_rules.go+1-1
space/space/space/space/space/space/services/cv_service.go+11-13
space/space/space/space/space/space/space/controller/cv/cv_controller.go+17-2
space/space/space/space/space/space/space/models/field_counter.goAdded+163
space/space/space/space/space/space/space/models/request_model.go+12
space/space/space/space/space/space/space/router/cv_route.go+2
space/space/space/space/space/space/space/services/cv_service.go+115
space/space/space/space/space/space/space/space/models/database_orm_model.go+47-9
space/space/space/space/space/space/space/space/repositories/quiz_repository.go+5-2
space/space/space/space/space/space/space/space/services/academy_quiz_service.go+1-1
space/space/space/space/space/space/space/space/space/pkg/validation/custom_rules.go+42
space/space/space/space/space/space/space/space/space/pkg/validation/validation.go+1
space/space/space/space/space/space/space/space/space/space/Makefile+9-1
space/space/space/space/space/space/space/space/space/space/config/config.go+3
space/space/space/space/space/space/space/space/space/space/controller/cv/cv_controller.go+20
space/space/space/space/space/space/space/space/space/space/docker-compose.yml+4-7
space/space/space/space/space/space/space/space/space/space/go.mod+1-1
space/space/space/space/space/space/space/space/space/space/main.go+8-4
space/space/space/space/space/space/space/space/space/space/models/exception_model.go+3-1