lifedebugger commited on
Commit
7e1ff30
·
1 Parent(s): f04ece2

Deploy files from GitHub repository

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. LICENSE +201 -0
  2. README.md +71 -8
  3. space/.github/workflows/main.yml +1 -1
  4. space/space/.github/workflows/main.yml +1 -1
  5. space/space/space/.gitignore +2 -1
  6. space/space/space/config/config.go +21 -0
  7. space/space/space/config/database_connection_config.go +60 -0
  8. space/space/space/controller/home_controller.go +9 -0
  9. space/space/space/controller/login_controller.go +19 -0
  10. space/space/space/controller/register_controller.go +19 -0
  11. space/space/space/middleware/authentication_middleware.go +104 -0
  12. space/space/space/middleware/response_middleware.go +39 -0
  13. space/space/space/models/authentication_payload_model.go +7 -0
  14. space/space/space/models/database_orm_model.go +31 -0
  15. space/space/space/models/exception_model.go +12 -0
  16. space/space/space/models/model.go +1 -0
  17. space/space/space/models/request_model.go +13 -0
  18. space/space/space/models/response_model.go +19 -0
  19. space/space/space/repositories/account_repository.go +24 -0
  20. space/space/space/repositories/repository.go +113 -0
  21. space/space/space/services/login_service.go +47 -0
  22. space/space/space/services/register_service.go +40 -0
  23. space/space/space/services/service.go +31 -0
  24. space/space/space/space/README.md +71 -8
  25. space/space/space/space/config/DatabaseConfig.go +17 -17
  26. space/space/space/space/controller/LoginController.go +2 -2
  27. space/space/space/space/controller/RegisterController.go +2 -2
  28. space/space/space/space/controller/controller.go +3 -3
  29. space/space/space/space/go.mod +26 -26
  30. space/space/space/space/go.sum +50 -72
  31. space/space/space/space/main.go +2 -2
  32. space/space/space/space/middleware/AuthMiddleware.go +13 -12
  33. space/space/space/space/repositories/AccountRepository.go +1 -1
  34. space/space/space/space/repositories/DatabaseScoope.go +1 -1
  35. space/space/space/space/repositories/repositories.go +1 -1
  36. space/space/space/space/router/router.go +2 -2
  37. space/space/space/space/services/LoginService.go +3 -3
  38. space/space/space/space/services/RegisterService.go +3 -3
  39. space/space/space/space/services/services.go +2 -2
  40. space/space/space/space/space/models/ExceptionModel.go +8 -7
  41. space/space/space/space/space/services/RegisterService.go +5 -0
  42. space/space/space/space/space/space/repositories/AccountRepository.go +2 -2
  43. space/space/space/space/space/space/repositories/repositories.go +0 -7
  44. space/space/space/space/space/space/services/LoginService.go +1 -1
  45. space/space/space/space/space/space/services/RegisterService.go +2 -0
  46. space/space/space/space/space/space/space/go.mod +1 -0
  47. space/space/space/space/space/space/space/go.sum +2 -0
  48. space/space/space/space/space/space/space/models/DatabaseModel.go +17 -5
  49. space/space/space/space/space/space/space/repositories/AccountRepository.go +0 -3
  50. space/space/space/space/space/space/space/services/RegisterService.go +3 -2
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,8 +1,71 @@
1
- ---
2
- title: Quzuu Api Dev
3
- emoji: 🐠
4
- colorFrom: indigo
5
- colorTo: gray
6
- sdk: docker
7
- pinned: false
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Golang API Boilerplate
2
+ This is a boilerplate for a RESTful API written in Golang.
3
+
4
+ ## Features
5
+ - [x] JWT Authentication
6
+ - [x] PostgreSQL Database
7
+ - [x] GORM ORM
8
+ - [x] Gin Framework
9
+ - [x] Docker Support
10
+ - [x] Environment Variables
11
+ - [x] Logging
12
+ - [x] Error Handling
13
+
14
+ ## Getting Started
15
+ 1. Clone the repository
16
+ 2. Run `go get` to download the dependencies
17
+ 3. Create a file named `.env` and add the following variables:
18
+ * `DB_HOST`
19
+ * `DB_USER`
20
+ * `DB_PASSWORD`
21
+ * `DB_NAME`
22
+ * `DB_PORT`
23
+ * `SALT`
24
+ * `HOST_ADDRESS`
25
+ * `HOST_PORT`
26
+ * `LOG_PATH`
27
+ 4. Run `go run main.go` to start the server
28
+ 5. Open your browser and navigate to `http://localhost:HOST_PORT`
29
+
30
+ ## API Endpoints
31
+ ### Authentication
32
+ - `POST /login`: Login with email and password
33
+ - `POST /register`: Register a new user
34
+ - `GET /logout`: Logout
35
+
36
+ ### Users
37
+ - `GET /users`: Get all users
38
+ - `GET /users/:id`: Get a user by ID
39
+ - `PUT /users/:id`: Update a user
40
+ - `DELETE /users/:id`: Delete a user
41
+
42
+ ## Docker Support
43
+ You can build a Docker image by running `docker build -t my-api .` and then run it with `docker run -p 8080:8080 my-api`.
44
+
45
+ ## Environment Variables
46
+ You can set the following environment variables:
47
+ - `DB_HOST`
48
+ - `DB_USER`
49
+ - `DB_PASSWORD`
50
+ - `DB_NAME`
51
+ - `DB_PORT`
52
+ - `SALT`
53
+ - `HOST_ADDRESS`
54
+ - `HOST_PORT`
55
+ - `LOG_PATH`
56
+
57
+ ## Logging
58
+ The API uses the `log` package to log errors. You can set the `LOG_PATH` environment variable to specify the log file path.
59
+
60
+ ## Error Handling
61
+ The API uses the `errors` package to handle errors. You can set the `ERROR_PATH` environment variable to specify the error file path.
62
+
63
+ # Command Documentation
64
+
65
+ ## Update Golang Project version
66
+ > go mod edit -go 1.24
67
+ > go mod tidy
68
+
69
+ ## Update all package
70
+ > go get -u ./...
71
+ > go mod tidy
space/.github/workflows/main.yml CHANGED
@@ -49,4 +49,4 @@ jobs:
49
  cd space
50
  git add .
51
  git commit -m "Deploy files from GitHub repository" || echo "No changes to commit"
52
- git push --force origin main || echo "No changes to push"
 
49
  cd space
50
  git add .
51
  git commit -m "Deploy files from GitHub repository" || echo "No changes to commit"
52
+ git push origin main || echo "No changes to push"
space/space/.github/workflows/main.yml CHANGED
@@ -49,4 +49,4 @@ jobs:
49
  cd space
50
  git add .
51
  git commit -m "Deploy files from GitHub repository" || echo "No changes to commit"
52
- git push origin main || echo "No changes to push"
 
49
  cd space
50
  git add .
51
  git commit -m "Deploy files from GitHub repository" || echo "No changes to commit"
52
+ git push --force origin main || echo "No changes to push"
space/space/space/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  .env
2
  vendor/
3
- quzuu-be.exe
 
 
1
  .env
2
  vendor/
