-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cedef9b
commit e730181
Showing
6 changed files
with
74 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package dto | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type Project struct { | ||
ID uint | ||
CreatedAt time.Time | ||
UpdatedAt time.Time | ||
Name string `json:"name" form:"name" validate:"required"` | ||
Description string `json:"description" form:"description"` | ||
} | ||
|
||
//TODO: Remove this later | ||
|
||
type Task struct { | ||
ID uint | ||
Title string `json:"title" form:"title" validate:"required"` | ||
Description string `json:"description" form:"description"` | ||
Status string `json:"status" form:"status"` | ||
Label string `json:"label" form:"label"` | ||
ProjectID uint `json:"projectId" form:"projectId"` | ||
CreatedAt time.Time | ||
UpdatedAt time.Time | ||
} | ||
|
||
type ProjectWithTasks struct { | ||
ID uint | ||
CreatedAt time.Time | ||
UpdatedAt time.Time | ||
Name string `json:"name" form:"name" validate:"required"` | ||
Description string `json:"description" form:"description"` | ||
Tasks []Task `json:"tasks"` | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,22 @@ | ||
package dbcontext | ||
|
||
import "gorm.io/gorm" | ||
|
||
type DBContext interface { | ||
ValidateIfExists(args ...interface{}) error | ||
} | ||
|
||
type dbcontext struct { | ||
db *gorm.DB | ||
} | ||
|
||
func NewDbContext(db *gorm.DB) *dbcontext { | ||
return &dbcontext{db} | ||
} | ||
|
||
func (d *dbcontext) ValidateIfExists(args ...interface{}) error { | ||
if err := d.db.First(args).Error; err != nil { | ||
return err | ||
} | ||
return nil | ||
} |