Spaces:
Configuration error
Configuration error
Commit ·
fea5ebb
1
Parent(s): c934e84
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)
- services/user_profile_service.go+3-1
- space/models/request_model.go+4-2
- space/services/authentication_service.go+2
- space/services/email_verification_service.go+4
- space/services/user_profile_service.go+5-2
- space/space/repositories/account_repository.go+9
- space/space/services/external_authentication_service.go+1-1
- space/space/services/user_profile_service.go+8
- space/space/space/services/user_profile_service.go-2
- space/space/space/space/docker-compose.yml+1-1
- space/space/space/space/space/space/Dockerfile+3
- space/space/space/space/space/space/services/region_service.go+10-8
- space/space/space/space/space/space/space/services/region_service.go+8-10
- space/space/space/space/space/space/space/space/README.md+5-1
- space/space/space/space/space/space/space/space/space/controller/user/user_profile_controller.go+1-1
- space/space/space/space/space/space/space/space/space/controller/user/user_update_profile_controller.go+2-4
- space/space/space/space/space/space/space/space/space/logs/error_log.txt+1
- space/space/space/space/space/space/space/space/space/middleware/authentication_middleware.go-3
- space/space/space/space/space/space/space/space/space/models/response_model.go+5
- space/space/space/space/space/space/space/space/space/repositories/account_repository.go-4
- space/space/space/space/space/space/space/space/space/repositories/forgot_password_repository.goAdded+22
- space/space/space/space/space/space/space/space/space/router/router.go+8-1
- space/space/space/space/space/space/space/space/space/services/external_authentication_service.go+4-5
- space/space/space/space/space/space/space/space/space/services/user_profile_service.go+50-6
- space/space/space/space/space/space/space/space/space/space/.gitignore+4-2
- space/space/space/space/space/space/space/space/space/space/config/config.go+10
- space/space/space/space/space/space/space/space/space/space/config/database_connection_config.go+4
- space/space/space/space/space/space/space/space/space/space/controller/auth/auth_external_controller.goAdded+20
- space/space/space/space/space/space/space/space/space/space/controller/auth/auth_forgot_password_controller.goAdded+1
- space/space/space/space/space/space/space/space/space/space/controller/email/email_create_verification_controller.goAdded+21
- space/space/space/space/space/space/space/space/space/space/controller/email/email_validate_controller.goAdded+24
- space/space/space/space/space/space/space/space/space/space/controller/options/option_category_controller.goAdded+19
- space/space/space/space/space/space/space/space/space/space/controller/options/option_value_controller.goAdded+19
- space/space/space/space/space/space/space/space/space/space/controller/region/city/city_list_controller.goAdded+21
- space/space/space/space/space/space/space/space/space/space/controller/region/city/city_seeds_controller.goAdded+17
- space/space/space/space/space/space/space/space/space/space/controller/region/province/province_list_controller.goAdded+17
- space/space/space/space/space/space/space/space/space/space/controller/region/province/province_seeds_controller.goAdded+17
- space/space/space/space/space/space/space/space/space/space/go.mod+23-2
- space/space/space/space/space/space/space/space/space/space/go.sum+46
- space/space/space/space/space/space/space/space/space/space/middleware/authentication_middleware.go+3-3
- space/space/space/space/space/space/space/space/space/space/models/request_model.go+17-4
- space/space/space/space/space/space/space/space/space/space/models/response_model.go+7
- space/space/space/space/space/space/space/space/space/space/repositories/email_verification_repository.go+15-1
- space/space/space/space/space/space/space/space/space/space/repositories/external_auth_repository.goAdded+37
- space/space/space/space/space/space/space/space/space/space/repositories/option_repository.goAdded+43
- space/space/space/space/space/space/space/space/space/space/repositories/region_repository.goAdded+47
- space/space/space/space/space/space/space/space/space/space/router/auth_route.go+1
- space/space/space/space/space/space/space/space/space/space/router/email_route.go+3-3
- space/space/space/space/space/space/space/space/space/space/router/options_route.goAdded+20
- space/space/space/space/space/space/space/space/space/space/router/router.go+1
1 unmodified line234567874 unmodified lines8384858586878889901 unmodified line
import (
"regexp"
"strconv"
"strings"
"api.qobiltu.id/models"74 unmodified lines } else {
initialName = "AKH_"
}
initialName += string(usersCount)
initialName += strconv.Itoa(usersCount)
s.Constructor.InitialName = initialName
userProfile := repositories.UpdateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {29 unmodified lines3031323334333435363729 unmodified lines}
type ExternalAuthRequest struct {
OauthID string `json:"oauth_id" binding:"required"`
OauthProvider string `json:"oauth_provider" binding:"required"`
OauthID string `json:"oauth_id" binding:"required"`
OauthProvider string `json:"oauth_provider" binding:"required"`
IsAgreeTerms bool `json:"is_agree_terms"`
IsSexualDisease bool `json:"is_sexual_disease"`
}17 unmodified lines181920212223244 unmodified lines2930313233343517 unmodified lines s.Exception.Message = "there is no account with given credentials!"
return
}
if VerifyPassword(accountData.Result.Password, s.Constructor.Password) != nil {
s.Exception.Unauthorized = true
s.Exception.Message = "incorrect password!"4 unmodified lines
if err_tok != nil {
s.Error = errors.Join(s.Error, err_tok)
return
}
accountData.Result.Password = "SECRET"55 unmodified lines56575859606162636412 unmodified lines777879808182838485868755 unmodified lines
err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)
if err != nil {
s.Error = err
log.Printf("Error sending verification email: %v", err)
return
}
}(accountRepo.Result.Email, token)
}12 unmodified lines s.Exception.Unauthorized = true
s.Exception.Message = "Token has expired!"
repositories.UpdateExpiredEmailVerification(s.Constructor.UUID)
s.Delete()
return
}
s.Result = repo.Result
s.Delete()
}
func (s *EmailVerificationService) Delete() {70 unmodified lines71727374747575767778798013 unmodified lines949596979870 unmodified lines}
func (s *UserProfileService) Update() {
if s.Constructor.PhoneNumber != nil {
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
}
usersCount := repositories.GetAllAccount().RowsCount
var initialName string
if *s.Constructor.Gender {13 unmodified lines Account: repositories.GetAccountById(s.Constructor.AccountID).Result,
Details: userProfile.Result,
}
s.Result.Account.Password = "SECRET"
}14 unmodified lines15161718192021222324252627282914 unmodified lines return *repo
}
func GetAllAccount() Repository[models.Account, []models.Account] {
repo := Construct[models.Account, []models.Account](
models.Account{},
)
repo.Transactions(
Find[models.Account, []models.Account],
)
return *repo
}
func GetAccountById(accountId uint) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
models.Account{Id: accountId},32 unmodified lines333435363637383932 unmodified lines })
s.Constructor.AccountID = createAccount.Result.Id
createGoogleAuth := repositories.CreateExternalAuth(s.Constructor)
GoogleAuth.Result.AccountID = createGoogleAuth.Result.ID
s.Error = createGoogleAuth.RowsError
s.Error = errors.Join(s.Error, createAccount.RowsError)
}72 unmodified lines737475767778798081828384858672 unmodified linesfunc (s *UserProfileService) Update() {
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
usersCount := repositories.GetAllAccount().RowsCount
var initialName string
if *s.Constructor.Gender {
initialName = "IKH_"
} else {
initialName = "AKH_"
}
initialName += string(usersCount)
userProfile := repositories.UpdateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {43 unmodified lines444546474847484943 unmodified lines return input
}
func (s *UserProfileService) Create() {
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
userProfile := repositories.CreateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {23 unmodified lines242526272728293023 unmodified lines ports: - "5432:5432" volumes: - db-data:/var/lib/postgresql/data - /home/qobiltu/postgres-data:/var/lib/postgresql/data restart: always
volumes:27 unmodified lines28293031323334353627 unmodified lines# Copy hasil build dari builder ke image runtimeCOPY --from=builder /app/main .
# Copy folder utils (termasuk file seeder) dari builder ke runtimeCOPY --from=builder /app/utils ./utils
# Copy file .env untuk konfigurasi environmentCOPY .env .env
3 unmodified lines45678910118 unmodified lines20212221222324232425262728296 unmodified lines36373837383940394041424344453 unmodified lines "encoding/json"
"log"
"os"
"path/filepath"
"runtime"
"api.qobiltu.id/models"
"api.qobiltu.id/repositories"8 unmodified lines}
func seedCity() ([]models.RegionCity, error) {
log.Println("Seed City..")
path := "utils/seeds/city.json"
file, err := os.Open(path)
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
}6 unmodified lines}
func seedProvince() ([]models.RegionProvince, error) {
log.Println("Seed Province..")
path := "utils/seeds/province.json"
file, err := os.Open(path)
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
}3 unmodified lines456787898 unmodified lines18192023242526212223242526276 unmodified lines34353639404142373839404142433 unmodified lines "encoding/json"
"log"
"os"
"path/filepath"
"runtime"
"api.qobiltu.id/models"
"api.qobiltu.id/repositories"8 unmodified lines}
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"))
log.Println("Seed City..")
path := "utils/seeds/city.json"
file, err := os.Open(path)
if err != nil {
return nil, err
}6 unmodified lines}
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"))
log.Println("Seed Province..")
path := "utils/seeds/province.json"
file, err := os.Open(path)
if err != nil {
return nil, err
}83 unmodified lines84858687878889909183 unmodified lines
### View Log container
> docker logs --tail=50 -f api-qobiltu
> docker logs postgres-db> docker logs postgres-db
### Menghapus Resource docker yang tidak dipakai
> docker system prune
> docker system prune -a --volumes8 unmodified lines9101112121314158 unmodified lines
func Profile(c *gin.Context) {
userProfile := services.UserProfileService{}
userProfileController := controller.Controller[any, models.AccountDetails, models.AccountDetails]{
userProfileController := controller.Controller[any, models.AccountDetails, models.UserProfileResponse]{
Service: &userProfile.Service,
}
userProfileController.HeaderParse(c, func() {123454562 unmodified lines9101114121314151 unmodified line1718192220212223package user
import (
"fmt"
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"2 unmodified lines
func UpdateProfile(c *gin.Context) {
userProfile := services.UserProfileService{}
userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.AccountDetails]{
userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.UserProfileResponse]{
Service: &userProfile.Service,
}
1 unmodified line userUpdateProfileController.Service.Constructor = userUpdateProfileController.Request
userUpdateProfileController.HeaderParse(c, func() {
userUpdateProfileController.Service.Constructor.AccountID = uint(userUpdateProfileController.AccountData.UserID)
fmt.Println("Account ID:", userUpdateProfileController.Service.Constructor.AccountID)
})
userProfile.Update()
},1
2 unmodified lines345676786 unmodified lines151617201819202 unmodified linespackage middleware
import (
"fmt"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"api.qobiltu.id/utils"6 unmodified lines token := c.Request.Header["Authorization"]
currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])
fmt.Println(token[0])
if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
currAccData.UserID = 024 unmodified lines252627282930313224 unmodified linestype OptionsResponse struct {
Options []Options `json:"options"`
}
type UserProfileResponse struct {
Account Account `json:"account"`
Details AccountDetails `json:"details"`
}1234545655 unmodified lines6263646768656667package repositories
import (
"fmt"
"api.qobiltu.id/models"
)
55 unmodified lines repo := Construct[models.AccountDetails, models.AccountDetails](
accountDetails,
)
fmt.Println(accountDetails)
fmt.Println("Account ID : ", accountDetails.AccountID)
Create(repo)
return *repo
}12345678910111213141516171819202122package repositories
import "api.qobiltu.id/models"
func CreateForgotPassword(forgotPassword models.ForgotPassword) Repository[models.ForgotPassword, models.ForgotPassword] {
repo := Construct[models.ForgotPassword, models.ForgotPassword](
forgotPassword,
)
Create(repo)
return *repo
}
func GetForgotPasswordByToken(token uint) Repository[models.ForgotPassword, models.ForgotPassword] {
repo := Construct[models.ForgotPassword, models.ForgotPassword](
models.ForgotPassword{Token: token},
)
repo.Transactions(
WhereGivenConstructor[models.ForgotPassword, models.ForgotPassword],
Find[models.ForgotPassword, models.ForgotPassword],
)
return *repo
}123456782 unmodified lines111213141516171819162021222324package router
import (
"log"
"api.qobiltu.id/config"
"api.qobiltu.id/controller"
"github.com/gin-gonic/gin"2 unmodified linesfunc StartService() {
router := gin.Default()
router.GET("/", controller.HomeController)
AuthRoute(router)
UserRoute(router)
EmailRoute(router)
OptionsRoute(router)
router.Run(config.TCP_ADDRESS)
err := router.Run(config.TCP_ADDRESS)
if err != nil {
log.Fatalf("Failed to run server: %v", err)
}
}26 unmodified lines2728293031323334303132333435363738394026 unmodified lines if GoogleAuth.NoRecord {
s.Constructor.UUID = uuid.NewV4()
s.Constructor.OauthProvider = "Google"
createGoogleAuth := repositories.CreateExternalAuth(s.Constructor)
s.Error = createGoogleAuth.RowsError
createAccount := repositories.CreateAccount(models.Account{
Email: email.(string),
IsEmailVerified: true,
})
s.Constructor.AccountID = createAccount.Result.Id
createGoogleAuth := repositories.CreateExternalAuth(s.Constructor)
s.Error = createGoogleAuth.RowsError
s.Error = errors.Join(s.Error, createAccount.RowsError)
}
accountData := repositories.GetAccountById(GoogleAuth.Result.AccountID)1234456789101111121314151617181920212223242526272829303132333435363738394041424344454647484950511 unmodified line53545522565758596061623 unmodified lines66676832697071727374753676777879801 unmodified line828384448586878889package services
import (
"fmt"
"regexp"
"strings"
"api.qobiltu.id/models"
"api.qobiltu.id/repositories"
)
type UserProfileService struct {
Service[models.AccountDetails, models.AccountDetails]
Service[models.AccountDetails, models.UserProfileResponse]
}
// SanitizePhoneNumber membersihkan dan menormalkan nomor telepon ke format +62
func SanitizePhoneNumber(input string) string {
// Hilangkan semua spasi dan strip
input = strings.ReplaceAll(input, " ", "")
input = strings.ReplaceAll(input, "-", "")
input = strings.ReplaceAll(input, "(", "")
input = strings.ReplaceAll(input, ")", "")
// Hilangkan semua karakter non-digit kecuali +
re := regexp.MustCompile(`[^0-9\+]`)
input = re.ReplaceAllString(input, "")
// Handle nomor diawali 0 (contoh: 0812...) menjadi +62812...
if strings.HasPrefix(input, "0") {
input = "+62" + input[1:]
}
// Handle jika diawali dengan 62 tanpa + (contoh: 62812...)
if strings.HasPrefix(input, "62") && !strings.HasPrefix(input, "+62") {
input = "+" + input
}
// Handle jika tidak ada awalan +62 sama sekali (contoh: 8123456789)
if !strings.HasPrefix(input, "+62") {
if strings.HasPrefix(input, "8") {
input = "+62" + input
}
}
return input
}
func (s *UserProfileService) Create() {
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
userProfile := repositories.CreateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {1 unmodified line s.Exception.Message = "There is no account with given credentials!"
return
}
s.Result = userProfile.Result
s.Result = models.UserProfileResponse{
Account: repositories.GetAccountById(s.Constructor.AccountID).Result,
Details: userProfile.Result,
}
}
func (s *UserProfileService) Retrieve() {
userProfile := repositories.GetDetailAccountById(s.Constructor.AccountID)3 unmodified lines s.Exception.Message = "There is no account with given credentials!"
return
}
s.Result = userProfile.Result
s.Result = models.UserProfileResponse{
Account: repositories.GetAccountById(s.Constructor.AccountID).Result,
Details: userProfile.Result,
}
}
func (s *UserProfileService) Update() {
fmt.Println("Account ID:", s.Constructor.AccountID)
phoneNumber := *s.Constructor.PhoneNumber
*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)
userProfile := repositories.UpdateAccountDetails(s.Constructor)
s.Error = userProfile.RowsError
if userProfile.NoRecord {1 unmodified line s.Exception.Message = "There is no account with given credentials!"
return
}
s.Result = userProfile.Result
s.Result = models.UserProfileResponse{
Account: repositories.GetAccountById(s.Constructor.AccountID).Result,
Details: userProfile.Result,
}
}123454567.env
vendor/
quzuu-be.exe
README.md.qodoREADME.md
.qodo
.error
logs/8 unmodified lines91011121314151617181920212223241 unmodified line2627282930313233348 unmodified lines
var TCP_ADDRESS string
var LOG_PATH string
var HOST_ADDRESS string
var HOST_PORT string
var EMAIL_VERIFICATION_DURATION int
var SMTP_SENDER_EMAIL string
var SMTP_SENDER_PASSWORD string
var SMTP_HOST string
var SMTP_PORT string
func init() {
godotenv.Load()
HOST_ADDRESS = os.Getenv("HOST_ADDRESS")1 unmodified line TCP_ADDRESS = HOST_ADDRESS + ":" + HOST_PORT
LOG_PATH = os.Getenv("LOG_PATH")
EMAIL_VERIFICATION_DURATION, _ = strconv.Atoi(os.Getenv("EMAIL_VERIFICATION_DURATION"))
SMTP_SENDER_EMAIL = os.Getenv("SMTP_SENDER_EMAIL")
SMTP_SENDER_PASSWORD = os.Getenv("SMTP_SENDER_PASSWORD")
SMTP_HOST = os.Getenv("SMTP_HOST")
SMTP_PORT = os.Getenv("SMTP_PORT")
// Menampilkan nilai variabel lingkungan
}59 unmodified lines6061626364656667686959 unmodified lines &models.AcademyContent{},
&models.AcademyMaterialProgress{},
&models.AcademyContentProgress{},
&models.RegionCity{},
&models.RegionProvince{},
&models.OptionCategory{},
&models.OptionValues{},
)
if err != nil {1234567891011121314151617181920package auth
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func ExternalAuth(c *gin.Context) {
ExternalAuthController := controller.Controller[models.ExternalAuthRequest, models.ExternalAuth, models.AuthenticatedUser]{}
ExternalAuthController.RequestJSON(c, func() {
if ExternalAuthController.Request.OauthProvider == "google" {
GoogleLogin := services.GoogleAuthService{}
ExternalAuthController.Service = &GoogleLogin.Service
ExternalAuthController.Service.Constructor.OauthID = ExternalAuthController.Request.OauthID
GoogleLogin.Authenticate()
}
})
}1package auth123456789101112131415161718192021package controller
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func CreateVerification(c *gin.Context) {
emailVerification := services.EmailVerificationService{}
emailVerificationController := controller.Controller[models.CreateVerifyEmailRequest, models.EmailVerification, models.EmailVerification]{
Service: &emailVerification.Service,
}
emailVerificationController.HeaderParse(c, func() {
emailVerificationController.Service.Constructor.AccountID = uint(emailVerificationController.AccountData.UserID)
emailVerification.Create()
emailVerificationController.Response(c)
})
}123456789101112131415161718192021222324package controller
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func Verify(c *gin.Context) {
emailVerification := services.EmailVerificationService{}
emailVerificationController := controller.Controller[models.CreateVerifyEmailRequest, models.EmailVerification, models.EmailVerification]{
Service: &emailVerification.Service,
}
emailVerificationController.HeaderParse(c, func() {
emailVerificationController.Service.Constructor.AccountID = uint(emailVerificationController.AccountData.UserID)
emailVerificationController.RequestJSON(c, func() {
emailVerificationController.Service.Constructor.Token = emailVerificationController.Request.Token
emailVerificationController.Service.Constructor.UUID = emailVerificationController.Request.UUID
emailVerification.Validate()
})
})
}12345678910111213141516171819package options
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func AddOptions(c *gin.Context) {
options := services.OptionService{}
addOptionController := controller.Controller[[]models.OptionsRequest, []models.OptionsRequest, models.OptionsResponse]{
Service: &options.Service,
}
addOptionController.RequestJSON(c, func() {
options.Constructor = addOptionController.Request
options.Create()
})
}12345678910111213141516171819package options
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func List(c *gin.Context) {
options := services.OptionValueService{}
optionValueController := controller.Controller[any, models.OptionCategory, models.Options]{
Service: &options.Service,
}
slug := c.Param("slug")
options.Constructor.OptionSlug = slug
options.Retrieve()
optionValueController.Response(c)
}123456789101112131415161718192021package city
import (
"strconv"
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func List(c *gin.Context) {
city := services.CityService{}
CityController := controller.Controller[any, models.RegionCity, []models.RegionCity]{
Service: &city.Service,
}
ProvinceID, _ := strconv.Atoi(c.Query("province_id"))
city.Constructor.ProvinceID = uint(ProvinceID)
city.Retrieve()
CityController.Response(c)
}1234567891011121314151617package city
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func Seeds(c *gin.Context) {
city := services.CityService{}
CityController := controller.Controller[any, models.RegionCity, []models.RegionCity]{
Service: &city.Service,
}
city.Create()
CityController.Response(c)
}1234567891011121314151617package province
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func List(c *gin.Context) {
province := services.ProvinceService{}
ProvinceController := controller.Controller[any, models.RegionProvince, []models.RegionProvince]{
Service: &province.Service,
}
province.Retrieve()
ProvinceController.Response(c)
}1234567891011121314151617package province
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func Seeds(c *gin.Context) {
province := services.ProvinceService{}
ProvinceController := controller.Controller[any, models.RegionProvince, []models.RegionProvince]{
Service: &province.Service,
}
province.Create()
ProvinceController.Response(c)
}12 unmodified lines13141516171819202122232425262728293031323334353637388 unmodified lines474849395051525354555657585960616263644765666768697012 unmodified lines)
require ( cloud.google.com/go/auth v0.15.0 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect cloud.google.com/go/compute/metadata v0.6.0 // indirect github.com/bytedance/sonic v1.13.1 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/cloudwego/base64x v0.1.5 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/gin-contrib/sse v1.0.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.25.0 // indirect github.com/goccy/go-json v0.10.5 // indirect github.com/google/s2a-go v0.1.9 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect github.com/googleapis/gax-go/v2 v2.14.1 // indirect github.com/gosimple/slug v1.15.0 // indirect github.com/gosimple/unidecode v1.0.1 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/pgx/v5 v5.7.2 // indirect8 unmodified lines github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect go.opentelemetry.io/otel v1.34.0 // indirect go.opentelemetry.io/otel/metric v1.34.0 // indirect go.opentelemetry.io/otel/trace v1.34.0 // indirect golang.org/x/arch v0.15.0 // indirect golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect golang.org/x/net v0.37.0 // indirect golang.org/x/oauth2 v0.28.0 // indirect golang.org/x/sync v0.12.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect google.golang.org/protobuf v1.36.5 // indirect google.golang.org/api v0.228.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect google.golang.org/grpc v1.71.0 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect)1234567896 unmodified lines161718192021222324252627282930313233349 unmodified lines4445464748495051525354555657585933 unmodified lines9394959697989912 unmodified lines1121131141151161171181191201211221231241251261271281291301311321331341351361373 unmodified lines141142143144145146147148149150151152153154155156cloud.google.com/go/auth v0.15.0 h1:Ly0u4aA5vG/fsSsxu98qCQBemXtAtJf+95z9HK+cxps=cloud.google.com/go/auth v0.15.0/go.mod h1:WJDGqZ1o9E9wKIL+IwStfyn/+s59zl4Bi+1KQNVXLZ8=cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=github.com/bytedance/sonic v1.13.1 h1:Jyd5CIvdFnkOWuKXr+wm4Nyk2h0yAFsr8ucJgEasO3g=github.com/bytedance/sonic v1.13.1/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=6 unmodified linesgithub.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=9 unmodified linesgithub.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4=github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=github.com/googleapis/gax-go/v2 v2.14.1 h1:hb0FFeiPaQskmvakKu5EbCbpntQn48jyHuvrkurSS/Q=github.com/googleapis/gax-go/v2 v2.14.1/go.mod h1:Hb/NubMaVM88SrNkvl8X/o8XWwDJEPqouaLeN2IUxoA=github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=33 unmodified linesgithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=12 unmodified linesgithub.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 h1:CV7UdSGJt/Ao6Gp4CXckLxVRRsRgDHoI8XjbL3PDl8s=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0/go.mod h1:FRmFuRJfag1IZ2dPkHnEoSFVgTVPUd2qf5Vi69hLb8I=go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=3 unmodified linesgolang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=google.golang.org/api v0.228.0 h1:X2DJ/uoWGnY5obVjewbp8icSL5U4FzuCfy9OjbLSnLs=google.golang.org/api v0.228.0/go.mod h1:wNvRS1Pbe8r4+IfBIniV8fwCpGwTrYa+kMUDiC5z5a4=google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 h1:iK2jbkWL86DXjEx0qiHcRE9dE4/Ahua5k6V8OWFb//c=google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=2 unmodified lines3456789104 unmodified lines1516171618191920202122232 unmodified linespackage middleware
import (
"fmt"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"api.qobiltu.id/utils"4 unmodified lines var currAccData models.AccountData
if c.Request.Header["Authorization"] != nil {
token := c.Request.Header["Authorization"]
// fmt.Println("Authorization :", token)
currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])
// fmt.Println("Verify Status :", currAccData.VerifyStatus)
// fmt.Println("Verify UserID :", currAccData.UserID)
fmt.Println(token[0])
if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
currAccData.UserID = 012345676 unmodified lines1415161516171817181920212223242526272829303132333435package models
import uuid "github.com/satori/go.uuid"
type LoginRequest struct {
Email string `json:"email" binding:"required"`
Password string `json:"password" binding:"required"`6 unmodified lines Password string `json:"password" binding:"required"`
}
type CreateEmailVerificationRequest struct {
AccountID int `json:"account_id" binding:"required"`
}
type ChangePasswordRequest struct {
OldPassword string `json:"old_password" binding:"required" `
NewPassword string `json:"new_password" binding:"required" `
}
type CreateVerifyEmailRequest struct {
Token uint `json:"token" binding:"required"`
UUID uuid.UUID `json:"uuid" 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"`
OauthProvider string `json:"oauth_provider" binding:"required"`
}17 unmodified lines1819202122232425262717 unmodified lines Account 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"`
}3 unmodified lines4567899101112131415161718192015 unmodified lines3637383940414243444546474849505152533 unmodified lines "time"
"api.qobiltu.id/models"
uuid "github.com/satori/go.uuid"
)
func CreateEmailVerification(accountId uint, dueTime time.Time, token uint) Repository[models.EmailVerification, models.EmailVerification] {
func CreateEmailVerification(uuid uuid.UUID, accountId uint, dueTime time.Time, token uint) Repository[models.EmailVerification, models.EmailVerification] {
repo := Construct[models.EmailVerification, models.EmailVerification](
models.EmailVerification{
AccountID: accountId,
IsExpired: false,
ExpiredAt: dueTime,
Token: token,
UUID: uuid,
},
)
Create(repo)15 unmodified lines return *repo
}
func UpdateExpiredEmailVerification(uuid uuid.UUID) Repository[models.EmailVerification, models.EmailVerification] {
repo := Construct[models.EmailVerification, models.EmailVerification](
models.EmailVerification{UUID: uuid},
)
repo.Transaction.Where("UUID = ?", uuid).First(&repo.Constructor)
repo.Constructor.IsExpired = true
repo.Transaction.Updates(repo.Constructor)
repo.Result = repo.Constructor
return *repo
}
func DeleteEmailVerification(token uint) Repository[models.EmailVerification, models.EmailVerification] {
repo := Construct[models.EmailVerification, models.EmailVerification](
models.EmailVerification{12345678910111213141516171819202122232425262728293031323334353637package repositories
import "api.qobiltu.id/models"
func CreateExternalAuth(oauth models.ExternalAuth) Repository[models.ExternalAuth, models.ExternalAuth] {
repo := Construct[models.ExternalAuth, models.ExternalAuth](
oauth,
)
Create(repo)
return *repo
}
func GetExternalAuthByAccountId(accountId uint) Repository[models.ExternalAuth, []models.ExternalAuth] {
repo := Construct[models.ExternalAuth, []models.ExternalAuth](
models.ExternalAuth{
AccountID: accountId,
},
)
repo.Transactions(
WhereGivenConstructor[models.ExternalAuth, []models.ExternalAuth],
Find[models.ExternalAuth, []models.ExternalAuth],
)
return *repo
}
func GetExternalAccountByOauthId(oauthId string) Repository[models.ExternalAuth, models.ExternalAuth] {
repo := Construct[models.ExternalAuth, models.ExternalAuth](
models.ExternalAuth{
OauthID: oauthId,
},
)
repo.Transactions(
WhereGivenConstructor[models.ExternalAuth, models.ExternalAuth],
Find[models.ExternalAuth, models.ExternalAuth],
)
return *repo
}12345678910111213141516171819202122232425262728293031323334353637383940414243package repositories
import (
"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
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647package repositories
import (
"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
}8 unmodified lines91011121314158 unmodified linesfunc AuthRoute(router *gin.Engine) {
routerGroup := router.Group("/api/v1/auth")
{
routerGroup.POST("/external-login", AuthController.ExternalAuth)
routerGroup.POST("/login", AuthController.Login)
routerGroup.POST("/register", AuthController.Register)
routerGroup.PUT("/change-password", middleware.AuthUser, AuthController.ChangePassword)1 unmodified line234567891011111213121314151 unmodified line
import (
EmailController "api.qobiltu.id/controller/email"
"api.qobiltu.id/middleware"
"github.com/gin-gonic/gin"
)
func EmailRoute(router *gin.Engine) {
routerGroup := router.Group("/api/v1/email")
{
routerGroup.POST("/verify", EmailController.CreateVerification)
routerGroup.POST("/create-verification", EmailController.CreateVerification)
routerGroup.DELETE("/delete-verification", EmailController.DeleteVerification)
routerGroup.POST("/verify", middleware.AuthUser, EmailController.Verify)
routerGroup.POST("/create-verification", middleware.AuthUser, EmailController.CreateVerification)
}
}1234567891011121314151617181920package router
import (
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)
}
}11 unmodified lines12131415161711 unmodified lines AuthRoute(router)
UserRoute(router)
EmailRoute(router)
OptionsRoute(router)
router.Run(config.TCP_ADDRESS)
}services/user_profile_service.go+3-1
space/models/request_model.go+4-2
space/services/authentication_service.go+2
space/services/email_verification_service.go+4
space/services/user_profile_service.go+5-2
space/space/repositories/account_repository.go+9
space/space/services/external_authentication_service.go+1-1
space/space/services/user_profile_service.go+8
space/space/space/services/user_profile_service.go-2
space/space/space/space/docker-compose.yml+1-1
space/space/space/space/space/space/Dockerfile+3
space/space/space/space/space/space/services/region_service.go+10-8
space/space/space/space/space/space/space/services/region_service.go+8-10
space/space/space/space/space/space/space/space/README.md+5-1
space/space/space/space/space/space/space/space/space/controller/user/user_profile_controller.go+1-1
space/space/space/space/space/space/space/space/space/controller/user/user_update_profile_controller.go+2-4
space/space/space/space/space/space/space/space/space/logs/error_log.txt+1
space/space/space/space/space/space/space/space/space/middleware/authentication_middleware.go-3
space/space/space/space/space/space/space/space/space/models/response_model.go+5
space/space/space/space/space/space/space/space/space/repositories/account_repository.go-4
space/space/space/space/space/space/space/space/space/repositories/forgot_password_repository.goAdded+22
space/space/space/space/space/space/space/space/space/router/router.go+8-1
space/space/space/space/space/space/space/space/space/services/external_authentication_service.go+4-5
space/space/space/space/space/space/space/space/space/services/user_profile_service.go+50-6
space/space/space/space/space/space/space/space/space/space/.gitignore+4-2
space/space/space/space/space/space/space/space/space/space/config/config.go+10
space/space/space/space/space/space/space/space/space/space/config/database_connection_config.go+4
space/space/space/space/space/space/space/space/space/space/controller/auth/auth_external_controller.goAdded+20
space/space/space/space/space/space/space/space/space/space/controller/auth/auth_forgot_password_controller.goAdded+1
space/space/space/space/space/space/space/space/space/space/controller/email/email_create_verification_controller.goAdded+21
space/space/space/space/space/space/space/space/space/space/controller/email/email_validate_controller.goAdded+24
space/space/space/space/space/space/space/space/space/space/controller/options/option_category_controller.goAdded+19
space/space/space/space/space/space/space/space/space/space/controller/options/option_value_controller.goAdded+19
space/space/space/space/space/space/space/space/space/space/controller/region/city/city_list_controller.goAdded+21
space/space/space/space/space/space/space/space/space/space/controller/region/city/city_seeds_controller.goAdded+17
space/space/space/space/space/space/space/space/space/space/controller/region/province/province_list_controller.goAdded+17
space/space/space/space/space/space/space/space/space/space/controller/region/province/province_seeds_controller.goAdded+17
space/space/space/space/space/space/space/space/space/space/go.mod+23-2
space/space/space/space/space/space/space/space/space/space/go.sum+46
space/space/space/space/space/space/space/space/space/space/middleware/authentication_middleware.go+3-3
space/space/space/space/space/space/space/space/space/space/models/request_model.go+17-4
space/space/space/space/space/space/space/space/space/space/models/response_model.go+7
space/space/space/space/space/space/space/space/space/space/repositories/email_verification_repository.go+15-1
space/space/space/space/space/space/space/space/space/space/repositories/external_auth_repository.goAdded+37
space/space/space/space/space/space/space/space/space/space/repositories/option_repository.goAdded+43
space/space/space/space/space/space/space/space/space/space/repositories/region_repository.goAdded+47
space/space/space/space/space/space/space/space/space/space/router/auth_route.go+1
space/space/space/space/space/space/space/space/space/space/router/email_route.go+3-3
space/space/space/space/space/space/space/space/space/space/router/options_route.goAdded+20
space/space/space/space/space/space/space/space/space/space/router/router.go+1