3
+ quzuu-be.exe
4
+ README.md
space/space/space/config/config.go ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package config
2
+
3
+ import (
4
+ "os"
5
+
6
+ "github.com/joho/godotenv"
7
+ )
8
+
9
+ var TCP_ADDRESS string
10
+ var LOG_PATH string
11
+ var HOST_ADDRESS string
12
+ var HOST_PORT string
13
+
14
+ func init() {
15
+ godotenv.Load()
16
+ HOST_ADDRESS = os.Getenv("HOST_ADDRESS")
17
+ HOST_PORT = os.Getenv("HOST_PORT")
18
+ TCP_ADDRESS = HOST_ADDRESS + ":" + HOST_PORT
19
+ LOG_PATH = os.Getenv("LOG_PATH")
20
+ // Menampilkan nilai variabel lingkungan
21
+ }
space/space/space/config/database_connection_config.go ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package config
2
+
3
+ import (
4
+ "fmt"
5
+ "log"
6
+ "os"
7
+
8
+ "gorm.io/driver/postgres"
9
+ "gorm.io/gorm"
10
+ "gorm.io/gorm/logger"
11
+
12
+ "api.qobiltu.id/models"
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
+ err := db.AutoMigrate(
52
+ &models.Account{},
53
+ &models.AccountDetails{},
54
+ )
55
+ if err != nil {
56
+ log.Fatal(err)
57
+ }
58
+
59
+ fmt.Println("Migration completed successfully.")
60
+ }
space/space/space/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
+ }
space/space/space/controller/login_controller.go ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package controller
2
+
3
+ import (
4
+ "api.qobiltu.id/models"
5
+ "api.qobiltu.id/services"
6
+ "github.com/gin-gonic/gin"
7
+ )
8
+
9
+ func LoginController(c *gin.Context) {
10
+ authentication := services.AuthenticationService{}
11
+ loginController := Controller[models.LoginRequest, services.LoginConstructor, models.AuthenticatedUser]{
12
+ Service: &authentication.Service,
13
+ }
14
+ loginController.RequestJSON(c, func() {
15
+ loginController.Service.Constructor.Email = loginController.Request.Email
16
+ loginController.Service.Constructor.Password = loginController.Request.Password
17
+ authentication.Authenticate()
18
+ })
19
+ }
space/space/space/controller/register_controller.go ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package controller
2
+
3
+ import (
4
+ "api.qobiltu.id/models"
5
+ "api.qobiltu.id/services"
6
+ "github.com/gin-gonic/gin"
7
+ )
8
+
9
+ func RegisterController(c *gin.Context) {
10
+ register := services.RegisterService{}
11
+ registerController := Controller[models.RegisterRequest, models.Account, models.Account]{
12
+ Service: &register.Service,
13
+ }
14
+ registerController.RequestJSON(c, func() {
15
+ registerController.Service.Constructor.Password = registerController.Request.Password
16
+ registerController.Service.Constructor.Email = registerController.Request.Email
17
+ register.Create()
18
+ })
19
+ }
space/space/space/middleware/authentication_middleware.go ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // auth/auth.go
2
+
3
+ package middleware
4
+
5
+ import (
6
+ "errors"
7
+ "time"
8
+
9
+ "api.qobiltu.id/config"
10
+ "api.qobiltu.id/models"
11
+ "github.com/gin-gonic/gin"
12
+ "github.com/golang-jwt/jwt/v5"
13
+ "golang.org/x/crypto/bcrypt"
14
+ )
15
+
16
+ // Define a secret key for signing the JWT token
17
+ var salt = config.Salt
18
+ var secretKey = []byte(salt)
19
+
20
+ // GenerateToken generates a JWT token for the given user
21
+ func GenerateToken(user *models.Account) (string, error) {
22
+
23
+ // Create a new token
24
+ token := jwt.New(jwt.SigningMethodHS256)
25
+
26
+ // Set claims
27
+ claims := token.Claims.(jwt.MapClaims)
28
+ claims["id"] = user.Id
29
+ claims["exp"] = time.Now().Add(time.Hour * 24).Unix() // Token expires in 24 hours
30
+
31
+ // Sign the token with the secret key
32
+ tokenString, err := token.SignedString(secretKey)
33
+ if err != nil {
34
+ return "", err
35
+ }
36
+
37
+ return tokenString, nil
38
+ }
39
+
40
+ // VerifyPassword verifies if the provided password matches the hashed password
41
+ func VerifyPassword(hashedPassword, password string) error {
42
+ err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
43
+ if err != nil {
44
+ return errors.New("invalid password")
45
+ }
46
+ return nil
47
+ }
48
+ func HashPassword(password string) (string, error) {
49
+ bytes, err := bcrypt.GenerateFromPassword([]byte(password), 14)
50
+ return string(bytes), err
51
+ }
52
+
53
+ type CustomClaims struct {
54
+ jwt.RegisteredClaims
55
+ UserID int `json:"id"`
56
+ }
57
+
58
+ func VerifyToken(bearer_token string) (int, string, error) {
59
+ // fmt.Println(bearer_token)
60
+ token, err := jwt.ParseWithClaims(bearer_token, &CustomClaims{}, func(token *jwt.Token) (interface{}, error) {
61
+ return secretKey, nil
62
+ })
63
+ if err != nil {
64
+ return 0, "invalid-token", err
65
+ }
66
+
67
+ // Extract the claims
68
+ claims, ok := token.Claims.(*CustomClaims)
69
+ if !ok || !token.Valid {
70
+ return 0, "invalid-token", err
71
+ }
72
+ if claims.ExpiresAt != nil && claims.ExpiresAt.Time.Before(time.Now()) {
73
+ return 0, "expired", err
74
+ }
75
+
76
+ return claims.UserID, "valid", err
77
+ }
78
+
79
+ func AuthUser(c *gin.Context) {
80
+ var currAccData models.AccountData
81
+ if c.Request.Header["Auth-Bearer-Token"] != nil {
82
+ token := c.Request.Header["Auth-Bearer-Token"]
83
+ currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = VerifyToken(token[0])
84
+ // fmt.Println("Verify Status :", currAccData.verifyStatus)
85
+ if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
86
+ currAccData.UserID = 0
87
+ message := "Your session is expired, Please re-Login!"
88
+ SendJSON401(c, &currAccData.VerifyStatus, &message)
89
+ c.Abort()
90
+ return
91
+ }
92
+ } else {
93
+ currAccData.UserID = 0
94
+ currAccData.VerifyStatus = "no-token"
95
+ currAccData.ErrVerif = nil
96
+ message := "You have to Login First!"
97
+ SendJSON401(c, &currAccData.VerifyStatus, &message)
98
+ c.Abort()
99
+ return
100
+ }
101
+
102
+ c.Set("accountData", currAccData)
103
+ c.Next()
104
+ }
space/space/space/middleware/response_middleware.go ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
13
+
14
+ // SendJSON400 sends a JSON response with HTTP status code 400
15
+ func SendJSON400(c *gin.Context, error_status *string, message *string) {
16
+ c.JSON(http.StatusBadRequest, gin.H{"status": "error", "error-status": error_status, "message": message})
17
+ }
18
+
19
+ // SendJSON401 sends a JSON response with HTTP status code 401
20
+ func SendJSON401(c *gin.Context, error_status *string, message *string) {
21
+ c.JSON(http.StatusUnauthorized, gin.H{"status": "error", "error-status": error_status, "message": message})
22
+ }
23
+
24
+ // SendJSON403 sends a JSON response with HTTP status code 403
25
+ func SendJSON403(c *gin.Context, message *string) {
26
+ c.JSON(http.StatusForbidden, gin.H{"status": "error", "message": message})
27
+ }
28
+
29
+ // SendJSON404 sends a JSON response with HTTP status code 404
30
+ func SendJSON404(c *gin.Context, message *string) {
31
+ c.JSON(http.StatusNotFound, gin.H{"status": "error", "message": message})
32
+ }
33
+
34
+ // SendJSON500 sends a JSON response with HTTP status code 500
35
+ func SendJSON500(c *gin.Context, error_status *string, message *string) {
36
+ c.JSON(http.StatusInternalServerError, gin.H{"status": "error", "error-status": error_status, "message": message})
37
+ }
38
+
39
+ // JSONResponseMiddleware is a middleware that provides functions for sending JSON responses
space/space/space/models/authentication_payload_model.go ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ package models
2
+
3
+ type AccountData struct {
4
+ UserID int
5
+ VerifyStatus string
6
+ ErrVerif error
7
+ }
space/space/space/models/database_orm_model.go ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package models
2
+
3
+ import (
4
+ "time"
5
+
6
+ uuid "github.com/satori/go.uuid"
7
+ )
8
+
9
+ type Account struct {
10
+ Id uint `gorm:"primaryKey" json:"id"`
11
+ UUID uuid.UUID `gorm:"type:uuid" json:"uuid" `
12
+ Email string `gorm:"uniqueIndex" json:"email"`
13
+ Password string `json:"password"`
14
+ IsEmailVerified bool `json:"is_email_verified"`
15
+ CreatedAt time.Time `json:"created_at"`
16
+ DeletedAt time.Time `json:"deleted_at"`
17
+ }
18
+
19
+ type AccountDetails struct {
20
+ IDDetail uint `gorm:"primaryKey" json:"id_detail"`
21
+ Account_id uint `json:"id_account"`
22
+ Province string `json:"province"`
23
+ City string `json:"city"`
24
+ Institution string `json:"institution"`
25
+ UpdatedAt time.Time `json:"updated_at"`
26
+ DeletedAt time.Time `json:"deleted_at"`
27
+ }
28
+
29
+ // Gorm table name settings
30
+ func (Account) TableName() string { return "account" }
31
+ func (AccountDetails) TableName() string { return "account_details" }
space/space/space/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
+ }
space/space/space/models/model.go ADDED
@@ -0,0 +1 @@
 
 
1
+ package models
space/space/space/models/request_model.go ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package models
2
+
3
+ type LoginRequest struct {
4
+ Email string `json:"email" binding:"required"`
5
+ Password string `json:"password" binding:"required"`
6
+ }
7
+
8
+ type RegisterRequest struct {
9
+ Name string `json:"name"`
10
+ Email string `json:"email" binding:"required,email"`
11
+ Phone int `json:"phone"`
12
+ Password string `json:"password" binding:"required"`
13
+ }
space/space/space/models/response_model.go ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
space/space/space/repositories/account_repository.go ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package repositories
2
+
3
+ import (
4
+ "api.qobiltu.id/models"
5
+ )
6
+
7
+ func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
8
+ repo := Construct[models.Account, models.Account](
9
+ models.Account{Email: email},
10
+ )
11
+ repo.Transactions(
12
+ WhereGivenConstructor[models.Account, models.Account],
13
+ Find[models.Account, models.Account],
14
+ )
15
+ return *repo
16
+ }
17
+
18
+ func CreateAccount(account models.Account) Repository[models.Account, models.Account] {
19
+ repo := Construct[models.Account, models.Account](
20
+ account,
21
+ )
22
+ Create(repo)
23
+ return *repo
24
+ }
space/space/space/repositories/repository.go ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package repositories
2
+
3
+ import (
4
+ "api.qobiltu.id/config"
5
+ "gorm.io/gorm"
6
+ )
7
+
8
+ type Repositories interface {
9
+ FindAllPaginate()
10
+ Where()
11
+ Find()
12
+ Create()
13
+ Update()
14
+ CustomQuery()
15
+ Delete()
16
+ }
17
+ type PaginationConstructor struct {
18
+ Limit int
19
+ Offset int
20
+ Filter string
21
+ }
22
+
23
+ type CustomQueryConstructor struct {
24
+ SQL string
25
+ Values interface{}
26
+ }
27
+
28
+ type Repository[TConstructor any, TResult any] struct {
29
+ Constructor TConstructor
30
+ Pagination PaginationConstructor
31
+ CustomQuery CustomQueryConstructor
32
+ Result TResult
33
+ Transaction *gorm.DB
34
+ RowsCount int
35
+ NoRecord bool
36
+ RowsError error
37
+ }
38
+
39
+ func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Repository[TConstructor, TResult] {
40
+ if len(constructor) == 1 {
41
+ return &Repository[TConstructor, TResult]{
42
+ Constructor: constructor[0],
43
+ Transaction: config.DB,
44
+ }
45
+ }
46
+ return &Repository[TConstructor, TResult]{
47
+ Constructor: constructor[0],
48
+ Transaction: config.DB.Begin(),
49
+ }
50
+ }
51
+ func (repo *Repository[T1, T2]) Transactions(transactions ...func(*Repository[T1, T2]) *gorm.DB) {
52
+ for _, tx := range transactions {
53
+ repo.Transaction = tx(repo)
54
+ if repo.RowsError != nil {
55
+ return
56
+ }
57
+ }
58
+ }
59
+ func WhereGivenConstructor[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
60
+ tx := repo.Transaction.Where(&repo.Constructor)
61
+ repo.RowsCount = int(tx.RowsAffected)
62
+ repo.NoRecord = repo.RowsCount == 0
63
+ repo.RowsError = tx.Error
64
+ return tx
65
+ }
66
+ func Find[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
67
+ tx := repo.Transaction.Find(&repo.Result)
68
+ repo.RowsCount = int(tx.RowsAffected)
69
+ repo.NoRecord = repo.RowsCount == 0
70
+ repo.RowsError = tx.Error
71
+ return tx
72
+ }
73
+
74
+ func FinddAllPaginate[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
75
+ tx := repo.Transaction.Limit(repo.Pagination.Limit).Offset(repo.Pagination.Offset).Find(&repo.Result)
76
+ repo.RowsCount = int(tx.RowsAffected)
77
+ repo.NoRecord = repo.RowsCount == 0
78
+ repo.RowsError = tx.Error
79
+ return tx
80
+ }
81
+
82
+ func Create[T1 any](repo *Repository[T1, T1]) *gorm.DB {
83
+ tx := repo.Transaction.Create(&repo.Constructor)
84
+ repo.RowsCount = int(tx.RowsAffected)
85
+ repo.NoRecord = repo.RowsCount == 0
86
+ repo.RowsError = tx.Error
87
+ repo.Result = repo.Constructor
88
+ return tx
89
+ }
90
+
91
+ func Update[T1 any](repo *Repository[T1, T1]) *gorm.DB {
92
+ tx := repo.Transaction.Save(&repo.Constructor)
93
+ repo.RowsCount = int(tx.RowsAffected)
94
+ repo.NoRecord = repo.RowsCount == 0
95
+ repo.RowsError = tx.Error
96
+ return tx
97
+ }
98
+
99
+ func Delete[T1 any](repo *Repository[T1, T1]) *gorm.DB {
100
+ tx := repo.Transaction.Delete(&repo.Constructor)
101
+ repo.RowsCount = int(tx.RowsAffected)
102
+ repo.NoRecord = repo.RowsCount == 0
103
+ repo.RowsError = tx.Error
104
+ return tx
105
+ }
106
+
107
+ func CustomQuery[T1 any, T2 any](repo *Repository[T1, T2]) *gorm.DB {
108
+ tx := repo.Transaction.Raw(repo.CustomQuery.SQL, repo.CustomQuery.Values).Scan(&repo.Result)
109
+ repo.RowsCount = int(tx.RowsAffected)
110
+ repo.NoRecord = repo.RowsCount == 0
111
+ repo.RowsError = tx.Error
112
+ return tx
113
+ }
space/space/space/services/login_service.go ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package services
2
+
3
+ import (
4
+ "errors"
5
+
6
+ "api.qobiltu.id/middleware"
7
+ "api.qobiltu.id/models"
8
+ "api.qobiltu.id/repositories"
9
+ )
10
+
11
+ type LoginConstructor struct {
12
+ Email string
13
+ Password string
14
+ }
15
+
16
+ type AuthenticationService struct {
17
+ Service[LoginConstructor, models.AuthenticatedUser]
18
+ }
19
+
20
+ func (s *AuthenticationService) Authenticate() {
21
+ accountData := repositories.GetAccountbyEmail(s.Constructor.Email)
22
+ if accountData.NoRecord {
23
+ s.Exception.DataNotFound = true
24
+ s.Exception.Message = "there is no account with given credentials!"
25
+ return
26
+ }
27
+ if middleware.VerifyPassword(accountData.Result.Password, s.Constructor.Password) != nil {
28
+ s.Exception.Unauthorized = true
29
+ s.Exception.Message = "incorrect password!"
30
+ return
31
+ }
32
+
33
+ token, err_tok := middleware.GenerateToken(&accountData.Result)
34
+
35
+ if err_tok != nil {
36
+ s.Error = errors.Join(s.Error, err_tok)
37
+ }
38
+
39
+ accountData.Result.Password = "SECRET"
40
+ s.Result = models.AuthenticatedUser{
41
+ Account: accountData.Result,
42
+ Token: token,
43
+ }
44
+ s.Error = accountData.RowsError
45
+ }
46
+
47
+ // LoginHandler handles user login
space/space/space/services/register_service.go ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package services
2
+
3
+ import (
4
+ "errors"
5
+
6
+ "api.qobiltu.id/middleware"
7
+ "api.qobiltu.id/models"
8
+ "api.qobiltu.id/repositories"
9
+ uuid "github.com/satori/go.uuid"
10
+ "gorm.io/gorm"
11
+ )
12
+
13
+ type RegisterService struct {
14
+ Service[models.Account, models.Account]
15
+ }
16
+
17
+ func (s *RegisterService) Create() {
18
+ if len(s.Constructor.Password) < 8 {
19
+ s.Exception.InvalidPasswordLength = true
20
+ s.Exception.Message = "Password must have at least 8 characters!"
21
+ return
22
+ }
23
+ hashed_password, err_hash := middleware.HashPassword(s.Constructor.Password)
24
+ s.Error = err_hash
25
+ s.Constructor.Password = hashed_password
26
+ s.Constructor.UUID = uuid.NewV4()
27
+ accountCreated := repositories.CreateAccount(s.Constructor)
28
+ if errors.Is(accountCreated.RowsError, gorm.ErrDuplicatedKey) {
29
+ s.Exception.DataDuplicate = true
30
+ s.Exception.Message = "Account with email " + s.Constructor.Email + " already exists!"
31
+ return
32
+ } else if errors.Is(accountCreated.RowsError, gorm.ErrModelAccessibleFieldsRequired) || errors.Is(accountCreated.RowsError, gorm.ErrInvalidData) || errors.Is(accountCreated.RowsError, gorm.ErrInvalidValue) || errors.Is(accountCreated.RowsError, gorm.ErrInvalidField) {
33
+ s.Exception.BadRequest = true
34
+ s.Exception.Message = "Bad request!"
35
+ return
36
+ }
37
+ s.Error = accountCreated.RowsError
38
+ s.Result = accountCreated.Result
39
+ s.Result.Password = "SECRET"
40
+ }
space/space/space/services/service.go ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package services
2
+
3
+ import "api.qobiltu.id/models"
4
+
5
+ type (
6
+ Services interface {
7
+ Retrieve()
8
+ Update()
9
+ Create()
10
+ Delete()
11
+ Validate()
12
+ Authenticate()
13
+ Authorize()
14
+ }
15
+ Service[TConstructor any, TResult any] struct {
16
+ Constructor TConstructor
17
+ Result TResult
18
+ Exception models.Exception
19
+ Error error
20
+ }
21
+ )
22
+
23
+ func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Service[TConstructor, TResult] {
24
+ if len(constructor) == 1 {
25
+ return &Service[TConstructor, TResult]{}
26
+ }
27
+
28
+ return &Service[TConstructor, TResult]{
29
+ Constructor: constructor[0],
30
+ }
31
+ }
space/space/space/space/README.md CHANGED
@@ -1,8 +1,71 @@
1
- ---
2
- title: Quzuu Api Dev
3
- emoji: 🐠
4
- colorFrom: indigo
5
- colorTo: gray
6
- sdk: docker
7
- pinned: false
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Golang API Boilerplate
2
+ This is a boilerplate for a RESTful API written in Golang.
3
+
4
+ ## Features
5
+ - [x] JWT Authentication
6
+ - [x] PostgreSQL Database
7
+ - [x] GORM ORM
8
+ - [x] Gin Framework
9
+ - [x] Docker Support
10
+ - [x] Environment Variables
11
+ - [x] Logging
12
+ - [x] Error Handling
13
+
14
+ ## Getting Started
15
+ 1. Clone the repository
16
+ 2. Run `go get` to download the dependencies
17
+ 3. Create a file named `.env` and add the following variables:
18
+ * `DB_HOST`
19
+ * `DB_USER`
20
+ * `DB_PASSWORD`
21
+ * `DB_NAME`
22
+ * `DB_PORT`
23
+ * `SALT`
24
+ * `HOST_ADDRESS`
25
+ * `HOST_PORT`
26
+ * `LOG_PATH`
27
+ 4. Run `go run main.go` to start the server
28
+ 5. Open your browser and navigate to `http://localhost:HOST_PORT`
29
+
30
+ ## API Endpoints
31
+ ### Authentication
32
+ - `POST /login`: Login with email and password
33
+ - `POST /register`: Register a new user
34
+ - `GET /logout`: Logout
35
+
36
+ ### Users
37
+ - `GET /users`: Get all users
38
+ - `GET /users/:id`: Get a user by ID
39
+ - `PUT /users/:id`: Update a user
40
+ - `DELETE /users/:id`: Delete a user
41
+
42
+ ## Docker Support
43
+ You can build a Docker image by running `docker build -t my-api .` and then run it with `docker run -p 8080:8080 my-api`.
44
+
45
+ ## Environment Variables
46
+ You can set the following environment variables:
47
+ - `DB_HOST`
48
+ - `DB_USER`
49
+ - `DB_PASSWORD`
50
+ - `DB_NAME`
51
+ - `DB_PORT`
52
+ - `SALT`
53
+ - `HOST_ADDRESS`
54
+ - `HOST_PORT`
55
+ - `LOG_PATH`
56
+
57
+ ## Logging
58
+ The API uses the `log` package to log errors. You can set the `LOG_PATH` environment variable to specify the log file path.
59
+
60
+ ## Error Handling
61
+ The API uses the `errors` package to handle errors. You can set the `ERROR_PATH` environment variable to specify the error file path.
62
+
63
+ # Command Documentation
64
+
65
+ ## Update Golang Project version
66
+ > go mod edit -go 1.24
67
+ > go mod tidy
68
+
69
+ ## Update all package
70
+ > go get -u ./...
71
+ > go mod tidy
space/space/space/space/config/DatabaseConfig.go CHANGED
@@ -9,26 +9,10 @@ import (
9
  "gorm.io/gorm"
10
  "gorm.io/gorm/logger"
11
 
 
12
  "github.com/joho/godotenv"
13
- "go-dp.abdanhafidz.com/models"
14
  )
