Spaces:
Configuration error
Configuration error
Commit ·
4f90512
1
Parent(s): aa83ff3
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)
- models/request_model.go+17-17
- repositories/academy_repository.go+11-7
- space/controller/academy/academy_controller.go+11-5
- space/models/database_orm_model.go+3-1
- space/models/request_model.go+56-4
- space/repositories/academy_repository.go+21-13
- space/repositories/quiz_repository.go+19
- space/router/quiz_route.go+1-1
- space/services/academy_service.go+17-17
- space/services/quiz_service.goAdded+37
- space/space/models/field_counter.go-2
- space/space/services/partner_criteria_service.go+2-2
- space/space/space/config/database_connection_config.go-2
- space/space/space/controller/academy/academy_controller.go+369-31
- space/space/space/controller/cv/cv_controller.go+12-60
- space/space/space/controller/email/email_controller.go+1-5
- space/space/space/controller/marriage_readiness_profile/marriage_readiness_profile_controller.go+2-6
- space/space/space/controller/options/options_controller.go+1-5
- space/space/space/controller/partner_criteria/partner_criteria_controller.go+1-5
- space/space/space/controller/quiz/list_quiz_controller.go+1-1
- space/space/space/main.go+6
- space/space/space/models/database_orm_model.go+32-50
- space/space/space/models/filter_and_paging.goAdded+107
- space/space/space/models/request_model.go+107-2
- space/space/space/models/response_model.go-13
- space/space/space/repositories/academy_repository.go+406-103
- space/space/space/repositories/question_repository.go+11
- space/space/space/response/api_response_v2.go+37-11
- space/space/space/router/academy_route.go+25-8
- space/space/space/router/router.go+1-1
- space/space/space/router/server.go+4
- space/space/space/services/academy_quiz_service.go+2-2
- space/space/space/services/academy_service.go+316-150
- space/space/space/space/space/assets/efs.go+8
- space/space/space/space/space/assets/seeds/city.jsonAdded+4114
- space/space/space/space/space/assets/seeds/province.jsonAdded+192
- space/space/space/space/space/controller/options/options_controller.goAdded+72
- space/space/space/space/space/controller/region/region_controller.goAdded+92
- space/space/space/space/space/main.go+13
- space/space/space/space/space/models/database_orm_model.go+8-5
- space/space/space/space/space/models/request_model.go+33-4
- space/space/space/space/space/models/response_model.go+2
- space/space/space/space/space/repositories/option_repository.go+82-36
- space/space/space/space/space/repositories/region_repository.go+41-31
- space/space/space/space/space/router/options_route.go+11-15
- space/space/space/space/space/router/router.go+1-1
- space/space/space/space/space/router/server.go+9-2
- space/space/space/space/space/services/options_service.goAdded+149
- space/space/space/space/space/services/region_service.go+41-63
- space/space/space/space/space/space/services/academy_quiz_navigation_service.go+1-1
55 unmodified lines565758596061626364656667686970717273747576777879808155 unmodified lines}UserAcademyMaterialResponse struct {ID int64 `gorm:"column:id" json:"id"`AcademyID int64 `gorm:"column:academy_id" json:"academy_id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug" json:"slug"`Order uint `gorm:"column:order" json:"order"`CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`IsRead bool `gorm:"is_read" json:"is_read"`}UserAcademyMaterialDetailResponse struct {ID int64 `gorm:"column:id" json:"id"`AcademyID int64 `gorm:"column:academy_id" json:"academy_id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug" json:"slug"`Content string `gorm:"column:content" json:"content"`Order uint `gorm:"column:order" json:"order"`CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`IsRead bool `gorm:"is_read" json:"is_read"`}CreateAcademyMaterialRequest struct {55 unmodified lines565758596061626364656667686970717273747576777879808155 unmodified lines}UserAcademyMaterialResponse struct {ID int64 `gorm:"column:id" json:"id"`AcademyID int64 `gorm:"column:academy_id" json:"academy_id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug" json:"slug"`Order uint `gorm:"column:order" json:"order"`CreatedAt *time.Time `gorm:"column:read_created_at" json:"created_at"`UpdatedAt *time.Time `gorm:"column:read_updated_at" json:"updated_at"`IsRead bool `gorm:"is_read" json:"is_read"`}UserAcademyMaterialDetailResponse struct {ID int64 `gorm:"column:id" json:"id"`AcademyID int64 `gorm:"column:academy_id" json:"academy_id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug" json:"slug"`Content string `gorm:"column:content" json:"content"`Order uint `gorm:"column:order" json:"order"`CreatedAt *time.Time `gorm:"column:read_created_at" json:"created_at"`UpdatedAt *time.Time `gorm:"column:read_updated_at" json:"updated_at"`IsRead bool `gorm:"is_read" json:"is_read"`}CreateAcademyMaterialRequest struct {
293 unmodified lines29429529629729829930030130230330430530630763 unmodified lines371372373374375376377293 unmodified linesq := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Select(`academy_materials.*,CASEWHEN amp.created_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, req.AccountID).Where("academy.slug = ?", req.Slug)if req.Filter.HasKeyword() {63 unmodified linesCASEWHEN amp.created_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ON293 unmodified lines29429529629729829930030130230330430530630730830963 unmodified lines373374375376377378379380381293 unmodified linesq := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Select(`academy_materials.*,amp.created_at AS read_created_at,amp.updated_at AS read_updated_at,CASEWHEN amp.created_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, req.AccountID).Where("academy.slug = ?", req.Slug)if req.Filter.HasKeyword() {63 unmodified linesCASEWHEN amp.created_at IS NOT NULL THEN trueELSE falseEND AS is_read,amp.created_at AS read_created_at,amp.updated_at AS read_updated_at`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ON
348 unmodified lines349350351352353354355356357358359360361362363348 unmodified lines}func (c *academyController) UserToggleAcademyMaterialProgress(ctx *gin.Context) {slug := ctx.Param("materialSlug")accountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.ToggleAcademyMaterialProgressRequest{AccountID: accountID,Slug: slug,}err := c.academyService.UserToggleAcademyMaterialProgress(ctx, &req)if err != nil {348 unmodified lines349350351352353354355356357358359360361362363364365366367368369348 unmodified lines}func (c *academyController) UserToggleAcademyMaterialProgress(ctx *gin.Context) {var req models.ToggleAcademyMaterialProgressRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}academySlug := ctx.Param("slug")materialSlug := ctx.Param("materialSlug")accountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req.AccountID = accountIDreq.AcademySlug = academySlugreq.MaterialSlug = materialSlugerr := c.academyService.UserToggleAcademyMaterialProgress(ctx, &req)if err != nil {
79 unmodified lines80818283848515 unmodified lines10110210310410510610779 unmodified linesSlug string `gorm:"column:slug;uniqueIndex" json:"slug"`Description string `gorm:"column:description" json:"description"`Order uint `gorm:"column:order" json:"order"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`}15 unmodified linesAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`AcademyMaterialID int64 `gorm:"primaryKey;column:academy_material_id" json:"academy_material_id"`AcademyMaterial *AcademyMaterial `gorm:"foreignKey:AcademyMaterialID;constraint:OnDelete:CASCADE" json:"academy_material,omitempty"`ReadAt *time.Time `gorm:"column:read_at" json:"read_at"`})79 unmodified lines8081828384858615 unmodified lines10210310410510610710810979 unmodified linesSlug string `gorm:"column:slug;uniqueIndex" json:"slug"`Description string `gorm:"column:description" json:"description"`Order uint `gorm:"column:order" json:"order"`Image *string `gorm:"column:image" json:"image"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`}15 unmodified linesAccount *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`AcademyMaterialID int64 `gorm:"primaryKey;column:academy_material_id" json:"academy_material_id"`AcademyMaterial *AcademyMaterial `gorm:"foreignKey:AcademyMaterialID;constraint:OnDelete:CASCADE" json:"academy_material,omitempty"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`})
55 unmodified lines565758596061626344 unmodified lines10810911011111211311411515 unmodified lines13113213313413513655 unmodified lines}UserAcademyMaterialResponse struct {AcademyMaterialIsRead bool `gorm:"is_read" json:"is_read"`}CreateAcademyMaterialRequest struct {44 unmodified lines}ToggleAcademyMaterialProgressRequest struct {AccountID int64 `json:"account_id"`Slug string `json:"slug"`})15 unmodified lines}}type (MultipleOptionsRequest struct {OptionName string `json:"option_name" validate:"required"`55 unmodified lines565758596061626364656667686970717273747576777879808144 unmodified lines12612712812913013113213313413515 unmodified lines15115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718855 unmodified lines}UserAcademyMaterialResponse struct {ID int64 `gorm:"column:id" json:"id"`AcademyID int64 `gorm:"column:academy_id" json:"academy_id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug" json:"slug"`Order uint `gorm:"column:order" json:"order"`CreatedAt *time.Time `gorm:"column:read_created_at" json:"created_at"`UpdatedAt *time.Time `gorm:"column:read_updated_at" json:"updated_at"`IsRead bool `gorm:"is_read" json:"is_read"`}UserAcademyMaterialDetailResponse struct {ID int64 `gorm:"column:id" json:"id"`AcademyID int64 `gorm:"column:academy_id" json:"academy_id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug" json:"slug"`Content string `gorm:"column:content" json:"content"`Order uint `gorm:"column:order" json:"order"`CreatedAt *time.Time `gorm:"column:read_created_at" json:"created_at"`UpdatedAt *time.Time `gorm:"column:read_updated_at" json:"updated_at"`IsRead bool `gorm:"is_read" json:"is_read"`}CreateAcademyMaterialRequest struct {44 unmodified lines}ToggleAcademyMaterialProgressRequest struct {AccountID int64 `json:"-"`MaterialSlug string `json:"-"`AcademySlug string `json:"-"`IsRead bool `json:"is_read"`})15 unmodified lines}}type (ListQuizRequest struct {AccountID int64 `json:"account_id"`AcademyID int64 `json:"academy_id" validate:"required"`}ListQuizResponse struct {Quiz []Quiz `json:"quiz"`}AttemptQuizRequest struct {AccountID int64 `json:"account_id"`QuizID int64 `json:"quiz_id" validate:"required"`}AttemptQuizResponse struct {QuizAttempt QuizAttempt `json:"quiz_attempt"`}GetQuestionQuizRequest struct {AccountID int64 `json:"account_id"`QuizID int64 `json:"quiz_id" validate:"required"`}GetQuestionQuizResponse struct {Question Question `json:"question"`Answer []Answer `json:"answer_options"`UserAnswer int `json:"current_user_answer"`IsDoubt bool `json:"is_doubt"`})type (MultipleOptionsRequest struct {OptionName string `json:"option_name" validate:"required"`
27 unmodified lines28293031323334210 unmodified lines24524624724824925025142 unmodified lines29429529629729829930030130230330430530630751 unmodified lines3593603613623633643653662 unmodified lines36937037137237337437537637737837938038138238338438538638738838939027 unmodified linesUserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error)UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error)UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error)UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error)UserSaveAcademyMaterialProgress(ctx context.Context, req *models.AcademyMaterialProgress) errorUserGetAcademyMaterialProgressByAccountID(ctx context.Context, accountID int64, materialID int64) (*models.AcademyMaterialProgress, error)UserDeleteAcademyMaterialProgress(ctx context.Context, accountID int64, materialID int64) error210 unmodified linesModel(&models.Academy{}).Select(`academy.*,COUNT(DISTINCT am.id) AS total_material,COUNT(DISTINCT CASE WHEN amp.read_at IS NOT NULL THEN amp.academy_material_id END) AS total_read_material`).Joins("LEFT JOIN academy_materials am ON am.academy_id = academy.id").Joins(`LEFT JOIN "academy_materials_progress" amp ON amp.academy_material_id = am.id AND amp.account_id = ?`, req.AccountID).Group("academy.id")42 unmodified linesq := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Select(`academy_materials.*,CASEWHEN amp.read_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, req.AccountID).Where("academy.slug = ?", req.Slug)if req.Filter.HasKeyword() {51 unmodified linesreturn &academy, nil}func (r *academyRepository) UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error) {var result models.UserAcademyMaterialResponseerr := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).2 unmodified linesacademy.title as academy_title,academy.slug as academy_slug,CASEWHEN amp.read_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, accountID).Where("academy_materials.slug = ?", slug).First(&result).Errorif err != nil {return nil, err}return &result, nil}27 unmodified lines28293031323334210 unmodified lines24524624724824925025142 unmodified lines29429529629729829930030130230330430530630730830951 unmodified lines3613623633643653663673682 unmodified lines37137237337437537637737837938038138238338438538638738838939039139239339439539639739827 unmodified linesUserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error)UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error)UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error)UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialDetailResponse, error)UserSaveAcademyMaterialProgress(ctx context.Context, req *models.AcademyMaterialProgress) errorUserGetAcademyMaterialProgressByAccountID(ctx context.Context, accountID int64, materialID int64) (*models.AcademyMaterialProgress, error)UserDeleteAcademyMaterialProgress(ctx context.Context, accountID int64, materialID int64) error210 unmodified linesModel(&models.Academy{}).Select(`academy.*,COUNT(DISTINCT am.id) AS total_material,COUNT(DISTINCT CASE WHEN amp.created_at IS NOT NULL THEN amp.academy_material_id END) AS total_read_material`).Joins("LEFT JOIN academy_materials am ON am.academy_id = academy.id").Joins(`LEFT JOIN "academy_materials_progress" amp ON amp.academy_material_id = am.id AND amp.account_id = ?`, req.AccountID).Group("academy.id")42 unmodified linesq := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Select(`academy_materials.*,amp.created_at AS read_created_at,amp.updated_at AS read_updated_at,CASEWHEN amp.created_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, req.AccountID).Where("academy.slug = ?", req.Slug)if req.Filter.HasKeyword() {51 unmodified linesreturn &academy, nil}func (r *academyRepository) UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialDetailResponse, error) {var result models.UserAcademyMaterialDetailResponseerr := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).2 unmodified linesacademy.title as academy_title,academy.slug as academy_slug,CASEWHEN amp.created_at IS NOT NULL THEN trueELSE falseEND AS is_read,amp.created_at AS read_created_at,amp.updated_at AS read_updated_at`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, accountID).Where("academy_materials.slug = ?", slug).Scan(&result).Errorif err != nil {return nil, err}if result.ID == 0 {return nil, gorm.ErrRecordNotFound}return &result, nil}
123456789package repositoriesimport ("api.qobiltu.id/models")func GetQuizbyAcademyId(academyId uint) Repository[models.Quiz, []models.Quiz] {repo := Construct[models.Quiz, []models.Quiz](models.Quiz{AcademyID: academyId},12345678910111213141516171819202122232425262728package repositoriesimport ("context""api.qobiltu.id/models""gorm.io/gorm")type QuizRepository interface {UserListQuiz(ctx context.Context, req *models.ListQuizRequest) (*models.ListQuizResponse, *models.Paging, error)}type quizRepository struct {db *gorm.DB}func NewQuizRepository(db *gorm.DB) QuizRepository {return &quizRepository{db: db}}func (r *quizRepository) UserListQuiz(ctx context.Context, req *models.ListQuizRequest) (*models.ListQuizResponse, *models.Paging, error) {panic("not implemented")}func GetQuizbyAcademyId(academyId uint) Repository[models.Quiz, []models.Quiz] {repo := Construct[models.Quiz, []models.Quiz](models.Quiz{AcademyID: academyId},
14 unmodified lines1516171819202114 unmodified linesrouterGroup.GET("/:academy_id/:quiz_id/review", middleware.AuthUser, QuizController.Review)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)routerGroup.GET("/navigation/:attempt_id", middleware.AuthUser, QuizController.Navigation)}14 unmodified lines1516171819202114 unmodified linesrouterGroup.GET("/:academy_id/:quiz_id/review", middleware.AuthUser, QuizController.Review)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)routerGroup.GET("/navigation/:attempt_id", middleware.AuthUser, QuizController.Navigation)}
32 unmodified lines33343536373839237 unmodified lines2772782792802812822833 unmodified lines28728828929029129229329429529629729829930030130230330430530630730830931031131231331431532 unmodified linesUserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error)UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error)UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error)UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error)UserToggleAcademyMaterialProgress(ctx context.Context, req *models.ToggleAcademyMaterialProgressRequest) error}237 unmodified linesreturn academy, nil}func (s *academyService) UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error) {academyMaterial, err := s.academyRepository.UserGetAcademyMaterialBySlug(ctx, slug, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")3 unmodified lines}func (s *academyService) UserToggleAcademyMaterialProgress(ctx context.Context, req *models.ToggleAcademyMaterialProgressRequest) error {academyMaterial, err := s.academyRepository.UserGetAcademyMaterialBySlug(ctx, req.Slug, req.AccountID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}if academyMaterial.IsRead {err = s.academyRepository.UserDeleteAcademyMaterialProgress(ctx, req.AccountID, academyMaterial.ID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}} else {now := time.Now()academyMaterialProgress := &models.AcademyMaterialProgress{AccountID: req.AccountID,AcademyMaterialID: academyMaterial.ID,ReadAt: &now,}err = s.academyRepository.UserSaveAcademyMaterialProgress(ctx, academyMaterialProgress)if err != nil {return response.HandleGormError(err, "Internal Server Error")}}return nil32 unmodified lines33343536373839237 unmodified lines2772782792802812822833 unmodified lines28728828929029129229329429529629729829930030130230330430530630730830931031131231331431532 unmodified linesUserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error)UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error)UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error)UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialDetailResponse, error)UserToggleAcademyMaterialProgress(ctx context.Context, req *models.ToggleAcademyMaterialProgressRequest) error}237 unmodified linesreturn academy, nil}func (s *academyService) UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialDetailResponse, error) {academyMaterial, err := s.academyRepository.UserGetAcademyMaterialBySlug(ctx, slug, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")3 unmodified lines}func (s *academyService) UserToggleAcademyMaterialProgress(ctx context.Context, req *models.ToggleAcademyMaterialProgressRequest) error {material, err := s.academyRepository.UserGetAcademyMaterialBySlug(ctx, req.MaterialSlug, req.AccountID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}// langsung hapus progress jika isRead adalah falseif !req.IsRead {err := s.academyRepository.UserDeleteAcademyMaterialProgress(ctx, req.AccountID, material.ID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}academyMaterialProgress := models.AcademyMaterialProgress{AccountID: req.AccountID,AcademyMaterialID: material.ID,CreatedAt: time.Now(),}err = s.academyRepository.UserSaveAcademyMaterialProgress(ctx, &academyMaterialProgress)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil
12345678910111213141516171819202122232425262728293031323334353637package services
// type QuizService interface {// // === ADMIN ===
// // === USER ===// UserListQuiz(ctx context.Context, req *models.ListQuizRequest) (*models.ListQuizResponse, *models.Paging, error)// UserAttemptQuiz(ctx context.Context, req *models.AttemptQuizRequest) (*models.AttemptQuizResponse, error)// UserGetQuestionQuiz(ctx context.Context, req *models.GetQuestionQuizRequest) (*models.GetQuestionQuizResponse, error)// // UserAnswerQuiz(ctx context.Context, req *models.AnswerQuizRequest) (*models.AnswerQuizResponse, error)// // UserReviewQuiz(ctx context.Context, req *models.ReviewQuizRequest) (*models.ReviewQuizResponse, error)// // UserSubmitQuiz(ctx context.Context, req *models.SubmitQuizRequest) (*models.SubmitQuizResponse, error)// // UserResultQuiz(ctx context.Context, req *models.ResultQuizRequest) (*models.ResultQuizResponse, error)// // UserListResultQuiz(ctx context.Context, req *models.ListResultQuizRequest) (*models.ListResultQuizResponse, *models.Paging, error)// }
// type quizService struct {// quizRepository repositories.QuizRepository// validator *validation.Validator// }
// func NewQuizService(quizRepository repositories.QuizRepository, validator *validation.Validator) QuizService {// return &quizService{quizRepository: quizRepository, validator: validator}// }
// func (s *quizService) UserListQuiz(ctx context.Context, req *models.ListQuizRequest) (*models.ListQuizResponse, *models.Paging, error) {// quiz, paging, err := s.quizRepository.UserListQuiz(ctx, req)// if err != nil {// return nil, nil, response.HandleGormError(err, "Internal Server Error")// }
// return quiz, paging, nil// }
// func (s *quizService) UserAttemptQuiz(ctx context.Context, req *models.AttemptQuizRequest) (*models.AttemptQuizResponse, error) {// panic("not implemented")// }123456715 unmodified lines23242526272829package modelsimport ("fmt""reflect""time")15 unmodified lines}counterTag := field.Tag.Get("counter")fmt.Println(field.Name, "=", counterTag)return counterTag == "skip"}12345615 unmodified lines222324252627package modelsimport ("reflect""time")15 unmodified lines}counterTag := field.Tag.Get("counter")return counterTag == "skip"}
58 unmodified lines59606162636465666758 unmodified linesutils.AssignIfNotNil(&partnerCriteria.ExpectedMaxHeightLimit, req.ExpectedMaxHeightLimit)utils.AssignIfNotNil(&partnerCriteria.ExpectedPartnerIncome, req.ExpectedPartnerIncome)utils.AssignIfNotNil(&partnerCriteria.ExpectedIncomeSources, req.ExpectedIncomeSources)utils.AssignIfNotNil(&partnerCriteria.ExpectedLastEducation, req.ExpectedLastEducation)utils.AssignIfNotNil(&partnerCriteria.ExpectedJobType, req.ExpectedJobType)res, err := s.partnerCriteriaRepository.SavePartnerCriteria(ctx, partnerCriteria)if err != nil {58 unmodified lines59606162636465666758 unmodified linesutils.AssignIfNotNil(&partnerCriteria.ExpectedMaxHeightLimit, req.ExpectedMaxHeightLimit)utils.AssignIfNotNil(&partnerCriteria.ExpectedPartnerIncome, req.ExpectedPartnerIncome)utils.AssignIfNotNil(&partnerCriteria.ExpectedLastEducation, req.ExpectedLastEducation)// utils.AssignIfNotNil(&partnerCriteria.ExpectedIncomeSources, req.ExpectedIncomeSources)// utils.AssignIfNotNil(&partnerCriteria.ExpectedJobType, req.ExpectedJobType)res, err := s.partnerCriteriaRepository.SavePartnerCriteria(ctx, partnerCriteria)if err != nil {
56 unmodified lines57585960616263646556 unmodified lines&models.ForgotPassword{},&models.Academy{},&models.AcademyMaterial{},&models.AcademyContent{},&models.AcademyMaterialProgress{},&models.AcademyContentProgress{},&models.RegionCity{},&models.RegionProvince{},&models.OptionCategory{},56 unmodified lines5758596061626356 unmodified lines&models.ForgotPassword{},&models.Academy{},&models.AcademyMaterial{},&models.AcademyMaterialProgress{},&models.RegionCity{},&models.RegionProvince{},&models.OptionCategory{},
12345678910111213141516171819202122232425262728293031package academyimport ("api.qobiltu.id/controller""api.qobiltu.id/models""api.qobiltu.id/services""github.com/gin-gonic/gin")func List(c *gin.Context) {academy := services.AcademyService{}academyController := controller.Controller[any, models.Academy, []models.Academy]{Service: &academy.Service,}academyController.Service.Constructor.Slug = c.Param("slug")academy.Retrieve()academyController.Response(c)}func Create(c *gin.Context) {createAcademy := services.CreateAcademyService{}academyController := controller.Controller[models.AllAcademyResponse, models.AllAcademyResponse, models.AllAcademyResponse]{Service: &createAcademy.Service,}academyController.RequestJSON(c, func() {academyController.Service.Constructor.Academies = academyController.Request.AcademiescreateAcademy.Create()})}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369package academy_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 AcademyController interface {// === ADMIN ===AdminCreateAcademy(ctx *gin.Context)AdminGetAcademy(ctx *gin.Context)AdminUpdateAcademy(ctx *gin.Context)AdminDeleteAcademy(ctx *gin.Context)AdminListAcademy(ctx *gin.Context)AdminReorderAcademy(ctx *gin.Context)AdminCreateAcademyMaterial(ctx *gin.Context)AdminGetAcademyMaterial(ctx *gin.Context)AdminUpdateAcademyMaterial(ctx *gin.Context)AdminDeleteAcademyMaterial(ctx *gin.Context)AdminListAcademyMaterial(ctx *gin.Context)AdminReorderAcademyMaterial(ctx *gin.Context)// === USER ===UserListAcademy(ctx *gin.Context)UserListAcademyMaterial(ctx *gin.Context)UserGetAcademyMaterialBySlug(ctx *gin.Context)UserToggleAcademyMaterialProgress(ctx *gin.Context)}type academyController struct {academyService services.AcademyService}func NewAcademyController(academyService services.AcademyService) AcademyController {return &academyController{academyService: academyService,}}func (c *academyController) AdminListAcademy(ctx *gin.Context) {req := models.NewListAcademyRequest()if err := ctx.ShouldBindQuery(&req); err != nil {response.HandleError(ctx, err)return}res, paging, err := c.academyService.AdminListAcademy(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy list retrieved successfully", res, paging)}func (c *academyController) AdminCreateAcademy(ctx *gin.Context) {var req models.CreateAcademyRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}accountData := middleware.GetAccountData(ctx)req.AccountID = int64(accountData.UserID)res, err := c.academyService.AdminCreateAcademy(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy created successfully", res, nil)}func (c *academyController) AdminGetAcademy(ctx *gin.Context) {id := ctx.Param("id")idInt, err := strconv.ParseInt(id, 10, 64)if err != nil {response.HandleError(ctx, err)return}res, err := c.academyService.AdminGetAcademyByID(ctx, idInt)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy retrieved successfully", res, nil)}func (c *academyController) AdminUpdateAcademy(ctx *gin.Context) {id := ctx.Param("id")idInt, err := strconv.ParseInt(id, 10, 64)if err != nil {response.HandleError(ctx, err)return}var req models.UpdateAcademyRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}req.ID = idIntres, err := c.academyService.AdminUpdateAcademy(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy updated successfully", res, nil)}func (c *academyController) AdminDeleteAcademy(ctx *gin.Context) {id := ctx.Param("id")idInt, err := strconv.ParseInt(id, 10, 64)if err != nil {response.HandleError(ctx, err)return}err = c.academyService.AdminDeleteAcademy(ctx, idInt)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy deleted successfully", nil, nil)}func (c *academyController) AdminReorderAcademy(ctx *gin.Context) {var req models.ReorderAcademyRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}err := c.academyService.AdminReorderAcademy(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy reordered successfully", nil, nil)}func (c *academyController) AdminCreateAcademyMaterial(ctx *gin.Context) {var req models.CreateAcademyMaterialRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}academyID := ctx.Param("id")academyIDInt, err := strconv.ParseInt(academyID, 10, 64)if err != nil {response.HandleError(ctx, err)return}req.AcademyID = academyIDIntres, err := c.academyService.AdminCreateAcademyMaterial(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material created successfully", res, nil)}func (c *academyController) AdminGetAcademyMaterial(ctx *gin.Context) {id := ctx.Param("materialId")idInt, err := strconv.ParseInt(id, 10, 64)if err != nil {response.HandleError(ctx, err)return}res, err := c.academyService.AdminGetAcademyMaterialByID(ctx, idInt)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material retrieved successfully", res, nil)}func (c *academyController) AdminUpdateAcademyMaterial(ctx *gin.Context) {id := ctx.Param("materialId")idInt, err := strconv.ParseInt(id, 10, 64)if err != nil {response.HandleError(ctx, err)return}var req models.UpdateAcademyMaterialRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}req.ID = idIntres, err := c.academyService.AdminUpdateAcademyMaterial(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material updated successfully", res, nil)}func (c *academyController) AdminDeleteAcademyMaterial(ctx *gin.Context) {id := ctx.Param("materialId")idInt, err := strconv.ParseInt(id, 10, 64)if err != nil {response.HandleError(ctx, err)return}err = c.academyService.AdminDeleteAcademyMaterial(ctx, idInt)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material deleted successfully", nil, nil)}func (c *academyController) AdminReorderAcademyMaterial(ctx *gin.Context) {req := models.ReorderAcademyMaterialRequest{}if err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}academyID := ctx.Param("id")academyIDInt, err := strconv.ParseInt(academyID, 10, 64)if err != nil {response.HandleError(ctx, err)return}req.AcademyID = academyIDInterr = c.academyService.AdminReorderAcademyMaterial(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material reordered successfully", nil, nil)}func (c *academyController) AdminListAcademyMaterial(ctx *gin.Context) {req := models.NewListAcademyMaterialRequest()if err := ctx.ShouldBindQuery(&req); err != nil {response.HandleError(ctx, err)return}academyID := ctx.Param("id")academyIDInt, err := strconv.ParseInt(academyID, 10, 64)if err != nil {response.HandleError(ctx, err)return}accountData := middleware.GetAccountData(ctx)req.AccountID = int64(accountData.UserID)req.AcademyID = academyIDIntres, paging, err := c.academyService.AdminListAcademyMaterial(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material list retrieved successfully", res, paging)}// === USER ===func (c *academyController) UserListAcademy(ctx *gin.Context) {req := models.NewListAcademyRequest()if err := ctx.ShouldBindQuery(&req); err != nil {response.HandleError(ctx, err)return}accountData := middleware.GetAccountData(ctx)req.AccountID = int64(accountData.UserID)res, paging, err := c.academyService.UserListAcademy(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy list retrieved successfully", res, paging)}func (c *academyController) UserListAcademyMaterial(ctx *gin.Context) {req := models.NewListAcademyMaterialRequest()if err := ctx.ShouldBindQuery(&req); err != nil {response.HandleError(ctx, err)return}accountData := middleware.GetAccountData(ctx)req.AccountID = int64(accountData.UserID)slug := ctx.Param("slug")req.Slug = slugres, paging, err := c.academyService.UserListAcademyMaterial(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material list retrieved successfully", res, paging)}func (c *academyController) UserGetAcademyMaterialBySlug(ctx *gin.Context) {slug := ctx.Param("materialSlug")accountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)res, err := c.academyService.UserGetAcademyMaterialBySlug(ctx, slug, accountID)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material retrieved successfully", res, nil)}func (c *academyController) UserToggleAcademyMaterialProgress(ctx *gin.Context) {slug := ctx.Param("materialSlug")accountData := middleware.GetAccountData(ctx)accountID := int64(accountData.UserID)req := models.ToggleAcademyMaterialProgressRequest{AccountID: accountID,Slug: slug,}err := c.academyService.UserToggleAcademyMaterialProgress(ctx, &req)if err != nil {response.HandleError(ctx, err)return}response.HandleSuccess(ctx, http.StatusOK, "Academy material progress toggled successfully", nil, nil)}
65 unmodified lines666768697071727374757631 unmodified lines10810911011111211311411511611711831 unmodified lines15015115215315415515615715815916019 unmodified lines18018118218318418518618718818919072 unmodified lines26326426526626726826927027127227331 unmodified lines30530630730830931031131231331431530 unmodified lines34634734834935035135235335435535619 unmodified lines37637737837938038138238338438538671 unmodified lines45845946046146246346446546646746819 unmodified lines48848949049149249349449549649749871 unmodified lines57057157257357457557657757857958019 unmodified lines60060160260360460560660760860961065 unmodified linesfunc (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}31 unmodified linesfunc (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}31 unmodified linesfunc (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}19 unmodified linesvar req models.UpdateFamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}72 unmodified linesfunc (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}31 unmodified linesfunc (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}30 unmodified linesfunc (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}19 unmodified linesvar req models.UpdateEducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}71 unmodified linesfunc (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}19 unmodified linesvar req models.UpdateJobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}71 unmodified linesfunc (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}19 unmodified linesvar req models.UpdateAchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}65 unmodified lines6667686970717231 unmodified lines10410510610710810911031 unmodified lines14214314414514614714819 unmodified lines16816917017117217317472 unmodified lines24724824925025125225331 unmodified lines28528628728828929029130 unmodified lines32232332432532632732819 unmodified lines34834935035135235335471 unmodified lines42642742842943043143219 unmodified lines45245345445545645745871 unmodified lines53053153253353453553619 unmodified lines55655755855956056156265 unmodified linesfunc (c *cvController) SaveAccountDetails(ctx *gin.Context) {var req models.SaveAccountDetailsRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}31 unmodified linesfunc (c *cvController) SavePersonalityAndPreference(ctx *gin.Context) {var req models.SavePersonalityAndPreferenceRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}31 unmodified linesfunc (c *cvController) CreateFamilyMember(ctx *gin.Context) {var req models.CreateFamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}19 unmodified linesvar req models.UpdateFamilyMemberRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}72 unmodified linesfunc (c *cvController) SavePhysicalAndHealth(ctx *gin.Context) {var req models.SavePhysicalAndHealthRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}31 unmodified linesfunc (c *cvController) SaveWorshipAndReligiousUnderstanding(ctx *gin.Context) {var req models.SaveWorshipAndReligiousUnderstandingRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}30 unmodified linesfunc (c *cvController) CreateEducation(ctx *gin.Context) {var req models.CreateEducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}19 unmodified linesvar req models.UpdateEducationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}71 unmodified linesfunc (c *cvController) CreateJob(ctx *gin.Context) {var req models.CreateJobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}19 unmodified linesvar req models.UpdateJobRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}71 unmodified linesfunc (c *cvController) CreateAchievement(ctx *gin.Context) {var req models.CreateAchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}19 unmodified linesvar req models.UpdateAchievementRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}
42 unmodified lines434445464748495051525342 unmodified linesfunc (c *emailController) Verify(ctx *gin.Context) {var req models.ValidateEmailVerificationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}42 unmodified lines4344454647484942 unmodified linesfunc (c *emailController) Verify(ctx *gin.Context) {var req models.ValidateEmailVerificationRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}
123423 unmodified lines2829303132333435363738package cv_controllerimport ("net/http"23 unmodified linesfunc (c *marriageReadinessProfileController) SaveMarriageReadinessProfile(ctx *gin.Context) {var req models.SaveMarriageReadinessProfileRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}123423 unmodified lines28293031323334package marriage_readiness_profile_controllerimport ("net/http"23 unmodified linesfunc (c *marriageReadinessProfileController) SaveMarriageReadinessProfile(ctx *gin.Context) {var req models.SaveMarriageReadinessProfileRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}
27 unmodified lines282930313233343536373827 unmodified linesfunc (c *optionsController) CreateOptions(ctx *gin.Context) {var req []models.MultipleOptionsRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}27 unmodified lines2829303132333427 unmodified linesfunc (c *optionsController) CreateOptions(ctx *gin.Context) {var req []models.MultipleOptionsRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}
27 unmodified lines282930313233343536373827 unmodified linesfunc (c *partnerCriteriaController) SavePartnerCriteria(ctx *gin.Context) {var req models.SavePartnerCriteriaRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, models.Exception{Message: "Invalid body request",BadRequest: true,Err: err,})return}27 unmodified lines2829303132333427 unmodified linesfunc (c *partnerCriteriaController) SavePartnerCriteria(ctx *gin.Context) {var req models.SavePartnerCriteriaRequestif err := ctx.ShouldBindJSON(&req); err != nil {response.HandleError(ctx, err)return}
15 unmodified lines1617181920212215 unmodified lines}quizListController.HeaderParse(c, func() {academy_id, _ := strconv.Atoi(c.Param("academy_id"))quizList.Constructor.ID = uint(academy_id)quizList.Retrieve()quizListController.Response(c)})15 unmodified lines1617181920212215 unmodified lines}quizListController.HeaderParse(c, func() {academy_id, _ := strconv.Atoi(c.Param("academy_id"))quizList.Constructor.ID = int64(academy_id)quizList.Retrieve()quizListController.Response(c)})
5 unmodified lines6789101158 unmodified lines70717273747516 unmodified lines9293949596975 unmodified lines"strconv""api.qobiltu.id/config"cv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"58 unmodified linesemailService := services.NewEmailService(emailRepository, taskDistributor)emailController := email_controller.NewEmailController(emailService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage, validator)cvController := cv_controller.NewCVController(cvService)16 unmodified linesregionController,optionController,emailController,cvController,marriageReadinessProfileController,partnerCriteriaController,5 unmodified lines678910111258 unmodified lines7172737475767778798016 unmodified lines9798991001011021035 unmodified lines"strconv""api.qobiltu.id/config"academy_controller "api.qobiltu.id/controller/academy"cv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"58 unmodified linesemailService := services.NewEmailService(emailRepository, taskDistributor)emailController := email_controller.NewEmailController(emailService)academyRepository := repositories.NewAcademyRepository(config.DB)academyService := services.NewAcademyService(academyRepository, validator)academyController := academy_controller.NewAcademyController(academyService)cvRepository := repositories.NewCVRepository(config.DB)cvService := services.NewCVService(cvRepository, localStorage, validator)cvController := cv_controller.NewCVController(cvService)16 unmodified linesregionController,optionController,emailController,academyController,cvController,marriageReadinessProfileController,partnerCriteriaController,
29 unmodified lines3031323334353636 unmodified lines7374757677787980818283848586878889909192939495969798991001011021031041051061071081091108 unmodified lines119120121122123124125126127128129130131132133134135136137138139284 unmodified lines4244254264274284294304314329 unmodified lines44244344444544644744844945029 unmodified linesGender *string `gorm:"column:gender" json:"gender"`LastEducation *string `gorm:"column:last_education" json:"last_education"`MaritalStatus *string `gorm:"column:marital_status" json:"marital_status"`Avatar *string `gorm:"column:avatar" json:"avatar"`PhoneNumber *string `gorm:"column:phone_number" json:"phone_number"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`36 unmodified linesExpiredAt time.Time `json:"expired_at"`}type Academy struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`Title string `json:"title"`Slug string `json:"slug" gorm:"uniqueIndex" `TotalMaterial int `json:"total_material"`CompletedMaterial int `json:"completed_material"`TotalQuiz int `json:"total_quiz"`PassedQuiz int `json:"passed_quiz"`IsCompletedRead bool `json:"is_read"`IsPassedExam bool `json:"is_passed_exam"`Description string `json:"description"`}type AcademyMaterial struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`AcademyID uint `json:"academy_id"`Title string `json:"title"`Slug string `json:"slug" gorm:"uniqueIndex"`IsCompleted bool `json:"is_completed"`Description string `json:"description"`}type AcademyContent struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `json:"uuid"`Title string `json:"title"`Order uint `json:"order"`AcademyMaterialID uint `json:"academy_material_id"`Description string `json:"description"`}type OptionCategory struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`8 unmodified linesOptionValue string `json:"option_value"`}type AcademyMaterialProgress struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`AccountID uint `json:"account_id"`AcademyMaterialID uint `json:"academy_material_id"`Progress uint `json:"progress"`}type AcademyContentProgress struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`AccountID uint `json:"account_id"`AcademyID uint `json:"academy_id"`}type RegionProvince struct {ID uint `json:"id"`Name string `json:"name"`284 unmodified lines// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkanExpectedIncomeSources *pq.StringArray `gorm:"column:expected_income_sources;type:varchar(255)[]" json:"expected_income_sources"` // sumber penghasilan pasanganExpectedLastEducation *pq.StringArray `gorm:"column:expected_last_education;type:varchar(255)[]" json:"expected_last_education"` // pendidikan terakhir yang diharapkanExpectedJobType *string `gorm:"column:expected_job_type" json:"expected_job_type"` // jenis pekerjaan pasangan yang diharapkanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`9 unmodified linesfunc (ForgotPassword) TableName() string { return "forgot_password" }func (Academy) TableName() string { return "academy" }func (AcademyMaterial) TableName() string { return "academy_materials" }func (AcademyContent) TableName() string { return "academy_contents" }func (AcademyMaterialProgress) TableName() string { return "academy_materials_progress" }func (AcademyContentProgress) TableName() string { return "academy_contents_progress" }func (RegionProvince) TableName() string { return "region_provinces" }func (RegionCity) TableName() string { return "region_cities" }func (Answer) TableName() string { return "answers" }29 unmodified lines3031323334353636 unmodified lines7374757677787980818283848586878889909192939495969798991001011021031041051061071081098 unmodified lines118119120121122123284 unmodified lines4084094104114124134144154169 unmodified lines42642742842943043143229 unmodified linesGender *string `gorm:"column:gender" json:"gender"`LastEducation *string `gorm:"column:last_education" json:"last_education"`MaritalStatus *string `gorm:"column:marital_status" json:"marital_status"`Avatar *string `gorm:"column:avatar" json:"avatar" counter:"skip"`PhoneNumber *string `gorm:"column:phone_number" json:"phone_number"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at" counter:"skip"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at" counter:"skip"`36 unmodified linesExpiredAt time.Time `json:"expired_at"`}type (Academy struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug;uniqueIndex" json:"slug"`Description string `gorm:"column:description" json:"description"`Order uint `gorm:"column:order" json:"order"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`}AcademyMaterial struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`AcademyID int64 `gorm:"column:academy_id;not null" json:"academy_id"`Academy *Academy `gorm:"foreignKey:AcademyID;constraint:OnDelete:CASCADE" json:"academy,omitempty"`Title string `gorm:"column:title" json:"title"`Slug string `gorm:"column:slug;uniqueIndex" json:"slug"`Content string `gorm:"column:content" json:"content"`Order uint `gorm:"column:order" json:"order"`CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`}AcademyMaterialProgress struct {AccountID int64 `gorm:"primaryKey;column:account_id" json:"account_id" counter:"skip"`Account *Account `gorm:"foreignKey:AccountID;constraint:OnDelete:CASCADE" json:"account,omitempty" counter:"skip"`AcademyMaterialID int64 `gorm:"primaryKey;column:academy_material_id" json:"academy_material_id"`AcademyMaterial *AcademyMaterial `gorm:"foreignKey:AcademyMaterialID;constraint:OnDelete:CASCADE" json:"academy_material,omitempty"`ReadAt *time.Time `gorm:"column:read_at" json:"read_at"`})type OptionCategory struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`8 unmodified linesOptionValue string `json:"option_value"`}type RegionProvince struct {ID uint `json:"id"`Name string `json:"name"`284 unmodified lines// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkanExpectedLastEducation *pq.StringArray `gorm:"column:expected_last_education;type:varchar(255)[]" json:"expected_last_education"` // pendidikan terakhir yang diharapkan// ExpectedIncomeSources *pq.StringArray `gorm:"column:expected_income_sources;type:varchar(255)[]" json:"expected_income_sources"` // sumber penghasilan pasangan// ExpectedJobType *string `gorm:"column:expected_job_type" json:"expected_job_type"` // jenis pekerjaan pasangan yang diharapkanCreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`9 unmodified linesfunc (ForgotPassword) TableName() string { return "forgot_password" }func (Academy) TableName() string { return "academy" }func (AcademyMaterial) TableName() string { return "academy_materials" }func (AcademyMaterialProgress) TableName() string { return "academy_materials_progress" }func (RegionProvince) TableName() string { return "region_provinces" }func (RegionCity) TableName() string { return "region_cities" }func (Answer) TableName() string { return "answers" }
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107package models
import ( "errors" "fmt" "strings")
const ( AscOrder string = "ASC" DescOrder string = "DESC" DefaultPageLimit int = 50 DefaultCurrentPage int = 1 DefaultColumnOrder string = AscOrder DefaultMaxPageLimit int = 100)
type Filter struct { CurrentPage int `json:"current_page" form:"current_page" query:"current_page"` // page (berpindah-pindah halaman) PerPage int `json:"per_page" form:"per_page" query:"per_page"` // limit (batas data yang ditampilkan) Keyword string `json:"keyword" form:"keyword" query:"keyword"` // search keyword (keyword pencarian) SortBy string `json:"sort_by" form:"sort_by" query:"sort_by"` // column name to sort Order string `json:"order" form:"order" query:"order"` // asc or desc order}
func NewFilter() Filter { return Filter{ CurrentPage: DefaultCurrentPage, PerPage: DefaultPageLimit, Order: DefaultColumnOrder, }}
func (f *Filter) GetLimit() int { return f.PerPage}
func (f *Filter) GetOffset() int { offset := (f.CurrentPage - 1) * f.PerPage // example: (1 - 1) * 10 = 0, (2 - 1) * 10 = 10 return offset}
func (f *Filter) HasKeyword() bool { return f.Keyword != ""}
func (f *Filter) HasSort() bool { return f.SortBy != ""}
func (f *Filter) IsDesc() bool { return strings.ToUpper(f.Order) == DescOrder}
// ===============================
type Paging struct { HasPreviousPage bool `json:"has_previous_page"` HasNextPage bool `json:"has_next_page"` CurrentPage int `json:"current_page"` PerPage int `json:"per_page"` TotalData int `json:"total_data"` LastPage int `json:"last_page"` From int `json:"from"` To int `json:"to"` TotalDataInCurrentPage int `json:"total_data_in_current_page"` Label string `json:"label"`}
var ErrPaging = errors.New("per_page harus lebih besar dari 0 dan offset tidak boleh negatif")
func NewPaging(currentPage, perPage, offset, totalData int) (*Paging, error) { if perPage <= 0 || offset < 0 { return nil, ErrPaging }
lastPage := totalData / perPage if totalData%perPage != 0 { lastPage++ }
to := min(offset+perPage, totalData) from := int(0) if to > offset { from = offset + 1 }
if currentPage > lastPage { currentPage = lastPage }
totalDataInCurrentPage := to - offset label := fmt.Sprintf("Menampilkan %d sampai %d dari %d data", from, to, totalData)
return &Paging{ HasPreviousPage: currentPage > 1, HasNextPage: currentPage < lastPage, CurrentPage: currentPage, PerPage: perPage, TotalData: totalData, LastPage: lastPage, From: from, To: to, TotalDataInCurrentPage: totalDataInCurrentPage, Label: label, }, nil}27 unmodified lines282930313233361 unmodified lines39539639739839940040140240327 unmodified linesToken uint `json:"token" binding:"required"`}type (MultipleOptionsRequest struct {OptionName string `json:"option_name" validate:"required"`361 unmodified lines// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkanExpectedIncomeSources *pq.StringArray `gorm:"column:expected_income_sources;type:varchar(255)[]" json:"expected_income_sources"` // sumber penghasilan pasanganExpectedLastEducation *pq.StringArray `gorm:"column:expected_last_education;type:varchar(255)[]" json:"expected_last_education"` // pendidikan terakhir yang diharapkanExpectedJobType *string `gorm:"column:expected_job_type" json:"expected_job_type"` // jenis pekerjaan pasangan yang diharapkan}27 unmodified lines282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136361 unmodified lines49849950050150250350450550650750827 unmodified linesToken uint `json:"token" binding:"required"`}type (CreateAcademyRequest struct {AccountID int64 `json:"account_id"`Title string `json:"title" validate:"required"`Description string `json:"description"`Order *uint `json:"order"`}UpdateAcademyRequest struct {ID int64 `json:"id"`Title *string `json:"title"`Description *string `json:"description"`Order *uint `json:"order"`}AcademyResponse struct {AcademyTotalMaterial int64 `gorm:"total_material" json:"total_material"`}UserAcademyResponse struct {AcademyTotalMaterial int64 `gorm:"total_material" json:"total_material"`TotalReadMaterial int64 `gorm:"total_read_material" json:"total_read_material"`PercentageReadMaterial float64 `gorm:"percentage_read_material" json:"percentage_read_material"`}UserAcademyMaterialResponse struct {AcademyMaterialIsRead bool `gorm:"is_read" json:"is_read"`}CreateAcademyMaterialRequest struct {AcademyID int64 `json:"academy_id" validate:"required"`Title string `json:"title" validate:"required"`Content string `json:"content"`Order *uint `json:"order"`}UpdateAcademyMaterialRequest struct {ID int64 `json:"id"`Title *string `json:"title"`Content *string `json:"content"`Order *uint `json:"order"`}ListAcademyRequest struct {AccountID int64Filter}ListAcademyMaterialRequest struct {AccountID int64AcademyID int64Slug stringFilter}ListAcademyContentRequest struct {AccountID int64AcademyID int64AcademyMaterialID int64Filter}ReorderRequest struct {ID int64 `json:"id"`Order int64 `json:"order"`}ReorderAcademyRequest struct {Reorder []ReorderRequest `json:"reorder"`}ReorderAcademyMaterialRequest struct {AcademyID int64 `json:"academy_id"`Reorder []ReorderRequest `json:"reorder"`}ToggleAcademyMaterialProgressRequest struct {AccountID int64 `json:"account_id"`Slug string `json:"slug"`})func NewListAcademyRequest() ListAcademyRequest {return ListAcademyRequest{Filter: NewFilter(),}}func NewListAcademyMaterialRequest() ListAcademyMaterialRequest {return ListAcademyMaterialRequest{Filter: NewFilter(),}}func NewListAcademyContentRequest() ListAcademyContentRequest {return ListAcademyContentRequest{Filter: NewFilter(),}}type (MultipleOptionsRequest struct {OptionName string `json:"option_name" validate:"required"`361 unmodified lines// Pendidikan & PekerjaanExpectedPartnerIncome *string `gorm:"column:expected_partner_income" json:"expected_partner_income"` // penghasilan pasangan per bulan yang diharapkanExpectedLastEducation *pq.StringArray `gorm:"column:expected_last_education;type:varchar(255)[]" json:"expected_last_education"` // pendidikan terakhir yang diharapkan// NOT USED// ExpectedIncomeSources *pq.StringArray `gorm:"column:expected_income_sources;type:varchar(255)[]" json:"expected_income_sources"` // sumber penghasilan pasangan// ExpectedJobType *string `gorm:"column:expected_job_type" json:"expected_job_type"` // jenis pekerjaan pasangan yang diharapkan}
32 unmodified lines3334353637383940414243444546474849505132 unmodified linesDetails AccountDetails `json:"details"`}type AcademyMaterialResponse struct {Materials AcademyMaterialContents AcademyContent}type AcademyResponse struct {Academy Academy `json:"academy"`Materials []AcademyMaterialResponse `json:"academy_materials"`}type AllAcademyResponse struct {Academies []AcademyResponse `json:"academy_dasar"`}type AttemptExamResponse struct {Exam Quiz `json:"exam"`Questions []Question `json:"questions"`32 unmodified lines33343536373832 unmodified linesDetails AccountDetails `json:"details"`}type AttemptExamResponse struct {Exam Quiz `json:"exam"`Questions []Question `json:"questions"`
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105package repositoriesimport "api.qobiltu.id/models"func GetAllAcademy() Repository[models.Academy, []models.Academy] {repo := Construct[models.Academy, []models.Academy](models.Academy{},)repo.Transactions(WhereGivenConstructor[models.Academy, []models.Academy],Find[models.Academy, []models.Academy],)return *repo}func GetAcademyDataBySlug(slug string) Repository[models.Academy, models.Academy] {repo := Construct[models.Academy, models.Academy](models.Academy{Slug: slug},)repo.Transactions(WhereGivenConstructor[models.Academy, models.Academy],Find[models.Academy, models.Academy],)return *repo}func GetAllAcademyMaterialsByAcademyID(acaddemyId uint) Repository[models.AcademyMaterial, []models.AcademyMaterial] {repo := Construct[models.AcademyMaterial, []models.AcademyMaterial](models.AcademyMaterial{AcademyID: acaddemyId},)repo.Transactions(WhereGivenConstructor[models.AcademyMaterial, []models.AcademyMaterial],Find[models.AcademyMaterial, []models.AcademyMaterial],)return *repo}func GetAllAcademyContentsByMaterialID(materialId uint) Repository[models.AcademyContent, models.AcademyContent] {repo := Construct[models.AcademyContent, models.AcademyContent](models.AcademyContent{AcademyMaterialID: materialId},)repo.Transactions(WhereGivenConstructor[models.AcademyContent, models.AcademyContent],Find[models.AcademyContent, models.AcademyContent],)return *repo}func CreateAcademy(academies models.Academy) Repository[models.Academy, models.Academy] {repo := Construct[models.Academy, models.Academy](academies,)Create(repo)return *repo}func CreateAcademyMaterial(academyMaterial models.AcademyMaterial) Repository[models.AcademyMaterial, models.AcademyMaterial] {repo := Construct[models.AcademyMaterial, models.AcademyMaterial](academyMaterial,)Create(repo)return *repo}func CreateAcademyContent(academyContent models.AcademyContent) Repository[models.AcademyContent, models.AcademyContent] {repo := Construct[models.AcademyContent, models.AcademyContent](academyContent,)Create(repo)return *repo}func GetAcademyMaterialBySlug(slug string) Repository[models.AcademyMaterial, models.AcademyMaterial] {repo := Construct[models.AcademyMaterial, models.AcademyMaterial](models.AcademyMaterial{Slug: slug},)repo.Transactions(WhereGivenConstructor[models.AcademyMaterial, models.AcademyMaterial],Find[models.AcademyMaterial, models.AcademyMaterial],)return *repo}func GetAcademyByID(id uint) Repository[models.Academy, models.Academy] {repo := Construct[models.Academy, models.Academy](models.Academy{ID: id},)repo.Transactions(WhereGivenConstructor[models.Academy, models.Academy],Find[models.Academy, models.Academy],)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)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408package repositoriesimport ("context""api.qobiltu.id/models""gorm.io/gorm""gorm.io/gorm/clause")type AcademyRepository interface {// === ADMIN ===AdminSaveAcademy(ctx context.Context, req *models.Academy) (*models.AcademyResponse, error)AdminGetAcademyByID(ctx context.Context, id int64) (*models.AcademyResponse, error)AdminListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.AcademyResponse, *models.Paging, error)AdminDeleteAcademy(ctx context.Context, id int64) errorAdminReorderAcademy(ctx context.Context, req *models.ReorderAcademyRequest) errorAdminGetLastOrderAcademy(ctx context.Context) (uint, error)AdminSaveAcademyMaterial(ctx context.Context, req *models.AcademyMaterial) errorAdminGetAcademyMaterialByID(ctx context.Context, id int64) (*models.AcademyMaterial, error)AdminListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.AcademyMaterial, *models.Paging, error)AdminDeleteAcademyMaterial(ctx context.Context, id int64) errorAdminReorderAcademyMaterial(ctx context.Context, req *models.ReorderAcademyMaterialRequest) errorAdminGetLastOrderAcademyMaterial(ctx context.Context) (uint, error)// === USER ===UserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error)UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error)UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error)UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error)UserSaveAcademyMaterialProgress(ctx context.Context, req *models.AcademyMaterialProgress) errorUserGetAcademyMaterialProgressByAccountID(ctx context.Context, accountID int64, materialID int64) (*models.AcademyMaterialProgress, error)UserDeleteAcademyMaterialProgress(ctx context.Context, accountID int64, materialID int64) error}type academyRepository struct {db *gorm.DB}func NewAcademyRepository(db *gorm.DB) AcademyRepository {return &academyRepository{db: db,}}func (r *academyRepository) AdminSaveAcademy(ctx context.Context, req *models.Academy) (*models.AcademyResponse, error) {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return nil, err}var academy models.AcademyResponsevar totalMaterial int64if err := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Where("academy_id = ?", req.ID).Count(&totalMaterial).Error; err != nil {return nil, err}academy.Academy = *reqacademy.TotalMaterial = totalMaterialreturn &academy, nil}func (r *academyRepository) AdminGetAcademyByID(ctx context.Context, id int64) (*models.AcademyResponse, error) {var academy models.AcademyResponsesubQuery := r.db.Model(&models.AcademyMaterial{}).Select("COUNT(*)").Where("academy_id = academy.id")if err := r.db.WithContext(ctx).Model(&models.Academy{}).Select("academy.*, (?) AS total_material", subQuery).Where("academy.id = ?", id).Scan(&academy).Error; err != nil {return nil, err}if academy.ID == 0 {return nil, gorm.ErrRecordNotFound}return &academy, nil}func (r *academyRepository) AdminListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.AcademyResponse, *models.Paging, error) {academies := make([]models.AcademyResponse, 0)offset := req.Filter.GetOffset()limit := req.Filter.GetLimit()// Subquery untuk count materialssubQuery := r.db.Model(&models.AcademyMaterial{}).Select("COUNT(*)").Where("academy_id = academy.id")q := r.db.WithContext(ctx).Model(&models.Academy{}).Select("academy.*, (?) AS total_material", subQuery)if req.Filter.HasKeyword() {q = q.Where("title ILIKE ? OR description ILIKE ?", "%"+req.Filter.Keyword+"%", "%"+req.Filter.Keyword+"%")}if req.Filter.HasSort() {q = q.Order(clause.OrderByColumn{Column: clause.Column{Name: req.Filter.SortBy},Desc: req.Filter.IsDesc(),})} else {q = q.Order(`"order" ASC`)}// Menghitung jumlah total data tanpa offset dan limitvar totalData int64if err := q.Count(&totalData).Error; err != nil {return nil, nil, err}q = q.Offset(int(offset)).Limit(int(limit))if err := q.Scan(&academies).Error; err != nil {return nil, nil, err}pageInfo, err := models.NewPaging(req.Filter.CurrentPage, limit, offset, int(totalData))if err != nil {return nil, nil, err}return academies, pageInfo, nil}func (r *academyRepository) AdminDeleteAcademy(ctx context.Context, id int64) error {return r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.Academy{}).Error}func (r *academyRepository) AdminReorderAcademy(ctx context.Context, req *models.ReorderAcademyRequest) error {return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {for _, reorder := range req.Reorder {if err := tx.Model(&models.Academy{}).Where("id = ?", reorder.ID).Update("order", reorder.Order).Error; err != nil {return err}}return nil})}func (r *academyRepository) AdminGetLastOrderAcademy(ctx context.Context) (uint, error) {var lastOrder uintif err := r.db.WithContext(ctx).Model(&models.Academy{}).Order(`"order" DESC`).Limit(1).Select("order").Scan(&lastOrder).Error; err != nil {return 0, err}return lastOrder, nil}func (r *academyRepository) AdminSaveAcademyMaterial(ctx context.Context, req *models.AcademyMaterial) error {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return err}return nil}func (r *academyRepository) AdminGetAcademyMaterialByID(ctx context.Context, id int64) (*models.AcademyMaterial, error) {var academyMaterial models.AcademyMaterialif err := r.db.WithContext(ctx).Where("id = ?", id).First(&academyMaterial).Error; err != nil {return nil, err}return &academyMaterial, nil}func (r *academyRepository) AdminListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.AcademyMaterial, *models.Paging, error) {academyMaterials := make([]models.AcademyMaterial, 0)offset := req.Filter.GetOffset()limit := req.Filter.GetLimit()q := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Where("academy_id = ?", req.AcademyID)if req.Filter.HasKeyword() {q = q.Where("title ILIKE ? OR description ILIKE ?", "%"+req.Filter.Keyword+"%", "%"+req.Filter.Keyword+"%")}if req.Filter.HasSort() {q = q.Order(clause.OrderByColumn{Column: clause.Column{Name: req.Filter.SortBy},Desc: req.Filter.IsDesc(),})} else {q = q.Order(`"order" ASC`)}// Menghitung jumlah total data tanpa offset dan limitvar totalData int64if err := q.Count(&totalData).Error; err != nil {return nil, nil, err}q = q.Offset(int(offset)).Limit(int(limit))if err := q.Scan(&academyMaterials).Error; err != nil {return nil, nil, err}pageInfo, err := models.NewPaging(req.Filter.CurrentPage, limit, offset, int(totalData))if err != nil {return nil, nil, err}return academyMaterials, pageInfo, nil}func (r *academyRepository) AdminDeleteAcademyMaterial(ctx context.Context, id int64) error {return r.db.WithContext(ctx).Where("id = ?", id).Delete(&models.AcademyMaterial{}).Error}func (r *academyRepository) AdminGetLastOrderAcademyMaterial(ctx context.Context) (uint, error) {var lastOrder uintif err := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Order(`"order" DESC`).Limit(1).Select("order").Scan(&lastOrder).Error; err != nil {return 0, err}return lastOrder, nil}func (r *academyRepository) AdminReorderAcademyMaterial(ctx context.Context, req *models.ReorderAcademyMaterialRequest) error {return r.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {for _, reorder := range req.Reorder {if err := tx.Model(&models.AcademyMaterial{}).Where("id = ? AND academy_id = ?", reorder.ID, req.AcademyID).Update("order", reorder.Order).Error; err != nil {return err}}return nil})}// === USER ===func (r *academyRepository) UserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error) {academies := make([]models.UserAcademyResponse, 0)offset := req.Filter.GetOffset()limit := req.Filter.GetLimit()// Base queryq := r.db.WithContext(ctx).Model(&models.Academy{}).Select(`academy.*,COUNT(DISTINCT am.id) AS total_material,COUNT(DISTINCT CASE WHEN amp.read_at IS NOT NULL THEN amp.academy_material_id END) AS total_read_material`).Joins("LEFT JOIN academy_materials am ON am.academy_id = academy.id").Joins(`LEFT JOIN "academy_materials_progress" amp ON amp.academy_material_id = am.id AND amp.account_id = ?`, req.AccountID).Group("academy.id")if req.Filter.HasKeyword() {q = q.Where("academy.title ILIKE ? OR academy.description ILIKE ?", "%"+req.Filter.Keyword+"%", "%"+req.Filter.Keyword+"%")}// Default orderingq = q.Order(`academy."order" ASC`)// Count total records (without limit/offset)var totalData int64countQuery := q.Session(&gorm.Session{NewDB: true}).Table("academy")if err := countQuery.Count(&totalData).Error; err != nil {return nil, nil, err}// Apply paginationq = q.Offset(int(offset)).Limit(int(limit))if err := q.Scan(&academies).Error; err != nil {return nil, nil, err}// Calculate percentagesfor i := range academies {if academies[i].TotalMaterial > 0 {academies[i].PercentageReadMaterial = float64(academies[i].TotalReadMaterial) / float64(academies[i].TotalMaterial) * 100}}pageInfo, err := models.NewPaging(req.Filter.CurrentPage, limit, offset, int(totalData))if err != nil {return nil, nil, err}return academies, pageInfo, nil}func (r *academyRepository) UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error) {materials := make([]models.UserAcademyMaterialResponse, 0)offset := req.Filter.GetOffset()limit := req.Filter.GetLimit()q := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Select(`academy_materials.*,CASEWHEN amp.read_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, req.AccountID).Where("academy.slug = ?", req.Slug)if req.Filter.HasKeyword() {q = q.Where("academy_materials.title ILIKE ?", "%"+req.Filter.Keyword+"%")}if req.Filter.HasSort() {q = q.Order(clause.OrderByColumn{Column: clause.Column{Name: req.Filter.SortBy},Desc: req.Filter.IsDesc(),})} else {q = q.Order("academy_materials.order ASC")}// Count total records (without limit/offset)var total int64if err := q.Count(&total).Error; err != nil {return nil, nil, err}q = q.Offset(int(offset)).Limit(int(limit))if err := q.Scan(&materials).Error; err != nil {return nil, nil, err}paging, err := models.NewPaging(req.Filter.CurrentPage, limit, offset, int(total))if err != nil {return nil, nil, err}return materials, paging, nil}func (r *academyRepository) UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error) {var academy models.AcademyResponsesubQuery := r.db.Model(&models.AcademyMaterial{}).Select("COUNT(*)").Where("academy_id = academy.id")if err := r.db.WithContext(ctx).Model(&models.Academy{}).Select("academy.*, (?) AS total_material", subQuery).Where("academy.slug = ?", slug).Scan(&academy).Error; err != nil {return nil, err}if academy.ID == 0 {return nil, gorm.ErrRecordNotFound}return &academy, nil}func (r *academyRepository) UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error) {var result models.UserAcademyMaterialResponseerr := r.db.WithContext(ctx).Model(&models.AcademyMaterial{}).Select(`academy_materials.*,academy.title as academy_title,academy.slug as academy_slug,CASEWHEN amp.read_at IS NOT NULL THEN trueELSE falseEND AS is_read`).Joins("JOIN academy ON academy.id = academy_materials.academy_id").Joins(`LEFT JOIN academy_materials_progress amp ONamp.academy_material_id = academy_materials.id ANDamp.account_id = ?`, accountID).Where("academy_materials.slug = ?", slug).First(&result).Errorif err != nil {return nil, err}return &result, nil}func (r *academyRepository) UserSaveAcademyMaterialProgress(ctx context.Context, req *models.AcademyMaterialProgress) error {if err := r.db.WithContext(ctx).Save(req).Error; err != nil {return err}return nil}func (r *academyRepository) UserGetAcademyMaterialProgressByAccountID(ctx context.Context, accountID int64, materialID int64) (*models.AcademyMaterialProgress, error) {var academyMaterialProgress models.AcademyMaterialProgressif err := r.db.WithContext(ctx).Where("account_id = ? AND academy_material_id = ?", accountID, materialID).First(&academyMaterialProgress).Error; err != nil {return nil, err}return &academyMaterialProgress, nil}func (r *academyRepository) UserDeleteAcademyMaterialProgress(ctx context.Context, accountID int64, materialID int64) error {return r.db.WithContext(ctx).Where("account_id = ? AND academy_material_id = ?", accountID, materialID).Delete(&models.AcademyMaterialProgress{}).Error}
33 unmodified lines34353633 unmodified lines)return *repo}33 unmodified lines343536373839404142434445464733 unmodified lines)return *repo}func GetAcademyByID(id uint) Repository[models.Academy, models.Academy] {repo := Construct[models.Academy, models.Academy](models.Academy{ID: int64(id)},)repo.Transactions(WhereGivenConstructor[models.Academy, models.Academy],Find[models.Academy, models.Academy],)return *repo}
123456789101128 unmodified lines40414243444546474849505152535455565 unmodified lines626364656667687 unmodified lines767778798081827 unmodified lines9091929394package responseimport ("api.qobiltu.id/models""api.qobiltu.id/pkg/validation""api.qobiltu.id/utils""errors""net/http""github.com/gin-gonic/gin")28 unmodified linescase exception.AttemptNotFound:responseError(c, http.StatusNotFound, exception)case exception.ValidationError:responseValidationError(c, http.StatusUnprocessableEntity, exception.ValidationErrorFields) // Gunakan fungsi khusus untuk validasidefault:responseError(c, http.StatusInternalServerError, exception)}} else {utils.LogError(err)responseError(c, http.StatusInternalServerError, models.Exception{InternalServerError: true,Message: "Internal Server Error",})}}func HandleSuccess(c *gin.Context, status int, msg string, data any, metaData any) {5 unmodified lines}c.JSON(status, res)return}func responseError(c *gin.Context, status int, exception models.Exception) {7 unmodified lines}c.AbortWithStatusJSON(status, res)return}func responseValidationError(c *gin.Context, status int, validationErrors []validation.ErrorMessage) {7 unmodified lines}c.AbortWithStatusJSON(status, res)return}1234567891011121328 unmodified lines42434445464748495051525354555657585960616263646566676869707172737475767778798081828384855 unmodified lines9192939495967 unmodified lines1041051061071081097 unmodified lines117118119120package responseimport ("encoding/json""errors""net/http""api.qobiltu.id/models""api.qobiltu.id/pkg/validation""api.qobiltu.id/utils""github.com/gin-gonic/gin")28 unmodified linescase exception.AttemptNotFound:responseError(c, http.StatusNotFound, exception)case exception.ValidationError:responseValidationError(c, http.StatusUnprocessableEntity, exception.ValidationErrorFields)default:responseError(c, http.StatusInternalServerError, exception)}return}var (jsonSyntaxError *json.SyntaxErrorjsonUnmarshalTypeError *json.UnmarshalTypeError)if errors.As(err, &jsonSyntaxError) {responseError(c, http.StatusBadRequest, models.Exception{BadRequest: true,Message: "Invalid JSON syntax",Err: err,})return}if errors.As(err, &jsonUnmarshalTypeError) {responseError(c, http.StatusBadRequest, models.Exception{BadRequest: true,Message: "Invalid body request",Err: err,})return}utils.LogError(err)responseError(c, http.StatusInternalServerError, models.Exception{InternalServerError: true,Message: "Internal Server Error",})}func HandleSuccess(c *gin.Context, status int, msg string, data any, metaData any) {5 unmodified lines}c.JSON(status, res)}func responseError(c *gin.Context, status int, exception models.Exception) {7 unmodified lines}c.AbortWithStatusJSON(status, res)}func responseValidationError(c *gin.Context, status int, validationErrors []validation.ErrorMessage) {7 unmodified lines}c.AbortWithStatusJSON(status, res)}
1234567891011121314151617package routerimport (AcademyController "api.qobiltu.id/controller/academy""api.qobiltu.id/middleware""github.com/gin-gonic/gin")func AcademyRoute(router *gin.Engine) {routerGroup := router.Group("/api/v1/academy"){routerGroup.GET("/:slug", middleware.AuthUser, AcademyController.MaterialsList)routerGroup.GET("/:slug/:slug_material", middleware.AuthUser, AcademyController.ContentList)routerGroup.GET("/list", middleware.AuthUser, AcademyController.List)routerGroup.POST("/create", middleware.AuthUser, AcademyController.Create)}}12345678910111213141516171819202122232425262728293031323334package routerimport ("api.qobiltu.id/middleware")func (s *Server) AcademyRoute() {adminRouterGroup := s.router.Group("/api/v1/admin/academy"){// TODO: add role checker middlewareadminRouterGroup.POST("", middleware.AuthUser, s.academyController.AdminCreateAcademy)adminRouterGroup.GET("", middleware.AuthUser, s.academyController.AdminListAcademy)adminRouterGroup.PUT("/reorder", middleware.AuthUser, s.academyController.AdminReorderAcademy)adminRouterGroup.GET("/:id", middleware.AuthUser, s.academyController.AdminGetAcademy)adminRouterGroup.PUT("/:id", middleware.AuthUser, s.academyController.AdminUpdateAcademy)adminRouterGroup.DELETE("/:id", middleware.AuthUser, s.academyController.AdminDeleteAcademy)adminRouterGroup.POST("/:id/materials", middleware.AuthUser, s.academyController.AdminCreateAcademyMaterial)adminRouterGroup.GET("/:id/materials", middleware.AuthUser, s.academyController.AdminListAcademyMaterial)adminRouterGroup.PUT("/:id/materials/reorder", middleware.AuthUser, s.academyController.AdminReorderAcademyMaterial)adminRouterGroup.GET("/:id/materials/:materialId", middleware.AuthUser, s.academyController.AdminGetAcademyMaterial)adminRouterGroup.PUT("/:id/materials/:materialId", middleware.AuthUser, s.academyController.AdminUpdateAcademyMaterial)adminRouterGroup.DELETE("/:id/materials/:materialId", middleware.AuthUser, s.academyController.AdminDeleteAcademyMaterial)}userRouterGroup := s.router.Group("/api/v1/academy"){userRouterGroup.GET("", middleware.AuthUser, s.academyController.UserListAcademy)userRouterGroup.GET("/:slug/materials", middleware.AuthUser, s.academyController.UserListAcademyMaterial)userRouterGroup.GET("/:slug/materials/:materialSlug", middleware.AuthUser, s.academyController.UserGetAcademyMaterialBySlug)userRouterGroup.POST("/:slug/materials/:materialSlug/toggle-read", middleware.AuthUser, s.academyController.UserToggleAcademyMaterialProgress)}}
9 unmodified lines10111213141516171819209 unmodified linesAuthRoute(s.router)UserRoute(s.router)AcademyRoute(s.router)QuizRoute(s.router)s.OptionsRoute()s.EmailRoute()s.CVRoute()s.MarriageReadinessProfileRoute()s.PartnerCriteriaRoute()9 unmodified lines10111213141516171819209 unmodified linesAuthRoute(s.router)UserRoute(s.router)QuizRoute(s.router)s.OptionsRoute()s.EmailRoute()s.AcademyRoute()s.CVRoute()s.MarriageReadinessProfileRoute()s.PartnerCriteriaRoute()
1234568 unmodified lines1516171819203 unmodified lines2425262728296 unmodified lines363738394041package routerimport (cv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"8 unmodified linesregionController region_controller.RegionControlleroptionsController options_controller.OptionsControlleremailController email_controller.EmailControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileControllerpartnerCriteriaController partner_criteria_controller.PartnerCriteriaController3 unmodified linesregionController region_controller.RegionController,optionsController options_controller.OptionsController,emailController email_controller.EmailController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,6 unmodified linesregionController: regionController,optionsController: optionsController,emailController: emailController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,12345678 unmodified lines161718192021223 unmodified lines262728293031326 unmodified lines39404142434445package routerimport (academy_controller "api.qobiltu.id/controller/academy"cv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"8 unmodified linesregionController region_controller.RegionControlleroptionsController options_controller.OptionsControlleremailController email_controller.EmailControlleracademyController academy_controller.AcademyControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileControllerpartnerCriteriaController partner_criteria_controller.PartnerCriteriaController3 unmodified linesregionController region_controller.RegionController,optionsController options_controller.OptionsController,emailController email_controller.EmailController,academyController academy_controller.AcademyController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,6 unmodified linesregionController: regionController,optionsController: optionsController,emailController: emailController,academyController: academyController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,
31 unmodified lines32333435363738134 unmodified lines17317417517617717817931 unmodified liness.Exception.Message = "There is no academy with given slug!"return}quizRepo := repositories.GetQuizbyAcademyId(academyRepo.Result.ID)s.Error = quizRepo.RowsErrorif quizRepo.NoRecord {s.Exception.DataNotFound = true134 unmodified lines}func (s *QuizListService) Retrieve() {quizRepo := repositories.GetQuizbyAcademyId(s.Constructor.ID)s.Error = quizRepo.RowsErrorif quizRepo.NoRecord {s.Exception.DataNotFound = true31 unmodified lines32333435363738134 unmodified lines17317417517617717817931 unmodified liness.Exception.Message = "There is no academy with given slug!"return}quizRepo := repositories.GetQuizbyAcademyId(uint(academyRepo.Result.ID))s.Error = quizRepo.RowsErrorif quizRepo.NoRecord {s.Exception.DataNotFound = true134 unmodified lines}func (s *QuizListService) Retrieve() {quizRepo := repositories.GetQuizbyAcademyId(uint(s.Constructor.ID))s.Error = quizRepo.RowsErrorif quizRepo.NoRecord {s.Exception.DataNotFound = true
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150package servicesimport ("errors""api.qobiltu.id/models""api.qobiltu.id/repositories""github.com/gosimple/slug"uuid "github.com/satori/go.uuid")type AcademyService struct {Service[models.Academy, []models.Academy]}type CreateAcademyService struct {Service[models.AllAcademyResponse, models.AllAcademyResponse]}type AcademyMaterialService struct {Service[models.Academy, []models.AcademyMaterial]}type AcademyContentService struct {Service[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)for _, academyMaterial := range academyMaterialsRepo.Result {ArrMaterials = append(ArrMaterials, models.AcademyMaterialResponse{Materials: academyMaterial,Contents: repositories.GetAllAcademyContentsByMaterialID(academyMaterial.ID).Result,})}return ArrMaterials}func (s *AcademyService) Retrieve() {if s.Constructor.Slug != "" {AcademyRepo := repositories.GetAcademyDataBySlug(s.Constructor.Slug)s.Error = AcademyRepo.RowsErrorif AcademyRepo.NoRecord {s.Exception.Message = "Academy not found"s.Exception.DataNotFound = truereturn}s.Result = []models.Academy{AcademyRepo.Result,}} else {AcademyRepo := repositories.GetAllAcademy()s.Error = AcademyRepo.RowsErrors.Result = AcademyRepo.Result}}func (s *CreateAcademyService) Create() {var ArrAcademy []models.AcademyResponsefor _, academy := range s.Constructor.Academies {academy.Academy.UUID = uuid.NewV4()if academy.Academy.Slug == "" {academy.Academy.Slug = slug.Make(academy.Academy.Title)}createdAcademy := repositories.CreateAcademy(academy.Academy)if createdAcademy.RowsError != nil {s.Error = createdAcademy.RowsErrorreturn}for _, material := range academy.Materials {material.Materials.AcademyID = createdAcademy.Result.IDmaterial.Materials.UUID = uuid.NewV4()if material.Materials.Slug == "" {material.Materials.Slug = slug.Make(material.Materials.Title)}createdMaterial := repositories.CreateAcademyMaterial(material.Materials)if createdMaterial.RowsError != nil {s.Error = createdMaterial.RowsErrorreturn}for _, content := range []models.AcademyContent{material.Contents} {content.UUID = uuid.NewV4()content.AcademyMaterialID = createdMaterial.Result.IDcreatedContent := repositories.CreateAcademyContent(content)if createdContent.RowsError != nil {s.Error = createdContent.RowsErrorreturn}ArrAcademy = append(ArrAcademy, models.AcademyResponse{Academy: createdAcademy.Result,Materials: castAcademyMaterials(createdAcademy.Result.ID),})}}}s.Result = models.AllAcademyResponse{Academies: ArrAcademy}}func (s *AcademyMaterialService) Retrieve() {academyRepo := repositories.GetAcademyDataBySlug(s.Constructor.Slug)if academyRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no Academy found with given Slug!"return}s.Error = academyRepo.RowsErroracademyMaterialRepo := repositories.GetAllAcademyMaterialsByAcademyID(academyRepo.Result.ID)s.Error = errors.Join(s.Error, academyMaterialRepo.RowsError)if academyMaterialRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no Academy Material with given ID"return}s.Result = academyMaterialRepo.Result}func (s *AcademyContentService) Retrieve() {academyMaterialRepo := repositories.GetAcademyMaterialBySlug(s.Constructor.Slug)s.Error = academyMaterialRepo.RowsErrorif academyMaterialRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no Academy Material with given Slug"return}academyContentRepo := repositories.GetAllAcademyContentsByMaterialID(academyMaterialRepo.Result.ID)s.Error = errors.Join(s.Error, academyContentRepo.RowsError)if academyContentRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "There is no Academy Contents with given Material ID"return}s.Result = academyContentRepo.Result}func (s *AcademyMarkReadService) Update() {markReadRepo := repositories.UpdateAcademyMaterialCompletedById(s.Constructor.ID)if markReadRepo.NoRecord {s.Exception.DataNotFound = trues.Error = markReadRepo.RowsErrorreturn}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316package servicesimport ("context""fmt""time""api.qobiltu.id/models""api.qobiltu.id/pkg/validation""api.qobiltu.id/repositories""api.qobiltu.id/response""github.com/gosimple/slug""gorm.io/gorm")type AcademyService interface {// === ADMIN ===AdminCreateAcademy(ctx context.Context, req *models.CreateAcademyRequest) (*models.AcademyResponse, error)AdminUpdateAcademy(ctx context.Context, req *models.UpdateAcademyRequest) (*models.AcademyResponse, error)AdminGetAcademyByID(ctx context.Context, id int64) (*models.AcademyResponse, error)AdminListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.AcademyResponse, *models.Paging, error)AdminDeleteAcademy(ctx context.Context, id int64) errorAdminReorderAcademy(ctx context.Context, req *models.ReorderAcademyRequest) errorAdminCreateAcademyMaterial(ctx context.Context, req *models.CreateAcademyMaterialRequest) (*models.AcademyMaterial, error)AdminUpdateAcademyMaterial(ctx context.Context, req *models.UpdateAcademyMaterialRequest) (*models.AcademyMaterial, error)AdminGetAcademyMaterialByID(ctx context.Context, id int64) (*models.AcademyMaterial, error)AdminListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.AcademyMaterial, *models.Paging, error)AdminDeleteAcademyMaterial(ctx context.Context, id int64) errorAdminReorderAcademyMaterial(ctx context.Context, req *models.ReorderAcademyMaterialRequest) error// === USER ===UserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error)UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error)UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error)UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error)UserToggleAcademyMaterialProgress(ctx context.Context, req *models.ToggleAcademyMaterialProgressRequest) error}type academyService struct {academyRepository repositories.AcademyRepositoryvalidator *validation.Validator}func NewAcademyService(academyRepository repositories.AcademyRepository, validator *validation.Validator) AcademyService {return &academyService{academyRepository: academyRepository,validator: validator,}}func (s *academyService) AdminCreateAcademy(ctx context.Context, req *models.CreateAcademyRequest) (*models.AcademyResponse, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}academy := &models.Academy{Title: req.Title,Slug: slug.Make(req.Title),Description: req.Description,}if req.Order == nil {lastOrder, err := s.academyRepository.AdminGetLastOrderAcademy(ctx)if err != nil {return nil, err}academy.Order = lastOrder + 1} else {academy.Order = *req.Order}res, err := s.academyRepository.AdminSaveAcademy(ctx, academy)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return res, nil}func (s *academyService) AdminUpdateAcademy(ctx context.Context, req *models.UpdateAcademyRequest) (*models.AcademyResponse, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}academy, err := s.academyRepository.AdminGetAcademyByID(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}if req.Title != nil {academy.Title = *req.Titleacademy.Slug = slug.Make(*req.Title)}if req.Description != nil {academy.Description = *req.Description}if req.Order != nil {academy.Order = *req.Order}fmt.Println("lolos")res, err := s.academyRepository.AdminSaveAcademy(ctx, &academy.Academy)if err != nil {return nil, err}return res, nil}func (s *academyService) AdminGetAcademyByID(ctx context.Context, id int64) (*models.AcademyResponse, error) {academy, err := s.academyRepository.AdminGetAcademyByID(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return academy, nil}func (s *academyService) AdminListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.AcademyResponse, *models.Paging, error) {academies, paging, err := s.academyRepository.AdminListAcademy(ctx, req)if err != nil {return nil, nil, response.HandleGormError(err, "Internal Server Error")}return academies, paging, nil}func (s *academyService) AdminDeleteAcademy(ctx context.Context, id int64) error {err := s.academyRepository.AdminDeleteAcademy(ctx, id)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}func (s *academyService) AdminReorderAcademy(ctx context.Context, req *models.ReorderAcademyRequest) error {err := s.academyRepository.AdminReorderAcademy(ctx, req)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}func (s *academyService) AdminCreateAcademyMaterial(ctx context.Context, req *models.CreateAcademyMaterialRequest) (*models.AcademyMaterial, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}academy, err := s.academyRepository.AdminGetAcademyByID(ctx, req.AcademyID)if err != nil {return nil, response.HandleGormError(gorm.ErrRecordNotFound, "Internal Server Error")}academyMaterial := &models.AcademyMaterial{AcademyID: academy.ID,Title: req.Title,Slug: slug.Make(req.Title),Content: req.Content,}if req.Order == nil {lastOrder, err := s.academyRepository.AdminGetLastOrderAcademyMaterial(ctx)if err != nil {return nil, err}academyMaterial.Order = lastOrder + 1} else {academyMaterial.Order = *req.Order}if err := s.academyRepository.AdminSaveAcademyMaterial(ctx, academyMaterial); err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return academyMaterial, nil}func (s *academyService) AdminUpdateAcademyMaterial(ctx context.Context, req *models.UpdateAcademyMaterialRequest) (*models.AcademyMaterial, error) {if err := s.validator.Validate(req); err != nil {return nil, response.HandleValidationError(err)}academyMaterial, err := s.academyRepository.AdminGetAcademyMaterialByID(ctx, req.ID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}if req.Title != nil {academyMaterial.Title = *req.TitleacademyMaterial.Slug = slug.Make(*req.Title)}if req.Content != nil {academyMaterial.Content = *req.Content}if req.Order != nil {academyMaterial.Order = *req.Order}if err := s.academyRepository.AdminSaveAcademyMaterial(ctx, academyMaterial); err != nil {return nil, err}return academyMaterial, nil}func (s *academyService) AdminGetAcademyMaterialByID(ctx context.Context, id int64) (*models.AcademyMaterial, error) {academyMaterial, err := s.academyRepository.AdminGetAcademyMaterialByID(ctx, id)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return academyMaterial, nil}func (s *academyService) AdminListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.AcademyMaterial, *models.Paging, error) {academyMaterials, paging, err := s.academyRepository.AdminListAcademyMaterial(ctx, req)if err != nil {return nil, nil, response.HandleGormError(err, "Internal Server Error")}return academyMaterials, paging, nil}func (s *academyService) AdminDeleteAcademyMaterial(ctx context.Context, id int64) error {err := s.academyRepository.AdminDeleteAcademyMaterial(ctx, id)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}func (s *academyService) AdminReorderAcademyMaterial(ctx context.Context, req *models.ReorderAcademyMaterialRequest) error {err := s.academyRepository.AdminReorderAcademyMaterial(ctx, req)if err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}// === USER ===func (s *academyService) UserListAcademy(ctx context.Context, req *models.ListAcademyRequest) ([]models.UserAcademyResponse, *models.Paging, error) {academies, paging, err := s.academyRepository.UserListAcademy(ctx, req)if err != nil {return nil, nil, response.HandleGormError(err, "Internal Server Error")}return academies, paging, nil}func (s *academyService) UserListAcademyMaterial(ctx context.Context, req *models.ListAcademyMaterialRequest) ([]models.UserAcademyMaterialResponse, *models.Paging, error) {academyMaterials, paging, err := s.academyRepository.UserListAcademyMaterial(ctx, req)if err != nil {return nil, nil, response.HandleGormError(err, "Internal Server Error")}return academyMaterials, paging, nil}func (s *academyService) UserGetAcademyBySlug(ctx context.Context, slug string) (*models.AcademyResponse, error) {academy, err := s.academyRepository.UserGetAcademyBySlug(ctx, slug)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return academy, nil}func (s *academyService) UserGetAcademyMaterialBySlug(ctx context.Context, slug string, accountID int64) (*models.UserAcademyMaterialResponse, error) {academyMaterial, err := s.academyRepository.UserGetAcademyMaterialBySlug(ctx, slug, accountID)if err != nil {return nil, response.HandleGormError(err, "Internal Server Error")}return academyMaterial, nil}func (s *academyService) UserToggleAcademyMaterialProgress(ctx context.Context, req *models.ToggleAcademyMaterialProgressRequest) error {academyMaterial, err := s.academyRepository.UserGetAcademyMaterialBySlug(ctx, req.Slug, req.AccountID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}if academyMaterial.IsRead {err = s.academyRepository.UserDeleteAcademyMaterialProgress(ctx, req.AccountID, academyMaterial.ID)if err != nil {return response.HandleGormError(err, "Internal Server Error")}} else {now := time.Now()academyMaterialProgress := &models.AcademyMaterialProgress{AccountID: req.AccountID,AcademyMaterialID: academyMaterial.ID,ReadAt: &now,}err = s.academyRepository.UserSaveAcademyMaterialProgress(ctx, academyMaterialProgress)if err != nil {return response.HandleGormError(err, "Internal Server Error")}}return nil}
10 unmodified lines11121310 unmodified linesEmailConfirmationTemplatePath = "emails/email-confirmation.tmpl"EmailForgotPasswordTemplatePath = "emails/email-forgot-password.tmpl")10 unmodified lines111213141516171819202110 unmodified linesEmailConfirmationTemplatePath = "emails/email-confirmation.tmpl"EmailForgotPasswordTemplatePath = "emails/email-forgot-password.tmpl")var (//go:embed "seeds/province.json"EmbeddedProvinceJSON []byte//go:embed "seeds/city.json"EmbeddedCityJSON []byte)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114[
{
"id": 1,
"type": "Kabupaten",
"name": "Aceh Barat",
"code": "05",
"full_code": "1105",
"province_id": 1
},
{
"id": 2,
"type": "Kabupaten",
"name": "Aceh Barat Daya",
"code": "12",
"full_code": "1112",
"province_id": 1
},
{
"id": 3,
"type": "Kabupaten",
"name": "Sabu Raijua",
"code": "20",
"full_code": "5320",
"province_id": 23
},
{
"id": 4,
"type": "Kota",
"name": "Salatiga",
"code": "73",
"full_code": "3373",
"province_id": 10
},
{
"id": 5,
"type": "Kabupaten",
"name": "Aceh Besar",
"code": "06",
"full_code": "1106",
"province_id": 1
},
{
"id": 6,
"type": "Kabupaten",
"name": "Aceh Jaya",
"code": "14",
"full_code": "1114",
"province_id": 1
},
{
"id": 7,
"type": "Kabupaten",
"name": "Aceh Selatan",
"code": "01",
"full_code": "1101",
"province_id": 1
},
{
"id": 8,
"type": "Kabupaten",
"name": "Aceh Singkil",
"code": "10",
"full_code": "1110",
"province_id": 1
},
{
"id": 9,
"type": "Kabupaten",
"name": "Aceh Tamiang",
"code": "16",
"full_code": "1116",
"province_id": 1
},
{
"id": 10,
"type": "Kabupaten",
"name": "Aceh Tengah",
"code": "04",
"full_code": "1104",
"province_id": 1
},
{
"id": 11,
"type": "Kabupaten",
"name": "Aceh Tenggara",
"code": "02",
"full_code": "1102",
"province_id": 1
},
{
"id": 12,
"type": "Kabupaten",
"name": "Aceh Timur",
"code": "03",
"full_code": "1103",
"province_id": 1
},
{
"id": 13,
"type": "Kabupaten",
"name": "Gorontalo Utara",
"code": "05",
"full_code": "7505",
"province_id": 7
},
{
"id": 14,
"type": "Kabupaten",
"name": "Aceh Utara",
"code": "08",
"full_code": "1108",
"province_id": 1
},
{
"id": 15,
"type": "Kabupaten",
"name": "Agam",
"code": "06",
"full_code": "1306",
"province_id": 36
},
{
"id": 16,
"type": "Kabupaten",
"name": "Alor",
"code": "05",
"full_code": "5305",
"province_id": 23
},
{
"id": 17,
"type": "Kota",
"name": "Ambon",
"code": "71",
"full_code": "8171",
"province_id": 20
},
{
"id": 18,
"type": "Kabupaten",
"name": "Gowa",
"code": "06",
"full_code": "7306",
"province_id": 32
},
{
"id": 19,
"type": "Kota",
"name": "Samarinda",
"code": "72",
"full_code": "6472",
"province_id": 15
},
{
"id": 20,
"type": "Kabupaten",
"name": "Asahan",
"code": "09",
"full_code": "1209",
"province_id": 38
},
{
"id": 21,
"type": "Kabupaten",
"name": "Sambas",
"code": "01",
"full_code": "6101",
"province_id": 12
},
{
"id": 22,
"type": "Kabupaten",
"name": "Asmat",
"code": "04",
"full_code": "9304",
"province_id": 28
},
{
"id": 23,
"type": "Kabupaten",
"name": "Samosir",
"code": "17",
"full_code": "1217",
"province_id": 38
},
{
"id": 24,
"type": "Kabupaten",
"name": "Badung",
"code": "03",
"full_code": "5103",
"province_id": 2
},
{
"id": 25,
"type": "Kabupaten",
"name": "Sampang",
"code": "27",
"full_code": "3527",
"province_id": 11
},
{
"id": 26,
"type": "Kabupaten",
"name": "Balangan",
"code": "11",
"full_code": "6311",
"province_id": 13
},
{
"id": 27,
"type": "Kabupaten",
"name": "Sanggau",
"code": "03",
"full_code": "6103",
"province_id": 12
},
{
"id": 28,
"type": "Kabupaten",
"name": "Sarmi",
"code": "10",
"full_code": "9110",
"province_id": 24
},
{
"id": 29,
"type": "Kabupaten",
"name": "Gresik",
"code": "25",
"full_code": "3525",
"province_id": 11
},
{
"id": 30,
"type": "Kabupaten",
"name": "Grobogan",
"code": "15",
"full_code": "3315",
"province_id": 10
},
{
"id": 31,
"type": "Kabupaten",
"name": "Gunung Mas",
"code": "10",
"full_code": "6210",
"province_id": 14
},
{
"id": 32,
"type": "Kabupaten",
"name": "Gunungkidul",
"code": "03",
"full_code": "3403",
"province_id": 5
},
{
"id": 33,
"type": "Kabupaten",
"name": "Sarolangun",
"code": "03",
"full_code": "1503",
"province_id": 8
},
{
"id": 34,
"type": "Kota",
"name": "Gunungsitoli",
"code": "78",
"full_code": "1278",
"province_id": 38
},
{
"id": 35,
"type": "Kota",
"name": "Sawahlunto",
"code": "73",
"full_code": "1373",
"province_id": 36
},
{
"id": 36,
"type": "Kabupaten",
"name": "Halmahera Barat",
"code": "01",
"full_code": "8201",
"province_id": 21
},
{
"id": 37,
"type": "Kabupaten",
"name": "Sekadau",
"code": "09",
"full_code": "6109",
"province_id": 12
},
{
"id": 38,
"type": "Kabupaten",
"name": "Halmahera Selatan",
"code": "04",
"full_code": "8204",
"province_id": 21
},
{
"id": 39,
"type": "Kabupaten",
"name": "Seluma",
"code": "05",
"full_code": "1705",
"province_id": 4
},
{
"id": 40,
"type": "Kabupaten",
"name": "Halmahera Tengah",
"code": "02",
"full_code": "8202",
"province_id": 21
},
{
"id": 41,
"type": "Kabupaten",
"name": "Semarang",
"code": "22",
"full_code": "3322",
"province_id": 10
},
{
"id": 42,
"type": "Kota",
"name": "Semarang",
"code": "74",
"full_code": "3374",
"province_id": 10
},
{
"id": 43,
"type": "Kabupaten",
"name": "Halmahera Timur",
"code": "06",
"full_code": "8206",
"province_id": 21
},
{
"id": 44,
"type": "Kabupaten",
"name": "Seram Bagian Barat",
"code": "06",
"full_code": "8106",
"province_id": 20
},
{
"id": 45,
"type": "Kabupaten",
"name": "Halmahera Utara",
"code": "03",
"full_code": "8203",
"province_id": 21
},
{
"id": 46,
"type": "Kabupaten",
"name": "Seram Bagian Timur",
"code": "05",
"full_code": "8105",
"province_id": 20
},
{
"id": 47,
"type": "Kabupaten",
"name": "Hulu Sungai Selatan",
"code": "06",
"full_code": "6306",
"province_id": 13
},
{
"id": 48,
"type": "Kabupaten",
"name": "Hulu Sungai Tengah",
"code": "07",
"full_code": "6307",
"province_id": 13
},
{
"id": 49,
"type": "Kabupaten",
"name": "Hulu Sungai Utara",
"code": "08",
"full_code": "6308",
"province_id": 13
},
{
"id": 50,
"type": "Kota",
"name": "Serang",
"code": "73",
"full_code": "3673",
"province_id": 3
},
{
"id": 51,
"type": "Kabupaten",
"name": "Serang",
"code": "04",
"full_code": "3604",
"province_id": 3
},
{
"id": 52,
"type": "Kabupaten",
"name": "Humbang Hasundutan",
"code": "16",
"full_code": "1216",
"province_id": 38
},
{
"id": 53,
"type": "Kota",
"name": "Balikpapan",
"code": "71",
"full_code": "6471",
"province_id": 15
},
{
"id": 54,
"type": "Kabupaten",
"name": "Indragiri Hilir",
"code": "04",
"full_code": "1404",
"province_id": 30
},
{
"id": 55,
"type": "Kabupaten",
"name": "Indragiri Hulu",
"code": "02",
"full_code": "1402",
"province_id": 30
},
{
"id": 56,
"type": "Kota",
"name": "Banda Aceh",
"code": "71",
"full_code": "1171",
"province_id": 1
},
{
"id": 57,
"type": "Kota",
"name": "Bandar Lampung",
"code": "71",
"full_code": "1871",
"province_id": 19
},
{
"id": 58,
"type": "Kota",
"name": "Bandung",
"code": "73",
"full_code": "3273",
"province_id": 9
},
{
"id": 59,
"type": "Kabupaten",
"name": "Bandung",
"code": "04",
"full_code": "3204",
"province_id": 9
},
{
"id": 60,
"type": "Kabupaten",
"name": "Bandung Barat",
"code": "17",
"full_code": "3217",
"province_id": 9
},
{
"id": 61,
"type": "Kabupaten",
"name": "Banggai",
"code": "01",
"full_code": "7201",
"province_id": 33
},
{
"id": 62,
"type": "Kabupaten",
"name": "Banggai Kepulauan",
"code": "07",
"full_code": "7207",
"province_id": 33
},
{
"id": 63,
"type": "Kabupaten",
"name": "Banggai Laut",
"code": "11",
"full_code": "7211",
"province_id": 33
},
{
"id": 64,
"type": "Kabupaten",
"name": "Bangka",
"code": "01",
"full_code": "1901",
"province_id": 17
},
{
"id": 65,
"type": "Kabupaten",
"name": "Bangka Barat",
"code": "05",
"full_code": "1905",
"province_id": 17
},
{
"id": 66,
"type": "Kabupaten",
"name": "Bangka Selatan",
"code": "03",
"full_code": "1903",
"province_id": 17
},
{
"id": 67,
"type": "Kabupaten",
"name": "Bangka Tengah",
"code": "04",
"full_code": "1904",
"province_id": 17
},
{
"id": 68,
"type": "Kabupaten",
"name": "Bangkalan",
"code": "26",
"full_code": "3526",
"province_id": 11
},
{
"id": 69,
"type": "Kabupaten",
"name": "Bangli",
"code": "06",
"full_code": "5106",
"province_id": 2
},
{
"id": 70,
"type": "Kota",
"name": "Banjar",
"code": "79",
"full_code": "3279",
"province_id": 9
},
{
"id": 71,
"type": "Kabupaten",
"name": "Banjar",
"code": "03",
"full_code": "6303",
"province_id": 13
},
{
"id": 72,
"type": "Kota",
"name": "Banjarbaru",
"code": "72",
"full_code": "6372",
"province_id": 13
},
{
"id": 73,
"type": "Kota",
"name": "Banjarmasin",
"code": "71",
"full_code": "6371",
"province_id": 13
},
{
"id": 74,
"type": "Kabupaten",
"name": "Banjarnegara",
"code": "04",
"full_code": "3304",
"province_id": 10
},
{
"id": 75,
"type": "Kabupaten",
"name": "Bantaeng",
"code": "03",
"full_code": "7303",
"province_id": 32
},
{
"id": 76,
"type": "Kabupaten",
"name": "Bantul",
"code": "02",
"full_code": "3402",
"province_id": 5
},
{
"id": 77,
"type": "Kabupaten",
"name": "Banyuasin",
"code": "07",
"full_code": "1607",
"province_id": 37
},
{
"id": 78,
"type": "Kabupaten",
"name": "Banyumas",
"code": "02",
"full_code": "3302",
"province_id": 10
},
{
"id": 79,
"type": "Kabupaten",
"name": "Banyuwangi",
"code": "10",
"full_code": "3510",
"province_id": 11
},
{
"id": 80,
"type": "Kabupaten",
"name": "Barito Kuala",
"code": "04",
"full_code": "6304",
"province_id": 13
},
{
"id": 81,
"type": "Kabupaten",
"name": "Barito Selatan",
"code": "04",
"full_code": "6204",
"province_id": 14
},
{
"id": 82,
"type": "Kabupaten",
"name": "Barito Timur",
"code": "13",
"full_code": "6213",
"province_id": 14
},
{
"id": 83,
"type": "Kabupaten",
"name": "Barito Utara",
"code": "05",
"full_code": "6205",
"province_id": 14
},
{
"id": 84,
"type": "Kabupaten",
"name": "Barru",
"code": "11",
"full_code": "7311",
"province_id": 32
},
{
"id": 85,
"type": "Kota",
"name": "Batam",
"code": "71",
"full_code": "2171",
"province_id": 18
},
{
"id": 86,
"type": "Kabupaten",
"name": "Batang",
"code": "25",
"full_code": "3325",
"province_id": 10
},
{
"id": 87,
"type": "Kabupaten",
"name": "Batanghari",
"code": "04",
"full_code": "1504",
"province_id": 8
},
{
"id": 88,
"type": "Kota",
"name": "Batu",
"code": "79",
"full_code": "3579",
"province_id": 11
},
{
"id": 89,
"type": "Kabupaten",
"name": "Batu Bara",
"code": "19",
"full_code": "1219",
"province_id": 38
},
{
"id": 90,
"type": "Kota",
"name": "Bau Bau",
"code": "72",
"full_code": "7472",
"province_id": 34
},
{
"id": 91,
"type": "Kota",
"name": "Bekasi",
"code": "75",
"full_code": "3275",
"province_id": 9
},
{
"id": 92,
"type": "Kabupaten",
"name": "Bekasi",
"code": "16",
"full_code": "3216",
"province_id": 9
},
{
"id": 93,
"type": "Kabupaten",
"name": "Belitung",
"code": "02",
"full_code": "1902",
"province_id": 17
},
{
"id": 94,
"type": "Kabupaten",
"name": "Belitung Timur",
"code": "06",
"full_code": "1906",
"province_id": 17
},
{
"id": 95,
"type": "Kabupaten",
"name": "Belu",
"code": "04",
"full_code": "5304",
"province_id": 23
},
{
"id": 96,
"type": "Kabupaten",
"name": "Bener Meriah",
"code": "17",
"full_code": "1117",
"province_id": 1
},
{
"id": 97,
"type": "Kabupaten",
"name": "Bengkalis",
"code": "03",
"full_code": "1403",
"province_id": 30
},
{
"id": 98,
"type": "Kabupaten",
"name": "Bengkayang",
"code": "07",
"full_code": "6107",
"province_id": 12
},
{
"id": 99,
"type": "Kabupaten",
"name": "Serdang Bedagai",
"code": "18",
"full_code": "1218",
"province_id": 38
},
{
"id": 100,
"type": "Kota",
"name": "Bengkulu",
"code": "71",
"full_code": "1771",
"province_id": 4
},
{
"id": 101,
"type": "Kabupaten",
"name": "Bengkulu Selatan",
"code": "01",
"full_code": "1701",
"province_id": 4
},
{
"id": 102,
"type": "Kabupaten",
"name": "Seruyan",
"code": "07",
"full_code": "6207",
"province_id": 14
},
{
"id": 103,
"type": "Kabupaten",
"name": "Indramayu",
"code": "12",
"full_code": "3212",
"province_id": 9
},
{
"id": 104,
"type": "Kabupaten",
"name": "Siak",
"code": "08",
"full_code": "1408",
"province_id": 30
},
{
"id": 105,
"type": "Kabupaten",
"name": "Intan Jaya",
"code": "07",
"full_code": "9407",
"province_id": 29
},
{
"id": 106,
"type": "Kota",
"name": "Jakarta Barat",
"code": "73",
"full_code": "3173",
"province_id": 6
},
{
"id": 107,
"type": "Kota",
"name": "Sibolga",
"code": "73",
"full_code": "1273",
"province_id": 38
},
{
"id": 108,
"type": "Kabupaten",
"name": "Bengkulu Tengah",
"code": "09",
"full_code": "1709",
"province_id": 4
},
{
"id": 109,
"type": "Kota",
"name": "Jakarta Pusat",
"code": "71",
"full_code": "3171",
"province_id": 6
},
{
"id": 110,
"type": "Kabupaten",
"name": "Sidenreng Rappang",
"code": "14",
"full_code": "7314",
"province_id": 32
},
{
"id": 111,
"type": "Kabupaten",
"name": "Bengkulu Utara",
"code": "03",
"full_code": "1703",
"province_id": 4
},
{
"id": 112,
"type": "Kota",
"name": "Jakarta Selatan",
"code": "74",
"full_code": "3174",
"province_id": 6
},
{
"id": 113,
"type": "Kabupaten",
"name": "Sidoarjo",
"code": "15",
"full_code": "3515",
"province_id": 11
},
{
"id": 114,
"type": "Kota",
"name": "Jakarta Timur",
"code": "75",
"full_code": "3175",
"province_id": 6
},
{
"id": 115,
"type": "Kabupaten",
"name": "Sigi",
"code": "10",
"full_code": "7210",
"province_id": 33
},
{
"id": 116,
"type": "Kabupaten",
"name": "Berau",
"code": "03",
"full_code": "6403",
"province_id": 15
},
{
"id": 117,
"type": "Kabupaten",
"name": "Biak Numfor",
"code": "06",
"full_code": "9106",
"province_id": 24
},
{
"id": 118,
"type": "Kabupaten",
"name": "Bima",
"code": "06",
"full_code": "5206",
"province_id": 22
},
{
"id": 119,
"type": "Kota",
"name": "Jakarta Utara",
"code": "72",
"full_code": "3172",
"province_id": 6
},
{
"id": 120,
"type": "Kota",
"name": "Bima",
"code": "72",
"full_code": "5272",
"province_id": 22
},
{
"id": 121,
"type": "Kota",
"name": "Jambi",
"code": "71",
"full_code": "1571",
"province_id": 8
},
{
"id": 122,
"type": "Kabupaten",
"name": "Sijunjung",
"code": "03",
"full_code": "1303",
"province_id": 36
},
{
"id": 123,
"type": "Kota",
"name": "Binjai",
"code": "75",
"full_code": "1275",
"province_id": 38
},
{
"id": 124,
"type": "Kabupaten",
"name": "Jayapura",
"code": "03",
"full_code": "9103",
"province_id": 24
},
{
"id": 125,
"type": "Kabupaten",
"name": "Bintan",
"code": "01",
"full_code": "2101",
"province_id": 18
},
{
"id": 126,
"type": "Kabupaten",
"name": "Sikka",
"code": "07",
"full_code": "5307",
"province_id": 23
},
{
"id": 127,
"type": "Kabupaten",
"name": "Bireuen",
"code": "11",
"full_code": "1111",
"province_id": 1
},
{
"id": 128,
"type": "Kabupaten",
"name": "Simalungun",
"code": "08",
"full_code": "1208",
"province_id": 38
},
{
"id": 129,
"type": "Kota",
"name": "Bitung",
"code": "72",
"full_code": "7172",
"province_id": 35
},
{
"id": 130,
"type": "Kota",
"name": "Jayapura",
"code": "71",
"full_code": "9171",
"province_id": 24
},
{
"id": 131,
"type": "Kabupaten",
"name": "Simeulue",
"code": "09",
"full_code": "1109",
"province_id": 1
},
{
"id": 132,
"type": "Kabupaten",
"name": "Jayawijaya",
"code": "01",
"full_code": "9501",
"province_id": 27
},
{
"id": 133,
"type": "Kabupaten",
"name": "Jember",
"code": "09",
"full_code": "3509",
"province_id": 11
},
{
"id": 134,
"type": "Kota",
"name": "Singkawang",
"code": "72",
"full_code": "6172",
"province_id": 12
},
{
"id": 135,
"type": "Kabupaten",
"name": "Blitar",
"code": "05",
"full_code": "3505",
"province_id": 11
},
{
"id": 136,
"type": "Kabupaten",
"name": "Jembrana",
"code": "01",
"full_code": "5101",
"province_id": 2
},
{
"id": 137,
"type": "Kabupaten",
"name": "Sinjai",
"code": "07",
"full_code": "7307",
"province_id": 32
},
{
"id": 138,
"type": "Kota",
"name": "Blitar",
"code": "72",
"full_code": "3572",
"province_id": 11
},
{
"id": 139,
"type": "Kabupaten",
"name": "Jeneponto",
"code": "04",
"full_code": "7304",
"province_id": 32
},
{
"id": 140,
"type": "Kabupaten",
"name": "Blora",
"code": "16",
"full_code": "3316",
"province_id": 10
},
{
"id": 141,
"type": "Kabupaten",
"name": "Jepara",
"code": "20",
"full_code": "3320",
"province_id": 10
},
{
"id": 142,
"type": "Kabupaten",
"name": "Sintang",
"code": "05",
"full_code": "6105",
"province_id": 12
},
{
"id": 143,
"type": "Kabupaten",
"name": "Boalemo",
"code": "02",
"full_code": "7502",
"province_id": 7
},
{
"id": 144,
"type": "Kabupaten",
"name": "Jombang",
"code": "17",
"full_code": "3517",
"province_id": 11
},
{
"id": 145,
"type": "Kabupaten",
"name": "Bogor",
"code": "01",
"full_code": "3201",
"province_id": 9
},
{
"id": 146,
"type": "Kabupaten",
"name": "Situbondo",
"code": "12",
"full_code": "3512",
"province_id": 11
},
{
"id": 147,
"type": "Kabupaten",
"name": "Kaimana",
"code": "08",
"full_code": "9208",
"province_id": 25
},
{
"id": 148,
"type": "Kota",
"name": "Bogor",
"code": "71",
"full_code": "3271",
"province_id": 9
},
{
"id": 149,
"type": "Kabupaten",
"name": "Sleman",
"code": "04",
"full_code": "3404",
"province_id": 5
},
{
"id": 150,
"type": "Kabupaten",
"name": "Kampar",
"code": "01",
"full_code": "1401",
"province_id": 30
},
{
"id": 151,
"type": "Kabupaten",
"name": "Bojonegoro",
"code": "22",
"full_code": "3522",
"province_id": 11
},
{
"id": 152,
"type": "Kabupaten",
"name": "Solok",
"code": "02",
"full_code": "1302",
"province_id": 36
},
{
"id": 153,
"type": "Kabupaten",
"name": "Bolaang Mongondow",
"code": "01",
"full_code": "7101",
"province_id": 35
},
{
"id": 154,
"type": "Kabupaten",
"name": "Bolaang Mongondow Selatan",
"code": "11",
"full_code": "7111",
"province_id": 35
},
{
"id": 155,
"type": "Kota",
"name": "Solok",
"code": "72",
"full_code": "1372",
"province_id": 36
},
{
"id": 156,
"type": "Kabupaten",
"name": "Kapuas",
"code": "03",
"full_code": "6203",
"province_id": 14
},
{
"id": 157,
"type": "Kabupaten",
"name": "Solok Selatan",
"code": "11",
"full_code": "1311",
"province_id": 36
},
{
"id": 158,
"type": "Kabupaten",
"name": "Bolaang Mongondow Timur",
"code": "10",
"full_code": "7110",
"province_id": 35
},
{
"id": 159,
"type": "Kabupaten",
"name": "Kapuas Hulu",
"code": "06",
"full_code": "6106",
"province_id": 12
},
{
"id": 160,
"type": "Kabupaten",
"name": "Karanganyar",
"code": "13",
"full_code": "3313",
"province_id": 10
},
{
"id": 161,
"type": "Kabupaten",
"name": "Karangasem",
"code": "07",
"full_code": "5107",
"province_id": 2
},
{
"id": 162,
"type": "Kabupaten",
"name": "Bolaang Mongondow Utara",
"code": "08",
"full_code": "7108",
"province_id": 35
},
{
"id": 163,
"type": "Kabupaten",
"name": "Karawang",
"code": "15",
"full_code": "3215",
"province_id": 9
},
{
"id": 164,
"type": "Kabupaten",
"name": "Bombana",
"code": "06",
"full_code": "7406",
"province_id": 34
},
{
"id": 165,
"type": "Kabupaten",
"name": "Karimun",
"code": "02",
"full_code": "2102",
"province_id": 18
},
{
"id": 166,
"type": "Kabupaten",
"name": "Bondowoso",
"code": "11",
"full_code": "3511",
"province_id": 11
},
{
"id": 167,
"type": "Kabupaten",
"name": "Karo",
"code": "06",
"full_code": "1206",
"province_id": 38
},
{
"id": 168,
"type": "Kabupaten",
"name": "Soppeng",
"code": "12",
"full_code": "7312",
"province_id": 32
},
{
"id": 169,
"type": "Kabupaten",
"name": "Katingan",
"code": "06",
"full_code": "6206",
"province_id": 14
},
{
"id": 170,
"type": "Kabupaten",
"name": "Kaur",
"code": "04",
"full_code": "1704",
"province_id": 4
},
{
"id": 171,
"type": "Kabupaten",
"name": "Sorong",
"code": "01",
"full_code": "9201",
"province_id": 26
},
{
"id": 172,
"type": "Kabupaten",
"name": "Kayong Utara",
"code": "11",
"full_code": "6111",
"province_id": 12
},
{
"id": 173,
"type": "Kota",
"name": "Sorong",
"code": "71",
"full_code": "9271",
"province_id": 26
},
{
"id": 174,
"type": "Kabupaten",
"name": "Sorong Selatan",
"code": "04",
"full_code": "9204",
"province_id": 26
},
{
"id": 175,
"type": "Kabupaten",
"name": "Kebumen",
"code": "05",
"full_code": "3305",
"province_id": 10
},
{
"id": 176,
"type": "Kabupaten",
"name": "Sragen",
"code": "14",
"full_code": "3314",
"province_id": 10
},
{
"id": 177,
"type": "Kabupaten",
"name": "Kediri",
"code": "06",
"full_code": "3506",
"province_id": 11
},
{
"id": 178,
"type": "Kabupaten",
"name": "Subang",
"code": "13",
"full_code": "3213",
"province_id": 9
},
{
"id": 179,
"type": "Kota",
"name": "Subulussalam",
"code": "75",
"full_code": "1175",
"province_id": 1
},
{
"id": 180,
"type": "Kota",
"name": "Sukabumi",
"code": "72",
"full_code": "3272",
"province_id": 9
},
{
"id": 181,
"type": "Kota",
"name": "Kediri",
"code": "71",
"full_code": "3571",
"province_id": 11
},
{
"id": 182,
"type": "Kabupaten",
"name": "Bone",
"code": "08",
"full_code": "7308",
"province_id": 32
},
{
"id": 183,
"type": "Kabupaten",
"name": "Keerom",
"code": "11",
"full_code": "9111",
"province_id": 24
},
{
"id": 184,
"type": "Kabupaten",
"name": "Sukabumi",
"code": "02",
"full_code": "3202",
"province_id": 9
},
{
"id": 185,
"type": "Kabupaten",
"name": "Bone Bolango",
"code": "03",
"full_code": "7503",
"province_id": 7
},
{
"id": 186,
"type": "Kabupaten",
"name": "Kendal",
"code": "24",
"full_code": "3324",
"province_id": 10
},
{
"id": 187,
"type": "Kota",
"name": "Bontang",
"code": "74",
"full_code": "6474",
"province_id": 15
},
{
"id": 188,
"type": "Kota",
"name": "Kendari",
"code": "71",
"full_code": "7471",
"province_id": 34
},
{
"id": 189,
"type": "Kabupaten",
"name": "Boven Digoel",
"code": "02",
"full_code": "9302",
"province_id": 28
},
{
"id": 190,
"type": "Kabupaten",
"name": "Kepahiang",
"code": "08",
"full_code": "1708",
"province_id": 4
},
{
"id": 191,
"type": "Kabupaten",
"name": "Boyolali",
"code": "09",
"full_code": "3309",
"province_id": 10
},
{
"id": 192,
"type": "Kabupaten",
"name": "Sukamara",
"code": "08",
"full_code": "6208",
"province_id": 14
},
{
"id": 193,
"type": "Kabupaten",
"name": "Kepulauan Anambas",
"code": "05",
"full_code": "2105",
"province_id": 18
},
{
"id": 194,
"type": "Kabupaten",
"name": "Sukoharjo",
"code": "11",
"full_code": "3311",
"province_id": 10
},
{
"id": 195,
"type": "Kabupaten",
"name": "Sumba Barat",
"code": "12",
"full_code": "5312",
"province_id": 23
},
{
"id": 196,
"type": "Kabupaten",
"name": "Brebes",
"code": "29",
"full_code": "3329",
"province_id": 10
},
{
"id": 197,
"type": "Kota",
"name": "Bukittinggi",
"code": "75",
"full_code": "1375",
"province_id": 36
},
{
"id": 198,
"type": "Kabupaten",
"name": "Buleleng",
"code": "08",
"full_code": "5108",
"province_id": 2
},
{
"id": 199,
"type": "Kabupaten",
"name": "Bulukumba",
"code": "02",
"full_code": "7302",
"province_id": 32
},
{
"id": 200,
"type": "Kabupaten",
"name": "Sumba Barat Daya",
"code": "18",
"full_code": "5318",
"province_id": 23
},
{
"id": 201,
"type": "Kabupaten",
"name": "Sumba Tengah",
"code": "17",
"full_code": "5317",
"province_id": 23
},
{
"id": 202,
"type": "Kabupaten",
"name": "Sumba Timur",
"code": "11",
"full_code": "5311",
"province_id": 23
},
{
"id": 203,
"type": "Kabupaten",
"name": "Bulungan",
"code": "01",
"full_code": "6501",
"province_id": 16
},
{
"id": 204,
"type": "Kabupaten",
"name": "Sumbawa",
"code": "04",
"full_code": "5204",
"province_id": 22
},
{
"id": 205,
"type": "Kabupaten",
"name": "Bungo",
"code": "08",
"full_code": "1508",
"province_id": 8
},
{
"id": 206,
"type": "Kabupaten",
"name": "Sumbawa Barat",
"code": "07",
"full_code": "5207",
"province_id": 22
},
{
"id": 207,
"type": "Kabupaten",
"name": "Buol",
"code": "05",
"full_code": "7205",
"province_id": 33
},
{
"id": 208,
"type": "Kabupaten",
"name": "Sumedang",
"code": "11",
"full_code": "3211",
"province_id": 9
},
{
"id": 209,
"type": "Kabupaten",
"name": "Buru",
"code": "04",
"full_code": "8104",
"province_id": 20
},
{
"id": 210,
"type": "Kabupaten",
"name": "Buru Selatan",
"code": "09",
"full_code": "8109",
"province_id": 20
},
{
"id": 211,
"type": "Kabupaten",
"name": "Kepulauan Aru",
"code": "07",
"full_code": "8107",
"province_id": 20
},
{
"id": 212,
"type": "Kabupaten",
"name": "Sumenep",
"code": "29",
"full_code": "3529",
"province_id": 11
},
{
"id": 213,
"type": "Kabupaten",
"name": "Buton",
"code": "04",
"full_code": "7404",
"province_id": 34
},
{
"id": 214,
"type": "Kota",
"name": "Sungai Penuh",
"code": "72",
"full_code": "1572",
"province_id": 8
},
{
"id": 215,
"type": "Kabupaten",
"name": "Buton Selatan",
"code": "15",
"full_code": "7415",
"province_id": 34
},
{
"id": 216,
"type": "Kabupaten",
"name": "Supiori",
"code": "19",
"full_code": "9119",
"province_id": 24
},
{
"id": 217,
"type": "Kabupaten",
"name": "Buton Tengah",
"code": "14",
"full_code": "7414",
"province_id": 34
},
{
"id": 218,
"type": "Kabupaten",
"name": "Buton Utara",
"code": "10",
"full_code": "7410",
"province_id": 34
},
{
"id": 219,
"type": "Kota",
"name": "Surabaya",
"code": "78",
"full_code": "3578",
"province_id": 11
},
{
"id": 220,
"type": "Kabupaten",
"name": "Kepulauan Mentawai",
"code": "09",
"full_code": "1309",
"province_id": 36
},
{
"id": 221,
"type": "Kabupaten",
"name": "Ciamis",
"code": "07",
"full_code": "3207",
"province_id": 9
},
{
"id": 222,
"type": "Kota",
"name": "Surakarta",
"code": "72",
"full_code": "3372",
"province_id": 10
},
{
"id": 223,
"type": "Kabupaten",
"name": "Kepulauan Meranti",
"code": "10",
"full_code": "1410",
"province_id": 30
},
{
"id": 224,
"type": "Kabupaten",
"name": "Cianjur",
"code": "03",
"full_code": "3203",
"province_id": 9
},
{
"id": 225,
"type": "Kabupaten",
"name": "Tabalong",
"code": "09",
"full_code": "6309",
"province_id": 13
},
{
"id": 226,
"type": "Kabupaten",
"name": "Kepulauan Sangihe",
"code": "03",
"full_code": "7103",
"province_id": 35
},
{
"id": 227,
"type": "Kabupaten",
"name": "Kepulauan Selayar",
"code": "01",
"full_code": "7301",
"province_id": 32
},
{
"id": 228,
"type": "Kabupaten",
"name": "Cilacap",
"code": "01",
"full_code": "3301",
"province_id": 10
},
{
"id": 229,
"type": "Kota",
"name": "Cilegon",
"code": "72",
"full_code": "3672",
"province_id": 3
},
{
"id": 230,
"type": "Kabupaten",
"name": "Tabanan",
"code": "02",
"full_code": "5102",
"province_id": 2
},
{
"id": 231,
"type": "Kota",
"name": "Cimahi",
"code": "77",
"full_code": "3277",
"province_id": 9
},
{
"id": 232,
"type": "Kabupaten",
"name": "Kepulauan Seribu",
"code": "01",
"full_code": "3101",
"province_id": 6
},
{
"id": 233,
"type": "Kabupaten",
"name": "Takalar",
"code": "05",
"full_code": "7305",
"province_id": 32
},
{
"id": 234,
"type": "Kota",
"name": "Cirebon",
"code": "74",
"full_code": "3274",
"province_id": 9
},
{
"id": 235,
"type": "Kabupaten",
"name": "Kepulauan Siau Tagulandang Biaro (Sitaro)",
"code": "09",
"full_code": "7109",
"province_id": 35
},
{
"id": 236,
"type": "Kabupaten",
"name": "Kepulauan Sula",
"code": "05",
"full_code": "8205",
"province_id": 21
},
{
"id": 237,
"type": "Kabupaten",
"name": "Tambrauw",
"code": "09",
"full_code": "9209",
"province_id": 26
},
{
"id": 238,
"type": "Kabupaten",
"name": "Kepulauan Talaud",
"code": "04",
"full_code": "7104",
"province_id": 35
},
{
"id": 239,
"type": "Kabupaten",
"name": "Kepulauan Tanimbar (Maluku Tenggara Barat)",
"code": "03",
"full_code": "8103",
"province_id": 20
},
{
"id": 240,
"type": "Kabupaten",
"name": "Cirebon",
"code": "09",
"full_code": "3209",
"province_id": 9
},
{
"id": 241,
"type": "Kabupaten",
"name": "Dairi",
"code": "11",
"full_code": "1211",
"province_id": 38
},
{
"id": 242,
"type": "Kabupaten",
"name": "Tana Tidung",
"code": "04",
"full_code": "6504",
"province_id": 16
},
{
"id": 243,
"type": "Kabupaten",
"name": "Deiyai",
"code": "08",
"full_code": "9408",
"province_id": 29
},
{
"id": 244,
"type": "Kabupaten",
"name": "Kepulauan Yapen",
"code": "05",
"full_code": "9105",
"province_id": 24
},
{
"id": 245,
"type": "Kabupaten",
"name": "Deli Serdang",
"code": "07",
"full_code": "1207",
"province_id": 38
},
{
"id": 246,
"type": "Kabupaten",
"name": "Tana Toraja",
"code": "18",
"full_code": "7318",
"province_id": 32
},
{
"id": 247,
"type": "Kabupaten",
"name": "Demak",
"code": "21",
"full_code": "3321",
"province_id": 10
},
{
"id": 248,
"type": "Kabupaten",
"name": "Kerinci",
"code": "01",
"full_code": "1501",
"province_id": 8
},
{
"id": 249,
"type": "Kabupaten",
"name": "Tanah Bumbu",
"code": "10",
"full_code": "6310",
"province_id": 13
},
{
"id": 250,
"type": "Kota",
"name": "Denpasar",
"code": "71",
"full_code": "5171",
"province_id": 2
},
{
"id": 251,
"type": "Kabupaten",
"name": "Ketapang",
"code": "04",
"full_code": "6104",
"province_id": 12
},
{
"id": 252,
"type": "Kota",
"name": "Depok",
"code": "76",
"full_code": "3276",
"province_id": 9
},
{
"id": 253,
"type": "Kabupaten",
"name": "Tanah Datar",
"code": "04",
"full_code": "1304",
"province_id": 36
},
{
"id": 254,
"type": "Kabupaten",
"name": "Klaten",
"code": "10",
"full_code": "3310",
"province_id": 10
},
{
"id": 255,
"type": "Kabupaten",
"name": "Dharmasraya",
"code": "10",
"full_code": "1310",
"province_id": 36
},
{
"id": 256,
"type": "Kabupaten",
"name": "Tanah Laut",
"code": "01",
"full_code": "6301",
"province_id": 13
},
{
"id": 257,
"type": "Kabupaten",
"name": "Dogiyai",
"code": "06",
"full_code": "9406",
"province_id": 29
},
{
"id": 258,
"type": "Kabupaten",
"name": "Klungkung",
"code": "05",
"full_code": "5105",
"province_id": 2
},
{
"id": 259,
"type": "Kabupaten",
"name": "Kolaka",
"code": "01",
"full_code": "7401",
"province_id": 34
},
{
"id": 260,
"type": "Kota",
"name": "Tangerang",
"code": "71",
"full_code": "3671",
"province_id": 3
},
{
"id": 261,
"type": "Kabupaten",
"name": "Kolaka Timur",
"code": "11",
"full_code": "7411",
"province_id": 34
},
{
"id": 262,
"type": "Kabupaten",
"name": "Tangerang",
"code": "03",
"full_code": "3603",
"province_id": 3
},
{
"id": 263,
"type": "Kota",
"name": "Tangerang Selatan",
"code": "74",
"full_code": "3674",
"province_id": 3
},
{
"id": 264,
"type": "Kabupaten",
"name": "Tanggamus",
"code": "06",
"full_code": "1806",
"province_id": 19
},
{
"id": 265,
"type": "Kabupaten",
"name": "Kolaka Utara",
"code": "08",
"full_code": "7408",
"province_id": 34
},
{
"id": 266,
"type": "Kabupaten",
"name": "Konawe",
"code": "02",
"full_code": "7402",
"province_id": 34
},
{
"id": 267,
"type": "Kabupaten",
"name": "Konawe Kepulauan",
"code": "12",
"full_code": "7412",
"province_id": 34
},
{
"id": 268,
"type": "Kota",
"name": "Tanjung Balai",
"code": "74",
"full_code": "1274",
"province_id": 38
},
{
"id": 269,
"type": "Kabupaten",
"name": "Konawe Selatan",
"code": "05",
"full_code": "7405",
"province_id": 34
},
{
"id": 270,
"type": "Kabupaten",
"name": "Konawe Utara",
"code": "09",
"full_code": "7409",
"province_id": 34
},
{
"id": 271,
"type": "Kabupaten",
"name": "Kotabaru",
"code": "02",
"full_code": "6302",
"province_id": 13
},
{
"id": 272,
"type": "Kabupaten",
"name": "Tanjung Jabung Barat",
"code": "06",
"full_code": "1506",
"province_id": 8
},
{
"id": 273,
"type": "Kota",
"name": "Kotamobagu",
"code": "74",
"full_code": "7174",
"province_id": 35
},
{
"id": 274,
"type": "Kabupaten",
"name": "Tanjung Jabung Timur",
"code": "07",
"full_code": "1507",
"province_id": 8
},
{
"id": 275,
"type": "Kabupaten",
"name": "Kotawaringin Barat",
"code": "01",
"full_code": "6201",
"province_id": 14
},
{
"id": 276,
"type": "Kabupaten",
"name": "Kotawaringin Timur",
"code": "02",
"full_code": "6202",
"province_id": 14
},
{
"id": 277,
"type": "Kota",
"name": "Tanjung Pinang",
"code": "72",
"full_code": "2172",
"province_id": 18
},
{
"id": 278,
"type": "Kabupaten",
"name": "Kuantan Singingi",
"code": "09",
"full_code": "1409",
"province_id": 30
},
{
"id": 279,
"type": "Kabupaten",
"name": "Tapanuli Selatan",
"code": "03",
"full_code": "1203",
"province_id": 38
},
{
"id": 280,
"type": "Kabupaten",
"name": "Kubu Raya",
"code": "12",
"full_code": "6112",
"province_id": 12
},
{
"id": 281,
"type": "Kabupaten",
"name": "Kudus",
"code": "19",
"full_code": "3319",
"province_id": 10
},
{
"id": 282,
"type": "Kabupaten",
"name": "Tapanuli Tengah",
"code": "01",
"full_code": "1201",
"province_id": 38
},
{
"id": 283,
"type": "Kabupaten",
"name": "Tapanuli Utara",
"code": "02",
"full_code": "1202",
"province_id": 38
},
{
"id": 284,
"type": "Kabupaten",
"name": "Tapin",
"code": "05",
"full_code": "6305",
"province_id": 13
},
{
"id": 285,
"type": "Kota",
"name": "Tarakan",
"code": "71",
"full_code": "6571",
"province_id": 16
},
{
"id": 286,
"type": "Kota",
"name": "Tasikmalaya",
"code": "78",
"full_code": "3278",
"province_id": 9
},
{
"id": 287,
"type": "Kabupaten",
"name": "Kulon Progo",
"code": "01",
"full_code": "3401",
"province_id": 5
},
{
"id": 288,
"type": "Kabupaten",
"name": "Kuningan",
"code": "08",
"full_code": "3208",
"province_id": 9
},
{
"id": 289,
"type": "Kabupaten",
"name": "Kupang",
"code": "01",
"full_code": "5301",
"province_id": 23
},
{
"id": 290,
"type": "Kota",
"name": "Kupang",
"code": "71",
"full_code": "5371",
"province_id": 23
},
{
"id": 291,
"type": "Kabupaten",
"name": "Tasikmalaya",
"code": "06",
"full_code": "3206",
"province_id": 9
},
{
"id": 292,
"type": "Kabupaten",
"name": "Kutai Barat",
"code": "07",
"full_code": "6407",
"province_id": 15
},
{
"id": 293,
"type": "Kabupaten",
"name": "Kutai Kartanegara",
"code": "02",
"full_code": "6402",
"province_id": 15
},
{
"id": 294,
"type": "Kabupaten",
"name": "Kutai Timur",
"code": "08",
"full_code": "6408",
"province_id": 15
},
{
"id": 295,
"type": "Kabupaten",
"name": "Labuhanbatu",
"code": "10",
"full_code": "1210",
"province_id": 38
},
{
"id": 296,
"type": "Kota",
"name": "Tebing Tinggi",
"code": "76",
"full_code": "1276",
"province_id": 38
},
{
"id": 297,
"type": "Kabupaten",
"name": "Labuhanbatu Selatan",
"code": "22",
"full_code": "1222",
"province_id": 38
},
{
"id": 298,
"type": "Kabupaten",
"name": "Tebo",
"code": "09",
"full_code": "1509",
"province_id": 8
},
{
"id": 299,
"type": "Kabupaten",
"name": "Tegal",
"code": "28",
"full_code": "3328",
"province_id": 10
},
{
"id": 300,
"type": "Kota",
"name": "Tegal",
"code": "76",
"full_code": "3376",
"province_id": 10
},
{
"id": 301,
"type": "Kabupaten",
"name": "Teluk Bintuni",
"code": "06",
"full_code": "9206",
"province_id": 25
},
{
"id": 302,
"type": "Kabupaten",
"name": "Teluk Wondama",
"code": "07",
"full_code": "9207",
"province_id": 25
},
{
"id": 303,
"type": "Kabupaten",
"name": "Labuhanbatu Utara",
"code": "23",
"full_code": "1223",
"province_id": 38
},
{
"id": 304,
"type": "Kabupaten",
"name": "Temanggung",
"code": "23",
"full_code": "3323",
"province_id": 10
},
{
"id": 305,
"type": "Kabupaten",
"name": "Lahat",
"code": "04",
"full_code": "1604",
"province_id": 37
},
{
"id": 306,
"type": "Kota",
"name": "Ternate",
"code": "71",
"full_code": "8271",
"province_id": 21
},
{
"id": 307,
"type": "Kabupaten",
"name": "Lamandau",
"code": "09",
"full_code": "6209",
"province_id": 14
},
{
"id": 308,
"type": "Kabupaten",
"name": "Dompu",
"code": "05",
"full_code": "5205",
"province_id": 22
},
{
"id": 309,
"type": "Kabupaten",
"name": "Donggala",
"code": "03",
"full_code": "7203",
"province_id": 33
},
{
"id": 310,
"type": "Kota",
"name": "Dumai",
"code": "72",
"full_code": "1472",
"province_id": 30
},
{
"id": 311,
"type": "Kabupaten",
"name": "Empat Lawang",
"code": "11",
"full_code": "1611",
"province_id": 37
},
{
"id": 312,
"type": "Kabupaten",
"name": "Lamongan",
"code": "24",
"full_code": "3524",
"province_id": 11
},
{
"id": 313,
"type": "Kabupaten",
"name": "Ende",
"code": "08",
"full_code": "5308",
"province_id": 23
},
{
"id": 314,
"type": "Kabupaten",
"name": "Lampung Barat",
"code": "04",
"full_code": "1804",
"province_id": 19
},
{
"id": 315,
"type": "Kota",
"name": "Tidore Kepulauan",
"code": "72",
"full_code": "8272",
"province_id": 21
},
{
"id": 316,
"type": "Kabupaten",
"name": "Enrekang",
"code": "16",
"full_code": "7316",
"province_id": 32
},
{
"id": 317,
"type": "Kabupaten",
"name": "Lampung Selatan",
"code": "01",
"full_code": "1801",
"province_id": 19
},
{
"id": 318,
"type": "Kabupaten",
"name": "Fak Fak",
"code": "03",
"full_code": "9203",
"province_id": 25
},
{
"id": 319,
"type": "Kabupaten",
"name": "Timor Tengah Selatan",
"code": "02",
"full_code": "5302",
"province_id": 23
},
{
"id": 320,
"type": "Kabupaten",
"name": "Lampung Tengah",
"code": "02",
"full_code": "1802",
"province_id": 19
},
{
"id": 321,
"type": "Kabupaten",
"name": "Flores Timur",
"code": "06",
"full_code": "5306",
"province_id": 23
},
{
"id": 322,
"type": "Kabupaten",
"name": "Lampung Timur",
"code": "07",
"full_code": "1807",
"province_id": 19
},
{
"id": 323,
"type": "Kabupaten",
"name": "Garut",
"code": "05",
"full_code": "3205",
"province_id": 9
},
{
"id": 324,
"type": "Kabupaten",
"name": "Timor Tengah Utara",
"code": "03",
"full_code": "5303",
"province_id": 23
},
{
"id": 325,
"type": "Kabupaten",
"name": "Lampung Utara",
"code": "03",
"full_code": "1803",
"province_id": 19
},
{
"id": 326,
"type": "Kabupaten",
"name": "Toba",
"code": "12",
"full_code": "1212",
"province_id": 38
},
{
"id": 327,
"type": "Kabupaten",
"name": "Tojo Una Una",
"code": "09",
"full_code": "7209",
"province_id": 33
},
{
"id": 328,
"type": "Kabupaten",
"name": "Gayo Lues",
"code": "13",
"full_code": "1113",
"province_id": 1
},
{
"id": 329,
"type": "Kabupaten",
"name": "Landak",
"code": "08",
"full_code": "6108",
"province_id": 12
},
{
"id": 330,
"type": "Kabupaten",
"name": "Gianyar",
"code": "04",
"full_code": "5104",
"province_id": 2
},
{
"id": 331,
"type": "Kabupaten",
"name": "Langkat",
"code": "05",
"full_code": "1205",
"province_id": 38
},
{
"id": 332,
"type": "Kabupaten",
"name": "Gorontalo",
"code": "01",
"full_code": "7501",
"province_id": 7
},
{
"id": 333,
"type": "Kota",
"name": "Langsa",
"code": "74",
"full_code": "1174",
"province_id": 1
},
{
"id": 334,
"type": "Kabupaten",
"name": "Toli Toli",
"code": "04",
"full_code": "7204",
"province_id": 33
},
{
"id": 335,
"type": "Kabupaten",
"name": "Lanny Jaya",
"code": "07",
"full_code": "9507",
"province_id": 27
},
{
"id": 336,
"type": "Kabupaten",
"name": "Lebak",
"code": "02",
"full_code": "3602",
"province_id": 3
},
{
"id": 337,
"type": "Kota",
"name": "Gorontalo",
"code": "71",
"full_code": "7571",
"province_id": 7
},
{
"id": 338,
"type": "Kabupaten",
"name": "Tolikara",
"code": "04",
"full_code": "9504",
"province_id": 27
},
{
"id": 339,
"type": "Kota",
"name": "Tomohon",
"code": "73",
"full_code": "7173",
"province_id": 35
},
{
"id": 340,
"type": "Kabupaten",
"name": "Lebong",
"code": "07",
"full_code": "1707",
"province_id": 4
},
{
"id": 341,
"type": "Kabupaten",
"name": "Toraja Utara",
"code": "26",
"full_code": "7326",
"province_id": 32
},
{
"id": 342,
"type": "Kabupaten",
"name": "Lembata",
"code": "13",
"full_code": "5313",
"province_id": 23
},
{
"id": 343,
"type": "Kota",
"name": "Lhokseumawe",
"code": "73",
"full_code": "1173",
"province_id": 1
},
{
"id": 344,
"type": "Kabupaten",
"name": "Lima Puluh Kota",
"code": "07",
"full_code": "1307",
"province_id": 36
},
{
"id": 345,
"type": "Kabupaten",
"name": "Lingga",
"code": "04",
"full_code": "2104",
"province_id": 18
},
{
"id": 346,
"type": "Kabupaten",
"name": "Trenggalek",
"code": "03",
"full_code": "3503",
"province_id": 11
},
{
"id": 347,
"type": "Kota",
"name": "Tual",
"code": "72",
"full_code": "8172",
"province_id": 20
},
{
"id": 348,
"type": "Kabupaten",
"name": "Tuban",
"code": "23",
"full_code": "3523",
"province_id": 11
},
{
"id": 349,
"type": "Kabupaten",
"name": "Lombok Barat",
"code": "01",
"full_code": "5201",
"province_id": 22
},
{
"id": 350,
"type": "Kabupaten",
"name": "Tulang Bawang",
"code": "05",
"full_code": "1805",
"province_id": 19
},
{
"id": 351,
"type": "Kabupaten",
"name": "Lombok Tengah",
"code": "02",
"full_code": "5202",
"province_id": 22
},
{
"id": 352,
"type": "Kabupaten",
"name": "Lombok Timur",
"code": "03",
"full_code": "5203",
"province_id": 22
},
{
"id": 353,
"type": "Kabupaten",
"name": "Tulang Bawang Barat",
"code": "12",
"full_code": "1812",
"province_id": 19
},
{
"id": 354,
"type": "Kabupaten",
"name": "Lombok Utara",
"code": "08",
"full_code": "5208",
"province_id": 22
},
{
"id": 355,
"type": "Kota",
"name": "Lubuk Linggau",
"code": "73",
"full_code": "1673",
"province_id": 37
},
{
"id": 356,
"type": "Kabupaten",
"name": "Tulungagung",
"code": "04",
"full_code": "3504",
"province_id": 11
},
{
"id": 357,
"type": "Kabupaten",
"name": "Lumajang",
"code": "08",
"full_code": "3508",
"province_id": 11
},
{
"id": 358,
"type": "Kabupaten",
"name": "Wajo",
"code": "13",
"full_code": "7313",
"province_id": 32
},
{
"id": 359,
"type": "Kabupaten",
"name": "Luwu",
"code": "17",
"full_code": "7317",
"province_id": 32
},
{
"id": 360,
"type": "Kabupaten",
"name": "Luwu Timur",
"code": "24",
"full_code": "7324",
"province_id": 32
},
{
"id": 361,
"type": "Kabupaten",
"name": "Wakatobi",
"code": "07",
"full_code": "7407",
"province_id": 34
},
{
"id": 362,
"type": "Kabupaten",
"name": "Waropen",
"code": "15",
"full_code": "9115",
"province_id": 24
},
{
"id": 363,
"type": "Kabupaten",
"name": "Way Kanan",
"code": "08",
"full_code": "1808",
"province_id": 19
},
{
"id": 364,
"type": "Kabupaten",
"name": "Wonogiri",
"code": "12",
"full_code": "3312",
"province_id": 10
},
{
"id": 365,
"type": "Kabupaten",
"name": "Wonosobo",
"code": "07",
"full_code": "3307",
"province_id": 10
},
{
"id": 366,
"type": "Kabupaten",
"name": "Yahukimo",
"code": "03",
"full_code": "9503",
"province_id": 27
},
{
"id": 367,
"type": "Kabupaten",
"name": "Yalimo",
"code": "06",
"full_code": "9506",
"province_id": 27
},
{
"id": 368,
"type": "Kota",
"name": "Yogyakarta",
"code": "71",
"full_code": "3471",
"province_id": 5
},
{
"id": 369,
"type": "Kabupaten",
"name": "Luwu Utara",
"code": "22",
"full_code": "7322",
"province_id": 32
},
{
"id": 370,
"type": "Kabupaten",
"name": "Madiun",
"code": "19",
"full_code": "3519",
"province_id": 11
},
{
"id": 371,
"type": "Kota",
"name": "Madiun",
"code": "77",
"full_code": "3577",
"province_id": 11
},
{
"id": 372,
"type": "Kabupaten",
"name": "Magelang",
"code": "08",
"full_code": "3308",
"province_id": 10
},
{
"id": 373,
"type": "Kota",
"name": "Magelang",
"code": "71",
"full_code": "3371",
"province_id": 10
},
{
"id": 374,
"type": "Kabupaten",
"name": "Magetan",
"code": "20",
"full_code": "3520",
"province_id": 11
},
{
"id": 375,
"type": "Kabupaten",
"name": "Mahakam Ulu",
"code": "11",
"full_code": "6411",
"province_id": 15
},
{
"id": 376,
"type": "Kabupaten",
"name": "Majalengka",
"code": "10",
"full_code": "3210",
"province_id": 9
},
{
"id": 377,
"type": "Kabupaten",
"name": "Majene",
"code": "05",
"full_code": "7605",
"province_id": 31
},
{
"id": 378,
"type": "Kota",
"name": "Makassar",
"code": "71",
"full_code": "7371",
"province_id": 32
},
{
"id": 379,
"type": "Kabupaten",
"name": "Malaka",
"code": "21",
"full_code": "5321",
"province_id": 23
},
{
"id": 380,
"type": "Kabupaten",
"name": "Malang",
"code": "07",
"full_code": "3507",
"province_id": 11
},
{
"id": 381,
"type": "Kota",
"name": "Malang",
"code": "73",
"full_code": "3573",
"province_id": 11
},
{
"id": 382,
"type": "Kabupaten",
"name": "Malinau",
"code": "02",
"full_code": "6502",
"province_id": 16
},
{
"id": 383,
"type": "Kabupaten",
"name": "Maluku Barat Daya",
"code": "08",
"full_code": "8108",
"province_id": 20
},
{
"id": 384,
"type": "Kabupaten",
"name": "Maluku Tengah",
"code": "01",
"full_code": "8101",
"province_id": 20
},
{
"id": 385,
"type": "Kabupaten",
"name": "Maluku Tenggara",
"code": "02",
"full_code": "8102",
"province_id": 20
},
{
"id": 386,
"type": "Kabupaten",
"name": "Mamasa",
"code": "03",
"full_code": "7603",
"province_id": 31
},
{
"id": 387,
"type": "Kabupaten",
"name": "Mamberamo Raya",
"code": "20",
"full_code": "9120",
"province_id": 24
},
{
"id": 388,
"type": "Kabupaten",
"name": "Mamberamo Tengah",
"code": "05",
"full_code": "9505",
"province_id": 27
},
{
"id": 389,
"type": "Kabupaten",
"name": "Mamuju",
"code": "02",
"full_code": "7602",
"province_id": 31
},
{
"id": 390,
"type": "Kabupaten",
"name": "Mamuju Tengah",
"code": "06",
"full_code": "7606",
"province_id": 31
},
{
"id": 391,
"type": "Kota",
"name": "Manado",
"code": "71",
"full_code": "7171",
"province_id": 35
},
{
"id": 392,
"type": "Kabupaten",
"name": "Mandailing Natal",
"code": "13",
"full_code": "1213",
"province_id": 38
},
{
"id": 393,
"type": "Kabupaten",
"name": "Manggarai",
"code": "10",
"full_code": "5310",
"province_id": 23
},
{
"id": 394,
"type": "Kabupaten",
"name": "Manggarai Barat",
"code": "15",
"full_code": "5315",
"province_id": 23
},
{
"id": 395,
"type": "Kabupaten",
"name": "Manggarai Timur",
"code": "19",
"full_code": "5319",
"province_id": 23
},
{
"id": 396,
"type": "Kabupaten",
"name": "Manokwari",
"code": "02",
"full_code": "9202",
"province_id": 25
},
{
"id": 397,
"type": "Kabupaten",
"name": "Manokwari Selatan",
"code": "11",
"full_code": "9211",
"province_id": 25
},
{
"id": 398,
"type": "Kabupaten",
"name": "Mappi",
"code": "03",
"full_code": "9303",
"province_id": 28
},
{
"id": 399,
"type": "Kabupaten",
"name": "Maros",
"code": "09",
"full_code": "7309",
"province_id": 32
},
{
"id": 400,
"type": "Kota",
"name": "Mataram",
"code": "71",
"full_code": "5271",
"province_id": 22
},
{
"id": 401,
"type": "Kabupaten",
"name": "Maybrat",
"code": "10",
"full_code": "9210",
"province_id": 26
},
{
"id": 402,
"type": "Kota",
"name": "Medan",
"code": "71",
"full_code": "1271",
"province_id": 38
},
{
"id": 403,
"type": "Kabupaten",
"name": "Melawi",
"code": "10",
"full_code": "6110",
"province_id": 12
},
{
"id": 404,
"type": "Kabupaten",
"name": "Mempawah",
"code": "02",
"full_code": "6102",
"province_id": 12
},
{
"id": 405,
"type": "Kabupaten",
"name": "Merangin",
"code": "02",
"full_code": "1502",
"province_id": 8
},
{
"id": 406,
"type": "Kabupaten",
"name": "Merauke",
"code": "01",
"full_code": "9301",
"province_id": 28
},
{
"id": 407,
"type": "Kabupaten",
"name": "Mesuji",
"code": "11",
"full_code": "1811",
"province_id": 19
},
{
"id": 408,
"type": "Kota",
"name": "Metro",
"code": "72",
"full_code": "1872",
"province_id": 19
},
{
"id": 409,
"type": "Kabupaten",
"name": "Mimika",
"code": "04",
"full_code": "9404",
"province_id": 29
},
{
"id": 410,
"type": "Kabupaten",
"name": "Minahasa",
"code": "02",
"full_code": "7102",
"province_id": 35
},
{
"id": 411,
"type": "Kabupaten",
"name": "Minahasa Selatan",
"code": "05",
"full_code": "7105",
"province_id": 35
},
{
"id": 412,
"type": "Kabupaten",
"name": "Minahasa Tenggara",
"code": "07",
"full_code": "7107",
"province_id": 35
},
{
"id": 413,
"type": "Kabupaten",
"name": "Minahasa Utara",
"code": "06",
"full_code": "7106",
"province_id": 35
},
{
"id": 414,
"type": "Kabupaten",
"name": "Mojokerto",
"code": "16",
"full_code": "3516",
"province_id": 11
},
{
"id": 415,
"type": "Kota",
"name": "Mojokerto",
"code": "76",
"full_code": "3576",
"province_id": 11
},
{
"id": 416,
"type": "Kabupaten",
"name": "Morowali",
"code": "06",
"full_code": "7206",
"province_id": 33
},
{
"id": 417,
"type": "Kabupaten",
"name": "Morowali Utara",
"code": "12",
"full_code": "7212",
"province_id": 33
},
{
"id": 418,
"type": "Kabupaten",
"name": "Muara Enim",
"code": "03",
"full_code": "1603",
"province_id": 37
},
{
"id": 419,
"type": "Kabupaten",
"name": "Muaro Jambi",
"code": "05",
"full_code": "1505",
"province_id": 8
},
{
"id": 420,
"type": "Kabupaten",
"name": "Muko Muko",
"code": "06",
"full_code": "1706",
"province_id": 4
},
{
"id": 421,
"type": "Kabupaten",
"name": "Muna",
"code": "03",
"full_code": "7403",
"province_id": 34
},
{
"id": 422,
"type": "Kabupaten",
"name": "Muna Barat",
"code": "13",
"full_code": "7413",
"province_id": 34
},
{
"id": 423,
"type": "Kabupaten",
"name": "Murung Raya",
"code": "12",
"full_code": "6212",
"province_id": 14
},
{
"id": 424,
"type": "Kabupaten",
"name": "Musi Banyuasin",
"code": "06",
"full_code": "1606",
"province_id": 37
},
{
"id": 425,
"type": "Kabupaten",
"name": "Musi Rawas",
"code": "05",
"full_code": "1605",
"province_id": 37
},
{
"id": 426,
"type": "Kabupaten",
"name": "Musi Rawas Utara",
"code": "13",
"full_code": "1613",
"province_id": 37
},
{
"id": 427,
"type": "Kabupaten",
"name": "Nabire",
"code": "01",
"full_code": "9401",
"province_id": 29
},
{
"id": 428,
"type": "Kabupaten",
"name": "Nagan Raya",
"code": "15",
"full_code": "1115",
"province_id": 1
},
{
"id": 429,
"type": "Kabupaten",
"name": "Nagekeo",
"code": "16",
"full_code": "5316",
"province_id": 23
},
{
"id": 430,
"type": "Kabupaten",
"name": "Natuna",
"code": "03",
"full_code": "2103",
"province_id": 18
},
{
"id": 431,
"type": "Kabupaten",
"name": "Nduga",
"code": "08",
"full_code": "9508",
"province_id": 27
},
{
"id": 432,
"type": "Kabupaten",
"name": "Ngada",
"code": "09",
"full_code": "5309",
"province_id": 23
},
{
"id": 433,
"type": "Kabupaten",
"name": "Nganjuk",
"code": "18",
"full_code": "3518",
"province_id": 11
},
{
"id": 434,
"type": "Kabupaten",
"name": "Ngawi",
"code": "21",
"full_code": "3521",
"province_id": 11
},
{
"id": 435,
"type": "Kabupaten",
"name": "Nias",
"code": "04",
"full_code": "1204",
"province_id": 38
},
{
"id": 436,
"type": "Kabupaten",
"name": "Nias Barat",
"code": "25",
"full_code": "1225",
"province_id": 38
},
{
"id": 437,
"type": "Kabupaten",
"name": "Nias Selatan",
"code": "14",
"full_code": "1214",
"province_id": 38
},
{
"id": 438,
"type": "Kabupaten",
"name": "Nias Utara",
"code": "24",
"full_code": "1224",
"province_id": 38
},
{
"id": 439,
"type": "Kabupaten",
"name": "Nunukan",
"code": "03",
"full_code": "6503",
"province_id": 16
},
{
"id": 440,
"type": "Kabupaten",
"name": "Ogan Ilir",
"code": "10",
"full_code": "1610",
"province_id": 37
},
{
"id": 441,
"type": "Kabupaten",
"name": "Ogan Komering Ilir",
"code": "02",
"full_code": "1602",
"province_id": 37
},
{
"id": 442,
"type": "Kabupaten",
"name": "Ogan Komering Ulu",
"code": "01",
"full_code": "1601",
"province_id": 37
},
{
"id": 443,
"type": "Kabupaten",
"name": "Ogan Komering Ulu Selatan",
"code": "09",
"full_code": "1609",
"province_id": 37
},
{
"id": 444,
"type": "Kabupaten",
"name": "Ogan Komering Ulu Timur",
"code": "08",
"full_code": "1608",
"province_id": 37
},
{
"id": 445,
"type": "Kabupaten",
"name": "Pacitan",
"code": "01",
"full_code": "3501",
"province_id": 11
},
{
"id": 446,
"type": "Kota",
"name": "Padang",
"code": "71",
"full_code": "1371",
"province_id": 36
},
{
"id": 447,
"type": "Kabupaten",
"name": "Padang Lawas",
"code": "21",
"full_code": "1221",
"province_id": 38
},
{
"id": 448,
"type": "Kabupaten",
"name": "Padang Lawas Utara",
"code": "20",
"full_code": "1220",
"province_id": 38
},
{
"id": 449,
"type": "Kota",
"name": "Padang Panjang",
"code": "74",
"full_code": "1374",
"province_id": 36
},
{
"id": 450,
"type": "Kabupaten",
"name": "Padang Pariaman",
"code": "05",
"full_code": "1305",
"province_id": 36
},
{
"id": 451,
"type": "Kota",
"name": "Padangsidimpuan",
"code": "77",
"full_code": "1277",
"province_id": 38
},
{
"id": 452,
"type": "Kota",
"name": "Pagar Alam",
"code": "72",
"full_code": "1672",
"province_id": 37
},
{
"id": 453,
"type": "Kabupaten",
"name": "Pahuwato",
"code": "04",
"full_code": "7504",
"province_id": 7
},
{
"id": 454,
"type": "Kabupaten",
"name": "Pakpak Bharat",
"code": "15",
"full_code": "1215",
"province_id": 38
},
{
"id": 455,
"type": "Kota",
"name": "Palangkaraya",
"code": "71",
"full_code": "6271",
"province_id": 14
},
{
"id": 456,
"type": "Kota",
"name": "Palembang",
"code": "71",
"full_code": "1671",
"province_id": 37
},
{
"id": 457,
"type": "Kota",
"name": "Palopo",
"code": "73",
"full_code": "7373",
"province_id": 32
},
{
"id": 458,
"type": "Kota",
"name": "Palu",
"code": "71",
"full_code": "7271",
"province_id": 33
},
{
"id": 459,
"type": "Kabupaten",
"name": "Pamekasan",
"code": "28",
"full_code": "3528",
"province_id": 11
},
{
"id": 460,
"type": "Kabupaten",
"name": "Pandeglang",
"code": "01",
"full_code": "3601",
"province_id": 3
},
{
"id": 461,
"type": "Kabupaten",
"name": "Pangandaran",
"code": "18",
"full_code": "3218",
"province_id": 9
},
{
"id": 462,
"type": "Kabupaten",
"name": "Pangkajene Kepulauan",
"code": "10",
"full_code": "7310",
"province_id": 32
},
{
"id": 463,
"type": "Kota",
"name": "Pangkal Pinang",
"code": "71",
"full_code": "1971",
"province_id": 17
},
{
"id": 464,
"type": "Kabupaten",
"name": "Paniai",
"code": "03",
"full_code": "9403",
"province_id": 29
},
{
"id": 465,
"type": "Kota",
"name": "Pare Pare",
"code": "72",
"full_code": "7372",
"province_id": 32
},
{
"id": 466,
"type": "Kota",
"name": "Pariaman",
"code": "77",
"full_code": "1377",
"province_id": 36
},
{
"id": 467,
"type": "Kabupaten",
"name": "Parigi Moutong",
"code": "08",
"full_code": "7208",
"province_id": 33
},
{
"id": 468,
"type": "Kabupaten",
"name": "Pasaman",
"code": "08",
"full_code": "1308",
"province_id": 36
},
{
"id": 469,
"type": "Kabupaten",
"name": "Pasaman Barat",
"code": "12",
"full_code": "1312",
"province_id": 36
},
{
"id": 470,
"type": "Kabupaten",
"name": "Pasangkayu (Mamuju Utara)",
"code": "01",
"full_code": "7601",
"province_id": 31
},
{
"id": 471,
"type": "Kabupaten",
"name": "Paser",
"code": "01",
"full_code": "6401",
"province_id": 15
},
{
"id": 472,
"type": "Kabupaten",
"name": "Pasuruan",
"code": "14",
"full_code": "3514",
"province_id": 11
},
{
"id": 473,
"type": "Kota",
"name": "Pasuruan",
"code": "75",
"full_code": "3575",
"province_id": 11
},
{
"id": 474,
"type": "Kabupaten",
"name": "Pati",
"code": "18",
"full_code": "3318",
"province_id": 10
},
{
"id": 475,
"type": "Kota",
"name": "Payakumbuh",
"code": "76",
"full_code": "1376",
"province_id": 36
},
{
"id": 476,
"type": "Kabupaten",
"name": "Pegunungan Arfak",
"code": "12",
"full_code": "9212",
"province_id": 25
},
{
"id": 477,
"type": "Kabupaten",
"name": "Pegunungan Bintang",
"code": "02",
"full_code": "9502",
"province_id": 27
},
{
"id": 478,
"type": "Kabupaten",
"name": "Pekalongan",
"code": "26",
"full_code": "3326",
"province_id": 10
},
{
"id": 479,
"type": "Kota",
"name": "Pekalongan",
"code": "75",
"full_code": "3375",
"province_id": 10
},
{
"id": 480,
"type": "Kota",
"name": "Pekanbaru",
"code": "71",
"full_code": "1471",
"province_id": 30
},
{
"id": 481,
"type": "Kabupaten",
"name": "Pelalawan",
"code": "05",
"full_code": "1405",
"province_id": 30
},
{
"id": 482,
"type": "Kabupaten",
"name": "Pemalang",
"code": "27",
"full_code": "3327",
"province_id": 10
},
{
"id": 483,
"type": "Kota",
"name": "Pematangsiantar",
"code": "72",
"full_code": "1272",
"province_id": 38
},
{
"id": 484,
"type": "Kabupaten",
"name": "Penajam Paser Utara",
"code": "09",
"full_code": "6409",
"province_id": 15
},
{
"id": 485,
"type": "Kabupaten",
"name": "Penukal Abab Lematang Ilir",
"code": "12",
"full_code": "1612",
"province_id": 37
},
{
"id": 486,
"type": "Kabupaten",
"name": "Pesawaran",
"code": "09",
"full_code": "1809",
"province_id": 19
},
{
"id": 487,
"type": "Kabupaten",
"name": "Pesisir Barat",
"code": "13",
"full_code": "1813",
"province_id": 19
},
{
"id": 488,
"type": "Kabupaten",
"name": "Pesisir Selatan",
"code": "01",
"full_code": "1301",
"province_id": 36
},
{
"id": 489,
"type": "Kabupaten",
"name": "Pidie",
"code": "07",
"full_code": "1107",
"province_id": 1
},
{
"id": 490,
"type": "Kabupaten",
"name": "Pidie Jaya",
"code": "18",
"full_code": "1118",
"province_id": 1
},
{
"id": 491,
"type": "Kabupaten",
"name": "Pinrang",
"code": "15",
"full_code": "7315",
"province_id": 32
},
{
"id": 492,
"type": "Kabupaten",
"name": "Polewali Mandar",
"code": "04",
"full_code": "7604",
"province_id": 31
},
{
"id": 493,
"type": "Kabupaten",
"name": "Ponorogo",
"code": "02",
"full_code": "3502",
"province_id": 11
},
{
"id": 494,
"type": "Kota",
"name": "Pontianak",
"code": "71",
"full_code": "6171",
"province_id": 12
},
{
"id": 495,
"type": "Kabupaten",
"name": "Poso",
"code": "02",
"full_code": "7202",
"province_id": 33
},
{
"id": 496,
"type": "Kota",
"name": "Prabumulih",
"code": "74",
"full_code": "1674",
"province_id": 37
},
{
"id": 497,
"type": "Kabupaten",
"name": "Pringsewu",
"code": "10",
"full_code": "1810",
"province_id": 19
},
{
"id": 498,
"type": "Kabupaten",
"name": "Probolinggo",
"code": "13",
"full_code": "3513",
"province_id": 11
},
{
"id": 499,
"type": "Kota",
"name": "Probolinggo",
"code": "74",
"full_code": "3574",
"province_id": 11
},
{
"id": 500,
"type": "Kabupaten",
"name": "Pulang Pisau",
"code": "11",
"full_code": "6211",
"province_id": 14
},
{
"id": 501,
"type": "Kabupaten",
"name": "Pulau Morotai",
"code": "07",
"full_code": "8207",
"province_id": 21
},
{
"id": 502,
"type": "Kabupaten",
"name": "Pulau Taliabu",
"code": "08",
"full_code": "8208",
"province_id": 21
},
{
"id": 503,
"type": "Kabupaten",
"name": "Puncak",
"code": "05",
"full_code": "9405",
"province_id": 29
},
{
"id": 504,
"type": "Kabupaten",
"name": "Puncak Jaya",
"code": "02",
"full_code": "9402",
"province_id": 29
},
{
"id": 505,
"type": "Kabupaten",
"name": "Purbalingga",
"code": "03",
"full_code": "3303",
"province_id": 10
},
{
"id": 506,
"type": "Kabupaten",
"name": "Purwakarta",
"code": "14",
"full_code": "3214",
"province_id": 9
},
{
"id": 507,
"type": "Kabupaten",
"name": "Purworejo",
"code": "06",
"full_code": "3306",
"province_id": 10
},
{
"id": 508,
"type": "Kabupaten",
"name": "Raja Ampat",
"code": "05",
"full_code": "9205",
"province_id": 26
},
{
"id": 509,
"type": "Kabupaten",
"name": "Rejang Lebong",
"code": "02",
"full_code": "1702",
"province_id": 4
},
{
"id": 510,
"type": "Kabupaten",
"name": "Rembang",
"code": "17",
"full_code": "3317",
"province_id": 10
},
{
"id": 511,
"type": "Kabupaten",
"name": "Rokan Hilir",
"code": "07",
"full_code": "1407",
"province_id": 30
},
{
"id": 512,
"type": "Kabupaten",
"name": "Rokan Hulu",
"code": "06",
"full_code": "1406",
"province_id": 30
},
{
"id": 513,
"type": "Kabupaten",
"name": "Rote Ndao",
"code": "14",
"full_code": "5314",
"province_id": 23
},
{
"id": 514,
"type": "Kota",
"name": "Sabang",
"code": "72",
"full_code": "1172",
"province_id": 1
}
]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192[
{
"id": 1,
"name": "Aceh (NAD)",
"code": "11"
},
{
"id": 2,
"name": "Bali",
"code": "51"
},
{
"id": 3,
"name": "Banten",
"code": "36"
},
{
"id": 4,
"name": "Bengkulu",
"code": "17"
},
{
"id": 5,
"name": "DI Yogyakarta",
"code": "34"
},
{
"id": 6,
"name": "DKI Jakarta",
"code": "31"
},
{
"id": 7,
"name": "Gorontalo",
"code": "75"
},
{
"id": 8,
"name": "Jambi",
"code": "15"
},
{
"id": 9,
"name": "Jawa Barat",
"code": "32"
},
{
"id": 10,
"name": "Jawa Tengah",
"code": "33"
},
{
"id": 11,
"name": "Jawa Timur",
"code": "35"
},
{
"id": 12,
"name": "Kalimantan Barat",
"code": "61"
},
{
"id": 13,
"name": "Kalimantan Selatan",
"code": "63"
},
{
"id": 14,
"name": "Kalimantan Tengah",
"code": "62"
},
{
"id": 15,
"name": "Kalimantan Timur",
"code": "64"
},
{
"id": 16,
"name": "Kalimantan Utara",
"code": "65"
},
{
"id": 17,
"name": "Kepulauan Bangka Belitung",
"code": "19"
},
{
"id": 18,
"name": "Kepulauan Riau",
"code": "21"
},
{
"id": 19,
"name": "Lampung",
"code": "18"
},
{
"id": 20,
"name": "Maluku",
"code": "81"
},
{
"id": 21,
"name": "Maluku Utara",
"code": "82"
},
{
"id": 22,
"name": "Nusa Tenggara Barat (NTB)",
"code": "52"
},
{
"id": 23,
"name": "Nusa Tenggara Timur (NTT)",
"code": "53"
},
{
"id": 24,
"name": "Papua",
"code": "91"
},
{
"id": 25,
"name": "Papua Barat",
"code": "92"
},
{
"id": 26,
"name": "Papua Barat Daya",
"code": "92"
},
{
"id": 27,
"name": "Papua Pegunungan",
"code": "95"
},
{
"id": 28,
"name": "Papua Selatan",
"code": "93"
},
{
"id": 29,
"name": "Papua Tengah",
"code": "94"
},
{
"id": 30,
"name": "Riau",
"code": "14"
},
{
"id": 31,
"name": "Sulawesi Barat",
"code": "76"
},
{
"id": 32,
"name": "Sulawesi Selatan",
"code": "73"
},
{
"id": 33,
"name": "Sulawesi Tengah",
"code": "72"
},
{
"id": 34,
"name": "Sulawesi Tenggara",
"code": "74"
},
{
"id": 35,
"name": "Sulawesi Utara",
"code": "71"
},
{
"id": 36,
"name": "Sumatera Barat",
"code": "13"
},
{
"id": 37,
"name": "Sumatera Selatan",
"code": "16"
},
{
"id": 38,
"name": "Sumatera Utara",
"code": "12"
}
]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172package options_controller
import ( "net/http"
"api.qobiltu.id/models" "api.qobiltu.id/response" "api.qobiltu.id/services" "github.com/gin-gonic/gin")
type OptionsController interface { CreateOptions(ctx *gin.Context) ListOptions(ctx *gin.Context) ListOptionsBySlug(ctx *gin.Context)}
type optionsController struct { optionService services.OptionsService}
func NewOptionsController(optionService services.OptionsService) OptionsController { return &optionsController{ optionService: optionService, }}
func (c *optionsController) CreateOptions(ctx *gin.Context) { var req []models.MultipleOptionsRequest if err := ctx.ShouldBindJSON(&req); err != nil { response.HandleError(ctx, models.Exception{ Message: "Invalid body request", BadRequest: true, Err: err, }) return }
res, err := c.optionService.CreateOptions(ctx, &models.CreateOptionsRequest{ Options: req, }) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Options created successfully", res, nil)}
func (c *optionsController) ListOptions(ctx *gin.Context) { res, err := c.optionService.ListOptions(ctx) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Options retrieved successfully", res.Options, nil)}
func (c *optionsController) ListOptionsBySlug(ctx *gin.Context) { slug := ctx.Param("slug")
res, err := c.optionService.ListOptionsBySlug(ctx, &models.ListOptionsBySlugRequest{ Slug: slug, }) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Options retrieved successfully", res, nil)}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192package cv_controller
import ( "net/http" "strconv"
"api.qobiltu.id/models" "api.qobiltu.id/response" "api.qobiltu.id/services" "github.com/gin-gonic/gin")
type RegionController interface { SeedProvince(ctx *gin.Context) SeedCity(ctx *gin.Context)
ListProvinces(ctx *gin.Context) ListCities(ctx *gin.Context)}
type regionController struct { regionService services.RegionService}
func NewRegionController(regionService services.RegionService) RegionController { return ®ionController{ regionService: regionService, }}
func (c *regionController) SeedProvince(ctx *gin.Context) { err := c.regionService.SeedProvince(ctx) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Province seeded", nil, nil)}
func (c *regionController) SeedCity(ctx *gin.Context) { err := c.regionService.SeedCity(ctx) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "City seeded", nil, nil)}
func (c *regionController) ListProvinces(ctx *gin.Context) { provinces, err := c.regionService.ListProvinces(ctx) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Provinces retrieved", provinces, nil)}
func (c *regionController) ListCities(ctx *gin.Context) { provinceID := ctx.Query("province_id")
if provinceID == "" { cities, err := c.regionService.ListCities(ctx) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Cities retrieved", cities, nil) return }
provinceIDInt, err := strconv.ParseInt(provinceID, 10, 64) if err != nil { response.HandleError(ctx, err) return }
req := models.ListCitiesByProvinceIdRequest{ ProvinceID: provinceIDInt, }
cities, err := c.regionService.ListCitiesByProvinceId(ctx, &req) if err != nil { response.HandleError(ctx, err) return }
response.HandleSuccess(ctx, http.StatusOK, "Cities by province retrieved", cities, nil)}8 unmodified lines910111213141539 unmodified lines55565758596017 unmodified lines7879808182838 unmodified linescv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""api.qobiltu.id/pkg/mail""api.qobiltu.id/pkg/storage""api.qobiltu.id/pkg/validation"39 unmodified linesworker.AsyncTaskDistributor = taskDistributor// setup repo, service, and controlleremailRepository := repositories.NewEmailRepository(config.DB)emailService := services.NewEmailService(emailRepository, taskDistributor)emailController := email_controller.NewEmailController(emailService)17 unmodified lines// create servers, err := router.NewServer(emailController,cvController,marriageReadinessProfileController,8 unmodified lines9101112131415161739 unmodified lines57585960616263646566676869707117 unmodified lines89909192939495968 unmodified linescv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"options_controller "api.qobiltu.id/controller/options"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria"region_controller "api.qobiltu.id/controller/region""api.qobiltu.id/pkg/mail""api.qobiltu.id/pkg/storage""api.qobiltu.id/pkg/validation"39 unmodified linesworker.AsyncTaskDistributor = taskDistributor// setup repo, service, and controllerregionRepository := repositories.NewRegionRepository(config.DB)regionService := services.NewRegionService(regionRepository)regionController := region_controller.NewRegionController(regionService)optionRepository := repositories.NewOptionRepository(config.DB)optionService := services.NewOptionsService(optionRepository)optionController := options_controller.NewOptionsController(optionService)emailRepository := repositories.NewEmailRepository(config.DB)emailService := services.NewEmailService(emailRepository, taskDistributor)emailController := email_controller.NewEmailController(emailService)17 unmodified lines// create servers, err := router.NewServer(regionController,optionController,emailController,cvController,marriageReadinessProfileController,
104 unmodified lines105106107108109110111112113114115116117118119120121104 unmodified linesAcademyMaterialID uint `json:"academy_material_id"`Description string `json:"description"`}type OptionCategory struct {ID uint `gorm:"primaryKey" json:"id"`OptionName string `json:"option_name"`OptionSlug string `json:"option_slug" gorm:"uniqueIndex"`}type OptionValues struct {ID uint `gorm:"primaryKey" json:"id"`OptionCategoryID uint `json:"option_category_id"`OptionValue string `json:"option_value"`}type AcademyMaterialProgress struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`104 unmodified lines105106107108109110111112113114115116117118119120121122123124104 unmodified linesAcademyMaterialID uint `json:"academy_material_id"`Description string `json:"description"`}type OptionCategory struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`OptionName string `json:"option_name"`OptionSlug string `json:"option_slug" gorm:"uniqueIndex"`OptionValues []OptionValues `gorm:"foreignKey:OptionCategoryID" json:"-"`}type OptionValues struct {ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`OptionCategoryID int64 `json:"option_category_id"`OptionValue string `json:"option_value"`}type AcademyMaterialProgress struct {ID uint `gorm:"primaryKey" json:"id"`UUID uuid.UUID `gorm:"type:uuid" json:"uuid"`
27 unmodified lines2829303132333435363719 unmodified lines57585960616227 unmodified linesToken uint `json:"token" binding:"required"`}type OptionsRequest struct {OptionName string `json:"option_name" binding:"required"`OptionValue []string `json:"option_values" binding:"required"`}type ExternalAuthRequest struct {OauthID string `json:"oauth_id" binding:"required"`19 unmodified linesAnswer int `json:"answer" binding:"required"`}type (CreateEmailVerificationRequest struct {AccountID int64 `json:"-"`27 unmodified lines28293031323334353637383940414243444546474849505152535455565758596019 unmodified lines80818283848586878889909127 unmodified linesToken uint `json:"token" binding:"required"`}type (MultipleOptionsRequest struct {OptionName string `json:"option_name" validate:"required"`OptionValue []string `json:"option_values" validate:"required"`}CreateOptionsRequest struct {Options []MultipleOptionsRequest `json:"options" validate:"required"`}CreateOptionsResponse struct {Options []Options `json:"options"`}ListOptionsResponse struct {Options []Options `json:"options"`}ListOptionsBySlugRequest struct {Slug string `json:"slug"`}ListOptionsBySlugResponse struct {OptionCategory *OptionCategory `json:"option_category"`OptionValues []OptionValues `json:"option_values"`})type ExternalAuthRequest struct {OauthID string `json:"oauth_id" binding:"required"`19 unmodified linesAnswer int `json:"answer" binding:"required"`}type (ListCitiesByProvinceIdRequest struct {ProvinceID int64 `json:"province_id" binding:"required"`})type (CreateEmailVerificationRequest struct {AccountID int64 `json:"-"`
17 unmodified lines1819202122232425262717 unmodified linesAccount Account `json:"account"`Token string `json:"token"`}type Options struct {OptionCategory OptionCategory `json:"option_category"`OptionValues []OptionValues `json:"option_values"`}type OptionsResponse struct {Options []Options `json:"options"`}17 unmodified lines18192021222324252627282917 unmodified linesAccount Account `json:"account"`Token string `json:"token"`}type Options struct {OptionCategory OptionCategory `json:"option_category"`OptionValues []OptionValues `json:"option_values"`}type OptionsResponse struct {Options []Options `json:"options"`}
12345678910111213141516171819202122232425262728293031323334353637383940414243package repositoriesimport ("api.qobiltu.id/models")func CreateOptionCategory(categories models.OptionCategory) Repository[models.OptionCategory, models.OptionCategory] {repo := Construct[models.OptionCategory, models.OptionCategory](categories,)Create(repo)return *repo}func CreateOptionValues(values models.OptionValues) Repository[models.OptionValues, models.OptionValues] {repo := Construct[models.OptionValues, models.OptionValues](values,)Create(repo)return *repo}func GetOptionCategoryBySlug(slug string) Repository[models.OptionCategory, models.OptionCategory] {repo := Construct[models.OptionCategory, models.OptionCategory](models.OptionCategory{OptionSlug: slug},)repo.Transactions(WhereGivenConstructor[models.OptionCategory, models.OptionCategory],Find[models.OptionCategory, models.OptionCategory],)return *repo}func GetOptionValuesByCategoryId(categoryId uint) Repository[models.OptionValues, []models.OptionValues] {repo := Construct[models.OptionValues, []models.OptionValues](models.OptionValues{OptionCategoryID: categoryId},)repo.Transactions(WhereGivenConstructor[models.OptionValues, []models.OptionValues],Find[models.OptionValues, []models.OptionValues],)return *repo}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889package repositoriesimport ("context""api.qobiltu.id/models""gorm.io/gorm")type OptionRepository interface {CreateOptionCategory(ctx context.Context, optionCategory *models.OptionCategory) (*models.OptionCategory, error)CreateOptionValues(ctx context.Context, optionValue *models.OptionValues) (*models.OptionValues, error)GetOptionCategoryBySlug(ctx context.Context, slug string) (*models.OptionCategory, error)GetOptionValuesByCategoryId(ctx context.Context, categoryId int64) ([]models.OptionValues, error)ListOptions(ctx context.Context) ([]models.OptionCategory, error)DeleteOptionValuesByCategoryId(ctx context.Context, categoryId int64) errorDeleteOptionValue(ctx context.Context, id int64) error}type optionRepository struct {db *gorm.DB}func NewOptionRepository(db *gorm.DB) OptionRepository {return &optionRepository{db: db}}func (r *optionRepository) CreateOptionCategory(ctx context.Context, optionCategory *models.OptionCategory) (*models.OptionCategory, error) {err := r.db.Save(&optionCategory).Errorif err != nil {return nil, err}return optionCategory, nil}func (r *optionRepository) CreateOptionValues(ctx context.Context, optionValue *models.OptionValues) (*models.OptionValues, error) {err := r.db.Save(&optionValue).Errorif err != nil {return nil, err}return optionValue, nil}func (r *optionRepository) GetOptionCategoryBySlug(ctx context.Context, slug string) (*models.OptionCategory, error) {var category models.OptionCategoryerr := r.db.Where("option_slug = ?", slug).First(&category).Errorif err != nil {return nil, err}return &category, nil}func (r *optionRepository) GetOptionValuesByCategoryId(ctx context.Context, categoryId int64) ([]models.OptionValues, error) {values := make([]models.OptionValues, 0)err := r.db.Where("option_category_id = ?", categoryId).Find(&values).Errorif err != nil {return nil, err}return values, nil}func (r *optionRepository) ListOptions(ctx context.Context) ([]models.OptionCategory, error) {categories := make([]models.OptionCategory, 0)err := r.db.WithContext(ctx).Preload("OptionValues").Find(&categories).Errorif err != nil {return nil, err}return categories, nil}func (r *optionRepository) DeleteOptionValuesByCategoryId(ctx context.Context, categoryId int64) error {err := r.db.Where("option_category_id = ?", categoryId).Delete(&models.OptionValues{}).Errorif err != nil {return err}return nil}func (r *optionRepository) DeleteOptionValue(ctx context.Context, id int64) error {err := r.db.Where("id = ?", id).Delete(&models.OptionValues{}).Errorif err != nil {return err}return nil}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647package repositoriesimport ("api.qobiltu.id/models")func BulkCreateProvince(provinces []models.RegionProvince) Repository[[]models.RegionProvince, []models.RegionProvince] {repo := Construct[[]models.RegionProvince, []models.RegionProvince](provinces,)Create(repo)return *repo}func BulkCreateCity(cities []models.RegionCity) Repository[[]models.RegionCity, []models.RegionCity] {repo := Construct[[]models.RegionCity, []models.RegionCity](cities,)Create(repo)return *repo}func GetListProvinces() Repository[models.RegionProvince, []models.RegionProvince] {repo := Construct[models.RegionProvince, []models.RegionProvince](models.RegionProvince{},)repo.Transactions(Find[models.RegionProvince, []models.RegionProvince],)return *repo}func GetListCitiesByProvinceId(provinceId uint) Repository[models.RegionCity, []models.RegionCity] {repo := Construct[models.RegionCity, []models.RegionCity](models.RegionCity{ProvinceID: provinceId,},)repo.Transactions(WhereGivenConstructor[models.RegionCity, []models.RegionCity],Find[models.RegionCity, []models.RegionCity],)return *repo}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657package repositoriesimport ("context""api.qobiltu.id/models""gorm.io/gorm")type RegionRepository interface {CreateProvince(ctx context.Context, provinces []models.RegionProvince) errorCreateCity(ctx context.Context, cities []models.RegionCity) errorListProvinces(ctx context.Context) ([]models.RegionProvince, error)ListCitiesByProvinceId(ctx context.Context, provinceId int64) ([]models.RegionCity, error)ListCities(ctx context.Context) ([]models.RegionCity, error)}type regionRepository struct {db *gorm.DB}func NewRegionRepository(db *gorm.DB) RegionRepository {return ®ionRepository{db: db}}func (r *regionRepository) CreateProvince(ctx context.Context, provinces []models.RegionProvince) error {return r.db.Save(provinces).Error}func (r *regionRepository) CreateCity(ctx context.Context, cities []models.RegionCity) error {return r.db.Save(cities).Error}func (r *regionRepository) ListProvinces(ctx context.Context) ([]models.RegionProvince, error) {provinces := make([]models.RegionProvince, 0)if err := r.db.Order("id ASC").Find(&provinces).Error; err != nil {return nil, err}return provinces, nil}func (r *regionRepository) ListCitiesByProvinceId(ctx context.Context, provinceId int64) ([]models.RegionCity, error) {cities := make([]models.RegionCity, 0)if err := r.db.Where("province_id = ?", provinceId).Order("id ASC").Find(&cities).Error; err != nil {return nil, err}return cities, nil}func (r *regionRepository) ListCities(ctx context.Context) ([]models.RegionCity, error) {cities := make([]models.RegionCity, 0)if err := r.db.Find(&cities).Error; err != nil {return nil, err}return cities, nil}
1234567891011121314151617181920package routerimport (OptionsController "api.qobiltu.id/controller/options"CityController "api.qobiltu.id/controller/region/city"ProvinceController "api.qobiltu.id/controller/region/province""github.com/gin-gonic/gin")func OptionsRoute(router *gin.Engine) {routerGroup := router.Group("/api/v1/options"){routerGroup.POST("/create", OptionsController.AddOptions)routerGroup.GET("/list/:slug", OptionsController.List)routerGroup.GET("/region/provinces", ProvinceController.List)routerGroup.GET("/region/cities", CityController.List)routerGroup.POST("/region/seed-provinces", ProvinceController.Seeds)routerGroup.POST("/region/seed-cities", CityController.Seeds)}}12345678910111213141516package routerfunc (s *Server) OptionsRoute() {routerGroup := s.router.Group("/api/v1/options"){routerGroup.POST("/create", s.optionsController.CreateOptions)routerGroup.GET("/list", s.optionsController.ListOptions)routerGroup.GET("/list/:slug", s.optionsController.ListOptionsBySlug)routerGroup.GET("/region/provinces", s.regionController.ListProvinces)routerGroup.GET("/region/cities", s.regionController.ListCities)routerGroup.POST("/region/seed-provinces", s.regionController.SeedProvince)routerGroup.POST("/region/seed-cities", s.regionController.SeedCity)}}
9 unmodified lines101112131415161718199 unmodified linesAuthRoute(s.router)UserRoute(s.router)OptionsRoute(s.router)AcademyRoute(s.router)QuizRoute(s.router)s.EmailRoute()s.CVRoute()s.MarriageReadinessProfileRoute()9 unmodified lines101112131415161718199 unmodified linesAuthRoute(s.router)UserRoute(s.router)AcademyRoute(s.router)QuizRoute(s.router)s.OptionsRoute()s.EmailRoute()s.CVRoute()s.MarriageReadinessProfileRoute()
3 unmodified lines4567891011121314151 unmodified line1718192021222324252627282930313233343536373 unmodified linescv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria""github.com/gin-gonic/gin")type Server struct {router *gin.EngineemailController email_controller.EmailControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController1 unmodified line}func NewServer(emailController email_controller.EmailController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,) (*Server, error) {router := gin.Default()router.Use(gin.Recovery())server := &Server{emailController: emailController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,router: router,}server.setupRoutes()3 unmodified lines456789101112131415161718191 unmodified line2122232425262728293031323334353637383940414243443 unmodified linescv_controller "api.qobiltu.id/controller/cv"email_controller "api.qobiltu.id/controller/email"marriage_readiness_profile_controller "api.qobiltu.id/controller/marriage_readiness_profile"options_controller "api.qobiltu.id/controller/options"partner_criteria_controller "api.qobiltu.id/controller/partner_criteria"region_controller "api.qobiltu.id/controller/region""github.com/gin-gonic/gin")type Server struct {router *gin.EngineregionController region_controller.RegionControlleroptionsController options_controller.OptionsControlleremailController email_controller.EmailControllercvController cv_controller.CVControllermarriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController1 unmodified line}func NewServer(regionController region_controller.RegionController,optionsController options_controller.OptionsController,emailController email_controller.EmailController,cvController cv_controller.CVController,marriageReadinessProfileController marriage_readiness_profile_controller.MarriageReadinessProfileController,partnerCriteriaController partner_criteria_controller.PartnerCriteriaController,) (*Server, error) {router := gin.Default()router.Use(gin.Recovery())server := &Server{router: router,regionController: regionController,optionsController: optionsController,emailController: emailController,cvController: cvController,marriageReadinessProfileController: marriageReadinessProfileController,partnerCriteriaController: partnerCriteriaController,}server.setupRoutes()
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149package services
import (
"context"
"errors"
"api.qobiltu.id/models"
"api.qobiltu.id/repositories"
"api.qobiltu.id/response"
"github.com/gosimple/slug"
"gorm.io/gorm"
)
type OptionsService interface {
CreateOptions(ctx context.Context, req *models.CreateOptionsRequest) (*models.CreateOptionsResponse, error)
ListOptions(ctx context.Context) (*models.ListOptionsResponse, error)
ListOptionsBySlug(ctx context.Context, req *models.ListOptionsBySlugRequest) (*models.ListOptionsBySlugResponse, error)
}
type optionsService struct {
optionRepository repositories.OptionRepository
}
func NewOptionsService(optionRepository repositories.OptionRepository) OptionsService {
return &optionsService{
optionRepository: optionRepository,
}
}
func (s *optionsService) CreateOptions(ctx context.Context, req *models.CreateOptionsRequest) (*models.CreateOptionsResponse, error) {
createdOptions := make([]models.Options, 0)
for _, optReq := range req.Options {
slug := slug.Make(optReq.OptionName)
// 1. Cek apakah kategori sudah ada
category, err := s.optionRepository.GetOptionCategoryBySlug(ctx, slug)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return nil, response.HandleGormError(err, "Internal server error")
}
if errors.Is(err, gorm.ErrRecordNotFound) {
// 2. Kalau belum ada, buat kategori baru
newCategory := models.OptionCategory{
OptionName: optReq.OptionName,
OptionSlug: slug,
}
category, err = s.optionRepository.CreateOptionCategory(ctx, &newCategory)
if err != nil {
return nil, response.HandleGormError(err, "Internal server error")
}
}
// 3. Ambil semua option values yang ada
existingValues, err := s.optionRepository.GetOptionValuesByCategoryId(ctx, category.ID)
if err != nil {
return nil, response.HandleGormError(err, "Internal server error")
}
// 4. Buat map untuk nilai yang sudah ada
existingValuesMap := make(map[string]bool)
for _, val := range existingValues {
existingValuesMap[val.OptionValue] = true
}
// 5. Proses setiap nilai yang diminta
for _, val := range optReq.OptionValue {
// Jika nilai belum ada, buat baru
if !existingValuesMap[val] {
_, err := s.optionRepository.CreateOptionValues(ctx, &models.OptionValues{
OptionCategoryID: category.ID,
OptionValue: val,
})
if err != nil {
return nil, response.HandleGormError(err, "Failed to create option value")
}
}
// Jika nilai sudah ada, tidak perlu dilakukan apa-apa
}
// 6. Hapus nilai yang tidak ada dalam request tapi ada di database
requestedValuesMap := make(map[string]bool)
for _, val := range optReq.OptionValue {
requestedValuesMap[val] = true
}
for _, existingVal := range existingValues {
if !requestedValuesMap[existingVal.OptionValue] {
err := s.optionRepository.DeleteOptionValue(ctx, existingVal.ID)
if err != nil {
return nil, response.HandleGormError(err, "Failed to delete unused option value")
}
}
}
// 7. Ambil ulang semua value terbaru
allValues, err := s.optionRepository.GetOptionValuesByCategoryId(ctx, category.ID)
if err != nil {
return nil, response.HandleGormError(err, "Internal server error")
}
// 8. Masukkan ke hasil response
createdOptions = append(createdOptions, models.Options{
OptionCategory: *category,
OptionValues: allValues,
})
}
return &models.CreateOptionsResponse{
Options: createdOptions,
}, nil
}
func (s *optionsService) ListOptions(ctx context.Context) (*models.ListOptionsResponse, error) {
listOptions, err := s.optionRepository.ListOptions(ctx)
if err != nil {
return nil, response.HandleGormError(err, "Internal server error")
}
options := make([]models.Options, 0)
for _, option := range listOptions {
options = append(options, models.Options{
OptionCategory: option,
OptionValues: option.OptionValues,
})
}
return &models.ListOptionsResponse{
Options: options,
}, nil
}
func (s *optionsService) ListOptionsBySlug(ctx context.Context, req *models.ListOptionsBySlugRequest) (*models.ListOptionsBySlugResponse, error) {
optionCategory, err := s.optionRepository.GetOptionCategoryBySlug(ctx, req.Slug)
if err != nil {
return nil, response.HandleGormError(err, "Internal server error")
}
optionValues, err := s.optionRepository.GetOptionValuesByCategoryId(ctx, optionCategory.ID)
if err != nil {
return nil, response.HandleGormError(err, "Internal server error")
}
return &models.ListOptionsBySlugResponse{
OptionCategory: optionCategory,
OptionValues: optionValues,
}, nil
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990package servicesimport ("encoding/json""log""os""path/filepath""runtime""api.qobiltu.id/models""api.qobiltu.id/repositories")type ProvinceService struct {Service[models.RegionProvince, []models.RegionProvince]}type CityService struct {Service[models.RegionCity, []models.RegionCity]}func seedCity() ([]models.RegionCity, error) {log.Println("Seed City")_, b, _, _ := runtime.Caller(0)basePath := filepath.Dir(b)file, err := os.Open(filepath.Join(basePath, "..", "utils", "seeds", "city.json"))if err != nil {return nil, err}defer file.Close()var cities []models.RegionCityif err := json.NewDecoder(file).Decode(&cities); err != nil {return nil, err}return cities, nil}func seedProvince() ([]models.RegionProvince, error) {log.Println("Seed City")_, b, _, _ := runtime.Caller(0)basePath := filepath.Dir(b)file, err := os.Open(filepath.Join(basePath, "..", "utils", "seeds", "province.json"))if err != nil {return nil, err}defer file.Close()var provinces []models.RegionProvinceif err := json.NewDecoder(file).Decode(&provinces); err != nil {return nil, err}return provinces, nil}func (s *ProvinceService) Create() {provinces, errSeed := seedProvince()if errSeed != nil {s.Error = errSeeds.Exception.InternalServerError = trues.Exception.Message = "Failed to seed province"return}createProvince := repositories.BulkCreateProvince(provinces)s.Error = createProvince.RowsErrors.Result = createProvince.Result}func (s *CityService) Create() {cities, errSeed := seedCity()if errSeed != nil {s.Error = errSeeds.Exception.InternalServerError = trues.Exception.Message = "Failed to seed province"return}createCity := repositories.BulkCreateCity(cities)s.Error = createCity.RowsErrors.Result = createCity.Result}func (s *ProvinceService) Retrieve() {Province := repositories.GetListProvinces()s.Error = Province.RowsErrors.Result = Province.Result}func (s *CityService) Retrieve() {cities := repositories.GetListCitiesByProvinceId(s.Constructor.ProvinceID)s.Error = cities.RowsErrors.Result = cities.Result}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768package servicesimport ("context""encoding/json""api.qobiltu.id/assets""api.qobiltu.id/models""api.qobiltu.id/repositories""api.qobiltu.id/response")type RegionService interface {SeedProvince(ctx context.Context) errorSeedCity(ctx context.Context) errorListProvinces(ctx context.Context) ([]models.RegionProvince, error)ListCitiesByProvinceId(ctx context.Context, req *models.ListCitiesByProvinceIdRequest) ([]models.RegionCity, error)ListCities(ctx context.Context) ([]models.RegionCity, error)}type regionService struct {regionRepository repositories.RegionRepository}func NewRegionService(regionRepository repositories.RegionRepository) RegionService {return ®ionService{regionRepository: regionRepository}}func (s *regionService) SeedProvince(ctx context.Context) error {provinces := make([]models.RegionProvince, 0)if err := json.Unmarshal(assets.EmbeddedProvinceJSON, &provinces); err != nil {return response.HandleGormError(err, "Internal Server Error")}if err := s.regionRepository.CreateProvince(ctx, provinces); err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}func (s *regionService) SeedCity(ctx context.Context) error {cities := make([]models.RegionCity, 0)if err := json.Unmarshal(assets.EmbeddedCityJSON, &cities); err != nil {return response.HandleGormError(err, "Internal Server Error")}if err := s.regionRepository.CreateCity(ctx, cities); err != nil {return response.HandleGormError(err, "Internal Server Error")}return nil}func (s *regionService) ListProvinces(ctx context.Context) ([]models.RegionProvince, error) {return s.regionRepository.ListProvinces(ctx)}func (s *regionService) ListCitiesByProvinceId(ctx context.Context, req *models.ListCitiesByProvinceIdRequest) ([]models.RegionCity, error) {return s.regionRepository.ListCitiesByProvinceId(ctx, req.ProvinceID)}func (s *regionService) ListCities(ctx context.Context) ([]models.RegionCity, error) {return s.regionRepository.ListCities(ctx)}
11 unmodified lines1213141516171811 unmodified lines}func (s *NavigationQuizService) Retrieve(userID uint) {attemptRepo := repositories.GetAttemptByUserId(userID)if attemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "there is no attempt data with given user ID!"11 unmodified lines1213141516171811 unmodified lines}func (s *NavigationQuizService) Retrieve(userID uint) {attemptRepo := repositories.GetAttemptByIdandUserId(s.Constructor.QuizAttemptID, userID)if attemptRepo.NoRecord {s.Exception.DataNotFound = trues.Exception.Message = "there is no attempt data with given user ID!"
models/request_model.go+17-17
repositories/academy_repository.go+11-7
space/controller/academy/academy_controller.go+11-5
space/models/database_orm_model.go+3-1
space/models/request_model.go+56-4
space/repositories/academy_repository.go+21-13
space/repositories/quiz_repository.go+19
space/router/quiz_route.go+1-1
space/services/academy_service.go+17-17
space/services/quiz_service.goAdded+37
space/space/models/field_counter.go-2
space/space/services/partner_criteria_service.go+2-2
space/space/space/config/database_connection_config.go-2
space/space/space/controller/academy/academy_controller.go+369-31
space/space/space/controller/cv/cv_controller.go+12-60
space/space/space/controller/email/email_controller.go+1-5
space/space/space/controller/marriage_readiness_profile/marriage_readiness_profile_controller.go+2-6
space/space/space/controller/options/options_controller.go+1-5
space/space/space/controller/partner_criteria/partner_criteria_controller.go+1-5
space/space/space/controller/quiz/list_quiz_controller.go+1-1
space/space/space/main.go+6
space/space/space/models/database_orm_model.go+32-50
space/space/space/models/filter_and_paging.goAdded+107
space/space/space/models/request_model.go+107-2
space/space/space/models/response_model.go-13
space/space/space/repositories/academy_repository.go+406-103
space/space/space/repositories/question_repository.go+11
space/space/space/response/api_response_v2.go+37-11
space/space/space/router/academy_route.go+25-8
space/space/space/router/router.go+1-1
space/space/space/router/server.go+4
space/space/space/services/academy_quiz_service.go+2-2
space/space/space/services/academy_service.go+316-150
space/space/space/space/space/assets/efs.go+8
space/space/space/space/space/assets/seeds/city.jsonAdded+4114
space/space/space/space/space/assets/seeds/province.jsonAdded+192
space/space/space/space/space/controller/options/options_controller.goAdded+72
space/space/space/space/space/controller/region/region_controller.goAdded+92
space/space/space/space/space/main.go+13
space/space/space/space/space/models/database_orm_model.go+8-5
space/space/space/space/space/models/request_model.go+33-4
space/space/space/space/space/models/response_model.go+2
space/space/space/space/space/repositories/option_repository.go+82-36
space/space/space/space/space/repositories/region_repository.go+41-31
space/space/space/space/space/router/options_route.go+11-15
space/space/space/space/space/router/router.go+1-1
space/space/space/space/space/router/server.go+9-2
space/space/space/space/space/services/options_service.goAdded+149
space/space/space/space/space/services/region_service.go+41-63
space/space/space/space/space/space/services/academy_quiz_navigation_service.go+1-1