division, division-position ids into codes
This commit is contained in:
No files matched your search
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
type Basic struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Division_Id *uint16 `json:"division_id"`
|
||||
Division_Code *string `json:"division_code" gorm:"size:10"`
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Division_Id *uint16 `json:"division_id"`
|
||||
Code string `json:"code" validate:"maxLength=10"`
|
||||
Name string `json:"name" validate:"maxLength=50"`
|
||||
HeadStatus bool `json:"headStatus"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Code string `json:"code" validate:"maxLength=10"`
|
||||
Name string `json:"name" validate:"maxLength=50"`
|
||||
HeadStatus bool `json:"headStatus"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -22,26 +22,27 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Division_Id *uint16 `json:"division-id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
HeadStatus *bool `json:"head-status"`
|
||||
Employee_Id *uint `json:"employee-id"`
|
||||
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
||||
Division_Code *string `json:"division-code"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
HeadStatus *bool `json:"head-status"`
|
||||
Employee_Id *uint `json:"employee-id"`
|
||||
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
@@ -52,23 +53,23 @@ type MetaDto struct {
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Division_Id *uint16 `json:"division_id"`
|
||||
Division *ed.Division `json:"division,omitempty"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
HeadStatus bool `json:"headStatus"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Employee *ee.Employee `json:"employee,omitempty"`
|
||||
Division_Code *string `json:"division_code"`
|
||||
Division *ed.Division `json:"division,omitempty"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
HeadStatus bool `json:"headStatus"`
|
||||
Employee_Id *uint `json:"employee_id"`
|
||||
Employee *ee.Employee `json:"employee,omitempty"`
|
||||
}
|
||||
|
||||
func (d DivisionPosition) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Division_Id: d.Division_Id,
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
HeadStatus: d.HeadStatus,
|
||||
Employee_Id: d.Employee_Id,
|
||||
Employee: d.Employee,
|
||||
Division_Code: d.Division_Code,
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
HeadStatus: d.HeadStatus,
|
||||
Employee_Id: d.Employee_Id,
|
||||
Employee: d.Employee,
|
||||
}
|
||||
resp.SmallMain = d.SmallMain
|
||||
if d.Division != nil {
|
||||
|
||||
@@ -7,5 +7,5 @@ import (
|
||||
|
||||
type DivisionPosition struct {
|
||||
eb.Basic
|
||||
Division *ed.Division `json:"division" gorm:"foreignKey:Division_Id;references:Id"`
|
||||
Division *ed.Division `json:"division" gorm:"foreignKey:Division_Code;references:Code"`
|
||||
}
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Code string `json:"code" validate:"maxLength=10"`
|
||||
Name string `json:"name" validate:"maxLength=50"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Code string `json:"code" validate:"maxLength=10"`
|
||||
Name string `json:"name" validate:"maxLength=50"`
|
||||
Parent_Code *string `json:"parent_code"`
|
||||
}
|
||||
|
||||
type ReadListDto struct {
|
||||
@@ -20,25 +20,26 @@ type ReadListDto struct {
|
||||
}
|
||||
|
||||
type FilterDto struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Parent_Id *uint16 `json:"parent-id"`
|
||||
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Parent_Code *string `json:"parent-code"`
|
||||
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
|
||||
}
|
||||
|
||||
type ReadDetailDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
Includes string `json:"includes"`
|
||||
}
|
||||
|
||||
type UpdateDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type DeleteDto struct {
|
||||
Id uint16 `json:"id"`
|
||||
Id *uint16 `json:"id"`
|
||||
Code *string `json:"code"`
|
||||
}
|
||||
|
||||
type MetaDto struct {
|
||||
@@ -51,7 +52,7 @@ type ResponseDto struct {
|
||||
ecore.SmallMain
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Parent_Code *string `json:"parent_code"`
|
||||
Parent *Division `json:"parent,omitempty"`
|
||||
Childrens []Division `json:"childrens,omitempty"`
|
||||
DivisionPosition []edpb.Basic `json:"divisionPositions,omitempty"`
|
||||
@@ -61,7 +62,7 @@ func (d Division) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Code: d.Code,
|
||||
Name: d.Name,
|
||||
Parent_Id: d.Parent_Id,
|
||||
Parent_Code: d.Parent_Code,
|
||||
Parent: d.Parent,
|
||||
Childrens: d.Childrens,
|
||||
DivisionPosition: d.DivisionPositions,
|
||||
|
||||
@@ -7,11 +7,10 @@ import (
|
||||
|
||||
type Division struct {
|
||||
ecore.SmallMain // adjust this according to the needs
|
||||
Code string `json:"code" gorm:"unique;size:10"`
|
||||
Code string `json:"code" gorm:"uniqueIndex;size:10"`
|
||||
Name string `json:"name" gorm:"size:50"`
|
||||
Parent_Id *uint16 `json:"parent_id"`
|
||||
Parent_Code *string `json:"parent_code" gorm:"size:10"`
|
||||
Parent *Division `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
|
||||
Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
|
||||
DivisionPositions []edpb.Basic `json:"divisionPositions,omitempty" gorm:"foreignKey:Division_Id;references:Id"`
|
||||
Parent *Division `json:"parent" gorm:"foreignKey:Parent_Code;references:Code"`
|
||||
Childrens []Division `json:"childrens" gorm:"foreignKey:Parent_Code;references:Code"` // may need references to self
|
||||
DivisionPositions []edpb.Basic `json:"divisionPositions,omitempty" gorm:"foreignKey:Division_Code;references:Code"`
|
||||
}
|
||||
Reference in New Issue
Block a user