pre-dev: initial commit

This commit is contained in:
2025-08-11 10:41:25 +07:00
parent e0ecf1c906
commit ee9b4a9035
50 changed files with 1020 additions and 1 deletions

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,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,31 @@
/*
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 sampel shows a workaround on how to avoid the circle-depency which is a
common problem when it involves the parent-child relationship. By default,
the relationship is defined in the child entity, and when the parent entity
needs to use the child as an attribute (array for example), the circle-depency
happens.
To avoid this problem, the parent will have a case-entity like 'full' entity,
which embeds the 'base' and the 'child' structs.
TODO:
- replace 'parent' with the name of the package, ie: myentity
- replace 'Parent' with the name of the entity, ie: MyEntity
*/
package parent
import (
ecore "simrs-vx/internal/domain/base-entities/core"
eb "simrs-vx/internal/domain/main-entities/parent/base"
)
type Parent struct {
ecore.Main
eb.Basic
eb.Default
eb.Extra
}
@@ -0,0 +1,24 @@
/*
DESCRIPTION:
Sample of a case-entity that utilized the base according to the needs. In this
sample, it imports the child entity, and uses it as an attribute. And by
separating this entity from the original entity, it avoids the circle dependency.
TODO:
replace 'parent' with the name of the package, ie: patient
replace 'Parent' with the name of the entity, ie: Patient
*/
package parent
import (
ec "simrs-vx/internal/domain/main-entities/child"
eb "simrs-vx/internal/domain/main-entities/parent/base"
// ec "simrs-vx/internal/domain/main-entities/child/minimal" // can use other case
)
type Parent struct {
Id int `json:"id"`
eb.Basic
eb.Default
Childs []ec.Child `json:"childs" gorm:"foreignKey:Parent_Id;references:Id"`
}
@@ -0,0 +1,19 @@
/*
DESCRIPTION:
Sample of a case-entity that utilized the base according to the needs.
TODO:
replace 'parent' with the name of the package, ie: patient
replace 'Parent' with the name of the entity, ie: Patient
*/
package parent
import (
eb "simrs-vx/internal/domain/main-entities/parent/base"
)
type Parent struct {
Id int `json:"id"`
eb.Basic
eb.Default
}