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
- .env.example +14 -0
- .github/workflows/main.yml +49 -0
- .gitignore +6 -0
- Dockerfile +30 -0
- LICENSE +201 -0
- README.md +2 -4
- config/config.go +34 -0
- config/database_connection_config.go +99 -0
- controller/auth/auth_change_password_controller.go +21 -0
- controller/auth/auth_external_controller.go +20 -0
- controller/auth/auth_forgot_password_controller.go +29 -0
- controller/auth/auth_login_controller.go +20 -0
- controller/auth/auth_register_controller.go +22 -0
- controller/controller.go +71 -0
- controller/email/email_create_verification_controller.go +20 -0
- controller/email/email_validate_controller.go +21 -0
- controller/event/event_detail_controller.go +21 -0
- controller/event/event_join_controller.go +22 -0
- controller/event/event_list_controller.go +54 -0
- controller/home_controller.go +9 -0
- controller/options/option_category_controller.go +19 -0
- controller/options/option_value_controller.go +19 -0
- controller/region/city/city_list_controller.go +21 -0
- controller/region/city/city_seeds_controller.go +17 -0
- controller/region/province/province_list_controller.go +17 -0
- controller/region/province/province_seeds_controller.go +17 -0
- controller/user/user_profile_controller.go +21 -0
- controller/user/user_update_profile_controller.go +25 -0
- go.mod +73 -0
- go.sum +200 -0
- logs/error_log.txt +1 -0
- logs/security_log.txt +0 -0
- main.go +14 -0
- middleware/authentication_middleware.go +38 -0
- middleware/middleware.go +30 -0
- middleware/response_middleware.go +45 -0
- models/authentication_payload_model.go +18 -0
- models/database_orm_model.go +264 -0
- models/exception_model.go +12 -0
- models/model.go +1 -0
- models/request_model.go +57 -0
- models/response_model.go +50 -0
- repositories/academy_repository.go +73 -0
- repositories/account_repository.go +88 -0
- repositories/email_verification_repository.go +63 -0
- repositories/event_repository.go +93 -0
- repositories/external_auth_repository.go +40 -0
- repositories/forgot_password_repository.go +22 -0
- repositories/option_repository.go +43 -0
- repositories/region_repository.go +47 -0
.env.example
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
DB_HOST = localhost
|
| 2 |
+
DB_USER = postgres
|
| 3 |
+
DB_PASSWORD =
|
| 4 |
+
DB_PORT =
|
| 5 |
+
DB_NAME =
|
| 6 |
+
SALT =
|
| 7 |
+
HOST_ADDRESS = localhost
|
| 8 |
+
HOST_PORT = 8080
|
| 9 |
+
LOG_PATH = logs
|
| 10 |
+
EMAIL_VERIFICATION_DURATION =
|
| 11 |
+
SMTP_SENDER_EMAIL =
|
| 12 |
+
SMTP_SENDER_PASSWORD =
|
| 13 |
+
SMTP_HOST =
|
| 14 |
+
SMTP_PORT =
|
.github/workflows/main.yml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Deploy to Huggingface
|
| 2 |
+
on:
|
| 3 |
+
push:
|
| 4 |
+
branches:
|
| 5 |
+
- master
|
| 6 |
+
jobs:
|
| 7 |
+
deploy-to-huggingface:
|
| 8 |
+
runs-on: ubuntu-latest
|
| 9 |
+
steps:
|
| 10 |
+
# Checkout repository
|
| 11 |
+
- name: Checkout Repository
|
| 12 |
+
uses: actions/checkout@v3
|
| 13 |
+
# Setup Git
|
| 14 |
+
- name: Setup Git for Huggingface
|
| 15 |
+
run: |
|
| 16 |
+
git config --global user.email "abdan.hafidz@gmail.com"
|
| 17 |
+
git config --global user.name "abdanhafidz"
|
| 18 |
+
# Clone Huggingface Space Repository
|
| 19 |
+
- name: Clone Huggingface Space
|
| 20 |
+
env:
|
| 21 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 22 |
+
run: |
|
| 23 |
+
git clone https://huggingface.co/spaces/lifedebugger/quzuu-api-dev space
|
| 24 |
+
# Update Git Remote URL and Pull Latest Changes
|
| 25 |
+
- name: Update Remote and Pull Changes
|
| 26 |
+
env:
|
| 27 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 28 |
+
run: |
|
| 29 |
+
cd space
|
| 30 |
+
git remote set-url origin https://lifedebugger:$HF_TOKEN@huggingface.co/spaces/lifedebugger/quzuu-api-dev
|
| 31 |
+
git pull origin main || echo "No changes to pull"
|
| 32 |
+
# Clean Space Directory - Delete all files except .git
|
| 33 |
+
- name: Clean Space Directory
|
| 34 |
+
run: |
|
| 35 |
+
cd space
|
| 36 |
+
find . -mindepth 1 -not -path "./.git*" -delete
|
| 37 |
+
# Copy Files to Huggingface Space
|
| 38 |
+
- name: Copy Files to Space
|
| 39 |
+
run: |
|
| 40 |
+
rsync -av --exclude='.git' ./ space/
|
| 41 |
+
# Commit and Push to Huggingface Space
|
| 42 |
+
- name: Commit and Push to Huggingface
|
| 43 |
+
env:
|
| 44 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 45 |
+
run: |
|
| 46 |
+
cd space
|
| 47 |
+
git add .
|
| 48 |
+
git commit -m "Deploy files from GitHub repository" || echo "No changes to commit"
|
| 49 |
+
git push origin main || echo "No changes to push"
|
.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.env
|
| 2 |
+
vendor/
|
| 3 |
+
quzuu-be.exe
|
| 4 |
+
README.md
|
| 5 |
+
.qodo
|
| 6 |
+
.idea/
|
Dockerfile
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gunakan image dasar Golang versi 1.24.1
|
| 2 |
+
FROM golang:1.24.1 AS builder
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy go.mod dan go.sum
|
| 8 |
+
COPY go.mod go.sum ./
|
| 9 |
+
|
| 10 |
+
# Download dependencies
|
| 11 |
+
RUN go mod download
|
| 12 |
+
|
| 13 |
+
# Copy seluruh kode
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Buat file .env dengan variabel environment yang dibutuhkan
|
| 17 |
+
RUN echo "DB_HOST=aws-0-ap-southeast-1.pooler.supabase.com" >> .env && \
|
| 18 |
+
echo "DB_USER=postgres.zvcysrvqmkmgtcqryslt" >> .env && \
|
| 19 |
+
echo "DB_PASSWORD=QuzuuAPIDEV2025" >> .env && \
|
| 20 |
+
echo "DB_PORT=5432" >> .env && \
|
| 21 |
+
echo "DB_NAME=postgres" >> .env && \
|
| 22 |
+
echo "HOST_ADDRESS = 0.0.0.0" >> .env && \
|
| 23 |
+
echo "HOST_PORT = 7860" >> .env && \
|
| 24 |
+
echo "EMAIL_VERIFICATION_DURATION = 2" >> .env
|
| 25 |
+
|
| 26 |
+
# Build aplikasi
|
| 27 |
+
RUN go build -o main .
|
| 28 |
+
|
| 29 |
+
# Jalankan aplikasi
|
| 30 |
+
CMD ["./main"]
|
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright 2025 Abdan Hafidz
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
| 1 |
---
|
| 2 |
title: Quzuu Api Dev
|
| 3 |
emoji: 🐠
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
-
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: Quzuu Api Dev
|
| 3 |
emoji: 🐠
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
---
|
|
|
|
|
|
config/config.go
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package config
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"os"
|
| 5 |
+
"strconv"
|
| 6 |
+
|
| 7 |
+
"github.com/joho/godotenv"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
var TCP_ADDRESS string
|
| 11 |
+
var LOG_PATH string
|
| 12 |
+
|
| 13 |
+
var HOST_ADDRESS string
|
| 14 |
+
var HOST_PORT string
|
| 15 |
+
var EMAIL_VERIFICATION_DURATION int
|
| 16 |
+
|
| 17 |
+
var SMTP_SENDER_EMAIL string
|
| 18 |
+
var SMTP_SENDER_PASSWORD string
|
| 19 |
+
var SMTP_HOST string
|
| 20 |
+
var SMTP_PORT string
|
| 21 |
+
|
| 22 |
+
func init() {
|
| 23 |
+
godotenv.Load()
|
| 24 |
+
HOST_ADDRESS = os.Getenv("HOST_ADDRESS")
|
| 25 |
+
HOST_PORT = os.Getenv("HOST_PORT")
|
| 26 |
+
TCP_ADDRESS = HOST_ADDRESS + ":" + HOST_PORT
|
| 27 |
+
LOG_PATH = os.Getenv("LOG_PATH")
|
| 28 |
+
EMAIL_VERIFICATION_DURATION, _ = strconv.Atoi(os.Getenv("EMAIL_VERIFICATION_DURATION"))
|
| 29 |
+
SMTP_SENDER_EMAIL = os.Getenv("SMTP_SENDER_EMAIL")
|
| 30 |
+
SMTP_SENDER_PASSWORD = os.Getenv("SMTP_SENDER_PASSWORD")
|
| 31 |
+
SMTP_HOST = os.Getenv("SMTP_HOST")
|
| 32 |
+
SMTP_PORT = os.Getenv("SMTP_PORT")
|
| 33 |
+
// Menampilkan nilai variabel lingkungan
|
| 34 |
+
}
|
config/database_connection_config.go
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package config
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"godp.abdanhafidz.com/models"
|
| 6 |
+
"log"
|
| 7 |
+
"os"
|
| 8 |
+
|
| 9 |
+
"gorm.io/driver/postgres"
|
| 10 |
+
"gorm.io/gorm"
|
| 11 |
+
"gorm.io/gorm/logger"
|
| 12 |
+
|
| 13 |
+
"github.com/joho/godotenv"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
var DB *gorm.DB
|
| 17 |
+
var err error
|
| 18 |
+
var Salt string
|
| 19 |
+
|
| 20 |
+
func init() {
|
| 21 |
+
godotenv.Load()
|
| 22 |
+
if err != nil {
|
| 23 |
+
fmt.Println("Gagal membaca file .env")
|
| 24 |
+
return
|
| 25 |
+
}
|
| 26 |
+
os.Setenv("TZ", "Asia/Jakarta")
|
| 27 |
+
dbHost := os.Getenv("DB_HOST")
|
| 28 |
+
dbPort := os.Getenv("DB_PORT")
|
| 29 |
+
dbUser := os.Getenv("DB_USER")
|
| 30 |
+
dbPassword := os.Getenv("DB_PASSWORD")
|
| 31 |
+
dbName := os.Getenv("DB_NAME")
|
| 32 |
+
Salt := os.Getenv("SALT")
|
| 33 |
+
dsn := "host=" + dbHost + " user=" + dbUser + " password=" + dbPassword + " dbname=" + dbName + " port=" + dbPort + " sslmode=disable TimeZone=Asia/Jakarta"
|
| 34 |
+
DB, err = gorm.Open(postgres.Open(dsn), &gorm.Config{TranslateError: true})
|
| 35 |
+
if err != nil {
|
| 36 |
+
panic(err)
|
| 37 |
+
}
|
| 38 |
+
if Salt == "" {
|
| 39 |
+
Salt = "D3f4u|t"
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// Call AutoMigrateAll to perform auto-migration
|
| 43 |
+
AutoMigrateAll(DB)
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
func AutoMigrateAll(db *gorm.DB) {
|
| 47 |
+
// Enable logger to see SQL logs
|
| 48 |
+
db.Logger.LogMode(logger.Info)
|
| 49 |
+
|
| 50 |
+
// Auto-migrate all models
|
| 51 |
+
db.Exec("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";")
|
| 52 |
+
if err := db.AutoMigrate(&models.Account{}); err != nil {
|
| 53 |
+
log.Fatal(err)
|
| 54 |
+
}
|
| 55 |
+
if err := db.AutoMigrate(&models.AccountDetails{}); err != nil {
|
| 56 |
+
log.Fatal(err)
|
| 57 |
+
}
|
| 58 |
+
if err := db.AutoMigrate(&models.EmailVerification{}); err != nil {
|
| 59 |
+
log.Fatal(err)
|
| 60 |
+
}
|
| 61 |
+
if err := db.AutoMigrate(&models.ExternalAuth{}); err != nil {
|
| 62 |
+
log.Fatal(err)
|
| 63 |
+
}
|
| 64 |
+
if err := db.AutoMigrate(&models.FCM{}); err != nil {
|
| 65 |
+
log.Fatal(err)
|
| 66 |
+
}
|
| 67 |
+
if err := db.AutoMigrate(&models.ForgotPassword{}); err != nil {
|
| 68 |
+
log.Fatal(err)
|
| 69 |
+
}
|
| 70 |
+
if err := db.AutoMigrate(&models.Events{}); err != nil {
|
| 71 |
+
log.Fatal(err)
|
| 72 |
+
}
|
| 73 |
+
if err := db.AutoMigrate(&models.Announcement{}); err != nil {
|
| 74 |
+
log.Fatal(err)
|
| 75 |
+
}
|
| 76 |
+
if err := db.AutoMigrate(&models.ProblemSet{}); err != nil {
|
| 77 |
+
log.Fatal(err)
|
| 78 |
+
}
|
| 79 |
+
if err := db.AutoMigrate(&models.Questions{}); err != nil {
|
| 80 |
+
log.Fatal(err)
|
| 81 |
+
}
|
| 82 |
+
if err := db.AutoMigrate(&models.EventAssign{}); err != nil {
|
| 83 |
+
log.Fatal(err)
|
| 84 |
+
}
|
| 85 |
+
if err := db.AutoMigrate(&models.ProblemSetAssign{}); err != nil {
|
| 86 |
+
log.Fatal(err)
|
| 87 |
+
}
|
| 88 |
+
if err := db.AutoMigrate(&models.ExamProgress{}); err != nil {
|
| 89 |
+
log.Fatal(err)
|
| 90 |
+
}
|
| 91 |
+
if err := db.AutoMigrate(&models.ExamProgress_Result{}); err != nil {
|
| 92 |
+
log.Fatal(err)
|
| 93 |
+
}
|
| 94 |
+
if err := db.AutoMigrate(&models.Result{}); err != nil {
|
| 95 |
+
log.Fatal(err)
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
fmt.Println("Migration completed successfully.")
|
| 99 |
+
}
|
controller/auth/auth_change_password_controller.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package auth
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func ChangePassword(c *gin.Context) {
|
| 11 |
+
authentication := services.AuthenticationService{}
|
| 12 |
+
changePasswordController := controller.Controller[models.ChangePasswordRequest, models.Account, models.AuthenticatedUser]{
|
| 13 |
+
Service: &authentication.Service,
|
| 14 |
+
}
|
| 15 |
+
changePasswordController.HeaderParse(c, func() {
|
| 16 |
+
changePasswordController.Service.Constructor.Id = changePasswordController.AccountData.UserID
|
| 17 |
+
})
|
| 18 |
+
changePasswordController.RequestJSON(c, func() {
|
| 19 |
+
authentication.Update(changePasswordController.Request.OldPassword, changePasswordController.Request.NewPassword)
|
| 20 |
+
})
|
| 21 |
+
}
|
controller/auth/auth_external_controller.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package auth
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func ExternalAuth(c *gin.Context) {
|
| 11 |
+
ExternalAuthController := controller.Controller[models.ExternalAuthRequest, models.ExternalAuth, models.AuthenticatedUser]{}
|
| 12 |
+
ExternalAuthController.RequestJSON(c, func() {
|
| 13 |
+
if ExternalAuthController.Request.OauthProvider == "google" {
|
| 14 |
+
GoogleLogin := services.GoogleAuthService{}
|
| 15 |
+
ExternalAuthController.Service = &GoogleLogin.Service
|
| 16 |
+
ExternalAuthController.Service.Constructor.OauthID = ExternalAuthController.Request.OauthID
|
| 17 |
+
GoogleLogin.Authenticate(true)
|
| 18 |
+
}
|
| 19 |
+
})
|
| 20 |
+
}
|
controller/auth/auth_forgot_password_controller.go
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package auth
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func CreateForgotPassword(c *gin.Context) {
|
| 11 |
+
ForgotPassword := services.ForgotPasswordService{}
|
| 12 |
+
ForgotPasswordController := controller.Controller[models.ForgotPasswordRequest, models.ForgotPassword, models.ForgotPassword]{
|
| 13 |
+
Service: &ForgotPassword.Service,
|
| 14 |
+
}
|
| 15 |
+
ForgotPasswordController.RequestJSON(c, func() {
|
| 16 |
+
ForgotPassword.Create(ForgotPasswordController.Request.Email)
|
| 17 |
+
})
|
| 18 |
+
|
| 19 |
+
}
|
| 20 |
+
func ValidateForgotPassword(c *gin.Context) {
|
| 21 |
+
ForgotPassword := services.ForgotPasswordService{}
|
| 22 |
+
ForgotPasswordController := controller.Controller[models.ValidateForgotPasswordRequest, models.ForgotPassword, models.ForgotPassword]{
|
| 23 |
+
Service: &ForgotPassword.Service,
|
| 24 |
+
}
|
| 25 |
+
ForgotPasswordController.RequestJSON(c, func() {
|
| 26 |
+
ForgotPasswordController.Service.Constructor.Token = ForgotPasswordController.Request.Token
|
| 27 |
+
ForgotPassword.Validate(&ForgotPasswordController.Request.NewPassword)
|
| 28 |
+
})
|
| 29 |
+
}
|
controller/auth/auth_login_controller.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package auth
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Login(c *gin.Context) {
|
| 11 |
+
authentication := services.AuthenticationService{}
|
| 12 |
+
loginController := controller.Controller[models.LoginRequest, models.Account, models.AuthenticatedUser]{
|
| 13 |
+
Service: &authentication.Service,
|
| 14 |
+
}
|
| 15 |
+
loginController.RequestJSON(c, func() {
|
| 16 |
+
loginController.Service.Constructor.Email = loginController.Request.Email
|
| 17 |
+
loginController.Service.Constructor.Password = loginController.Request.Password
|
| 18 |
+
authentication.Authenticate()
|
| 19 |
+
})
|
| 20 |
+
}
|
controller/auth/auth_register_controller.go
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package auth
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Register(c *gin.Context) {
|
| 11 |
+
register := services.RegisterService{}
|
| 12 |
+
registerController := controller.Controller[models.RegisterRequest, models.Account, models.Account]{
|
| 13 |
+
Service: ®ister.Service,
|
| 14 |
+
}
|
| 15 |
+
registerController.RequestJSON(c, func() {
|
| 16 |
+
registerController.Service.Constructor.Password = registerController.Request.Password
|
| 17 |
+
registerController.Service.Constructor.Email = registerController.Request.Email
|
| 18 |
+
registerController.Service.Constructor.Username = registerController.Request.Username
|
| 19 |
+
registerController.Service.Constructor.Role = "USER"
|
| 20 |
+
register.Create()
|
| 21 |
+
})
|
| 22 |
+
}
|
controller/controller.go
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package controller
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/models"
|
| 6 |
+
"godp.abdanhafidz.com/repositories"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
"godp.abdanhafidz.com/utils"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
type (
|
| 12 |
+
Controllers interface {
|
| 13 |
+
RequestJSON(c *gin.Context)
|
| 14 |
+
Response(c *gin.Context)
|
| 15 |
+
}
|
| 16 |
+
Controller[TRequest any, TConstructor any, TResult any] struct {
|
| 17 |
+
AccountData models.AccountData
|
| 18 |
+
Request TRequest
|
| 19 |
+
Service *services.Service[TConstructor, TResult]
|
| 20 |
+
}
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
func (controller *Controller[T1, T2, T3]) HeaderParse(c *gin.Context, act func()) {
|
| 24 |
+
cParam, _ := c.Get("accountData")
|
| 25 |
+
if cParam != nil {
|
| 26 |
+
controller.AccountData = cParam.(models.AccountData)
|
| 27 |
+
}
|
| 28 |
+
act()
|
| 29 |
+
}
|
| 30 |
+
func (controller *Controller[T1, T2, T3]) RequestJSON(c *gin.Context, act func()) {
|
| 31 |
+
cParam, _ := c.Get("accountData")
|
| 32 |
+
if cParam != nil {
|
| 33 |
+
controller.AccountData = cParam.(models.AccountData)
|
| 34 |
+
}
|
| 35 |
+
errBinding := c.ShouldBindJSON(&controller.Request)
|
| 36 |
+
if errBinding != nil {
|
| 37 |
+
utils.ResponseFAIL(c, 400, models.Exception{
|
| 38 |
+
BadRequest: true,
|
| 39 |
+
Message: "Invalid Request!, recheck your request, there's must be some problem about required parameter or type parameter",
|
| 40 |
+
})
|
| 41 |
+
return
|
| 42 |
+
} else {
|
| 43 |
+
act()
|
| 44 |
+
controller.Response(c)
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
func (controller *Controller[T1, T2, T3]) Response(c *gin.Context) {
|
| 48 |
+
switch {
|
| 49 |
+
case controller.Service.Error != nil:
|
| 50 |
+
utils.LogError(controller.Service.Error)
|
| 51 |
+
utils.ResponseFAIL(c, 500, models.Exception{
|
| 52 |
+
InternalServerError: true,
|
| 53 |
+
Message: "Internal Server Error",
|
| 54 |
+
})
|
| 55 |
+
|
| 56 |
+
case controller.Service.Exception.DataDuplicate:
|
| 57 |
+
utils.ResponseFAIL(c, 400, controller.Service.Exception)
|
| 58 |
+
case controller.Service.Exception.Unauthorized:
|
| 59 |
+
utils.ResponseFAIL(c, 401, controller.Service.Exception)
|
| 60 |
+
case controller.Service.Exception.DataNotFound:
|
| 61 |
+
utils.ResponseFAIL(c, 404, controller.Service.Exception)
|
| 62 |
+
case controller.Service.Exception.Message != "":
|
| 63 |
+
utils.ResponseFAIL(c, 400, controller.Service.Exception)
|
| 64 |
+
default:
|
| 65 |
+
if controller.Service.MetaData != (repositories.PaginationMetadata{}) {
|
| 66 |
+
utils.ResponseOK(c, controller.Service.Result, controller.Service.MetaData)
|
| 67 |
+
} else {
|
| 68 |
+
utils.ResponseOK(c, controller.Service.Result, struct{}{})
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
controller/email/email_create_verification_controller.go
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package controller
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func CreateVerification(c *gin.Context) {
|
| 11 |
+
emailVerification := services.EmailVerificationService{}
|
| 12 |
+
emailVerificationController := controller.Controller[models.CreateEmailVerificationRequest, models.EmailVerification, models.EmailVerification]{
|
| 13 |
+
Service: &emailVerification.Service,
|
| 14 |
+
}
|
| 15 |
+
emailVerificationController.RequestJSON(c, func() {
|
| 16 |
+
emailVerification.Create(emailVerificationController.Request.Email)
|
| 17 |
+
emailVerificationController.Response(c)
|
| 18 |
+
})
|
| 19 |
+
|
| 20 |
+
}
|
controller/email/email_validate_controller.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package controller
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Verify(c *gin.Context) {
|
| 11 |
+
emailVerification := services.EmailVerificationService{}
|
| 12 |
+
emailVerificationController := controller.Controller[models.ValidateVerifyEmailRequest, models.EmailVerification, models.EmailVerification]{
|
| 13 |
+
Service: &emailVerification.Service,
|
| 14 |
+
}
|
| 15 |
+
emailVerificationController.RequestJSON(c, func() {
|
| 16 |
+
|
| 17 |
+
emailVerificationController.Service.Constructor.Token = emailVerificationController.Request.Token
|
| 18 |
+
emailVerification.Validate(emailVerificationController.Request.Email)
|
| 19 |
+
})
|
| 20 |
+
|
| 21 |
+
}
|
controller/event/event_detail_controller.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package event
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func EventDetail(c *gin.Context) {
|
| 11 |
+
eventDetail := services.EventDetailService{}
|
| 12 |
+
eventDetailController := controller.Controller[any, models.Events, models.EventDetailResponse]{
|
| 13 |
+
Service: &eventDetail.Service,
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
eventDetailController.HeaderParse(c, func() {
|
| 17 |
+
eventDetailController.Service.Constructor.Slug = c.Param("event_slug")
|
| 18 |
+
eventDetail.Retrieve(eventDetailController.AccountData.UserID)
|
| 19 |
+
eventDetailController.Response(c)
|
| 20 |
+
})
|
| 21 |
+
}
|
controller/event/event_join_controller.go
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package event
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Register(c *gin.Context) {
|
| 11 |
+
eventAssign := services.JoinEventService{}
|
| 12 |
+
eventAssignController := controller.Controller[models.JoinEventRequest, models.JoinEventRequest, models.EventDetailResponse]{
|
| 13 |
+
Service: &eventAssign.Service,
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
eventAssignController.RequestJSON(c, func() {
|
| 17 |
+
eventAssignController.Service.Constructor.EventId = eventAssignController.Request.EventId
|
| 18 |
+
eventAssignController.Service.Constructor.EventCode = eventAssignController.Request.EventCode
|
| 19 |
+
idUser := eventAssignController.AccountData.UserID
|
| 20 |
+
eventAssign.Create(idUser)
|
| 21 |
+
})
|
| 22 |
+
}
|
controller/event/event_list_controller.go
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package event
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"strconv"
|
| 5 |
+
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
"godp.abdanhafidz.com/controller"
|
| 8 |
+
"godp.abdanhafidz.com/models"
|
| 9 |
+
"godp.abdanhafidz.com/repositories"
|
| 10 |
+
"godp.abdanhafidz.com/services"
|
| 11 |
+
"godp.abdanhafidz.com/utils"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
func EventList(c *gin.Context) {
|
| 15 |
+
limit, err := strconv.Atoi(c.DefaultQuery("limit", "10"))
|
| 16 |
+
if err != nil {
|
| 17 |
+
service := services.Service[any, any]{
|
| 18 |
+
Exception: models.Exception{
|
| 19 |
+
Message: "Invalid limit parameter",
|
| 20 |
+
},
|
| 21 |
+
}
|
| 22 |
+
utils.SendResponse(c, service)
|
| 23 |
+
return
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
offset, err := strconv.Atoi(c.DefaultQuery("offset", "0"))
|
| 27 |
+
if err != nil {
|
| 28 |
+
service := services.Service[any, any]{
|
| 29 |
+
Exception: models.Exception{
|
| 30 |
+
Message: "Invalid offset parameter",
|
| 31 |
+
},
|
| 32 |
+
}
|
| 33 |
+
utils.SendResponse(c, service)
|
| 34 |
+
return
|
| 35 |
+
}
|
| 36 |
+
filter := c.DefaultQuery("filter", "")
|
| 37 |
+
filterBy := c.DefaultQuery("filter_by", "")
|
| 38 |
+
|
| 39 |
+
pagination := repositories.PaginationConstructor{
|
| 40 |
+
Limit: limit,
|
| 41 |
+
Offset: offset,
|
| 42 |
+
Filter: filter,
|
| 43 |
+
FilterBy: filterBy,
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
eventsService := services.GetAllEventService{}
|
| 47 |
+
getAllEventController := controller.Controller[any, models.Events, []models.Events]{
|
| 48 |
+
Service: &eventsService.Service,
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
eventsService.Retrieve(pagination)
|
| 52 |
+
|
| 53 |
+
getAllEventController.Response(c)
|
| 54 |
+
}
|
controller/home_controller.go
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package controller
|
| 2 |
+
|
| 3 |
+
import "github.com/gin-gonic/gin"
|
| 4 |
+
|
| 5 |
+
func HomeController(c *gin.Context) {
|
| 6 |
+
c.JSON(200, gin.H{
|
| 7 |
+
"message": "Api Qobiltu 2025!",
|
| 8 |
+
})
|
| 9 |
+
}
|
controller/options/option_category_controller.go
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package options
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func AddOptions(c *gin.Context) {
|
| 11 |
+
options := services.OptionService{}
|
| 12 |
+
addOptionController := controller.Controller[[]models.OptionsRequest, []models.OptionsRequest, models.OptionsResponse]{
|
| 13 |
+
Service: &options.Service,
|
| 14 |
+
}
|
| 15 |
+
addOptionController.RequestJSON(c, func() {
|
| 16 |
+
options.Constructor = addOptionController.Request
|
| 17 |
+
options.Create()
|
| 18 |
+
})
|
| 19 |
+
}
|
controller/options/option_value_controller.go
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package options
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func List(c *gin.Context) {
|
| 11 |
+
options := services.OptionValueService{}
|
| 12 |
+
optionValueController := controller.Controller[any, models.OptionCategory, models.Options]{
|
| 13 |
+
Service: &options.Service,
|
| 14 |
+
}
|
| 15 |
+
slug := c.Param("slug")
|
| 16 |
+
options.Constructor.OptionSlug = slug
|
| 17 |
+
options.Retrieve()
|
| 18 |
+
optionValueController.Response(c)
|
| 19 |
+
}
|
controller/region/city/city_list_controller.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package city
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"strconv"
|
| 5 |
+
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
"godp.abdanhafidz.com/controller"
|
| 8 |
+
"godp.abdanhafidz.com/models"
|
| 9 |
+
"godp.abdanhafidz.com/services"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
func List(c *gin.Context) {
|
| 13 |
+
city := services.CityService{}
|
| 14 |
+
CityController := controller.Controller[any, models.RegionCity, []models.RegionCity]{
|
| 15 |
+
Service: &city.Service,
|
| 16 |
+
}
|
| 17 |
+
ProvinceID, _ := strconv.Atoi(c.Query("province_id"))
|
| 18 |
+
city.Constructor.ProvinceId = uint(ProvinceID)
|
| 19 |
+
city.Retrieve()
|
| 20 |
+
CityController.Response(c)
|
| 21 |
+
}
|
controller/region/city/city_seeds_controller.go
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package city
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Seeds(c *gin.Context) {
|
| 11 |
+
city := services.CityService{}
|
| 12 |
+
CityController := controller.Controller[any, models.RegionCity, []models.RegionCity]{
|
| 13 |
+
Service: &city.Service,
|
| 14 |
+
}
|
| 15 |
+
city.Create()
|
| 16 |
+
CityController.Response(c)
|
| 17 |
+
}
|
controller/region/province/province_list_controller.go
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package province
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func List(c *gin.Context) {
|
| 11 |
+
province := services.ProvinceService{}
|
| 12 |
+
ProvinceController := controller.Controller[any, models.RegionProvince, []models.RegionProvince]{
|
| 13 |
+
Service: &province.Service,
|
| 14 |
+
}
|
| 15 |
+
province.Retrieve()
|
| 16 |
+
ProvinceController.Response(c)
|
| 17 |
+
}
|
controller/region/province/province_seeds_controller.go
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package province
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Seeds(c *gin.Context) {
|
| 11 |
+
province := services.ProvinceService{}
|
| 12 |
+
ProvinceController := controller.Controller[any, models.RegionProvince, []models.RegionProvince]{
|
| 13 |
+
Service: &province.Service,
|
| 14 |
+
}
|
| 15 |
+
province.Create()
|
| 16 |
+
ProvinceController.Response(c)
|
| 17 |
+
}
|
controller/user/user_profile_controller.go
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package user
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func Profile(c *gin.Context) {
|
| 11 |
+
userProfile := services.UserProfileService{}
|
| 12 |
+
userProfileController := controller.Controller[any, models.AccountDetails, models.UserProfileResponse]{
|
| 13 |
+
Service: &userProfile.Service,
|
| 14 |
+
}
|
| 15 |
+
userProfileController.HeaderParse(c, func() {
|
| 16 |
+
userProfileController.Service.Constructor.AccountId = userProfileController.AccountData.UserID
|
| 17 |
+
userProfile.Retrieve()
|
| 18 |
+
userProfileController.Response(c)
|
| 19 |
+
},
|
| 20 |
+
)
|
| 21 |
+
}
|
controller/user/user_update_profile_controller.go
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package user
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
"godp.abdanhafidz.com/controller"
|
| 6 |
+
"godp.abdanhafidz.com/models"
|
| 7 |
+
"godp.abdanhafidz.com/services"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func UpdateProfile(c *gin.Context) {
|
| 11 |
+
userProfile := services.UserProfileService{}
|
| 12 |
+
userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.UserProfileResponse]{
|
| 13 |
+
Service: &userProfile.Service,
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
userUpdateProfileController.RequestJSON(c, func() {
|
| 17 |
+
userUpdateProfileController.Service.Constructor = userUpdateProfileController.Request
|
| 18 |
+
userUpdateProfileController.HeaderParse(c, func() {
|
| 19 |
+
userUpdateProfileController.Service.Constructor.AccountId = userUpdateProfileController.AccountData.UserID
|
| 20 |
+
|
| 21 |
+
})
|
| 22 |
+
userProfile.Update()
|
| 23 |
+
},
|
| 24 |
+
)
|
| 25 |
+
}
|
go.mod
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module godp.abdanhafidz.com
|
| 2 |
+
|
| 3 |
+
go 1.24.0
|
| 4 |
+
|
| 5 |
+
require (
|
| 6 |
+
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
| 7 |
+
github.com/gin-gonic/gin v1.10.0
|
| 8 |
+
github.com/golang-jwt/jwt/v5 v5.2.1
|
| 9 |
+
github.com/joho/godotenv v1.5.1
|
| 10 |
+
github.com/satori/go.uuid v1.2.0
|
| 11 |
+
golang.org/x/crypto v0.37.0
|
| 12 |
+
gorm.io/driver/postgres v1.5.11
|
| 13 |
+
gorm.io/gorm v1.25.12
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
require (
|
| 17 |
+
cloud.google.com/go/auth v0.16.0 // indirect
|
| 18 |
+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
|
| 19 |
+
cloud.google.com/go/compute/metadata v0.6.0 // indirect
|
| 20 |
+
github.com/bytedance/sonic v1.13.1 // indirect
|
| 21 |
+
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
| 22 |
+
github.com/cloudwego/base64x v0.1.5 // indirect
|
| 23 |
+
github.com/felixge/httpsnoop v1.0.4 // indirect
|
| 24 |
+
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
| 25 |
+
github.com/gin-contrib/sse v1.0.0 // indirect
|
| 26 |
+
github.com/go-logr/logr v1.4.2 // indirect
|
| 27 |
+
github.com/go-logr/stdr v1.2.2 // indirect
|
| 28 |
+
github.com/go-playground/locales v0.14.1 // indirect
|
| 29 |
+
github.com/go-playground/universal-translator v0.18.1 // indirect
|
| 30 |
+
github.com/go-playground/validator/v10 v10.25.0 // indirect
|
| 31 |
+
github.com/goccy/go-json v0.10.5 // indirect
|
| 32 |
+
github.com/google/s2a-go v0.1.9 // indirect
|
| 33 |
+
github.com/google/uuid v1.6.0 // indirect
|
| 34 |
+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
|
| 35 |
+
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
|
| 36 |
+
github.com/gosimple/slug v1.15.0 // indirect
|
| 37 |
+
github.com/gosimple/unidecode v1.0.1 // indirect
|
| 38 |
+
github.com/jackc/pgpassfile v1.0.0 // indirect
|
| 39 |
+
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
| 40 |
+
github.com/jackc/pgx/v5 v5.7.2 // indirect
|
| 41 |
+
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
| 42 |
+
github.com/jinzhu/gorm v1.9.16 // indirect
|
| 43 |
+
github.com/jinzhu/inflection v1.0.0 // indirect
|
| 44 |
+
github.com/jinzhu/now v1.1.5 // indirect
|
| 45 |
+
github.com/json-iterator/go v1.1.12 // indirect
|
| 46 |
+
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
| 47 |
+
github.com/kr/text v0.2.0 // indirect
|
| 48 |
+
github.com/leodido/go-urn v1.4.0 // indirect
|
| 49 |
+
github.com/lib/pq v1.1.1 // indirect
|
| 50 |
+
github.com/mattn/go-isatty v0.0.20 // indirect
|
| 51 |
+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
| 52 |
+
github.com/modern-go/reflect2 v1.0.2 // indirect
|
| 53 |
+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
| 54 |
+
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
| 55 |
+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
| 56 |
+
github.com/ugorji/go/codec v1.2.12 // indirect
|
| 57 |
+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
| 58 |
+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
|
| 59 |
+
go.opentelemetry.io/otel v1.35.0 // indirect
|
| 60 |
+
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
| 61 |
+
go.opentelemetry.io/otel/trace v1.35.0 // indirect
|
| 62 |
+
golang.org/x/arch v0.15.0 // indirect
|
| 63 |
+
golang.org/x/net v0.39.0 // indirect
|
| 64 |
+
golang.org/x/oauth2 v0.29.0 // indirect
|
| 65 |
+
golang.org/x/sync v0.13.0 // indirect
|
| 66 |
+
golang.org/x/sys v0.32.0 // indirect
|
| 67 |
+
golang.org/x/text v0.24.0 // indirect
|
| 68 |
+
google.golang.org/api v0.229.0 // indirect
|
| 69 |
+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
|
| 70 |
+
google.golang.org/grpc v1.71.1 // indirect
|
| 71 |
+
google.golang.org/protobuf v1.36.6 // indirect
|
| 72 |
+
gopkg.in/yaml.v3 v3.0.1 // indirect
|
| 73 |
+
)
|
go.sum
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cloud.google.com/go/auth v0.16.0 h1:Pd8P1s9WkcrBE2n/PhAwKsdrR35V3Sg2II9B+ndM3CU=
|
| 2 |
+
cloud.google.com/go/auth v0.16.0/go.mod h1:1howDHJ5IETh/LwYs3ZxvlkXF48aSqqJUM+5o02dNOI=
|
| 3 |
+
cloud.google.com/go/auth/oauth2adapt v0.2.8 h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=
|
| 4 |
+
cloud.google.com/go/auth/oauth2adapt v0.2.8/go.mod h1:XQ9y31RkqZCcwJWNSx2Xvric3RrU88hAYYbjDWYDL+c=
|
| 5 |
+
cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=
|
| 6 |
+
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
|
| 7 |
+
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
| 8 |
+
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
| 9 |
+
github.com/bytedance/sonic v1.13.1 h1:Jyd5CIvdFnkOWuKXr+wm4Nyk2h0yAFsr8ucJgEasO3g=
|
| 10 |
+
github.com/bytedance/sonic v1.13.1/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
| 11 |
+
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
| 12 |
+
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
| 13 |
+
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
| 14 |
+
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
| 15 |
+
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
| 16 |
+
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
| 17 |
+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
| 18 |
+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 19 |
+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
| 20 |
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 21 |
+
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
| 22 |
+
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
| 23 |
+
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
| 24 |
+
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
| 25 |
+
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
| 26 |
+
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
| 27 |
+
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
| 28 |
+
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
| 29 |
+
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
| 30 |
+
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
| 31 |
+
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
| 32 |
+
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
| 33 |
+
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
| 34 |
+
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
| 35 |
+
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
| 36 |
+
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
| 37 |
+
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
| 38 |
+
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
| 39 |
+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
| 40 |
+
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
| 41 |
+
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
| 42 |
+
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
| 43 |
+
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
| 44 |
+
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
|
| 45 |
+
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
|
| 46 |
+
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
| 47 |
+
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
| 48 |
+
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
| 49 |
+
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
| 50 |
+
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
| 51 |
+
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
| 52 |
+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
| 53 |
+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
| 54 |
+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
| 55 |
+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
| 56 |
+
github.com/google/s2a-go v0.1.9 h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
|
| 57 |
+
github.com/google/s2a-go v0.1.9/go.mod h1:YA0Ei2ZQL3acow2O62kdp9UlnvMmU7kA6Eutn0dXayM=
|
| 58 |
+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
| 59 |
+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
| 60 |
+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4=
|
| 61 |
+
github.com/googleapis/enterprise-certificate-proxy v0.3.6/go.mod h1:MkHOF77EYAE7qfSuSS9PU6g4Nt4e11cnsDUowfwewLA=
|
| 62 |
+
github.com/googleapis/gax-go/v2 v2.14.1 h1:hb0FFeiPaQskmvakKu5EbCbpntQn48jyHuvrkurSS/Q=
|
| 63 |
+
github.com/googleapis/gax-go/v2 v2.14.1/go.mod h1:Hb/NubMaVM88SrNkvl8X/o8XWwDJEPqouaLeN2IUxoA=
|
| 64 |
+
github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=
|
| 65 |
+
github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ=
|
| 66 |
+
github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o=
|
| 67 |
+
github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc=
|
| 68 |
+
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
| 69 |
+
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
| 70 |
+
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
| 71 |
+
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
| 72 |
+
github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=
|
| 73 |
+
github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
|
| 74 |
+
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
| 75 |
+
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
| 76 |
+
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
|
| 77 |
+
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
|
| 78 |
+
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
| 79 |
+
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
| 80 |
+
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
| 81 |
+
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
| 82 |
+
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
| 83 |
+
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
| 84 |
+
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
| 85 |
+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
| 86 |
+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
| 87 |
+
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
| 88 |
+
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
| 89 |
+
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
| 90 |
+
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
| 91 |
+
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
| 92 |
+
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
| 93 |
+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
| 94 |
+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
| 95 |
+
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
| 96 |
+
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
| 97 |
+
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
| 98 |
+
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
| 99 |
+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
| 100 |
+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
| 101 |
+
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
| 102 |
+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
| 103 |
+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
| 104 |
+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
| 105 |
+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
| 106 |
+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
| 107 |
+
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
| 108 |
+
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
| 109 |
+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
| 110 |
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
| 111 |
+
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
| 112 |
+
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
| 113 |
+
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
| 114 |
+
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
| 115 |
+
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
| 116 |
+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
| 117 |
+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
| 118 |
+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
| 119 |
+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
| 120 |
+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
| 121 |
+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 122 |
+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 123 |
+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
| 124 |
+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
| 125 |
+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
| 126 |
+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
| 127 |
+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
| 128 |
+
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
| 129 |
+
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
| 130 |
+
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
| 131 |
+
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
| 132 |
+
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
| 133 |
+
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
| 134 |
+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
|
| 135 |
+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
|
| 136 |
+
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
| 137 |
+
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
| 138 |
+
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
| 139 |
+
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
| 140 |
+
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
| 141 |
+
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
| 142 |
+
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
| 143 |
+
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
| 144 |
+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
| 145 |
+
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
| 146 |
+
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
| 147 |
+
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
| 148 |
+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
| 149 |
+
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
|
| 150 |
+
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
|
| 151 |
+
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 152 |
+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
| 153 |
+
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
| 154 |
+
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
| 155 |
+
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
| 156 |
+
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
| 157 |
+
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
|
| 158 |
+
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
|
| 159 |
+
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
| 160 |
+
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
| 161 |
+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
|
| 162 |
+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
| 163 |
+
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
|
| 164 |
+
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
| 165 |
+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 166 |
+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 167 |
+
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 168 |
+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 169 |
+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
| 170 |
+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
| 171 |
+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
| 172 |
+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
| 173 |
+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
| 174 |
+
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
| 175 |
+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
| 176 |
+
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
|
| 177 |
+
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
|
| 178 |
+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
| 179 |
+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 180 |
+
google.golang.org/api v0.229.0 h1:p98ymMtqeJ5i3lIBMj5MpR9kzIIgzpHHh8vQ+vgAzx8=
|
| 181 |
+
google.golang.org/api v0.229.0/go.mod h1:wyDfmq5g1wYJWn29O22FDWN48P7Xcz0xz+LBpptYvB0=
|
| 182 |
+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA=
|
| 183 |
+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
| 184 |
+
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=
|
| 185 |
+
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
| 186 |
+
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
| 187 |
+
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
| 188 |
+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
| 189 |
+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
| 190 |
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
| 191 |
+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
| 192 |
+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
| 193 |
+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
| 194 |
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
| 195 |
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
| 196 |
+
gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314=
|
| 197 |
+
gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
|
| 198 |
+
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
| 199 |
+
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
| 200 |
+
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
logs/error_log.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
logs/security_log.txt
ADDED
|
File without changes
|
main.go
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
|
| 6 |
+
"godp.abdanhafidz.com/config"
|
| 7 |
+
"godp.abdanhafidz.com/router"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func main() {
|
| 11 |
+
fmt.Println("Server started on ", config.TCP_ADDRESS, ", port :", config.HOST_PORT)
|
| 12 |
+
router.StartService()
|
| 13 |
+
|
| 14 |
+
}
|
middleware/authentication_middleware.go
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// auth/auth.go
|
| 2 |
+
|
| 3 |
+
package middleware
|
| 4 |
+
|
| 5 |
+
import (
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
"github.com/google/uuid"
|
| 8 |
+
"godp.abdanhafidz.com/models"
|
| 9 |
+
"godp.abdanhafidz.com/services"
|
| 10 |
+
"godp.abdanhafidz.com/utils"
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
func AuthUser(c *gin.Context) {
|
| 14 |
+
var currAccData models.AccountData
|
| 15 |
+
if c.Request.Header["Authorization"] != nil {
|
| 16 |
+
token := c.Request.Header["Authorization"]
|
| 17 |
+
|
| 18 |
+
currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])
|
| 19 |
+
|
| 20 |
+
if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
|
| 21 |
+
currAccData.UserID = uuid.UUID{}
|
| 22 |
+
utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "Your session is expired, Please re-Login!"})
|
| 23 |
+
c.Abort()
|
| 24 |
+
return
|
| 25 |
+
} else {
|
| 26 |
+
c.Set("accountData", currAccData)
|
| 27 |
+
c.Next()
|
| 28 |
+
}
|
| 29 |
+
} else {
|
| 30 |
+
currAccData.UserID = uuid.UUID{}
|
| 31 |
+
currAccData.VerifyStatus = "no-token"
|
| 32 |
+
currAccData.ErrVerif = nil
|
| 33 |
+
utils.ResponseFAIL(c, 401, models.Exception{Unauthorized: true, Message: "You have to login first!"})
|
| 34 |
+
c.Abort()
|
| 35 |
+
return
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
}
|
middleware/middleware.go
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"math"
|
| 5 |
+
"time"
|
| 6 |
+
|
| 7 |
+
"gorm.io/gorm"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func RecordCheck(rows *gorm.DB) (string, error) {
|
| 11 |
+
count := rows.RowsAffected
|
| 12 |
+
err := rows.Error
|
| 13 |
+
|
| 14 |
+
if count == 0 {
|
| 15 |
+
return "no-record", err
|
| 16 |
+
} else if err != nil {
|
| 17 |
+
return "query-error", err
|
| 18 |
+
} else {
|
| 19 |
+
return "ok", err
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
func DiffTime(t1 time.Time, t2 time.Time) (int, int, int) {
|
| 24 |
+
hs := t1.Sub(t2).Hours()
|
| 25 |
+
hs, mf := math.Modf(hs)
|
| 26 |
+
ms := mf * 60
|
| 27 |
+
ms, sf := math.Modf(ms)
|
| 28 |
+
ss := sf * 60
|
| 29 |
+
return int(hs), int(ms), int(ss)
|
| 30 |
+
}
|
middleware/response_middleware.go
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"net/http"
|
| 5 |
+
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
// SendJSON200 sends a JSON response with HTTP status code 200
|
| 10 |
+
func SendJSON200(c *gin.Context, data interface{}) {
|
| 11 |
+
c.JSON(http.StatusOK, gin.H{"status": "success", "data": data})
|
| 12 |
+
return
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
// SendJSON400 sends a JSON response with HTTP status code 400
|
| 16 |
+
func SendJSON400(c *gin.Context, error_status *string, message *string) {
|
| 17 |
+
c.JSON(http.StatusBadRequest, gin.H{"status": "error", "error-status": error_status, "message": message})
|
| 18 |
+
return
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// SendJSON401 sends a JSON response with HTTP status code 401
|
| 22 |
+
func SendJSON401(c *gin.Context, error_status *string, message *string) {
|
| 23 |
+
c.JSON(http.StatusUnauthorized, gin.H{"status": "error", "error-status": error_status, "message": message})
|
| 24 |
+
return
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
// SendJSON403 sends a JSON response with HTTP status code 403
|
| 28 |
+
func SendJSON403(c *gin.Context, message *string) {
|
| 29 |
+
c.JSON(http.StatusForbidden, gin.H{"status": "error", "message": message})
|
| 30 |
+
return
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
// SendJSON404 sends a JSON response with HTTP status code 404
|
| 34 |
+
func SendJSON404(c *gin.Context, message *string) {
|
| 35 |
+
c.JSON(http.StatusNotFound, gin.H{"status": "error", "message": message})
|
| 36 |
+
return
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// SendJSON500 sends a JSON response with HTTP status code 500
|
| 40 |
+
func SendJSON500(c *gin.Context, error_status *string, message *string) {
|
| 41 |
+
c.JSON(http.StatusInternalServerError, gin.H{"status": "error", "error-status": error_status, "message": message})
|
| 42 |
+
return
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// JSONResponseMiddleware is a middleware that provides functions for sending JSON responses
|
models/authentication_payload_model.go
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package models
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/golang-jwt/jwt/v5"
|
| 5 |
+
"github.com/google/uuid"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
type AccountData struct {
|
| 9 |
+
UserID uuid.UUID
|
| 10 |
+
VerifyStatus string
|
| 11 |
+
Role string
|
| 12 |
+
ErrVerif error
|
| 13 |
+
}
|
| 14 |
+
type CustomClaims struct {
|
| 15 |
+
jwt.RegisteredClaims
|
| 16 |
+
UserID uuid.UUID `json:"id"`
|
| 17 |
+
Role string `json:"role"`
|
| 18 |
+
}
|
models/database_orm_model.go
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package models
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"time"
|
| 5 |
+
|
| 6 |
+
"github.com/google/uuid"
|
| 7 |
+
"github.com/jinzhu/gorm/dialects/postgres"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
type Account struct {
|
| 11 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 12 |
+
Username string `gorm:"uniqueIndex" json:"username"`
|
| 13 |
+
Email string `gorm:"uniqueIndex" json:"email"`
|
| 14 |
+
Role string `json:"role"`
|
| 15 |
+
Password string `json:"password"`
|
| 16 |
+
IsEmailVerified bool `json:"is_email_verified"`
|
| 17 |
+
IsDetailCompleted bool `json:"is_detail_completed"`
|
| 18 |
+
CreatedAt time.Time `json:"created_at"`
|
| 19 |
+
DeletedAt *time.Time `json:"deleted_at" gorm:"default:null"`
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
type AccountDetails struct {
|
| 23 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 24 |
+
AccountId uuid.UUID `json:"account_id"`
|
| 25 |
+
FullName *string `json:"full_name"`
|
| 26 |
+
SchoolName *string `json:"school_name"`
|
| 27 |
+
Province *string `json:"province"`
|
| 28 |
+
City *string `json:"city"`
|
| 29 |
+
Avatar *string `json:"avatar"`
|
| 30 |
+
PhoneNumber *string `json:"phone_number"`
|
| 31 |
+
Account *Account `gorm:"foreignKey:AccountId"`
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
type EmailVerification struct {
|
| 35 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 36 |
+
Token uint `json:"token"`
|
| 37 |
+
AccountId uuid.UUID `json:"account_id"`
|
| 38 |
+
IsExpired bool `json:"is_expired"`
|
| 39 |
+
CreatedAt time.Time `json:"created_at"`
|
| 40 |
+
ExpiredAt time.Time `json:"expired_at"`
|
| 41 |
+
|
| 42 |
+
Account *Account `gorm:"foreignKey:AccountId"`
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
type ExternalAuth struct {
|
| 46 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 47 |
+
OauthID string `json:"oauth_id"`
|
| 48 |
+
AccountId uuid.UUID `json:"account_id"`
|
| 49 |
+
OauthProvider string `json:"oauth_provider"`
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
type FCM struct {
|
| 53 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 54 |
+
AccountId uuid.UUID `json:"account_id"`
|
| 55 |
+
FCMToken string `json:"fcm_token"`
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
type ForgotPassword struct {
|
| 59 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id"`
|
| 60 |
+
Token uint `json:"token"`
|
| 61 |
+
AccountId uuid.UUID `json:"account_id"`
|
| 62 |
+
IsExpired bool `json:"is_expired"`
|
| 63 |
+
CreatedAt time.Time `json:"created_at"`
|
| 64 |
+
ExpiredAt time.Time `json:"expired_at"`
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
type Events struct {
|
| 68 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_event"`
|
| 69 |
+
Title string `json:"title"`
|
| 70 |
+
Slug string `json:"slug"`
|
| 71 |
+
StartEvent time.Time `json:"start_event"`
|
| 72 |
+
EndEvent time.Time `json:"end_event"`
|
| 73 |
+
EventCode string `json:"event_code"`
|
| 74 |
+
IsPublic bool `json:"is_public"`
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
type Announcement struct {
|
| 78 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_announcement"`
|
| 79 |
+
Title string `json:"title"`
|
| 80 |
+
CreatedAt time.Time `json:"created_at"`
|
| 81 |
+
Message string `json:"message"`
|
| 82 |
+
Publisher string `json:"publisher"`
|
| 83 |
+
EventId uuid.UUID `json:"id_event"`
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
type ProblemSet struct {
|
| 87 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_problem_set"`
|
| 88 |
+
Title string `json:"title"`
|
| 89 |
+
Duration time.Duration `json:"duration"`
|
| 90 |
+
Randomize uint `json:"randomize"`
|
| 91 |
+
MC_Count uint `json:"mc_count"`
|
| 92 |
+
SA_Count uint `json:"sa_count"`
|
| 93 |
+
Essay_Count uint `json:"essay_count"`
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
type Questions struct {
|
| 97 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_question"`
|
| 98 |
+
Type string `json:"type"` //MultChoices, ShortAns, Essay, IntPuzzle, IntType
|
| 99 |
+
Question string `json:"question"`
|
| 100 |
+
Options []string `gorm:"type:text[]" json:"options"`
|
| 101 |
+
AnsKey []string `gorm:"type:text[]" json:"ans_key"`
|
| 102 |
+
CorrMark float64 `json:"corr_mark"`
|
| 103 |
+
IncorrMark float64 `json:"incorr_mark"`
|
| 104 |
+
NullMark float64 `json:"null_mark"`
|
| 105 |
+
ProblemSetId uuid.UUID `json:"id_problem_set"`
|
| 106 |
+
|
| 107 |
+
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
type EventAssign struct {
|
| 111 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_assign"`
|
| 112 |
+
AccountId uuid.UUID `json:"id_account"`
|
| 113 |
+
EventId uuid.UUID `json:"id_event"`
|
| 114 |
+
AssignedAt time.Time `json:"assigned_at"`
|
| 115 |
+
|
| 116 |
+
Account *Account `gorm:"foreignKey:AccountId"`
|
| 117 |
+
Event *Events `gorm:"foreignKey:EventId"`
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
type ProblemSetAssign struct {
|
| 121 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_problem_set_assign"`
|
| 122 |
+
EventId uuid.UUID `json:"id_event"`
|
| 123 |
+
ProblemSetId uuid.UUID `json:"id_problem_set"`
|
| 124 |
+
|
| 125 |
+
Event *Events `gorm:"foreignKey:EventId"`
|
| 126 |
+
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
type ExamProgress struct {
|
| 130 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_progress"`
|
| 131 |
+
AccountId uuid.UUID `json:"id_account"`
|
| 132 |
+
EventId uuid.UUID `json:"id_event"`
|
| 133 |
+
ProblemSetId uuid.UUID `json:"id_problem_set"`
|
| 134 |
+
CreatedAt time.Time `json:"created_at"`
|
| 135 |
+
DueAt time.Time `json:"due_at"`
|
| 136 |
+
QuestionsOrder []string `gorm:"type:text[]" json:"questions_order"`
|
| 137 |
+
Answers any `gorm:"type:jsonb" json:"answers"`
|
| 138 |
+
|
| 139 |
+
Account *Account `gorm:"foreignKey:AccountId"`
|
| 140 |
+
Event *Events `gorm:"foreignKey:EventId"`
|
| 141 |
+
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
type ExamProgress_Result struct {
|
| 145 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_progress"`
|
| 146 |
+
AccountId uuid.UUID `json:"id_account"`
|
| 147 |
+
EventId uuid.UUID `json:"id_event"`
|
| 148 |
+
ProblemSetId uuid.UUID `json:"id_problem_set"`
|
| 149 |
+
CreatedAt time.Time `json:"created_at"`
|
| 150 |
+
DueAt time.Time `json:"due_at"`
|
| 151 |
+
QuestionsOrder []string `gorm:"type:text[]" json:"questions_order"`
|
| 152 |
+
Answers postgres.Jsonb `gorm:"type:jsonb" json:"answers"`
|
| 153 |
+
|
| 154 |
+
Account *Account `gorm:"foreignKey:AccountId"`
|
| 155 |
+
Event *Events `gorm:"foreignKey:EventId"`
|
| 156 |
+
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
type Result struct {
|
| 160 |
+
Id uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()" json:"id_result"`
|
| 161 |
+
AccountId uuid.UUID `json:"id_account"`
|
| 162 |
+
EventId uuid.UUID `json:"id_event"`
|
| 163 |
+
ProblemSetId uuid.UUID `json:"id_problem_set"`
|
| 164 |
+
ProgressId uuid.UUID `json:"id_progress"`
|
| 165 |
+
FinishTime time.Time `json:"finish_time"`
|
| 166 |
+
Correct uint `json:"correct"`
|
| 167 |
+
Incorrect uint `json:"incorrect"`
|
| 168 |
+
Empty uint `json:"empty"`
|
| 169 |
+
OnCorrection uint `json:"on_correction"`
|
| 170 |
+
ManualScoring float64 `json:"manual_scoring"`
|
| 171 |
+
MCScore float64 `json:"mc_score"`
|
| 172 |
+
ManualScore float64 `json:"manual_score"`
|
| 173 |
+
FinalScore float64 `json:"final_score"`
|
| 174 |
+
|
| 175 |
+
Account *Account `gorm:"foreignKey:AccountId"`
|
| 176 |
+
Event *Events `gorm:"foreignKey:EventId"`
|
| 177 |
+
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId"`
|
| 178 |
+
ExamProgress *ExamProgress `gorm:"foreignKey:ProgressId"`
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
type Academy struct {
|
| 182 |
+
Id uuid.UUID `gorm:"primaryKey" json:"id"`
|
| 183 |
+
Title string `json:"title"`
|
| 184 |
+
Slug string `json:"slug"`
|
| 185 |
+
Description string `json:"description"`
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
type AcademyMaterial struct {
|
| 189 |
+
ID uuid.UUID `gorm:"primaryKey" json:"id"`
|
| 190 |
+
AcademyId uint `json:"academy_id"`
|
| 191 |
+
Title string `json:"title"`
|
| 192 |
+
Slug string `json:"slug"`
|
| 193 |
+
Description string `json:"description"`
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
type AcademyContent struct {
|
| 197 |
+
Id uuid.UUID `gorm:"primaryKey" json:"id"`
|
| 198 |
+
Title string `json:"title"`
|
| 199 |
+
Order uint `json:"order"`
|
| 200 |
+
AcademyMaterialId uint `json:"academy_material_id"`
|
| 201 |
+
Description string `json:"description"`
|
| 202 |
+
}
|
| 203 |
+
type OptionCategory struct {
|
| 204 |
+
Id uint `gorm:"primaryKey" json:"id"`
|
| 205 |
+
OptionName string `json:"option_name"`
|
| 206 |
+
OptionSlug string `json:"option_slug"`
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
type OptionValues struct {
|
| 210 |
+
Id uint `gorm:"primaryKey" json:"id"`
|
| 211 |
+
OptionCategoryId uint `json:"option_category_id"`
|
| 212 |
+
OptionValue string `json:"option_value"`
|
| 213 |
+
}
|
| 214 |
+
type AcademyMaterialProgress struct {
|
| 215 |
+
Id uuid.UUID `gorm:"primaryKey" json:"id"`
|
| 216 |
+
AccountId uint `json:"account_id"`
|
| 217 |
+
AcademyMaterialId uint `json:"academy_material_id"`
|
| 218 |
+
Progress uint `json:"progress"`
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
type AcademyContentProgress struct {
|
| 222 |
+
Id uuid.UUID `gorm:"primaryKey" json:"id"`
|
| 223 |
+
AccountId uuid.UUID `json:"account_id"`
|
| 224 |
+
AcademyId uuid.UUID `json:"academy_id"`
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
type RegionProvince struct {
|
| 228 |
+
Id uint `json:"id"`
|
| 229 |
+
Name string `json:"name"`
|
| 230 |
+
Code string `json:"code"`
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
type RegionCity struct {
|
| 234 |
+
Id uint `json:"id"`
|
| 235 |
+
Type string `json:"type"`
|
| 236 |
+
Name string `json:"name"`
|
| 237 |
+
Code string `json:"code"`
|
| 238 |
+
FullCode string `json:"full_code"`
|
| 239 |
+
ProvinceId uint `json:"province_id"`
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
// Gorm table name settings
|
| 243 |
+
func (Account) TableName() string { return "account" }
|
| 244 |
+
func (AccountDetails) TableName() string { return "account_details" }
|
| 245 |
+
func (EmailVerification) TableName() string { return "email_verification" }
|
| 246 |
+
func (ExternalAuth) TableName() string { return "external_auth" }
|
| 247 |
+
func (FCM) TableName() string { return "fcm" }
|
| 248 |
+
func (ForgotPassword) TableName() string { return "forgot_password" }
|
| 249 |
+
func (Events) TableName() string { return "events" }
|
| 250 |
+
func (Announcement) TableName() string { return "announcement" }
|
| 251 |
+
func (ProblemSet) TableName() string { return "problem_sets" }
|
| 252 |
+
func (Questions) TableName() string { return "questions" }
|
| 253 |
+
func (EventAssign) TableName() string { return "event_assign" }
|
| 254 |
+
func (ProblemSetAssign) TableName() string { return "problem_sets_assign" }
|
| 255 |
+
func (Result) TableName() string { return "result" }
|
| 256 |
+
func (ExamProgress) TableName() string { return "exam_progress" }
|
| 257 |
+
func (ExamProgress_Result) TableName() string { return "exam_progress_result" }
|
| 258 |
+
func (Academy) TableName() string { return "academy" }
|
| 259 |
+
func (AcademyMaterial) TableName() string { return "academy_materials" }
|
| 260 |
+
func (AcademyContent) TableName() string { return "academy_contents" }
|
| 261 |
+
func (AcademyMaterialProgress) TableName() string { return "academy_materials_progress" }
|
| 262 |
+
func (AcademyContentProgress) TableName() string { return "academy_contents_progress" }
|
| 263 |
+
func (RegionProvince) TableName() string { return "region_provinces" }
|
| 264 |
+
func (RegionCity) TableName() string { return "region_cities" }
|
models/exception_model.go
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package models
|
| 2 |
+
|
| 3 |
+
type Exception struct {
|
| 4 |
+
Unauthorized bool `json:"unauthorized,omitempty"`
|
| 5 |
+
BadRequest bool `json:"bad_request,omitempty"`
|
| 6 |
+
DataNotFound bool `json:"data_not_found,omitempty"`
|
| 7 |
+
InternalServerError bool `json:"internal_server_error,omitempty"`
|
| 8 |
+
DataDuplicate bool `json:"data_duplicate,omitempty"`
|
| 9 |
+
QueryError bool `json:"query_error,omitempty"`
|
| 10 |
+
InvalidPasswordLength bool `json:"invalid_password_length,omitempty"`
|
| 11 |
+
Message string `json:"message,omitempty"`
|
| 12 |
+
}
|
models/model.go
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
package models
|
models/request_model.go
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package models
|
| 2 |
+
|
| 3 |
+
import "github.com/google/uuid"
|
| 4 |
+
|
| 5 |
+
type LoginRequest struct {
|
| 6 |
+
Email string `json:"email" binding:"required"`
|
| 7 |
+
Password string `json:"password" binding:"required"`
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
type RegisterRequest struct {
|
| 11 |
+
Name string `json:"name"`
|
| 12 |
+
Email string `json:"email" binding:"required,email"`
|
| 13 |
+
Username string `json:"username" binding:"required"`
|
| 14 |
+
Password string `json:"password" binding:"required"`
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
type CreateEmailVerificationRequest struct {
|
| 18 |
+
Email string `json:"email" binding:"required,email"`
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
type ChangePasswordRequest struct {
|
| 22 |
+
OldPassword string `json:"old_password" binding:"required" `
|
| 23 |
+
NewPassword string `json:"new_password" binding:"required" `
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
type EventDetailRequest struct {
|
| 27 |
+
IdUser uuid.UUID `json:"id_user"`
|
| 28 |
+
EventId uuid.UUID `json:"id_event"`
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
type JoinEventRequest struct {
|
| 32 |
+
EventId uuid.UUID `json:"id_event"`
|
| 33 |
+
EventCode string `json:"event_code"`
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
type ValidateVerifyEmailRequest struct {
|
| 37 |
+
Email string `json:"email" binding:"required,email"`
|
| 38 |
+
Token uint `json:"token" binding:"required"`
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
type OptionsRequest struct {
|
| 42 |
+
OptionName string `json:"option_name" binding:"required"`
|
| 43 |
+
OptionValue []string `json:"option_values" binding:"required"`
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
type ExternalAuthRequest struct {
|
| 47 |
+
OauthID string `json:"oauth_id" binding:"required"`
|
| 48 |
+
OauthProvider string `json:"oauth_provider" binding:"required"`
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
type ForgotPasswordRequest struct {
|
| 52 |
+
Email string `json:"email" binding:"required,email"`
|
| 53 |
+
}
|
| 54 |
+
type ValidateForgotPasswordRequest struct {
|
| 55 |
+
Token uint `json:"token" binding:"required"`
|
| 56 |
+
NewPassword string `json:"new_password"`
|
| 57 |
+
}
|
models/response_model.go
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package models
|
| 2 |
+
|
| 3 |
+
type SuccessResponse struct {
|
| 4 |
+
Status string `json:"status"`
|
| 5 |
+
Message string `json:"message"`
|
| 6 |
+
Data any `json:"data"`
|
| 7 |
+
MetaData any `json:"meta_data"`
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
type ErrorResponse struct {
|
| 11 |
+
Status string `json:"status"`
|
| 12 |
+
Message string `json:"message"`
|
| 13 |
+
Errors Exception `json:"errors"`
|
| 14 |
+
MetaData any `json:"meta_data"`
|
| 15 |
+
}
|
| 16 |
+
type AuthenticatedUser struct {
|
| 17 |
+
Account Account `json:"account"`
|
| 18 |
+
Token string `json:"token"`
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
type EventDetailResponse struct {
|
| 22 |
+
Data *Events
|
| 23 |
+
RegisterStatus int `json:"register_status"`
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
type Options struct {
|
| 27 |
+
OptionCategory OptionCategory `json:"option_category"`
|
| 28 |
+
OptionValues []OptionValues `json:"option_values"`
|
| 29 |
+
}
|
| 30 |
+
type OptionsResponse struct {
|
| 31 |
+
Options []Options `json:"options"`
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
type UserProfileResponse struct {
|
| 35 |
+
Account Account `json:"account"`
|
| 36 |
+
Details AccountDetails `json:"details"`
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
type AcademyMaterialResponse struct {
|
| 40 |
+
Materials AcademyMaterial
|
| 41 |
+
Contents []AcademyContent
|
| 42 |
+
}
|
| 43 |
+
type AcademyResponse struct {
|
| 44 |
+
Academy Academy `json:"academy"`
|
| 45 |
+
Materials []AcademyMaterialResponse `json:"academy_materials"`
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
type AllAcademyResponse struct {
|
| 49 |
+
Academies []AcademyResponse `json:"academy_dasar"`
|
| 50 |
+
}
|
repositories/academy_repository.go
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import "godp.abdanhafidz.com/models"
|
| 4 |
+
|
| 5 |
+
func GetAllAcademy() Repository[models.Academy, []models.Academy] {
|
| 6 |
+
repo := Construct[models.Academy, []models.Academy](
|
| 7 |
+
models.Academy{},
|
| 8 |
+
)
|
| 9 |
+
repo.Transactions(
|
| 10 |
+
WhereGivenConstructor[models.Academy, []models.Academy],
|
| 11 |
+
Find[models.Academy, []models.Academy],
|
| 12 |
+
)
|
| 13 |
+
return *repo
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
func GetAcademyDataBySlug(slug string) Repository[models.Academy, models.Academy] {
|
| 17 |
+
repo := Construct[models.Academy, models.Academy](
|
| 18 |
+
models.Academy{Slug: slug},
|
| 19 |
+
)
|
| 20 |
+
repo.Transactions(
|
| 21 |
+
WhereGivenConstructor[models.Academy, models.Academy],
|
| 22 |
+
Find[models.Academy, models.Academy],
|
| 23 |
+
)
|
| 24 |
+
return *repo
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
func GetAllAcademyMaterialsByAcademyId(acaddemyId uint) Repository[models.AcademyMaterial, []models.AcademyMaterial] {
|
| 28 |
+
repo := Construct[models.AcademyMaterial, []models.AcademyMaterial](
|
| 29 |
+
models.AcademyMaterial{AcademyId: acaddemyId},
|
| 30 |
+
)
|
| 31 |
+
repo.Transactions(
|
| 32 |
+
WhereGivenConstructor[models.AcademyMaterial, []models.AcademyMaterial],
|
| 33 |
+
Find[models.AcademyMaterial, []models.AcademyMaterial],
|
| 34 |
+
)
|
| 35 |
+
return *repo
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
func GetAllAcademyContentsByMaterialID(materialId uint) Repository[models.AcademyContent, []models.AcademyContent] {
|
| 39 |
+
repo := Construct[models.AcademyContent, []models.AcademyContent](
|
| 40 |
+
models.AcademyContent{AcademyMaterialId: materialId},
|
| 41 |
+
)
|
| 42 |
+
repo.Transactions(
|
| 43 |
+
WhereGivenConstructor[models.AcademyContent, []models.AcademyContent],
|
| 44 |
+
Find[models.AcademyContent, []models.AcademyContent],
|
| 45 |
+
)
|
| 46 |
+
return *repo
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
func CreateAcademy(academies models.Academy) Repository[models.Academy, models.Academy] {
|
| 50 |
+
repo := Construct[models.Academy, models.Academy](
|
| 51 |
+
academies,
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
Create(repo)
|
| 55 |
+
return *repo
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
func CreateAcademyMaterial(academyMaterial models.AcademyMaterial) Repository[models.AcademyMaterial, models.AcademyMaterial] {
|
| 59 |
+
repo := Construct[models.AcademyMaterial, models.AcademyMaterial](
|
| 60 |
+
academyMaterial,
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
Create(repo)
|
| 64 |
+
return *repo
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
func CreateAcademyContent(academyContent models.AcademyContent) Repository[models.AcademyContent, models.AcademyContent] {
|
| 68 |
+
repo := Construct[models.AcademyContent, models.AcademyContent](
|
| 69 |
+
academyContent,
|
| 70 |
+
)
|
| 71 |
+
Create(repo)
|
| 72 |
+
return *repo
|
| 73 |
+
}
|
repositories/account_repository.go
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/google/uuid"
|
| 5 |
+
"godp.abdanhafidz.com/models"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
|
| 9 |
+
repo := Construct[models.Account, models.Account](
|
| 10 |
+
models.Account{Email: email},
|
| 11 |
+
)
|
| 12 |
+
repo.Transactions(
|
| 13 |
+
WhereGivenConstructor[models.Account, models.Account],
|
| 14 |
+
Find[models.Account, models.Account],
|
| 15 |
+
)
|
| 16 |
+
return *repo
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
func GetAllAccount() Repository[models.Account, []models.Account] {
|
| 20 |
+
repo := Construct[models.Account, []models.Account](
|
| 21 |
+
models.Account{},
|
| 22 |
+
)
|
| 23 |
+
repo.Transactions(
|
| 24 |
+
Find[models.Account, []models.Account],
|
| 25 |
+
)
|
| 26 |
+
return *repo
|
| 27 |
+
}
|
| 28 |
+
func GetAccountById(AccountId uuid.UUID) Repository[models.Account, models.Account] {
|
| 29 |
+
repo := Construct[models.Account, models.Account](
|
| 30 |
+
models.Account{Id: AccountId},
|
| 31 |
+
)
|
| 32 |
+
repo.Transactions(
|
| 33 |
+
WhereGivenConstructor[models.Account, models.Account],
|
| 34 |
+
Find[models.Account, models.Account],
|
| 35 |
+
)
|
| 36 |
+
return *repo
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
func UpdateAccount(account models.Account) Repository[models.Account, models.Account] {
|
| 40 |
+
repo := Construct[models.Account, models.Account](
|
| 41 |
+
account,
|
| 42 |
+
)
|
| 43 |
+
repo.Transaction.Save(&repo.Constructor)
|
| 44 |
+
repo.Result = repo.Constructor
|
| 45 |
+
return *repo
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
func GetDetailAccountById(AccountId uuid.UUID) Repository[models.AccountDetails, models.AccountDetails] {
|
| 49 |
+
repo := Construct[models.AccountDetails, models.AccountDetails](
|
| 50 |
+
models.AccountDetails{AccountId: AccountId},
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
// fmt.Println("Account ID:", repo.Constructor.AccountId)
|
| 54 |
+
repo.Transactions(
|
| 55 |
+
WhereGivenConstructor[models.AccountDetails, models.AccountDetails],
|
| 56 |
+
Find[models.AccountDetails, models.AccountDetails],
|
| 57 |
+
)
|
| 58 |
+
return *repo
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
func CreateAccount(account models.Account) Repository[models.Account, models.Account] {
|
| 62 |
+
repo := Construct[models.Account, models.Account](
|
| 63 |
+
account,
|
| 64 |
+
)
|
| 65 |
+
Create(repo)
|
| 66 |
+
return *repo
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
func CreateAccountDetails(accountDetails models.AccountDetails) Repository[models.AccountDetails, models.AccountDetails] {
|
| 70 |
+
repo := Construct[models.AccountDetails, models.AccountDetails](
|
| 71 |
+
accountDetails,
|
| 72 |
+
)
|
| 73 |
+
Create(repo)
|
| 74 |
+
return *repo
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
func UpdateAccountDetails(accountDetails models.AccountDetails) Repository[models.AccountDetails, models.AccountDetails] {
|
| 78 |
+
repo := Construct[models.AccountDetails, models.AccountDetails](
|
| 79 |
+
models.AccountDetails{AccountId: accountDetails.AccountId},
|
| 80 |
+
)
|
| 81 |
+
repo.Transaction.Where("account_id = ?", accountDetails.AccountId).First(&repo.Constructor)
|
| 82 |
+
accountDetails.Id = repo.Constructor.Id
|
| 83 |
+
// fmt.Println(repo.Constructor)
|
| 84 |
+
// fmt.Println(accountDetails)
|
| 85 |
+
repo.Transaction.Updates(accountDetails)
|
| 86 |
+
repo.Result = accountDetails
|
| 87 |
+
return *repo
|
| 88 |
+
}
|
repositories/email_verification_repository.go
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"time"
|
| 5 |
+
|
| 6 |
+
"github.com/google/uuid"
|
| 7 |
+
"godp.abdanhafidz.com/models"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func CreateEmailVerification(uuid uuid.UUID, AccountId uuid.UUID, dueTime time.Time, token uint) Repository[models.EmailVerification, models.EmailVerification] {
|
| 11 |
+
repo := Construct[models.EmailVerification, models.EmailVerification](
|
| 12 |
+
models.EmailVerification{
|
| 13 |
+
AccountId: AccountId,
|
| 14 |
+
IsExpired: false,
|
| 15 |
+
ExpiredAt: dueTime,
|
| 16 |
+
Token: token,
|
| 17 |
+
Id: uuid,
|
| 18 |
+
},
|
| 19 |
+
)
|
| 20 |
+
Create(repo)
|
| 21 |
+
return *repo
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
func GetEmailVerification(AccountId uuid.UUID, token uint) Repository[models.EmailVerification, models.EmailVerification] {
|
| 25 |
+
repo := Construct[models.EmailVerification, models.EmailVerification](
|
| 26 |
+
models.EmailVerification{
|
| 27 |
+
AccountId: AccountId,
|
| 28 |
+
IsExpired: false,
|
| 29 |
+
Token: token,
|
| 30 |
+
},
|
| 31 |
+
)
|
| 32 |
+
repo.Transactions(
|
| 33 |
+
WhereGivenConstructor[models.EmailVerification, models.EmailVerification],
|
| 34 |
+
Find[models.EmailVerification, models.EmailVerification],
|
| 35 |
+
)
|
| 36 |
+
return *repo
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
func UpdateExpiredEmailVerification(uuid uuid.UUID) Repository[models.EmailVerification, models.EmailVerification] {
|
| 40 |
+
repo := Construct[models.EmailVerification, models.EmailVerification](
|
| 41 |
+
models.EmailVerification{Id: uuid},
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
repo.Transaction.Where("UUID = ?", uuid).First(&repo.Constructor)
|
| 45 |
+
repo.Constructor.IsExpired = true
|
| 46 |
+
repo.Transaction.Updates(repo.Constructor)
|
| 47 |
+
repo.Result = repo.Constructor
|
| 48 |
+
return *repo
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
func DeleteEmailVerification(token uint) Repository[models.EmailVerification, models.EmailVerification] {
|
| 52 |
+
repo := Construct[models.EmailVerification, models.EmailVerification](
|
| 53 |
+
models.EmailVerification{
|
| 54 |
+
Token: token,
|
| 55 |
+
},
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
repo.Transactions(
|
| 59 |
+
WhereGivenConstructor[models.EmailVerification, models.EmailVerification],
|
| 60 |
+
Delete[models.EmailVerification],
|
| 61 |
+
)
|
| 62 |
+
return *repo
|
| 63 |
+
}
|
repositories/event_repository.go
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"log"
|
| 5 |
+
|
| 6 |
+
"github.com/google/uuid"
|
| 7 |
+
"godp.abdanhafidz.com/models"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func GetAllEventsPaginate(pagination PaginationConstructor) Repository[models.Events, []models.Events] {
|
| 11 |
+
repo := Construct[models.Events, []models.Events](
|
| 12 |
+
models.Events{},
|
| 13 |
+
)
|
| 14 |
+
repo.Pagination = pagination
|
| 15 |
+
|
| 16 |
+
// Add debug log to verify pagination values
|
| 17 |
+
log.Printf("Pagination - Limit: %d, Offset: %d", pagination.Limit, pagination.Offset)
|
| 18 |
+
|
| 19 |
+
// Transactions that execute the query
|
| 20 |
+
repo.Transactions(
|
| 21 |
+
FindAllPaginate[models.Events, []models.Events],
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
// Check if there's an error or no records
|
| 25 |
+
if repo.RowsCount == 0 {
|
| 26 |
+
log.Println("No events found with the provided pagination")
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
return *repo
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
func GetEventDetailByEventId(EventId uuid.UUID) Repository[models.Events, models.Events] {
|
| 33 |
+
repo := Construct[models.Events, models.Events](
|
| 34 |
+
models.Events{
|
| 35 |
+
Id: EventId,
|
| 36 |
+
},
|
| 37 |
+
)
|
| 38 |
+
repo.Transactions(
|
| 39 |
+
WhereGivenConstructor[models.Events, models.Events],
|
| 40 |
+
Find[models.Events, models.Events],
|
| 41 |
+
)
|
| 42 |
+
return *repo
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
func GetEventDetailBySlug(slug string) Repository[models.Events, models.Events] {
|
| 46 |
+
repo := Construct[models.Events, models.Events](
|
| 47 |
+
models.Events{
|
| 48 |
+
Slug: slug,
|
| 49 |
+
},
|
| 50 |
+
)
|
| 51 |
+
repo.Transactions(
|
| 52 |
+
WhereGivenConstructor[models.Events, models.Events],
|
| 53 |
+
Find[models.Events, models.Events],
|
| 54 |
+
)
|
| 55 |
+
return *repo
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
func GetEventAssigned(EventId uuid.UUID, AccountId uuid.UUID) Repository[models.EventAssign, models.EventAssign] {
|
| 59 |
+
repo := Construct[models.EventAssign, models.EventAssign](
|
| 60 |
+
models.EventAssign{
|
| 61 |
+
EventId: EventId,
|
| 62 |
+
AccountId: AccountId,
|
| 63 |
+
},
|
| 64 |
+
)
|
| 65 |
+
repo.Transactions(
|
| 66 |
+
WhereGivenConstructor[models.EventAssign, models.EventAssign],
|
| 67 |
+
Find[models.EventAssign, models.EventAssign],
|
| 68 |
+
)
|
| 69 |
+
return *repo
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
func GetEventByCode(code string) Repository[models.Events, models.Events] {
|
| 73 |
+
repo := Construct[models.Events, models.Events](
|
| 74 |
+
models.Events{EventCode: code},
|
| 75 |
+
)
|
| 76 |
+
|
| 77 |
+
repo.Transactions(
|
| 78 |
+
WhereGivenConstructor[models.Events, models.Events],
|
| 79 |
+
Find[models.Events, models.Events],
|
| 80 |
+
)
|
| 81 |
+
if repo.RowsCount == 0 {
|
| 82 |
+
log.Println("No events found with the provided code")
|
| 83 |
+
}
|
| 84 |
+
return *repo
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
func AssignEvent(eventAssign models.EventAssign) Repository[models.EventAssign, models.EventAssign] {
|
| 88 |
+
repo := Construct[models.EventAssign, models.EventAssign](
|
| 89 |
+
eventAssign,
|
| 90 |
+
)
|
| 91 |
+
Create(repo)
|
| 92 |
+
return *repo
|
| 93 |
+
}
|
repositories/external_auth_repository.go
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/google/uuid"
|
| 5 |
+
"godp.abdanhafidz.com/models"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
func CreateExternalAuth(oauth models.ExternalAuth) Repository[models.ExternalAuth, models.ExternalAuth] {
|
| 9 |
+
repo := Construct[models.ExternalAuth, models.ExternalAuth](
|
| 10 |
+
oauth,
|
| 11 |
+
)
|
| 12 |
+
Create(repo)
|
| 13 |
+
return *repo
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
func GetExternalAuthByAccountId(AccountId uuid.UUID) Repository[models.ExternalAuth, []models.ExternalAuth] {
|
| 17 |
+
repo := Construct[models.ExternalAuth, []models.ExternalAuth](
|
| 18 |
+
models.ExternalAuth{
|
| 19 |
+
AccountId: AccountId,
|
| 20 |
+
},
|
| 21 |
+
)
|
| 22 |
+
repo.Transactions(
|
| 23 |
+
WhereGivenConstructor[models.ExternalAuth, []models.ExternalAuth],
|
| 24 |
+
Find[models.ExternalAuth, []models.ExternalAuth],
|
| 25 |
+
)
|
| 26 |
+
return *repo
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
func GetExternalAccountByOauthId(oauthId string) Repository[models.ExternalAuth, models.ExternalAuth] {
|
| 30 |
+
repo := Construct[models.ExternalAuth, models.ExternalAuth](
|
| 31 |
+
models.ExternalAuth{
|
| 32 |
+
OauthID: oauthId,
|
| 33 |
+
},
|
| 34 |
+
)
|
| 35 |
+
repo.Transactions(
|
| 36 |
+
WhereGivenConstructor[models.ExternalAuth, models.ExternalAuth],
|
| 37 |
+
Find[models.ExternalAuth, models.ExternalAuth],
|
| 38 |
+
)
|
| 39 |
+
return *repo
|
| 40 |
+
}
|
repositories/forgot_password_repository.go
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import "godp.abdanhafidz.com/models"
|
| 4 |
+
|
| 5 |
+
func CreateForgotPassword(forgotPassword models.ForgotPassword) Repository[models.ForgotPassword, models.ForgotPassword] {
|
| 6 |
+
repo := Construct[models.ForgotPassword, models.ForgotPassword](
|
| 7 |
+
forgotPassword,
|
| 8 |
+
)
|
| 9 |
+
Create(repo)
|
| 10 |
+
return *repo
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
func GetForgotPasswordByToken(token uint) Repository[models.ForgotPassword, models.ForgotPassword] {
|
| 14 |
+
repo := Construct[models.ForgotPassword, models.ForgotPassword](
|
| 15 |
+
models.ForgotPassword{Token: token},
|
| 16 |
+
)
|
| 17 |
+
repo.Transactions(
|
| 18 |
+
WhereGivenConstructor[models.ForgotPassword, models.ForgotPassword],
|
| 19 |
+
Find[models.ForgotPassword, models.ForgotPassword],
|
| 20 |
+
)
|
| 21 |
+
return *repo
|
| 22 |
+
}
|
repositories/option_repository.go
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"godp.abdanhafidz.com/models"
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
func CreateOptionCategory(categories models.OptionCategory) Repository[models.OptionCategory, models.OptionCategory] {
|
| 8 |
+
repo := Construct[models.OptionCategory, models.OptionCategory](
|
| 9 |
+
categories,
|
| 10 |
+
)
|
| 11 |
+
Create(repo)
|
| 12 |
+
return *repo
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
func CreateOptionValues(values models.OptionValues) Repository[models.OptionValues, models.OptionValues] {
|
| 16 |
+
repo := Construct[models.OptionValues, models.OptionValues](
|
| 17 |
+
values,
|
| 18 |
+
)
|
| 19 |
+
Create(repo)
|
| 20 |
+
return *repo
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
func GetOptionCategoryBySlug(slug string) Repository[models.OptionCategory, models.OptionCategory] {
|
| 24 |
+
repo := Construct[models.OptionCategory, models.OptionCategory](
|
| 25 |
+
models.OptionCategory{OptionSlug: slug},
|
| 26 |
+
)
|
| 27 |
+
repo.Transactions(
|
| 28 |
+
WhereGivenConstructor[models.OptionCategory, models.OptionCategory],
|
| 29 |
+
Find[models.OptionCategory, models.OptionCategory],
|
| 30 |
+
)
|
| 31 |
+
return *repo
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
func GetOptionValuesByCategoryId(categoryId uint) Repository[models.OptionValues, []models.OptionValues] {
|
| 35 |
+
repo := Construct[models.OptionValues, []models.OptionValues](
|
| 36 |
+
models.OptionValues{OptionCategoryId: categoryId},
|
| 37 |
+
)
|
| 38 |
+
repo.Transactions(
|
| 39 |
+
WhereGivenConstructor[models.OptionValues, []models.OptionValues],
|
| 40 |
+
Find[models.OptionValues, []models.OptionValues],
|
| 41 |
+
)
|
| 42 |
+
return *repo
|
| 43 |
+
}
|
repositories/region_repository.go
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package repositories
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"godp.abdanhafidz.com/models"
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
func BulkCreateProvince(provinces []models.RegionProvince) Repository[[]models.RegionProvince, []models.RegionProvince] {
|
| 8 |
+
repo := Construct[[]models.RegionProvince, []models.RegionProvince](
|
| 9 |
+
provinces,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
Create(repo)
|
| 13 |
+
return *repo
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
func BulkCreateCity(cities []models.RegionCity) Repository[[]models.RegionCity, []models.RegionCity] {
|
| 17 |
+
repo := Construct[[]models.RegionCity, []models.RegionCity](
|
| 18 |
+
cities,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
Create(repo)
|
| 22 |
+
return *repo
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
func GetListProvinces() Repository[models.RegionProvince, []models.RegionProvince] {
|
| 26 |
+
repo := Construct[models.RegionProvince, []models.RegionProvince](
|
| 27 |
+
models.RegionProvince{},
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
repo.Transactions(
|
| 31 |
+
Find[models.RegionProvince, []models.RegionProvince],
|
| 32 |
+
)
|
| 33 |
+
return *repo
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
func GetListCitiesByProvinceId(provinceId uint) Repository[models.RegionCity, []models.RegionCity] {
|
| 37 |
+
repo := Construct[models.RegionCity, []models.RegionCity](
|
| 38 |
+
models.RegionCity{
|
| 39 |
+
ProvinceId: provinceId,
|
| 40 |
+
},
|
| 41 |
+
)
|
| 42 |
+
repo.Transactions(
|
| 43 |
+
WhereGivenConstructor[models.RegionCity, []models.RegionCity],
|
| 44 |
+
Find[models.RegionCity, []models.RegionCity],
|
| 45 |
+
)
|
| 46 |
+
return *repo
|
| 47 |
+
}
|