-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hngprojects:main' into feat-certbot-config-scrpt
- Loading branch information
Showing
40 changed files
with
1,719 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ _ignore/ | |
app.env | ||
tmp/ | ||
.idea/ | ||
|
||
app.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package migrations | ||
|
||
import "github.com/hngprojects/hng_boilerplate_golang_web/internal/models" | ||
|
||
func AuthMigrationModels() []interface{} { | ||
return []interface{}{ | ||
models.Organisation{}, | ||
models.Profile{}, | ||
models.Product{}, | ||
models.User{}, | ||
} // an array of db models, example: User{} | ||
} | ||
|
||
func AlterColumnModels() []AlterColumn { | ||
return []AlterColumn{} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
"gorm.io/gorm" | ||
|
||
"github.com/hngprojects/hng_boilerplate_golang_web/pkg/repository/storage/postgresql" | ||
) | ||
|
||
type Organisation struct { | ||
ID string `gorm:"type:uuid;primaryKey;unique;not null" json:"id"` | ||
Name string `gorm:"type:varchar(255);not null" json:"name"` | ||
Description string `gorm:"type:text" json:"description"` | ||
Email string `gorm:"type:varchar(255);unique" json:"email"` | ||
State string `gorm:"type:varchar(255)" json:"state"` | ||
Industry string `gorm:"type:varchar(255)" json:"industry"` | ||
Type string `gorm:"type:varchar(255)" json:"type"` | ||
Address string `gorm:"type:varchar(255)" json:"address"` | ||
Country string `gorm:"type:varchar(255)" json:"country"` | ||
OwnerID string `gorm:"type:uuid;" json:"owner_id"` | ||
Users []User `gorm:"many2many:user_organisations;foreignKey:ID;joinForeignKey:org_id;References:ID;joinReferences:user_id"` | ||
CreatedAt time.Time `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"` | ||
UpdatedAt time.Time `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"` | ||
} | ||
|
||
type CreateOrgRequestModel struct { | ||
Name string `json:"name" validate:"required,min=2,max=255"` | ||
Description string `json:"description" ` | ||
Email string `json:"email" validate:"required"` | ||
State string `json:"state" validate:"required"` | ||
Industry string `json:"industry" validate:"required"` | ||
Type string `json:"type" validate:"required"` | ||
Address string `json:"address" validate:"required"` | ||
Country string `json:"country" validate:"required"` | ||
} | ||
|
||
func (c *Organisation) CreateOrganisation(db *gorm.DB) error { | ||
|
||
err := postgresql.CreateOneRecord(db, &c) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package models | ||
|
||
import "time" | ||
|
||
type Product struct { | ||
ID string `gorm:"type:uuid;primaryKey" json:"product_id"` | ||
Name string `gorm:"column:name; type:varchar(255); not null" json:"name"` | ||
Description string `gorm:"column:description;type:text;" json:"description"` | ||
OwnerID string `gorm:"type:uuid;" json:"owner_id"` | ||
CreatedAt time.Time `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"` | ||
UpdatedAt time.Time `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package models | ||
|
||
import "time" | ||
|
||
type Profile struct { | ||
ID string `gorm:"type:uuid;primary_key" json:"profile_id"` | ||
FirstName string `gorm:"column:first_name; type:text; not null" json:"first_name"` | ||
LastName string `gorm:"column:last_name; type:text;not null" json:"last_name"` | ||
Phone string `gorm:"type:varchar(255)" json:"phone"` | ||
AvatarURL string `gorm:"type:varchar(255)" json:"avatar_url"` | ||
Userid string `gorm:"type:uuid;" json:"user_id"` | ||
CreatedAt time.Time `gorm:"column:created_at; not null; autoCreateTime" json:"created_at"` | ||
UpdatedAt time.Time `gorm:"column:updated_at; null; autoUpdateTime" json:"updated_at"` | ||
} |
Oops, something went wrong.