15
 
16
- func AutoMigrateAll(db *gorm.DB) {
17
- // Enable logger to see SQL logs
18
- db.Logger.LogMode(logger.Info)
19
-
20
- // Auto-migrate all models
21
- err := db.AutoMigrate(
22
- &models.Account{},
23
- &models.AccountDetails{},
24
- )
25
- if err != nil {
26
- log.Fatal(err)
27
- }
28
-
29
- fmt.Println("Migration completed successfully.")
30
- }
31
-
32
  var DB *gorm.DB
33
  var err error
34
  var Salt string
@@ -58,3 +42,19 @@ func init() {
58
  // Call AutoMigrateAll to perform auto-migration
59
  AutoMigrateAll(DB)
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  "gorm.io/gorm"
10
  "gorm.io/gorm/logger"
11
 
12
+ "api.qobiltu.id/models"
13
  "github.com/joho/godotenv"
 
14
  )
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  var DB *gorm.DB
17
  var err error
18
  var Salt string
 
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
+ err := db.AutoMigrate(
52
+ &models.Account{},
53
+ &models.AccountDetails{},
54
+ )
55
+ if err != nil {
56
+ log.Fatal(err)
57
+ }
58
+
59
+ fmt.Println("Migration completed successfully.")
60
+ }
space/space/space/space/controller/LoginController.go CHANGED
@@ -1,9 +1,9 @@
1
  package controller
