Mhamdans17 commited on
Commit ·
ac5c922
1
Parent(s): 17e3823
feat: add optional NPWP field during registration
Browse files- controllers/auth_controller.go +2 -0
- fix_constraints.go +23 -0
- fix_constraints_2.go +30 -0
- models/models.go +1 -0
controllers/auth_controller.go
CHANGED
|
@@ -103,6 +103,7 @@ type RegisterRequest struct {
|
|
| 103 |
type TenantRegistrationRequest struct {
|
| 104 |
CompanyName string `json:"company_name" binding:"required"`
|
| 105 |
CompanyAddress string `json:"company_address"`
|
|
|
|
| 106 |
OwnerName string `json:"owner_name" binding:"required"`
|
| 107 |
OwnerEmail string `json:"owner_email" binding:"required,email"`
|
| 108 |
OwnerPhone string `json:"owner_phone" binding:"required"`
|
|
@@ -286,6 +287,7 @@ func RegisterTenant(c *gin.Context) {
|
|
| 286 |
comp := models.Company{
|
| 287 |
Name: req.CompanyName,
|
| 288 |
Address: req.CompanyAddress,
|
|
|
|
| 289 |
BankAccountNumber: req.BankAccountNumber,
|
| 290 |
BankName: req.BankName,
|
| 291 |
Email: req.OwnerEmail,
|
|
|
|
| 103 |
type TenantRegistrationRequest struct {
|
| 104 |
CompanyName string `json:"company_name" binding:"required"`
|
| 105 |
CompanyAddress string `json:"company_address"`
|
| 106 |
+
NPWP string `json:"npwp"`
|
| 107 |
OwnerName string `json:"owner_name" binding:"required"`
|
| 108 |
OwnerEmail string `json:"owner_email" binding:"required,email"`
|
| 109 |
OwnerPhone string `json:"owner_phone" binding:"required"`
|
|
|
|
| 287 |
comp := models.Company{
|
| 288 |
Name: req.CompanyName,
|
| 289 |
Address: req.CompanyAddress,
|
| 290 |
+
NPWP: req.NPWP,
|
| 291 |
BankAccountNumber: req.BankAccountNumber,
|
| 292 |
BankName: req.BankName,
|
| 293 |
Email: req.OwnerEmail,
|
fix_constraints.go
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"log"
|
| 5 |
+
"service-warungpos-go/config"
|
| 6 |
+
"service-warungpos-go/models"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
func main() {
|
| 10 |
+
config.LoadConfig()
|
| 11 |
+
config.ConnectDatabase()
|
| 12 |
+
|
| 13 |
+
log.Println("Dropping constraints...")
|
| 14 |
+
config.DB.Exec("ALTER TABLE members DROP CONSTRAINT IF EXISTS fk_members_created_by")
|
| 15 |
+
config.DB.Exec("ALTER TABLE members DROP CONSTRAINT IF EXISTS fk_members_branch")
|
| 16 |
+
config.DB.Exec("ALTER TABLE users DROP CONSTRAINT IF EXISTS fk_users_branch")
|
| 17 |
+
config.DB.Exec("ALTER TABLE orders DROP CONSTRAINT IF EXISTS fk_orders_branch")
|
| 18 |
+
|
| 19 |
+
log.Println("Running AutoMigrate...")
|
| 20 |
+
config.DB.AutoMigrate(&models.Member{}, &models.User{}, &models.Order{})
|
| 21 |
+
|
| 22 |
+
log.Println("Done")
|
| 23 |
+
}
|
fix_constraints_2.go
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"log"
|
| 5 |
+
"service-warungpos-go/config"
|
| 6 |
+
"service-warungpos-go/models"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
func main() {
|
| 10 |
+
config.LoadConfig()
|
| 11 |
+
config.ConnectDatabase()
|
| 12 |
+
|
| 13 |
+
log.Println("Dropping more constraints...")
|
| 14 |
+
config.DB.Exec("ALTER TABLE wallet_transactions DROP CONSTRAINT IF EXISTS fk_wallet_transactions_company")
|
| 15 |
+
config.DB.Exec("ALTER TABLE wallet_transactions DROP CONSTRAINT IF EXISTS fk_companies_wallet_transactions")
|
| 16 |
+
|
| 17 |
+
config.DB.Exec("ALTER TABLE topup_requests DROP CONSTRAINT IF EXISTS fk_topup_requests_company")
|
| 18 |
+
config.DB.Exec("ALTER TABLE topup_requests DROP CONSTRAINT IF EXISTS fk_companies_topup_requests")
|
| 19 |
+
|
| 20 |
+
config.DB.Exec("ALTER TABLE point_histories DROP CONSTRAINT IF EXISTS fk_point_histories_company")
|
| 21 |
+
config.DB.Exec("ALTER TABLE point_histories DROP CONSTRAINT IF EXISTS fk_companies_point_histories")
|
| 22 |
+
|
| 23 |
+
config.DB.Exec("ALTER TABLE point_histories DROP CONSTRAINT IF EXISTS fk_point_histories_member")
|
| 24 |
+
config.DB.Exec("ALTER TABLE point_histories DROP CONSTRAINT IF EXISTS fk_members_point_histories")
|
| 25 |
+
|
| 26 |
+
log.Println("Running AutoMigrate...")
|
| 27 |
+
config.DB.AutoMigrate(&models.Company{}, &models.WalletTransaction{}, &models.TopupRequest{}, &models.PointHistory{}, &models.Member{})
|
| 28 |
+
|
| 29 |
+
log.Println("Done")
|
| 30 |
+
}
|
models/models.go
CHANGED
|
@@ -10,6 +10,7 @@ type Company struct {
|
|
| 10 |
BankAccountNumber string `gorm:"type:varchar(50)" json:"bank_account_number"`
|
| 11 |
BankName string `gorm:"type:varchar(100)" json:"bank_name"`
|
| 12 |
Address string `gorm:"type:varchar(255)" json:"address"`
|
|
|
|
| 13 |
Email string `gorm:"type:varchar(100)" json:"email"`
|
| 14 |
Phone string `gorm:"type:varchar(20)" json:"phone"`
|
| 15 |
LogoURL string `gorm:"type:varchar(255)" json:"logo_url"`
|
|
|
|
| 10 |
BankAccountNumber string `gorm:"type:varchar(50)" json:"bank_account_number"`
|
| 11 |
BankName string `gorm:"type:varchar(100)" json:"bank_name"`
|
| 12 |
Address string `gorm:"type:varchar(255)" json:"address"`
|
| 13 |
+
NPWP string `gorm:"type:varchar(50)" json:"npwp"`
|
| 14 |
Email string `gorm:"type:varchar(100)" json:"email"`
|
| 15 |
Phone string `gorm:"type:varchar(20)" json:"phone"`
|
| 16 |
LogoURL string `gorm:"type:varchar(255)" json:"logo_url"`
|