Spaces:
Runtime error
Runtime error
Commit ·
e762600
1
Parent(s): e356e6e
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)
- .env.exampleAdded+14
- .github/workflows/main.ymlAdded+49
- .gitignoreAdded+6
- DockerfileAdded+30
- LICENSEAdded+201
- README.md+2-4
- config/config.goAdded+34
- config/database_connection_config.goAdded+99
- controller/auth/auth_change_password_controller.goAdded+21
- controller/auth/auth_external_controller.goAdded+20
- controller/auth/auth_forgot_password_controller.goAdded+29
- controller/auth/auth_login_controller.goAdded+20
- controller/auth/auth_register_controller.goAdded+22
- controller/controller.goAdded+71
- controller/email/email_create_verification_controller.goAdded+20
- controller/email/email_validate_controller.goAdded+21
- controller/event/event_detail_controller.goAdded+21
- controller/event/event_join_controller.goAdded+22
- controller/event/event_list_controller.goAdded+54
- controller/home_controller.goAdded+9
- controller/options/option_category_controller.goAdded+19
- controller/options/option_value_controller.goAdded+19
- controller/region/city/city_list_controller.goAdded+21
- controller/region/city/city_seeds_controller.goAdded+17
- controller/region/province/province_list_controller.goAdded+17
- controller/region/province/province_seeds_controller.goAdded+17
- controller/user/user_profile_controller.goAdded+21
- controller/user/user_update_profile_controller.goAdded+25
- go.modAdded+73
- go.sumAdded+200
- logs/error_log.txtAdded+1
- logs/security_log.txtAdded
- main.goAdded+14
- middleware/authentication_middleware.goAdded+38
- middleware/middleware.goAdded+30
- middleware/response_middleware.goAdded+45
- models/authentication_payload_model.goAdded+18
- models/database_orm_model.goAdded+264
- models/exception_model.goAdded+12
- models/model.goAdded+1
- models/request_model.goAdded+57
- models/response_model.goAdded+50
- repositories/academy_repository.goAdded+73
- repositories/account_repository.goAdded+88
- repositories/email_verification_repository.goAdded+63
- repositories/event_repository.goAdded+93
- repositories/external_auth_repository.goAdded+40
- repositories/forgot_password_repository.goAdded+22
- repositories/option_repository.goAdded+43
- repositories/region_repository.goAdded+47
1234567891011121314DB_HOST = localhostDB_USER = postgresDB_PASSWORD = DB_PORT = DB_NAME =SALT =HOST_ADDRESS = localhostHOST_PORT = 8080LOG_PATH = logsEMAIL_VERIFICATION_DURATION = SMTP_SENDER_EMAIL = SMTP_SENDER_PASSWORD = SMTP_HOST = SMTP_PORT = 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849name: Deploy to Huggingfaceon: push: branches: - masterjobs: deploy-to-huggingface: runs-on: ubuntu-latest steps: # Checkout repository - name: Checkout Repository uses: actions/checkout@v3 # Setup Git - name: Setup Git for Huggingface run: | git config --global user.email "abdan.hafidz@gmail.com" git config --global user.name "abdanhafidz" # Clone Huggingface Space Repository - name: Clone Huggingface Space env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | git clone https://huggingface.co/spaces/lifedebugger/quzuu-api-dev space # Update Git Remote URL and Pull Latest Changes - name: Update Remote and Pull Changes env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | cd space git remote set-url origin https://lifedebugger:$HF_TOKEN@huggingface.co/spaces/lifedebugger/quzuu-api-dev git pull origin main || echo "No changes to pull" # Clean Space Directory - Delete all files except .git - name: Clean Space Directory run: | cd space find . -mindepth 1 -not -path "./.git*" -delete # Copy Files to Huggingface Space - name: Copy Files to Space run: | rsync -av --exclude='.git' ./ space/ # Commit and Push to Huggingface Space - name: Commit and Push to Huggingface env: HF_TOKEN: ${{ secrets.HF_TOKEN }} run: | cd space git add . git commit -m "Deploy files from GitHub repository" || echo "No changes to commit" git push origin main || echo "No changes to push"123456.env
vendor/
quzuu-be.exe
README.md
.qodo
.idea/123456789101112131415161718192021222324252627282930# Gunakan image dasar Golang versi 1.24.1
FROM golang:1.24.1 AS builder
# Set working directory
WORKDIR /app
# Copy go.mod dan go.sum
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy seluruh kode
COPY . .
# Buat file .env dengan variabel environment yang dibutuhkan
RUN echo "DB_HOST=aws-0-ap-southeast-1.pooler.supabase.com" >> .env && \
echo "DB_USER=postgres.zvcysrvqmkmgtcqryslt" >> .env && \
echo "DB_PASSWORD=QuzuuAPIDEV2025" >> .env && \
echo "DB_PORT=5432" >> .env && \
echo "DB_NAME=postgres" >> .env && \
echo "HOST_ADDRESS = 0.0.0.0" >> .env && \
echo "HOST_PORT = 7860" >> .env && \
echo "EMAIL_VERIFICATION_DURATION = 2" >> .env
# Build aplikasi
RUN go build -o main .
# Jalankan aplikasi
CMD ["./main"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright 2025 Abdan Hafidz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.12345678910---title: Quzuu Api Devemoji: 🐠colorFrom: purplecolorTo: pinksdk: dockerpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678---title: Quzuu Api Devemoji: 🐠colorFrom: indigocolorTo: graysdk: dockerpinned: false---
12345678910111213141516171819202122232425262728293031323334package config
import (
"os"
"strconv"
"github.com/joho/godotenv"
)
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")
HOST_PORT = os.Getenv("HOST_PORT")
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
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899package config
import ( "fmt" "godp.abdanhafidz.com/models" "log" "os"
"gorm.io/driver/postgres" "gorm.io/gorm" "gorm.io/gorm/logger"
"github.com/joho/godotenv")
var DB *gorm.DBvar err errorvar Salt string
func init() { godotenv.Load() if err != nil { fmt.Println("Gagal membaca file .env") return } os.Setenv("TZ", "Asia/Jakarta") dbHost := os.Getenv("DB_HOST") dbPort := os.Getenv("DB_PORT") dbUser := os.Getenv("DB_USER") dbPassword := os.Getenv("DB_PASSWORD") dbName := os.Getenv("DB_NAME") Salt := os.Getenv("SALT") dsn := "host=" + dbHost + " user=" + dbUser + " password=" + dbPassword + " dbname=" + dbName + " port=" + dbPort + " sslmode=disable TimeZone=Asia/Jakarta" DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{TranslateError: true}) if err != nil { panic(err) } if Salt == "" { Salt = "D3f4u|t" }
// Call AutoMigrateAll to perform auto-migration AutoMigrateAll(DB)}
func AutoMigrateAll(db *gorm.DB) { // Enable logger to see SQL logs db.Logger.LogMode(logger.Info)
// Auto-migrate all models db.Exec("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";") if err := db.AutoMigrate(&models.Account{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.AccountDetails{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.EmailVerification{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.ExternalAuth{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.FCM{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.ForgotPassword{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.Events{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.Announcement{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.ProblemSet{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.Questions{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.EventAssign{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.ProblemSetAssign{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.ExamProgress{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.ExamProgress_Result{}); err != nil { log.Fatal(err) } if err := db.AutoMigrate(&models.Result{}); err != nil { log.Fatal(err) }
fmt.Println("Migration completed successfully.")}123456789101112131415161718192021package auth
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func ChangePassword(c *gin.Context) {
authentication := services.AuthenticationService{}
changePasswordController := controller.Controller[models.ChangePasswordRequest, models.Account, models.AuthenticatedUser]{
Service: &authentication.Service,
}
changePasswordController.HeaderParse(c, func() {
changePasswordController.Service.Constructor.Id = changePasswordController.AccountData.UserID
})
changePasswordController.RequestJSON(c, func() {
authentication.Update(changePasswordController.Request.OldPassword, changePasswordController.Request.NewPassword)
})
}1234567891011121314151617181920package auth
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
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(true)
}
})
}1234567891011121314151617181920212223242526272829package auth
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func CreateForgotPassword(c *gin.Context) {
ForgotPassword := services.ForgotPasswordService{}
ForgotPasswordController := controller.Controller[models.ForgotPasswordRequest, models.ForgotPassword, models.ForgotPassword]{
Service: &ForgotPassword.Service,
}
ForgotPasswordController.RequestJSON(c, func() {
ForgotPassword.Create(ForgotPasswordController.Request.Email)
})
}
func ValidateForgotPassword(c *gin.Context) {
ForgotPassword := services.ForgotPasswordService{}
ForgotPasswordController := controller.Controller[models.ValidateForgotPasswordRequest, models.ForgotPassword, models.ForgotPassword]{
Service: &ForgotPassword.Service,
}
ForgotPasswordController.RequestJSON(c, func() {
ForgotPasswordController.Service.Constructor.Token = ForgotPasswordController.Request.Token
ForgotPassword.Validate(&ForgotPasswordController.Request.NewPassword)
})
}1234567891011121314151617181920package auth
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func Login(c *gin.Context) {
authentication := services.AuthenticationService{}
loginController := controller.Controller[models.LoginRequest, models.Account, models.AuthenticatedUser]{
Service: &authentication.Service,
}
loginController.RequestJSON(c, func() {
loginController.Service.Constructor.Email = loginController.Request.Email
loginController.Service.Constructor.Password = loginController.Request.Password
authentication.Authenticate()
})
}12345678910111213141516171819202122package auth
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func Register(c *gin.Context) {
register := services.RegisterService{}
registerController := controller.Controller[models.RegisterRequest, models.Account, models.Account]{
Service: ®ister.Service,
}
registerController.RequestJSON(c, func() {
registerController.Service.Constructor.Password = registerController.Request.Password
registerController.Service.Constructor.Email = registerController.Request.Email
registerController.Service.Constructor.Username = registerController.Request.Username
registerController.Service.Constructor.Role = "USER"
register.Create()
})
}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071package controller
import ( "github.com/gin-gonic/gin" "godp.abdanhafidz.com/models" "godp.abdanhafidz.com/repositories" "godp.abdanhafidz.com/services" "godp.abdanhafidz.com/utils")
type ( Controllers interface { RequestJSON(c *gin.Context) Response(c *gin.Context) } Controller[TRequest any, TConstructor any, TResult any] struct { AccountData models.AccountData Request TRequest Service *services.Service[TConstructor, TResult] })
func (controller *Controller[T1, T2, T3]) HeaderParse(c *gin.Context, act func()) { cParam, _ := c.Get("accountData") if cParam != nil { controller.AccountData = cParam.(models.AccountData) } act()}func (controller *Controller[T1, T2, T3]) RequestJSON(c *gin.Context, act func()) { cParam, _ := c.Get("accountData") if cParam != nil { controller.AccountData = cParam.(models.AccountData) } errBinding := c.ShouldBindJSON(&controller.Request) if errBinding != nil { utils.ResponseFAIL(c, 400, models.Exception{ BadRequest: true, Message: "Invalid Request!, recheck your request, there's must be some problem about required parameter or type parameter", }) return } else { act() controller.Response(c) }}func (controller *Controller[T1, T2, T3]) Response(c *gin.Context) { switch { case controller.Service.Error != nil: utils.LogError(controller.Service.Error) utils.ResponseFAIL(c, 500, models.Exception{ InternalServerError: true, Message: "Internal Server Error", })
case controller.Service.Exception.DataDuplicate: utils.ResponseFAIL(c, 400, controller.Service.Exception) case controller.Service.Exception.Unauthorized: utils.ResponseFAIL(c, 401, controller.Service.Exception) case controller.Service.Exception.DataNotFound: utils.ResponseFAIL(c, 404, controller.Service.Exception) case controller.Service.Exception.Message != "": utils.ResponseFAIL(c, 400, controller.Service.Exception) default: if controller.Service.MetaData != (repositories.PaginationMetadata{}) { utils.ResponseOK(c, controller.Service.Result, controller.Service.MetaData) } else { utils.ResponseOK(c, controller.Service.Result, struct{}{}) } }}1234567891011121314151617181920package controller
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func CreateVerification(c *gin.Context) {
emailVerification := services.EmailVerificationService{}
emailVerificationController := controller.Controller[models.CreateEmailVerificationRequest, models.EmailVerification, models.EmailVerification]{
Service: &emailVerification.Service,
}
emailVerificationController.RequestJSON(c, func() {
emailVerification.Create(emailVerificationController.Request.Email)
emailVerificationController.Response(c)
})
}123456789101112131415161718192021package controller
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func Verify(c *gin.Context) {
emailVerification := services.EmailVerificationService{}
emailVerificationController := controller.Controller[models.ValidateVerifyEmailRequest, models.EmailVerification, models.EmailVerification]{
Service: &emailVerification.Service,
}
emailVerificationController.RequestJSON(c, func() {
emailVerificationController.Service.Constructor.Token = emailVerificationController.Request.Token
emailVerification.Validate(emailVerificationController.Request.Email)
})
}123456789101112131415161718192021package event
import ( "github.com/gin-gonic/gin" "godp.abdanhafidz.com/controller" "godp.abdanhafidz.com/models" "godp.abdanhafidz.com/services")
func EventDetail(c *gin.Context) { eventDetail := services.EventDetailService{} eventDetailController := controller.Controller[any, models.Events, models.EventDetailResponse]{ Service: &eventDetail.Service, }
eventDetailController.HeaderParse(c, func() { eventDetailController.Service.Constructor.Slug = c.Param("event_slug") eventDetail.Retrieve(eventDetailController.AccountData.UserID) eventDetailController.Response(c) })}12345678910111213141516171819202122package event
import ( "github.com/gin-gonic/gin" "godp.abdanhafidz.com/controller" "godp.abdanhafidz.com/models" "godp.abdanhafidz.com/services")
func Register(c *gin.Context) { eventAssign := services.JoinEventService{} eventAssignController := controller.Controller[models.JoinEventRequest, models.JoinEventRequest, models.EventDetailResponse]{ Service: &eventAssign.Service, }
eventAssignController.RequestJSON(c, func() { eventAssignController.Service.Constructor.EventId = eventAssignController.Request.EventId eventAssignController.Service.Constructor.EventCode = eventAssignController.Request.EventCode idUser := eventAssignController.AccountData.UserID eventAssign.Create(idUser) })}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354package event
import ( "strconv"
"github.com/gin-gonic/gin" "godp.abdanhafidz.com/controller" "godp.abdanhafidz.com/models" "godp.abdanhafidz.com/repositories" "godp.abdanhafidz.com/services" "godp.abdanhafidz.com/utils")
func EventList(c *gin.Context) { limit, err := strconv.Atoi(c.DefaultQuery("limit", "10")) if err != nil { service := services.Service[any, any]{ Exception: models.Exception{ Message: "Invalid limit parameter", }, } utils.SendResponse(c, service) return }
offset, err := strconv.Atoi(c.DefaultQuery("offset", "0")) if err != nil { service := services.Service[any, any]{ Exception: models.Exception{ Message: "Invalid offset parameter", }, } utils.SendResponse(c, service) return } filter := c.DefaultQuery("filter", "") filterBy := c.DefaultQuery("filter_by", "")
pagination := repositories.PaginationConstructor{ Limit: limit, Offset: offset, Filter: filter, FilterBy: filterBy, }
eventsService := services.GetAllEventService{} getAllEventController := controller.Controller[any, models.Events, []models.Events]{ Service: &eventsService.Service, }
eventsService.Retrieve(pagination)
getAllEventController.Response(c)}123456789package controller
import "github.com/gin-gonic/gin"
func HomeController(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Api Qobiltu 2025!",
})
}12345678910111213141516171819package options
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
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 (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
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"
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
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 (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
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 (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
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 (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func Seeds(c *gin.Context) {
province := services.ProvinceService{}
ProvinceController := controller.Controller[any, models.RegionProvince, []models.RegionProvince]{
Service: &province.Service,
}
province.Create()
ProvinceController.Response(c)
}123456789101112131415161718192021package user
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func Profile(c *gin.Context) {
userProfile := services.UserProfileService{}
userProfileController := controller.Controller[any, models.AccountDetails, models.UserProfileResponse]{
Service: &userProfile.Service,
}
userProfileController.HeaderParse(c, func() {
userProfileController.Service.Constructor.AccountId = userProfileController.AccountData.UserID
userProfile.Retrieve()
userProfileController.Response(c)
},
)
}12345678910111213141516171819202122232425package user
import (
"github.com/gin-gonic/gin"
"godp.abdanhafidz.com/controller"
"godp.abdanhafidz.com/models"
"godp.abdanhafidz.com/services"
)
func UpdateProfile(c *gin.Context) {
userProfile := services.UserProfileService{}
userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.UserProfileResponse]{
Service: &userProfile.Service,
}
userUpdateProfileController.RequestJSON(c, func() {
userUpdateProfileController.Service.Constructor = userUpdateProfileController.Request
userUpdateProfileController.HeaderParse(c, func() {
userUpdateProfileController.Service.Constructor.AccountId = userUpdateProfileController.AccountData.UserID
})
userProfile.Update()
},
)
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273module godp.abdanhafidz.com
go 1.24.0
require ( github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gin-gonic/gin v1.10.0 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/joho/godotenv v1.5.1 github.com/satori/go.uuid v1.2.0 golang.org/x/crypto v0.37.0 gorm.io/driver/postgres v1.5.11 gorm.io/gorm v1.25.12)
require ( cloud.google.com/go/auth v0.16.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/google/uuid v1.6.0 // 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 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/jinzhu/gorm v1.9.16 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/lib/pq v1.1.1 // indirect github.com/mattn/go-isatty v0.0.20 // indirect 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.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.60.0 // indirect go.opentelemetry.io/otel v1.35.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect go.opentelemetry.io/otel/trace v1.35.0 // indirect golang.org/x/arch v0.15.0 // indirect golang.org/x/net v0.39.0 // indirect golang.org/x/oauth2 v0.29.0 // indirect golang.org/x/sync v0.13.0 // indirect golang.org/x/sys v0.32.0 // indirect golang.org/x/text v0.24.0 // indirect google.golang.org/api v0.229.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect google.golang.org/grpc v1.71.1 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200cloud.google.com/go/auth v0.16.0 h1:Pd8P1s9WkcrBE2n/PhAwKsdrR35V3Sg2II9B+ndM3CU=cloud.google.com/go/auth v0.16.0/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI=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/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=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=github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=github.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/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=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=github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=github.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/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=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/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=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=github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=github.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=github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=github.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.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=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.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=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/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=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/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=golang.org/x/oauth2 v0.29.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/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=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.229.0 h1:p98ymMtqeJ5i3lIBMj5MpR9kzIIgzpHHh8vQ+vgAzx8=google.golang.org/api v0.229.0/go.mod h1:wyDfmq5g1wYJWn29O22FDWN48P7Xcz0xz+LBpptYvB0=google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA=google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=google.golang.org/grpc v1.71.1/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=gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314=gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=1
1234567891011121314package main
import ( "fmt"
"godp.abdanhafidz.com/config" "godp.abdanhafidz.com/router")
func main() { fmt.Println("Server started on ", config.TCP_ADDRESS, ", port :", config.HOST_PORT) router.StartService()
}1234567891011121314151617181920212223242526272829303132333435363738// auth/auth.go
package middleware
import ( "github.com/gin-gonic/gin" "github.com/google/uuid" "godp.abdanhafidz.com/models" "godp.abdanhafidz.com/services" "godp.abdanhafidz.com/utils")
func AuthUser(c *gin.Context) { var currAccData models.AccountData if c.Request.Header["Authorization"] != nil { token := c.Request.Header["Authorization"]
currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])
if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" { currAccData.UserID = uuid.UUID{} utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "Your session is expired, Please re-Login!"}) c.Abort() return } else { c.Set("accountData", currAccData) c.Next() } } else { currAccData.UserID = uuid.UUID{} currAccData.VerifyStatus = "no-token" currAccData.ErrVerif = nil utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "You have to login first!"}) c.Abort() return }
}123456789101112131415161718192021222324252627282930package middleware
import (
"math"
"time"
"gorm.io/gorm"
)
func RecordCheck(rows *gorm.DB) (string, error) {
count := rows.RowsAffected
err := rows.Error
if count == 0 {
return "no-record", err
} else if err != nil {
return "query-error", err
} else {
return "ok", err
}
}
func DiffTime(t1 time.Time, t2 time.Time) (int, int, int) {
hs := t1.Sub(t2).Hours()
hs, mf := math.Modf(hs)
ms := mf * 60
ms, sf := math.Modf(ms)
ss := sf * 60
return int(hs), int(ms), int(ss)
}123456789101112131415161718192021222324252627282930313233343536373839404142434445package middleware
import (
"net/http"
"github.com/gin-gonic/gin"
)
// SendJSON200 sends a JSON response with HTTP status code 200
func SendJSON200(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, gin.H{"status": "success", "data": data})
return
}
// SendJSON400 sends a JSON response with HTTP status code 400
func SendJSON400(c *gin.Context, error_status *string, message *string) {
c.JSON(http.StatusBadRequest, gin.H{"status": "error", "error-status": error_status, "message": message})
return
}
// SendJSON401 sends a JSON response with HTTP status code 401
func SendJSON401(c *gin.Context, error_status *string, message *string) {
c.JSON(http.StatusUnauthorized, gin.H{"status": "error", "error-status": error_status, "message": message})
return
}
// SendJSON403 sends a JSON response with HTTP status code 403
func SendJSON403(c *gin.Context, message *string) {
c.JSON(http.StatusForbidden, gin.H{"status": "error", "message": message})
return
}
// SendJSON404 sends a JSON response with HTTP status code 404
func SendJSON404(c *gin.Context, message *string) {
c.JSON(http.StatusNotFound, gin.H{"status": "error", "message": message})
return
}
// SendJSON500 sends a JSON response with HTTP status code 500
func SendJSON500(c *gin.Context, error_status *string, message *string) {
c.JSON(http.StatusInternalServerError, gin.H{"status": "error", "error-status": error_status, "message": message})
return
}
// JSONResponseMiddleware is a middleware that provides functions for sending JSON responses123456789101112131415161718package models
import ( "github.com/golang-jwt/jwt/v5" "github.com/google/uuid")
type AccountData struct { UserID uuid.UUID VerifyStatus string Role string ErrVerif error}type CustomClaims struct { jwt.RegisteredClaims UserID uuid.UUID `json:"id"` Role string `json:"role"`}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264package models
import ( "time"
"github.com/google/uuid" "github.com/jinzhu/gorm/dialects/postgres")
type Account struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"` Username string `gorm:"uniqueIndex" json:"username"` Email string `gorm:"uniqueIndex" json:"email"` Role string `json:"role"` Password string `json:"password"` IsEmailVerified bool `json:"is_email_verified"` IsDetailCompleted bool `json:"is_detail_completed"` CreatedAt time.Time `json:"created_at"` DeletedAt *time.Time `json:"deleted_at" gorm:"default:null"`}
type AccountDetails struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"` AccountId uuid.UUID `json:"account_id"` FullName *string `json:"full_name"` SchoolName *string `json:"school_name"` Province *string `json:"province"` City *string `json:"city"` Avatar *string `json:"avatar"` PhoneNumber *string `json:"phone_number"` Account *Account `gorm:"foreignKey:AccountId"`}
type EmailVerification struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"` Token uint `json:"token"` AccountId uuid.UUID `json:"account_id"` IsExpired bool `json:"is_expired"` CreatedAt time.Time `json:"created_at"` ExpiredAt time.Time `json:"expired_at"`
Account *Account `gorm:"foreignKey:AccountId"`}
type ExternalAuth struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"` OauthID string `json:"oauth_id"` AccountId uuid.UUID `json:"account_id"` OauthProvider string `json:"oauth_provider"`}
type FCM struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"` AccountId uuid.UUID `json:"account_id"` FCMToken string `json:"fcm_token"`}
type ForgotPassword struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"` Token uint `json:"token"` AccountId uuid.UUID `json:"account_id"` IsExpired bool `json:"is_expired"` CreatedAt time.Time `json:"created_at"` ExpiredAt time.Time `json:"expired_at"`}
type Events struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_event"` Title string `json:"title"` Slug string `json:"slug"` StartEvent time.Time `json:"start_event"` EndEvent time.Time `json:"end_event"` EventCode string `json:"event_code"` IsPublic bool `json:"is_public"`}
type Announcement struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_announcement"` Title string `json:"title"` CreatedAt time.Time `json:"created_at"` Message string `json:"message"` Publisher string `json:"publisher"` EventId uuid.UUID `json:"id_event"`}
type ProblemSet struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_problem_set"` Title string `json:"title"` Duration time.Duration `json:"duration"` Randomize uint `json:"randomize"` MC_Count uint `json:"mc_count"` SA_Count uint `json:"sa_count"` Essay_Count uint `json:"essay_count"`}
type Questions struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_question"` Type string `json:"type"` //MultChoices, ShortAns, Essay, IntPuzzle, IntType Question string `json:"question"` Options []string `gorm:"type:text[]" json:"options"` AnsKey []string `gorm:"type:text[]" json:"ans_key"` CorrMark float64 `json:"corr_mark"` IncorrMark float64 `json:"incorr_mark"` NullMark float64 `json:"null_mark"` ProblemSetId uuid.UUID `json:"id_problem_set"`
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`}
type EventAssign struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_assign"` AccountId uuid.UUID `json:"id_account"` EventId uuid.UUID `json:"id_event"` AssignedAt time.Time `json:"assigned_at"`
Account *Account `gorm:"foreignKey:AccountId"` Event *Events `gorm:"foreignKey:EventId"`}
type ProblemSetAssign struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_problem_set_assign"` EventId uuid.UUID `json:"id_event"` ProblemSetId uuid.UUID `json:"id_problem_set"`
Event *Events `gorm:"foreignKey:EventId"` ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`}
type ExamProgress struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_progress"` AccountId uuid.UUID `json:"id_account"` EventId uuid.UUID `json:"id_event"` ProblemSetId uuid.UUID `json:"id_problem_set"` CreatedAt time.Time `json:"created_at"` DueAt time.Time `json:"due_at"` QuestionsOrder []string `gorm:"type:text[]" json:"questions_order"` Answers any `gorm:"type:jsonb" json:"answers"`
Account *Account `gorm:"foreignKey:AccountId"` Event *Events `gorm:"foreignKey:EventId"` ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`}
type ExamProgress_Result struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_progress"` AccountId uuid.UUID `json:"id_account"` EventId uuid.UUID `json:"id_event"` ProblemSetId uuid.UUID `json:"id_problem_set"` CreatedAt time.Time `json:"created_at"` DueAt time.Time `json:"due_at"` QuestionsOrder []string `gorm:"type:text[]" json:"questions_order"` Answers postgres.Jsonb `gorm:"type:jsonb" json:"answers"`
Account *Account `gorm:"foreignKey:AccountId"` Event *Events `gorm:"foreignKey:EventId"` ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`}
type Result struct { Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_result"` AccountId uuid.UUID `json:"id_account"` EventId uuid.UUID `json:"id_event"` ProblemSetId uuid.UUID `json:"id_problem_set"` ProgressId uuid.UUID `json:"id_progress"` FinishTime time.Time `json:"finish_time"` Correct uint `json:"correct"` Incorrect uint `json:"incorrect"` Empty uint `json:"empty"` OnCorrection uint `json:"on_correction"` ManualScoring float64 `json:"manual_scoring"` MCScore float64 `json:"mc_score"` ManualScore float64 `json:"manual_score"` FinalScore float64 `json:"final_score"`
Account *Account `gorm:"foreignKey:AccountId"` Event *Events `gorm:"foreignKey:EventId"` ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"` ExamProgress *ExamProgress `gorm:"foreignKey:ProgressId"`}
type Academy struct { Id uuid.UUID `gorm:"primaryKey" json:"id"` Title string `json:"title"` Slug string `json:"slug"` Description string `json:"description"`}
type AcademyMaterial struct { ID uuid.UUID `gorm:"primaryKey" json:"id"` AcademyId uint `json:"academy_id"` Title string `json:"title"` Slug string `json:"slug"` Description string `json:"description"`}
type AcademyContent struct { Id uuid.UUID `gorm:"primaryKey" json:"id"` Title string `json:"title"` Order uint `json:"order"` AcademyMaterialId 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"`}
type OptionValues struct { Id uint `gorm:"primaryKey" json:"id"` OptionCategoryId uint `json:"option_category_id"` OptionValue string `json:"option_value"`}type AcademyMaterialProgress struct { Id uuid.UUID `gorm:"primaryKey" json:"id"` AccountId uint `json:"account_id"` AcademyMaterialId uint `json:"academy_material_id"` Progress uint `json:"progress"`}
type AcademyContentProgress struct { Id uuid.UUID `gorm:"primaryKey" json:"id"` AccountId uuid.UUID `json:"account_id"` AcademyId uuid.UUID `json:"academy_id"`}
type RegionProvince struct { Id uint `json:"id"` Name string `json:"name"` Code string `json:"code"`}
type RegionCity struct { Id uint `json:"id"` Type string `json:"type"` Name string `json:"name"` Code string `json:"code"` FullCode string `json:"full_code"` ProvinceId uint `json:"province_id"`}
// Gorm table name settingsfunc (Account) TableName() string { return "account" }func (AccountDetails) TableName() string { return "account_details" }func (EmailVerification) TableName() string { return "email_verification" }func (ExternalAuth) TableName() string { return "external_auth" }func (FCM) TableName() string { return "fcm" }func (ForgotPassword) TableName() string { return "forgot_password" }func (Events) TableName() string { return "events" }func (Announcement) TableName() string { return "announcement" }func (ProblemSet) TableName() string { return "problem_sets" }func (Questions) TableName() string { return "questions" }func (EventAssign) TableName() string { return "event_assign" }func (ProblemSetAssign) TableName() string { return "problem_sets_assign" }func (Result) TableName() string { return "result" }func (ExamProgress) TableName() string { return "exam_progress" }func (ExamProgress_Result) TableName() string { return "exam_progress_result" }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" }123456789101112package models
type Exception struct {
Unauthorized bool `json:"unauthorized,omitempty"`
BadRequest bool `json:"bad_request,omitempty"`
DataNotFound bool `json:"data_not_found,omitempty"`
InternalServerError bool `json:"internal_server_error,omitempty"`
DataDuplicate bool `json:"data_duplicate,omitempty"`
QueryError bool `json:"query_error,omitempty"`
InvalidPasswordLength bool `json:"invalid_password_length,omitempty"`
Message string `json:"message,omitempty"`
}1package models123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657package models
import "github.com/google/uuid"
type LoginRequest struct { Email string `json:"email" binding:"required"` Password string `json:"password" binding:"required"`}
type RegisterRequest struct { Name string `json:"name"` Email string `json:"email" binding:"required,email"` Username string `json:"username" binding:"required"` Password string `json:"password" binding:"required"`}
type CreateEmailVerificationRequest struct { Email string `json:"email" binding:"required,email"`}
type ChangePasswordRequest struct { OldPassword string `json:"old_password" binding:"required" ` NewPassword string `json:"new_password" binding:"required" `}
type EventDetailRequest struct { IdUser uuid.UUID `json:"id_user"` EventId uuid.UUID `json:"id_event"`}
type JoinEventRequest struct { EventId uuid.UUID `json:"id_event"` EventCode string `json:"event_code"`}
type ValidateVerifyEmailRequest struct { Email string `json:"email" binding:"required,email"` Token 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"` OauthProvider string `json:"oauth_provider" binding:"required"`}
type ForgotPasswordRequest struct { Email string `json:"email" binding:"required,email"`}type ValidateForgotPasswordRequest struct { Token uint `json:"token" binding:"required"` NewPassword string `json:"new_password"`}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950package models
type SuccessResponse struct { Status string `json:"status"` Message string `json:"message"` Data any `json:"data"` MetaData any `json:"meta_data"`}
type ErrorResponse struct { Status string `json:"status"` Message string `json:"message"` Errors Exception `json:"errors"` MetaData any `json:"meta_data"`}type AuthenticatedUser struct { Account Account `json:"account"` Token string `json:"token"`}
type EventDetailResponse struct { Data *Events RegisterStatus int `json:"register_status"`}
type Options struct { OptionCategory OptionCategory `json:"option_category"` OptionValues []OptionValues `json:"option_values"`}type OptionsResponse struct { Options []Options `json:"options"`}
type UserProfileResponse struct { Account Account `json:"account"` Details AccountDetails `json:"details"`}
type AcademyMaterialResponse struct { Materials AcademyMaterial Contents []AcademyContent}type AcademyResponse struct { Academy Academy `json:"academy"` Materials []AcademyMaterialResponse `json:"academy_materials"`}
type AllAcademyResponse struct { Academies []AcademyResponse `json:"academy_dasar"`}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273package repositories
import "godp.abdanhafidz.com/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
}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788package repositories
import (
"github.com/google/uuid"
"godp.abdanhafidz.com/models"
)
func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
models.Account{Email: email},
)
repo.Transactions(
WhereGivenConstructor[models.Account, models.Account],
Find[models.Account, models.Account],
)
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 uuid.UUID) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
models.Account{Id: AccountId},
)
repo.Transactions(
WhereGivenConstructor[models.Account, models.Account],
Find[models.Account, models.Account],
)
return *repo
}
func UpdateAccount(account models.Account) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
account,
)
repo.Transaction.Save(&repo.Constructor)
repo.Result = repo.Constructor
return *repo
}
func GetDetailAccountById(AccountId uuid.UUID) Repository[models.AccountDetails, models.AccountDetails] {
repo := Construct[models.AccountDetails, models.AccountDetails](
models.AccountDetails{AccountId: AccountId},
)
// fmt.Println("Account ID:", repo.Constructor.AccountId)
repo.Transactions(
WhereGivenConstructor[models.AccountDetails, models.AccountDetails],
Find[models.AccountDetails, models.AccountDetails],
)
return *repo
}
func CreateAccount(account models.Account) Repository[models.Account, models.Account] {
repo := Construct[models.Account, models.Account](
account,
)
Create(repo)
return *repo
}
func CreateAccountDetails(accountDetails models.AccountDetails) Repository[models.AccountDetails, models.AccountDetails] {
repo := Construct[models.AccountDetails, models.AccountDetails](
accountDetails,
)
Create(repo)
return *repo
}
func UpdateAccountDetails(accountDetails models.AccountDetails) Repository[models.AccountDetails, models.AccountDetails] {
repo := Construct[models.AccountDetails, models.AccountDetails](
models.AccountDetails{AccountId: accountDetails.AccountId},
)
repo.Transaction.Where("account_id = ?", accountDetails.AccountId).First(&repo.Constructor)
accountDetails.Id = repo.Constructor.Id
// fmt.Println(repo.Constructor)
// fmt.Println(accountDetails)
repo.Transaction.Updates(accountDetails)
repo.Result = accountDetails
return *repo
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263package repositories
import (
"time"
"github.com/google/uuid"
"godp.abdanhafidz.com/models"
)
func CreateEmailVerification(uuid uuid.UUID, AccountId uuid.UUID, 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,
Id: uuid,
},
)
Create(repo)
return *repo
}
func GetEmailVerification(AccountId uuid.UUID, token uint) Repository[models.EmailVerification, models.EmailVerification] {
repo := Construct[models.EmailVerification, models.EmailVerification](
models.EmailVerification{
AccountId: AccountId,
IsExpired: false,
Token: token,
},
)
repo.Transactions(
WhereGivenConstructor[models.EmailVerification, models.EmailVerification],
Find[models.EmailVerification, models.EmailVerification],
)
return *repo
}
func UpdateExpiredEmailVerification(uuid uuid.UUID) Repository[models.EmailVerification, models.EmailVerification] {
repo := Construct[models.EmailVerification, models.EmailVerification](
models.EmailVerification{Id: 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{
Token: token,
},
)
repo.Transactions(
WhereGivenConstructor[models.EmailVerification, models.EmailVerification],
Delete[models.EmailVerification],
)
return *repo
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293package repositories
import ( "log"
"github.com/google/uuid" "godp.abdanhafidz.com/models")
func GetAllEventsPaginate(pagination PaginationConstructor) Repository[models.Events, []models.Events] { repo := Construct[models.Events, []models.Events]( models.Events{}, ) repo.Pagination = pagination
// Add debug log to verify pagination values log.Printf("Pagination - Limit: %d, Offset: %d", pagination.Limit, pagination.Offset)
// Transactions that execute the query repo.Transactions( FindAllPaginate[models.Events, []models.Events], )
// Check if there's an error or no records if repo.RowsCount == 0 { log.Println("No events found with the provided pagination") }
return *repo}
func GetEventDetailByEventId(EventId uuid.UUID) Repository[models.Events, models.Events] { repo := Construct[models.Events, models.Events]( models.Events{ Id: EventId, }, ) repo.Transactions( WhereGivenConstructor[models.Events, models.Events], Find[models.Events, models.Events], ) return *repo}
func GetEventDetailBySlug(slug string) Repository[models.Events, models.Events] { repo := Construct[models.Events, models.Events]( models.Events{ Slug: slug, }, ) repo.Transactions( WhereGivenConstructor[models.Events, models.Events], Find[models.Events, models.Events], ) return *repo}
func GetEventAssigned(EventId uuid.UUID, AccountId uuid.UUID) Repository[models.EventAssign, models.EventAssign] { repo := Construct[models.EventAssign, models.EventAssign]( models.EventAssign{ EventId: EventId, AccountId: AccountId, }, ) repo.Transactions( WhereGivenConstructor[models.EventAssign, models.EventAssign], Find[models.EventAssign, models.EventAssign], ) return *repo}
func GetEventByCode(code string) Repository[models.Events, models.Events] { repo := Construct[models.Events, models.Events]( models.Events{EventCode: code}, )
repo.Transactions( WhereGivenConstructor[models.Events, models.Events], Find[models.Events, models.Events], ) if repo.RowsCount == 0 { log.Println("No events found with the provided code") } return *repo}
func AssignEvent(eventAssign models.EventAssign) Repository[models.EventAssign, models.EventAssign] { repo := Construct[models.EventAssign, models.EventAssign]( eventAssign, ) Create(repo) return *repo}12345678910111213141516171819202122232425262728293031323334353637383940package repositories
import (
"github.com/google/uuid"
"godp.abdanhafidz.com/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 uuid.UUID) 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
}12345678910111213141516171819202122package repositories
import "godp.abdanhafidz.com/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
}12345678910111213141516171819202122232425262728293031323334353637383940414243package repositories
import (
"godp.abdanhafidz.com/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 (
"godp.abdanhafidz.com/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
}.env.exampleAdded+14
.github/workflows/main.ymlAdded+49
.gitignoreAdded+6
DockerfileAdded+30
LICENSEAdded+201
README.md+2-4
config/config.goAdded+34
config/database_connection_config.goAdded+99
controller/auth/auth_change_password_controller.goAdded+21
controller/auth/auth_external_controller.goAdded+20
controller/auth/auth_forgot_password_controller.goAdded+29
controller/auth/auth_login_controller.goAdded+20
controller/auth/auth_register_controller.goAdded+22
controller/controller.goAdded+71
controller/email/email_create_verification_controller.goAdded+20
controller/email/email_validate_controller.goAdded+21
controller/event/event_detail_controller.goAdded+21
controller/event/event_join_controller.goAdded+22
controller/event/event_list_controller.goAdded+54
controller/home_controller.goAdded+9
controller/options/option_category_controller.goAdded+19
controller/options/option_value_controller.goAdded+19
controller/region/city/city_list_controller.goAdded+21
controller/region/city/city_seeds_controller.goAdded+17
controller/region/province/province_list_controller.goAdded+17
controller/region/province/province_seeds_controller.goAdded+17
controller/user/user_profile_controller.goAdded+21
controller/user/user_update_profile_controller.goAdded+25
go.modAdded+73
go.sumAdded+200
logs/error_log.txtAdded+1
logs/security_log.txtAdded
main.goAdded+14
middleware/authentication_middleware.goAdded+38
middleware/middleware.goAdded+30
middleware/response_middleware.goAdded+45
models/authentication_payload_model.goAdded+18
models/database_orm_model.goAdded+264
models/exception_model.goAdded+12
models/model.goAdded+1
models/request_model.goAdded+57
models/response_model.goAdded+50
repositories/academy_repository.goAdded+73
repositories/account_repository.goAdded+88
repositories/email_verification_repository.goAdded+63
repositories/event_repository.goAdded+93
repositories/external_auth_repository.goAdded+40
repositories/forgot_password_repository.goAdded+22
repositories/option_repository.goAdded+43
repositories/region_repository.goAdded+47