2
 
3
  import (
 
 
4
  "github.com/gin-gonic/gin"
5
- "go-dp.abdanhafidz.com/models"
6
- "go-dp.abdanhafidz.com/services"
7
  )
8
 
9
  func LoginController(c *gin.Context) {
 
1
  package controller
2
 
3
  import (
4
+ "api.qobiltu.id/models"
5
+ "api.qobiltu.id/services"
6
  "github.com/gin-gonic/gin"
 
 
7
  )
8
 
9
  func LoginController(c *gin.Context) {
space/space/space/space/controller/RegisterController.go CHANGED
@@ -1,9 +1,9 @@
1
  package controller
2
 
3
  import (
 
 
4
  "github.com/gin-gonic/gin"
5
- "go-dp.abdanhafidz.com/models"
6
- "go-dp.abdanhafidz.com/services"
7
  )
8
 
9
  func RegisterController(c *gin.Context) {
 
1
  package controller
2
 
3
  import (
4
+ "api.qobiltu.id/models"
5
+ "api.qobiltu.id/services"
6
  "github.com/gin-gonic/gin"
 
 
7
  )
8
 
9
  func RegisterController(c *gin.Context) {
space/space/space/space/controller/controller.go CHANGED
@@ -1,10 +1,10 @@
1
  package controller
2
 
3
  import (
 
 
 
4
  "github.com/gin-gonic/gin"
5
- "go-dp.abdanhafidz.com/models"
6
- "go-dp.abdanhafidz.com/services"
7
- "go-dp.abdanhafidz.com/utils"
8
  )
9
 
10
  type (
 
1
  package controller
2
 
3
  import (
4
+ "api.qobiltu.id/models"
5
+ "api.qobiltu.id/services"
6
+ "api.qobiltu.id/utils"
7
  "github.com/gin-gonic/gin"
 
 
 
8
  )
9
 
10
  type (
space/space/space/space/go.mod CHANGED
@@ -1,49 +1,49 @@
1
- module go-dp.abdanhafidz.com
2
 
3
- go 1.21.0
4
 
5
  require (
6
- github.com/dgrijalva/jwt-go v3.2.0+incompatible
7
- github.com/gin-gonic/gin v1.9.1
8
  github.com/joho/godotenv v1.5.1
9
- golang.org/x/crypto v0.32.0
10
- gorm.io/driver/postgres v1.5.4
11
- gorm.io/gorm v1.25.5
 
12
  )
13
 
14
  require (
15
- github.com/bytedance/sonic v1.10.2 // indirect
16
- github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
17
- github.com/chenzhuoyu/iasm v0.9.0 // indirect
18
  github.com/gabriel-vasile/mimetype v1.4.8 // indirect
19
- github.com/gin-contrib/sse v0.1.0 // indirect
20
  github.com/go-playground/locales v0.14.1 // indirect
21
  github.com/go-playground/universal-translator v0.18.1 // indirect
22
  github.com/go-playground/validator/v10 v10.25.0 // indirect
23
- github.com/goccy/go-json v0.10.2 // indirect
24
  github.com/jackc/pgpassfile v1.0.0 // indirect
25
- github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
26
- github.com/jackc/pgx/v5 v5.5.0 // indirect
27
- github.com/jackc/puddle/v2 v2.2.1 // indirect
28
  github.com/jinzhu/inflection v1.0.0 // indirect
29
  github.com/jinzhu/now v1.1.5 // indirect
30
  github.com/json-iterator/go v1.1.12 // indirect
31
- github.com/klauspost/cpuid/v2 v2.2.6 // indirect
32
  github.com/kr/text v0.2.0 // indirect
33
  github.com/leodido/go-urn v1.4.0 // indirect
34
  github.com/mattn/go-isatty v0.0.20 // indirect
35
  github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
36
  github.com/modern-go/reflect2 v1.0.2 // indirect
37
- github.com/pelletier/go-toml/v2 v2.1.0 // indirect
38
  github.com/rogpeppe/go-internal v1.11.0 // indirect
39
- github.com/satori/go.uuid v1.2.0 // indirect
40
  github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
41
- github.com/ugorji/go/codec v1.2.11 // indirect
42
- golang.org/x/arch v0.6.0 // indirect
43
- golang.org/x/net v0.34.0 // indirect
44
- golang.org/x/sync v0.10.0 // indirect
45
- golang.org/x/sys v0.29.0 // indirect
46
- golang.org/x/text v0.21.0 // indirect
47
- google.golang.org/protobuf v1.31.0 // indirect
48
  gopkg.in/yaml.v3 v3.0.1 // indirect
49
- )
 
1
+ module api.qobiltu.id
2
 
3
+ go 1.24.0
4
 
5
  require (
6
+ github.com/gin-gonic/gin v1.10.0
7
+ github.com/golang-jwt/jwt/v5 v5.2.1
8
  github.com/joho/godotenv v1.5.1
9
+ github.com/satori/go.uuid v1.2.0
10
+ golang.org/x/crypto v0.36.0
11
+ gorm.io/driver/postgres v1.5.11
12
+ gorm.io/gorm v1.25.12
13
  )
14
 
15
  require (
16
+ github.com/bytedance/sonic v1.13.1 // indirect
17
+ github.com/bytedance/sonic/loader v0.2.4 // indirect
18
+ github.com/cloudwego/base64x v0.1.5 // indirect
19
  github.com/gabriel-vasile/mimetype v1.4.8 // indirect
20
+ github.com/gin-contrib/sse v1.0.0 // indirect
21
  github.com/go-playground/locales v0.14.1 // indirect
22
  github.com/go-playground/universal-translator v0.18.1 // indirect
23
  github.com/go-playground/validator/v10 v10.25.0 // indirect
24
+ github.com/goccy/go-json v0.10.5 // indirect
25
  github.com/jackc/pgpassfile v1.0.0 // indirect
26
+ github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
27
+ github.com/jackc/pgx/v5 v5.7.2 // indirect
28
+ github.com/jackc/puddle/v2 v2.2.2 // indirect
29
  github.com/jinzhu/inflection v1.0.0 // indirect
30
  github.com/jinzhu/now v1.1.5 // indirect
31
  github.com/json-iterator/go v1.1.12 // indirect
32
+ github.com/klauspost/cpuid/v2 v2.2.10 // indirect
33
  github.com/kr/text v0.2.0 // indirect
34
  github.com/leodido/go-urn v1.4.0 // indirect
35
  github.com/mattn/go-isatty v0.0.20 // indirect
36
  github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
37
  github.com/modern-go/reflect2 v1.0.2 // indirect
38
+ github.com/pelletier/go-toml/v2 v2.2.3 // indirect
39
  github.com/rogpeppe/go-internal v1.11.0 // indirect
 
40
  github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
41
+ github.com/ugorji/go/codec v1.2.12 // indirect
42
+ golang.org/x/arch v0.15.0 // indirect
43
+ golang.org/x/net v0.37.0 // indirect
44
+ golang.org/x/sync v0.12.0 // indirect
45
+ golang.org/x/sys v0.31.0 // indirect
46
+ golang.org/x/text v0.23.0 // indirect
47
+ google.golang.org/protobuf v1.36.5 // indirect
48
  gopkg.in/yaml.v3 v3.0.1 // indirect
49
+ )
space/space/space/space/go.sum CHANGED
@@ -1,51 +1,44 @@
1
- github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
2
- github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
3
- github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
4
- github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
5
- github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
6
- github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
7
- github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
8
- github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
9
- github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
10
- github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
11
  github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
12
  github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13
  github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
14
  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
15
- github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
16
- github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
17
- github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
18
- github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
19
  github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
20
  github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
21
- github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
22
- github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
23
- github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
24
- github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
25
  github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
26
  github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
27
  github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
28
  github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
29
  github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
30
  github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
31
- github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE=
32
- github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
33
  github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
34
  github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
35
- github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
36
- github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
37
- github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 
38
  github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
39
  github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
40
  github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
41
  github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
42
  github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
43
- github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
44
- github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
45
- github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw=
46
- github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
47
- github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
48
- github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
49
  github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
50
  github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
51
  github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@@ -55,15 +48,13 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA
55
  github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
56
  github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
57
  github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
58
- github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
59
- github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
60
  github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
61
  github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
62
  github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
63
  github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
64
  github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
65
- github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
66
- github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
67
  github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
68
  github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
69
  github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
@@ -73,8 +64,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
73
  github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
74
  github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
75
  github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
76
- github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
77
- github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
78
  github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
79
  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
80
  github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
@@ -84,57 +75,44 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
84
  github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
85
  github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
86
  github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 
87
  github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
88
  github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
89
  github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
90
  github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
91
  github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
92
- github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
93
- github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
94
  github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 
 
95
  github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
96
  github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
97
- github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
98
- github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
99
- golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
100
- golang.org/x/arch v0.6.0 h1:S0JTfE48HbRj80+4tbvZDYsJ3tGv6BUU3XxyZ7CirAc=
101
- golang.org/x/arch v0.6.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
102
- golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
103
- golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
104
- golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
105
- golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
106
- golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
107
- golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
108
- golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
109
- golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
110
- golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
111
- golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
112
- golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
113
- golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
114
- golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
115
  golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
116
- golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
117
- golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
118
- golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
119
- golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
120
- golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
121
- golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
122
- golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
123
- golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
124
  golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
125
  golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
126
- google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
127
- google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
128
- google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
129
  gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
130
  gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
131
  gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
132
  gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
133
  gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
134
  gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
135
- gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo=
136
- gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0=
137
- gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
138
- gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
139
- nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
140
- rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
 
1
+ github.com/bytedance/sonic v1.13.1 h1:Jyd5CIvdFnkOWuKXr+wm4Nyk2h0yAFsr8ucJgEasO3g=
2
+ github.com/bytedance/sonic v1.13.1/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
3
+ github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
4
+ github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
5
+ github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
6
+ github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
7
+ github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
8
+ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
 
 
9
  github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
10
  github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11
  github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
12
  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 
 
 
 
13
  github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
14
  github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
15
+ github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
16
+ github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
17
+ github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
18
+ github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
19
  github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
20
  github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
21
  github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
22
  github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
23
  github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
24
  github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
 
 
25
  github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
26
  github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
27
+ github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
28
+ github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
29
+ github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
30
+ github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
31
  github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
32
  github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
33
  github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
34
  github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
35
  github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
36
+ github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
37
+ github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
38
+ github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=
39
+ github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
40
+ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
41
+ github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
42
  github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
43
  github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
44
  github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
 
48
  github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
49
  github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
50
  github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
51
+ github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
52
+ github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
53
  github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
54
  github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
55
  github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
56
  github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
57
  github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 
 
58
  github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
59
  github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
60
  github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 
64
  github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
65
  github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
66
  github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
67
+ github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
68
+ github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
69
  github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
70
  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
71
  github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
 
75
  github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
76
  github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
77
  github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
78
+ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
79
  github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
80
  github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
81
  github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
82
  github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
83
  github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 
 
84
  github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
85
+ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
86
+ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
87
  github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
88
  github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
89
+ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
90
+ github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
91
+ golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
92
+ golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
93
+ golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
94
+ golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
95
+ golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
96
+ golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
97
+ golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
98
+ golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
 
 
 
 
 
 
 
 
99
  golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
100
+ golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
101
+ golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
102
+ golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
103
+ golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
 
 
 
 
104
  golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
105
  golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
106
+ google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
107
+ google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
 
108
  gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
109
  gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
110
  gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
111
  gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
112
  gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
113
  gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
114
+ gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314=
115
+ gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
116
+ gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
117
+ gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
118
+ nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
 
space/space/space/space/main.go CHANGED
@@ -3,8 +3,8 @@ package main
3
  import (
4
  "fmt"
5
 
6
- "go-dp.abdanhafidz.com/config"
7
- "go-dp.abdanhafidz.com/router"
8
  )
9
 
10
  func main() {
 
3
  import (
4
  "fmt"
5
 
6
+ "api.qobiltu.id/config"
7
+ "api.qobiltu.id/router"
8
  )
9
 
10
  func main() {
space/space/space/space/middleware/AuthMiddleware.go CHANGED
@@ -6,10 +6,10 @@ import (
6
  "errors"
7
  "time"
8
 
9
- "github.com/dgrijalva/jwt-go"
 
10
  "github.com/gin-gonic/gin"
11
- "go-dp.abdanhafidz.com/config"
12
- "go-dp.abdanhafidz.com/models"
13
  "golang.org/x/crypto/bcrypt"
14
  )
15
 
@@ -51,8 +51,8 @@ func HashPassword(password string) (string, error) {
51
  }
52
 
53
  type CustomClaims struct {
54
- jwt.StandardClaims
55
- IDUser int `json:"id"`
56
  }
57
 
58
  func VerifyToken(bearer_token string) (int, string, error) {
@@ -63,33 +63,34 @@ func VerifyToken(bearer_token string) (int, string, error) {
63
  if err != nil {
64
  return 0, "invalid-token", err
65
  }
 
 
66
  claims, ok := token.Claims.(*CustomClaims)
67
  if !ok || !token.Valid {
68
  return 0, "invalid-token", err
69
- } else if claims.StandardClaims.ExpiresAt != 0 && claims.ExpiresAt < time.Now().Unix() {
 
70
  return 0, "expired", err
71
- } else if !ok && token.Valid {
72
- return 0, "invalid-token", err
73
  }
74
 
75
- return claims.IDUser, "valid", err
76
  }
77
 
78
  func AuthUser(c *gin.Context) {
79
  var currAccData models.AccountData
80
  if c.Request.Header["Auth-Bearer-Token"] != nil {
81
  token := c.Request.Header["Auth-Bearer-Token"]
82
- currAccData.IdUser, currAccData.VerifyStatus, currAccData.ErrVerif = VerifyToken(token[0])
83
  // fmt.Println("Verify Status :", currAccData.verifyStatus)
84
  if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
85
- currAccData.IdUser = 0
86
  message := "Your session is expired, Please re-Login!"
87
  SendJSON401(c, &currAccData.VerifyStatus, &message)
88
  c.Abort()
89
  return
90
  }
91
  } else {
92
- currAccData.IdUser = 0
93
  currAccData.VerifyStatus = "no-token"
94
  currAccData.ErrVerif = nil
95
  message := "You have to Login First!"
 
6
  "errors"
7
  "time"
8
 
9
+ "api.qobiltu.id/config"
10
+ "api.qobiltu.id/models"
11
  "github.com/gin-gonic/gin"
12
+ "github.com/golang-jwt/jwt/v5"
 
13
  "golang.org/x/crypto/bcrypt"
14
  )
15
 
 
51
  }
52
 
53
  type CustomClaims struct {
54
+ jwt.RegisteredClaims
55
+ UserID int `json:"id"`
56
  }
57
 
58
  func VerifyToken(bearer_token string) (int, string, error) {
 
63
  if err != nil {
64
  return 0, "invalid-token", err
65
  }
66
+
67
+ // Extract the claims
68
  claims, ok := token.Claims.(*CustomClaims)
69
  if !ok || !token.Valid {
70
  return 0, "invalid-token", err
71
+ }
72
+ if claims.ExpiresAt != nil && claims.ExpiresAt.Time.Before(time.Now()) {
73
  return 0, "expired", err
 
 
74
  }
75
 
76
+ return claims.UserID, "valid", err
77
  }
78
 
79
  func AuthUser(c *gin.Context) {
80
  var currAccData models.AccountData
81
  if c.Request.Header["Auth-Bearer-Token"] != nil {
82
  token := c.Request.Header["Auth-Bearer-Token"]
83
+ currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = VerifyToken(token[0])
84
  // fmt.Println("Verify Status :", currAccData.verifyStatus)
85
  if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {
86
+ currAccData.UserID = 0
87
  message := "Your session is expired, Please re-Login!"
88
  SendJSON401(c, &currAccData.VerifyStatus, &message)
89
  c.Abort()
90
  return
91
  }
92
  } else {
93
+ currAccData.UserID = 0
94
  currAccData.VerifyStatus = "no-token"
95
  currAccData.ErrVerif = nil
96
  message := "You have to Login First!"
space/space/space/space/repositories/AccountRepository.go CHANGED
@@ -1,7 +1,7 @@
1
  package repositories
2
 
3
  import (
4
- "go-dp.abdanhafidz.com/models"
5
  )
6
 
7
  func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
 
1
  package repositories
2
 
3
  import (
4
+ "api.qobiltu.id/models"
5
  )
6
 
7
  func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
space/space/space/space/repositories/DatabaseScoope.go CHANGED
@@ -1,5 +1,5 @@
1
  package repositories
2
 
3
- import "go-dp.abdanhafidz.com/config"
4
 
5
  var db = config.DB
 
1
  package repositories
2
 
3
+ import "api.qobiltu.id/config"
4
 
5
  var db = config.DB
space/space/space/space/repositories/repositories.go CHANGED
@@ -1,7 +1,7 @@
1
  package repositories
2
 
3
  import (
4
- "go-dp.abdanhafidz.com/config"
5
  "gorm.io/gorm"
6
  )
7
 
 
1
  package repositories
2
 
3
  import (
4
+ "api.qobiltu.id/config"
5
  "gorm.io/gorm"
6
  )
7
 
space/space/space/space/router/router.go CHANGED
@@ -1,9 +1,9 @@
1
  package router
2
 
3
  import (
 
 
4
  "github.com/gin-gonic/gin"
5
- "go-dp.abdanhafidz.com/config"
6
- "go-dp.abdanhafidz.com/controller"
7
  )
8
 
9
  func StartService() {
 
1
  package router
2
 
3
  import (
4
+ "api.qobiltu.id/config"
5
+ "api.qobiltu.id/controller"
6
  "github.com/gin-gonic/gin"
 
 
7
  )
8
 
9
  func StartService() {
space/space/space/space/services/LoginService.go CHANGED
@@ -3,9 +3,9 @@ package services
3
  import (
4
  "errors"
5
 
6
- "go-dp.abdanhafidz.com/middleware"
7
- "go-dp.abdanhafidz.com/models"
8
- "go-dp.abdanhafidz.com/repositories"
9
  )
10
 
11
  type LoginConstructor struct {
 
3
  import (
4
  "errors"
5
 
6
+ "api.qobiltu.id/middleware"
7
+ "api.qobiltu.id/models"
8
+ "api.qobiltu.id/repositories"
9
  )
10
 
11
  type LoginConstructor struct {
space/space/space/space/services/RegisterService.go CHANGED
@@ -3,10 +3,10 @@ package services
3
  import (
4
  "errors"
5
 
 
 
 
6
  uuid "github.com/satori/go.uuid"
7
- "go-dp.abdanhafidz.com/middleware"
8
- "go-dp.abdanhafidz.com/models"
9
- "go-dp.abdanhafidz.com/repositories"
10
  "gorm.io/gorm"
11
  )
12
 
 
3
  import (
4
  "errors"
5
 
6
+ "api.qobiltu.id/middleware"
7
+ "api.qobiltu.id/models"
8
+ "api.qobiltu.id/repositories"
9
  uuid "github.com/satori/go.uuid"
 
 
 
10
  "gorm.io/gorm"
11
  )
12
 
space/space/space/space/services/services.go CHANGED
@@ -1,6 +1,6 @@
1
  package services
2
 
3
- import "go-dp.abdanhafidz.com/models"
4
 
5
  type (
6
  Services interface {
@@ -21,7 +21,7 @@ type (
21
  )
22
 
23
  func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Service[TConstructor, TResult] {
24
- if len(constructor) == 0 {
25
  return &Service[TConstructor, TResult]{}
26
  }
27
 
 
1
  package services
2
 
3
+ import "api.qobiltu.id/models"
4
 
5
  type (
6
  Services interface {
 
21
  )
22
 
23
  func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Service[TConstructor, TResult] {
24
+ if len(constructor) == 1 {
25
  return &Service[TConstructor, TResult]{}
26
  }
27
 
space/space/space/space/space/models/ExceptionModel.go CHANGED
@@ -1,11 +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
- Message string `json:"message,omitempty"`
 
11
  }
 
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
  }
space/space/space/space/space/services/RegisterService.go CHANGED
@@ -15,6 +15,11 @@ type RegisterService struct {
15
  }
16
 
17
  func (s *RegisterService) Create() {
 
 
 
 
 
18
  hashed_password, err_hash := middleware.HashPassword(s.Constructor.Password)
19
  s.Error = err_hash
20
  s.Constructor.Password = hashed_password
 
15
  }
16
 
17
  func (s *RegisterService) Create() {
18
+ if len(s.Constructor.Password) < 8 {
19
+ s.Exception.InvalidPasswordLength = true
20
+ s.Exception.Message = "Password must have at least 8 characters!"
21
+ return
22
+ }
23
  hashed_password, err_hash := middleware.HashPassword(s.Constructor.Password)
24
  s.Error = err_hash
25
  s.Constructor.Password = hashed_password
space/space/space/space/space/space/repositories/AccountRepository.go CHANGED
@@ -4,9 +4,9 @@ import (
4
  "go-dp.abdanhafidz.com/models"
5
  )
6
 
7
- func GetAccountbyEmailPassword(email string, password string) Repository[models.Account, models.Account] {
8
  repo := Construct[models.Account, models.Account](
9
- models.Account{Email: email, Password: password},
10
  )
11
  repo.Transactions(
12
  WhereGivenConstructor[models.Account, models.Account],
 
4
  "go-dp.abdanhafidz.com/models"
5
  )
6
 
7
+ func GetAccountbyEmail(email string) Repository[models.Account, models.Account] {
8
  repo := Construct[models.Account, models.Account](
9
+ models.Account{Email: email},
10
  )
11
  repo.Transactions(
12
  WhereGivenConstructor[models.Account, models.Account],
space/space/space/space/space/space/repositories/repositories.go CHANGED
@@ -1,8 +1,6 @@
1
  package repositories
2
 
3
  import (
4
- "strconv"
5
-
6
  "go-dp.abdanhafidz.com/config"
7
  "gorm.io/gorm"
8
  )
@@ -51,15 +49,10 @@ func Construct[TConstructor any, TResult any](constructor ...TConstructor) *Repo
51
  }
52
  }
53
  func (repo *Repository[T1, T2]) Transactions(transactions ...func(*Repository[T1, T2]) *gorm.DB) {
54
- i := 1
55
  for _, tx := range transactions {
56
  repo.Transaction = tx(repo)
57
  if repo.RowsError != nil {
58
- repo.Transaction.Rollback()
59
  return
60
- } else {
61
- repo.Transaction.SavePoint("Save Point : " + strconv.Itoa(i))
62
- repo.Transaction.Commit()
63
  }
64
  }
65
  }
 
1
  package repositories
2
 
3
  import (
 
 
4
  "go-dp.abdanhafidz.com/config"
5
  "gorm.io/gorm"
6
  )
 
49
  }
50
  }
51
  func (repo *Repository[T1, T2]) Transactions(transactions ...func(*Repository[T1, T2]) *gorm.DB) {
 
52
  for _, tx := range transactions {
53
  repo.Transaction = tx(repo)
54
  if repo.RowsError != nil {
 
55
  return
 
 
 
56
  }
57
  }
58
  }
space/space/space/space/space/space/services/LoginService.go CHANGED
@@ -18,7 +18,7 @@ type AuthenticationService struct {
18
  }
19
 
20
  func (s *AuthenticationService) Authenticate() {
21
- accountData := repositories.GetAccountbyEmailPassword(s.Constructor.Email, s.Constructor.Password)
22
  if accountData.NoRecord {
23
  s.Exception.DataNotFound = true
24
  s.Exception.Message = "there is no account with given credentials!"
 
18
  }
19
 
20
  func (s *AuthenticationService) Authenticate() {
21
+ accountData := repositories.GetAccountbyEmail(s.Constructor.Email)
22
  if accountData.NoRecord {
23
  s.Exception.DataNotFound = true
24
  s.Exception.Message = "there is no account with given credentials!"
space/space/space/space/space/space/services/RegisterService.go CHANGED
@@ -3,6 +3,7 @@ package services
3
  import (
4
  "errors"
5
 
 
6
  "go-dp.abdanhafidz.com/middleware"
7
  "go-dp.abdanhafidz.com/models"
8
  "go-dp.abdanhafidz.com/repositories"
@@ -17,6 +18,7 @@ func (s *RegisterService) Create() {
17
  hashed_password, err_hash := middleware.HashPassword(s.Constructor.Password)
18
  s.Error = err_hash
19
  s.Constructor.Password = hashed_password
 
20
  accountCreated := repositories.CreateAccount(s.Constructor)
21
  if errors.Is(accountCreated.RowsError, gorm.ErrDuplicatedKey) {
22
  s.Exception.DataDuplicate = true
 
3
  import (
4
  "errors"
5
 
6
+ uuid "github.com/satori/go.uuid"
7
  "go-dp.abdanhafidz.com/middleware"
8
  "go-dp.abdanhafidz.com/models"
9
  "go-dp.abdanhafidz.com/repositories"
 
18
  hashed_password, err_hash := middleware.HashPassword(s.Constructor.Password)
19
  s.Error = err_hash
20
  s.Constructor.Password = hashed_password
21
+ s.Constructor.UUID = uuid.NewV4()
22
  accountCreated := repositories.CreateAccount(s.Constructor)
23
  if errors.Is(accountCreated.RowsError, gorm.ErrDuplicatedKey) {
24
  s.Exception.DataDuplicate = true
space/space/space/space/space/space/space/go.mod CHANGED
@@ -36,6 +36,7 @@ require (
36
  github.com/modern-go/reflect2 v1.0.2 // indirect
37
  github.com/pelletier/go-toml/v2 v2.1.0 // indirect
38
  github.com/rogpeppe/go-internal v1.11.0 // indirect
 
39
  github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
40
  github.com/ugorji/go/codec v1.2.11 // indirect
41
  golang.org/x/arch v0.6.0 // indirect
 
36
  github.com/modern-go/reflect2 v1.0.2 // indirect
37
  github.com/pelletier/go-toml/v2 v2.1.0 // indirect
38
  github.com/rogpeppe/go-internal v1.11.0 // indirect
39
+ github.com/satori/go.uuid v1.2.0 // indirect
40
  github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
41
  github.com/ugorji/go/codec v1.2.11 // indirect
42
  golang.org/x/arch v0.6.0 // indirect
space/space/space/space/space/space/space/go.sum CHANGED
@@ -79,6 +79,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
79
  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
80
  github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
81
  github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
 
 
82
  github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
83
  github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
84
  github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 
79
  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
80
  github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
81
  github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
82
+ github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
83
+ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
84
  github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
85
  github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
86
  github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
space/space/space/space/space/space/space/models/DatabaseModel.go CHANGED
@@ -2,14 +2,18 @@ package models
2
 
3
  import (
4
  "time"
 
 
5
  )
6
 
7
  type Account struct {
8
- Id uint `gorm:"primaryKey" json:"id"`
9
- Email string `gorm:"uniqueIndex" json:"email"`
10
- Password string `json:"password"`
11
- CreatedAt time.Time `json:"created_at"`
12
- DeletedAt time.Time `json:"deleted_at"`
 
 
13
  }
14
 
15
  type AccountDetails struct {
@@ -22,6 +26,14 @@ type AccountDetails struct {
22
  DeletedAt time.Time `json:"deleted_at"`
23
  }
24
 
 
 
 
 
 
 
 
 
25
  // Gorm table name settings
26
  func (Account) TableName() string { return "account" }
27
  func (AccountDetails) TableName() string { return "account_details" }
 
2
 
3
  import (
4
  "time"
5
+
6
+ uuid "github.com/satori/go.uuid"
7
  )
8
 
9
  type Account struct {
10
+ Id uint `gorm:"primaryKey" json:"id"`
11
+ UUID uuid.UUID `gorm:"type:uuid" json:"uuid" `
12
+ Email string `gorm:"uniqueIndex" json:"email"`
13
+ Password string `json:"password"`
14
+ IsEmailVerified bool `json:"is_email_verified"`
15
+ CreatedAt time.Time `json:"created_at"`
16
+ DeletedAt time.Time `json:"deleted_at"`
17
  }
18
 
19
  type AccountDetails struct {
 
26
  DeletedAt time.Time `json:"deleted_at"`
27
  }
28
 
29
+ type EmailVerification struct {
30
+ Id int `gorm:"primaryKey" json:"id"`
31
+ AccountId int `json:"account_id"`
32
+ UUID uuid.UUID `gorm:"type:uuid" json:"uuid" `
33
+ CreatedAt time.Time `json:"created_at"`
34
+ ExpiredAt time.Time `json:"expired_at"`
35
+ }
36
+
37
  // Gorm table name settings
38
  func (Account) TableName() string { return "account" }
39
  func (AccountDetails) TableName() string { return "account_details" }
space/space/space/space/space/space/space/repositories/AccountRepository.go CHANGED
@@ -1,8 +1,6 @@
1
  package repositories
2
 
3
  import (
4
- "fmt"
5
-
6
  "go-dp.abdanhafidz.com/models"
7
  )
8
 
@@ -10,7 +8,6 @@ func GetAccountbyEmailPassword(email string, password string) Repository[models.
10
  repo := Construct[models.Account, models.Account](
11
  models.Account{Email: email, Password: password},
12
  )
13
- fmt.Println(repo.Constructor)
14
  repo.Transactions(
15
  WhereGivenConstructor[models.Account, models.Account],
16
  Find[models.Account, models.Account],
 
1
  package repositories
2
 
3
  import (
 
 
4
  "go-dp.abdanhafidz.com/models"
5
  )
6
 
 
8
  repo := Construct[models.Account, models.Account](
9
  models.Account{Email: email, Password: password},
10
  )
 
11
  repo.Transactions(
12
  WhereGivenConstructor[models.Account, models.Account],
13
  Find[models.Account, models.Account],
space/space/space/space/space/space/space/services/RegisterService.go CHANGED
@@ -14,7 +14,8 @@ type RegisterService struct {
14
  }
15
 
16
  func (s *RegisterService) Create() {
17
- hashed_password, _ := middleware.HashPassword(s.Constructor.Password)
 
18
  s.Constructor.Password = hashed_password
19
  accountCreated := repositories.CreateAccount(s.Constructor)
20
  if errors.Is(accountCreated.RowsError, gorm.ErrDuplicatedKey) {
@@ -26,7 +27,7 @@ func (s *RegisterService) Create() {
26
  s.Exception.Message = "Bad request!"
27
  return
28
  }
29
-
30
  s.Result = accountCreated.Result
31
  s.Result.Password = "SECRET"
32
  }
 
14
  }
15
 
16
  func (s *RegisterService) Create() {
17
+ hashed_password, err_hash := middleware.HashPassword(s.Constructor.Password)
18
+ s.Error = err_hash
19
  s.Constructor.Password = hashed_password
20
  accountCreated := repositories.CreateAccount(s.Constructor)
21
  if errors.Is(accountCreated.RowsError, gorm.ErrDuplicatedKey) {
 
27
  s.Exception.Message = "Bad request!"
28
  return
29
  }
30
+ s.Error = accountCreated.RowsError
31
  s.Result = accountCreated.Result
32
  s.Result.Password = "SECRET"
33
  }