pre-dev: initial commit
This commit is contained in:
No files matched your search
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Sample of base-entity, results of the extraction of the attributes from the
|
||||
original entity.
|
||||
|
||||
NOTE:
|
||||
Make sure to use 'case-sensitive' option when searching
|
||||
|
||||
TODO:
|
||||
create several types according to the needs
|
||||
*/
|
||||
package base // adjust this
|
||||
|
||||
type Basic struct {
|
||||
Code string `json:"code" gorm:"uniqueIndex;not null;size:10"`
|
||||
Name string `json:"name" gorm:"not null;size:100"`
|
||||
}
|
||||
|
||||
type Default struct {
|
||||
Type_Code TypeCode `json:"type" gorm:"not null;size:10"`
|
||||
Status_Code StatusCode `json:"status" gorm:"not null;size:10"`
|
||||
}
|
||||
|
||||
type Extra struct {
|
||||
Description string `json:"description"`
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
A sample, part of the package that contains functions.
|
||||
*/
|
||||
package base
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (b *Basic) ExtractName() []string {
|
||||
return strings.Split(b.Name, " ")
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
A sample, part of the package that contains type, constants, and/or variables.
|
||||
*/
|
||||
package base // adjust this
|
||||
|
||||
type StatusCode string
|
||||
type TypeCode string
|
||||
|
||||
const (
|
||||
SCActive StatusCode = "active" // prefixed with SC that stands for StatusCode
|
||||
SCInactive StatusCode = "inactive"
|
||||
|
||||
TCPrimary TypeCode = "prim" // prefixed with TC that stands for TypeCode
|
||||
TCScondary TypeCode = "seco"
|
||||
TCTertiary TypeCode = "tert"
|
||||
)
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Sample of struct to define an entity both in the application and database.
|
||||
Uses the base struct from the core package for the standard attributes.
|
||||
|
||||
The original attributes are extracted and grouped into several parts (structs),
|
||||
which later embeded. The extracted attributes are stored into the subdirectory
|
||||
'base'.
|
||||
|
||||
The extraction is done to cover several cases regarding the eficiency the of
|
||||
the data retreiving by using only needed attributes. Each case has its own
|
||||
directory with the same struct name with the main entity that embeds the
|
||||
needed attributes from the 'base'.
|
||||
|
||||
NOTES:
|
||||
Make sure to use 'case-sensitive' option when doing search-replace
|
||||
|
||||
TODO:
|
||||
- replace 'separated' with the name of the package, ie: myentity
|
||||
- replace 'Separated' with the name of the entity, ie: MyEntity
|
||||
*/
|
||||
package separated
|
||||
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
eb "simrs-vx/internal/domain/main-entities/separated/base"
|
||||
)
|
||||
|
||||
type Separated struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
eb.Basic
|
||||
eb.Default
|
||||
eb.Extra
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Sample of a case-entity that utilized the base according to the needs.
|
||||
|
||||
NOTE:
|
||||
Make sure to use 'case-sensitive' option when searching
|
||||
|
||||
TODO:
|
||||
replace 'separated' with the name of the package, ie: myentity
|
||||
replace 'Separated' with the name of the entity, ie: MyEntity
|
||||
*/
|
||||
package separated
|
||||
|
||||
import (
|
||||
eb "simrs-vx/internal/domain/main-entities/separated/base"
|
||||
)
|
||||
|
||||
type Separated struct {
|
||||
Id int `json:"id"`
|
||||
eb.Basic
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
DESCRIPTION:
|
||||
Sample of a case-entity that utilized the base according to the needs.
|
||||
|
||||
NOTE:
|
||||
Make sure to use 'case-sensitive' option when searching
|
||||
|
||||
TODO:
|
||||
replace 'separated' with the name of the package, ie: myentity
|
||||
replace 'Separated' with the name of the entity, ie: MyEntity
|
||||
*/
|
||||
package separated
|
||||
|
||||
import (
|
||||
eb "simrs-vx/internal/domain/main-entities/separated/base"
|
||||
)
|
||||
|
||||
type Separated struct {
|
||||
Id int `json:"id"` // in many cases the usage of
|
||||
eb.Basic
|
||||
eb.Default
|
||||
}
|
||||
Reference in New Issue
Block a user