infra, room, item, medicine, device, material ids into codes

This commit is contained in:
dpurbosakti
2025-11-07 15:28:32 +07:00
parent feb54bd2f5
commit a944105f72
40 changed files with 277 additions and 218 deletions
@@ -0,0 +1,6 @@
-- Modify "Infra" table
ALTER TABLE "public"."Infra" ADD COLUMN "Parent_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL;
-- Create index "idx_Infra_Code" to table: "Infra"
CREATE UNIQUE INDEX "idx_Infra_Code" ON "public"."Infra" ("Code");
-- Modify "Room" table
ALTER TABLE "public"."Room" DROP CONSTRAINT "fk_Room_Specialist", DROP CONSTRAINT "fk_Room_Subspecialist", DROP CONSTRAINT "fk_Room_Unit", DROP COLUMN "Infra_Id", DROP COLUMN "Unit_Id", DROP COLUMN "Specialist_Id", DROP COLUMN "Subspecialist_Id", ADD CONSTRAINT "fk_Room_Specialist" FOREIGN KEY ("Specialist_Code") REFERENCES "public"."Specialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Room_Subspecialist" FOREIGN KEY ("Subspecialist_Code") REFERENCES "public"."Subspecialist" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION, ADD CONSTRAINT "fk_Room_Unit" FOREIGN KEY ("Unit_Code") REFERENCES "public"."Unit" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
@@ -0,0 +1,4 @@
-- Modify "Nurse" table
ALTER TABLE "public"."Nurse" DROP CONSTRAINT "fk_Nurse_Infra";
-- Modify "Infra" table
ALTER TABLE "public"."Infra" DROP CONSTRAINT "uni_Infra_Code";
@@ -0,0 +1,4 @@
-- Modify "Nurse" table
ALTER TABLE "public"."Nurse" ADD CONSTRAINT "fk_Nurse_Infra" FOREIGN KEY ("Infra_Code") REFERENCES "public"."Infra" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
-- Modify "Room" table
ALTER TABLE "public"."Room" ADD CONSTRAINT "fk_Room_Infra" FOREIGN KEY ("Infra_Code") REFERENCES "public"."Infra" ("Code") ON UPDATE NO ACTION ON DELETE NO ACTION;
@@ -0,0 +1,2 @@
-- Modify "Item" table
ALTER TABLE "public"."Item" ADD COLUMN "Infra_Code" character varying(10) NULL;
@@ -0,0 +1,6 @@
-- Modify "Device" table
ALTER TABLE "public"."Device" ADD COLUMN "Infra_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL;
-- Modify "Material" table
ALTER TABLE "public"."Material" ADD COLUMN "Infra_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL;
-- Modify "Medicine" table
ALTER TABLE "public"."Medicine" ADD COLUMN "Infra_Code" character varying(10) NULL, ADD COLUMN "Item_Code" character varying(50) NULL;
+18 -13
View File
@@ -1,4 +1,4 @@
h1:mPG9xfcT+aorrateezmQ8OvETRVigtmHiY1O8i2dpwg=
h1:A8U7W3JZbEUXu6uzF9wfKvSgX/j+G1nQoxchM989kiw=
20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k=
20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0=
20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI=
@@ -75,15 +75,20 @@ h1:mPG9xfcT+aorrateezmQ8OvETRVigtmHiY1O8i2dpwg=
20251106040137.sql h1:ppcqkVoT0o9jZcjI/TN7LuaPxXhJQhnIXEJtloP/46o=
20251106041333.sql h1:2JkxyelQ/EeB+boL5bfpnzefw32ttEGKvKchtQjWmAU=
20251106042006.sql h1:ruppYa1kAJQUU3ufQBbKGMcXrGbGJJiRPclT+dNc/YQ=
20251106050412.sql h1:MiEMJ1HCFYnalKuq3Z38xJeogfBAMqsTv2sG4EF8dDw=
20251106063418.sql h1:y3veDJPjKekOWLCZek/LgQwXPRhZtOppTfUXiqoL95s=
20251106071906.sql h1:/TUZA3XpMY23qEJXdkTwlzrNMvSSl6JJniPcgAttBaw=
20251106073157.sql h1:78txeibJ602DMD7huD618ZSMt6phSRzDNPTlo0PGyrc=
20251106074218.sql h1:8Xz7WywrtUnSxOHhlal53gG9rE7r86LFUt5zBFe/mIs=
20251106081846.sql h1:jp91Bf5bxGXMiUB1VIuN6y768vb2iWwow44WfCE5J5k=
20251106082844.sql h1:RHYzRO4G1fSWwf+xc/3QezZ/Iil67cZPIgNpNz3TNhQ=
20251106090021.sql h1:dFDk6mq+zjbYWmfWIrHf9DiKvvoXHjrr0++zssMTWP8=
20251106144745.sql h1:aHcr23iBFqCHer5D/SsPMXBCLjGqUYvWYfRU8jSJgIw=
20251107012049.sql h1:hu/7NHhnAkT4xK0RNtqmMDdH1Bo5EZbl7itDRjiCT+g=
20251107064812.sql h1:sfCXDQYnMf0ddrQ9oYljWJLLSt9NJjJV6o8VS3p7aZE=
20251107064937.sql h1:DlYGJ9LZFwZyR7jBP5zaGB128aIc4HAixBKPYCz9EkY=
20251106050412.sql h1:1002KYtHd8AwrQTMewbs/PPHDylHDghigE/3S7PVdMA=
20251106063418.sql h1:jPW/gBnbFl4RO39lQ0ZMDtYA6xbhyD6CgQupT50HmaY=
20251106071906.sql h1:leYGKxR3EQn794aOehf0sd/ZPmOnvBMZPy5/anGmRB4=
20251106073157.sql h1:KASMzjjjk5UB7Zj8lCRtM1utc4ZnDjlnpZbtTe3vONE=
20251106074218.sql h1:Z5q5deOvLaZDPhiVTN9st3/s56RepBa2YOyrMXBdj4A=
20251106081846.sql h1:P+VsWwhGt60adDIZuE/Aa38JVp/yX1rnsdpXpxASodw=
20251106082844.sql h1:Dmi5A8i9frQZvdXYPwc7f8CisZtBH8liSXq1rI6z1iM=
20251106090021.sql h1:4JwdKgO8T46YhyWVJUxpRIwudBDlG8QN1brSOYmgQ20=
20251106144745.sql h1:nqnQCzGrVJaq8ilOEOGXeRUL1dolj+OPWKuP8A92FRA=
20251107012049.sql h1:Pff4UqltGS3clSlGr0qq8CQM56L29wyxY0FC/N/YAhU=
20251107064812.sql h1:jjpcAi0B/geEOKWmmR6+1UhWMhjstWhWQcz9lUWrtTY=
20251107064937.sql h1:1nPu0THBf+YquFIJSE4pc1dA7r3EydH92cpp26ozysw=
20251107071420.sql h1:Q+e+OqjdiuK/sghDQ5NxjU+u2zYl+vh/eRBlUz9Idhg=
20251107074318.sql h1:VbOWMw2rClEWgMnDSejXPqXkFoQ4odVsHn3/UAEiCYA=
20251107075050.sql h1:ZZaKJEWXIJ94/0/2Gzzz+HXjmebEs5eP8iUIot26/c8=
20251107080604.sql h1:aq+tINa0ULCZlJcUK2jaeGh6rRH4jJz3e2NrK47m0Ec=
20251107081830.sql h1:Bl9kniyLWeMqd3nrvgCgiUpdcJWp8qX1F41JAM1WbiE=
+9 -8
View File
@@ -8,11 +8,11 @@ import (
)
type CreateDto struct {
Code string `json:"code" validate:"maxLength=10"`
Name string `json:"name" validate:"maxLength=50"`
Uom_Code string `json:"uom_code" validate:"maxLength=10"`
Infra_Id *uint16 `json:"infra_id"`
Item_Id *uint `json:"item_id"`
Code string `json:"code" validate:"maxLength=10"`
Name string `json:"name" validate:"maxLength=50"`
Uom_Code string `json:"uom_code" validate:"maxLength=10"`
Infra_Code *string `json:"infra_code"`
Item_Code *string `json:"item_code"`
}
type ReadListDto struct {
@@ -32,17 +32,18 @@ type FilterDto struct {
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Id *uint16 `json:"id"`
Code *string `json:"code"`
}
type UpdateDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
Code *string `json:"code"`
}
type MetaDto struct {
@@ -14,7 +14,9 @@ type Device struct {
Uom_Code string `json:"uom_code" gorm:"size:10"`
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code" gorm:"size:10"`
Infra *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"`
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code" gorm:"size:50"`
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
}
+21 -20
View File
@@ -9,15 +9,15 @@ import (
)
type CreateDto struct {
Code string `json:"code" validate:"maxLength=10"`
Name string `json:"name" validate:"maxLength=50"`
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" validate:"maxLength=15"`
Parent_Id *uint16 `json:"parent_id"`
Item_Id *uint `json:"item_id"`
Unit_Id *uint16 `json:"unit_id"`
Specialist_Id *uint16 `json:"specialist_id"`
Subspecialist_Id *uint16 `json:"subspecialist_id"`
Infra_Id *uint16 `json:"-"` // for room
Code string `json:"code" validate:"maxLength=10"`
Name string `json:"name" validate:"maxLength=50"`
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" validate:"maxLength=15"`
Parent_Code *string `json:"parent_code"`
Item_Id *uint `json:"-"`
Unit_Code *string `json:"unit_code"`
Specialist_Code *string `json:"specialist_code"`
Subspecialist_Code *string `json:"subspecialist_code"`
Infra_Code *string `json:"infra_code"` // for room
}
type ReadListDto struct {
@@ -32,24 +32,25 @@ type FilterDto struct {
Code string `json:"code"`
Name string `json:"name"`
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup-code"`
Parent_Id *uint16 `json:"parent-id"`
Item_Id *uint `json:"item-id"`
Parent_Code *string `json:"parent-code"`
Item_Id *string `json:"item-code"`
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code *string `json:"code"`
Item_Id *uint `json:"item_id"`
Id *uint16 `json:"id"`
Code *string `json:"code"`
Item_Code *string `json:"item_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 {
@@ -63,10 +64,10 @@ type ResponseDto struct {
Code string `json:"code"`
Name string `json:"name"`
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code"`
Parent_Id *uint16 `json:"parent_id"`
Parent_Code *string `json:"parent_code"`
Parent *Infra `json:"parent,omitempty"`
Childrens []Infra `json:"childrens,omitempty"`
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code"`
Item *ei.Item `json:"item,omitempty"`
Rooms []erb.Basic `json:"rooms,omitempty"`
}
@@ -76,10 +77,10 @@ func (d Infra) ToResponse() ResponseDto {
Code: d.Code,
Name: d.Name,
InfraGroup_Code: d.InfraGroup_Code,
Parent_Id: d.Parent_Id,
Parent_Code: d.Parent_Code,
Parent: d.Parent,
Childrens: d.Childrens,
Item_Id: d.Item_Id,
Item_Code: d.Item_Code,
Item: d.Item,
Rooms: d.Rooms,
}
@@ -3,6 +3,7 @@ package infra
import (
ecore "simrs-vx/internal/domain/base-entities/core"
ei "simrs-vx/internal/domain/main-entities/item"
erb "simrs-vx/internal/domain/main-entities/room/base"
ero "simrs-vx/internal/domain/references/organization"
@@ -10,13 +11,15 @@ import (
type Infra 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"`
InfraGroup_Code ero.InfraGroupCode `json:"infraGroup_code" gorm:"size:15"`
Parent_Id *uint16 `json:"parent_id"`
Parent_Code *string `json:"parent_code" gorm:"size:10"`
Parent *Infra `json:"parent" gorm:"foreignKey:Parent_Id;references:Id"`
Childrens []Infra `json:"childrens" gorm:"foreignKey:Parent_Id"` // may need references to self
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code" gorm:"size:50"`
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
Rooms []erb.Basic `json:"rooms" gorm:"foreignKey:Infra_Id"`
Rooms []erb.Basic `json:"rooms" gorm:"foreignKey:Infra_Code;references:Code"`
}
+8 -7
View File
@@ -11,7 +11,7 @@ type CreateDto struct {
Name string `json:"name" validate:"maxLength=100"`
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code" validate:"maxLength=10"`
Uom_Code *string `json:"uom_code" validate:"maxLength=10"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code"`
Stock *int `json:"stock"`
}
@@ -27,23 +27,24 @@ type FilterDto struct {
Name string `json:"name"`
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup-code"`
Uom_Code *string `json:"uom-code"`
Infra_Id *uint16 `json:"infra-id"`
Infra_Code *string `json:"infra-code"`
Stock *int `json:"stock"`
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 uint `json:"id"`
Id *uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
Code *string `json:"code"`
}
type MetaDto struct {
@@ -59,7 +60,7 @@ type ResponseDto struct {
ItemGroup_Code ero.ItemGroupCode `json:"itemGroup_code"`
Uom_Code *string `json:"uom_code"`
Uom *eu.Uom `json:"uom,omitempty"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code"`
Stock *int `json:"stock"`
}
@@ -70,7 +71,7 @@ func (d Item) ToResponse() ResponseDto {
ItemGroup_Code: d.ItemGroup_Code,
Uom_Code: d.Uom_Code,
Uom: d.Uom,
Infra_Id: d.Infra_Id,
Infra_Code: d.Infra_Code,
Stock: d.Stock,
}
resp.Main = d.Main
@@ -15,5 +15,6 @@ type Item struct {
Uom_Code *string `json:"uom_code" gorm:"size:10"`
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code" gorm:"size:10"`
Stock *int `json:"stock"`
}
+35 -34
View File
@@ -8,12 +8,12 @@ import (
)
type CreateDto struct {
Code string `json:"code" validate:"maxLength=10"`
Name string `json:"name" validate:"maxLength=50"`
Uom_Code string `json:"uom_code" validate:"maxLength=10"`
Infra_Id *uint16 `json:"infra_id"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item_id"`
Code string `json:"code" validate:"maxLength=10"`
Name string `json:"name" validate:"maxLength=50"`
Uom_Code string `json:"uom_code" validate:"maxLength=10"`
Infra_Code *string `json:"infra_code"`
Stock *int `json:"stock"`
Item_Code *string `json:"item_code"`
}
type ReadListDto struct {
@@ -24,28 +24,29 @@ type ReadListDto struct {
}
type FilterDto struct {
Code string `json:"code"`
Name string `json:"name"`
Uom_Code string `json:"uom-code"`
Infra_Id *uint16 `json:"infra-id"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item-id"`
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
Code string `json:"code"`
Name string `json:"name"`
Uom_Code string `json:"uom-code"`
Infra_Code *string `json:"infra-code"`
Stock *int `json:"stock"`
Item_Code *string `json:"item-code"`
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Id *uint16 `json:"id"`
Code *string `json:"code"`
Item_Id *uint `json:"item_id"`
}
type UpdateDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
Code *string `json:"code"`
}
type MetaDto struct {
@@ -56,28 +57,28 @@ type MetaDto struct {
type ResponseDto struct {
ecore.Main
Code string `json:"code"`
Name string `json:"name"`
Uom_Code string `json:"uom_code"`
Uom *eu.Uom `json:"uom,omitempty"`
Infra_Id *uint16 `json:"infra_id"`
Infra *ein.Infra `json:"infra,omitempty"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item_id"`
Item *ei.Item `json:"item,omitempty"`
Code string `json:"code"`
Name string `json:"name"`
Uom_Code string `json:"uom_code"`
Uom *eu.Uom `json:"uom,omitempty"`
Infra_Code *string `json:"infra_code"`
Infra *ein.Infra `json:"infra,omitempty"`
Stock *int `json:"stock"`
Item_Code *string `json:"item_code"`
Item *ei.Item `json:"item,omitempty"`
}
func (d Material) ToResponse() ResponseDto {
resp := ResponseDto{
Code: d.Code,
Name: d.Name,
Uom_Code: d.Uom_Code,
Uom: d.Uom,
Infra_Id: d.Infra_Id,
Infra: d.Infra,
Stock: d.Stock,
Item_Id: d.Item_Id,
Item: d.Item,
Code: d.Code,
Name: d.Name,
Uom_Code: d.Uom_Code,
Uom: d.Uom,
Infra_Code: d.Infra_Code,
Infra: d.Infra,
Stock: d.Stock,
Item_Code: d.Item_Code,
Item: d.Item,
}
resp.Main = d.Main
return resp
@@ -14,8 +14,10 @@ type Material struct {
Uom_Code string `json:"uom_code" gorm:"size:10"`
Uom *eu.Uom `json:"uom,omitempty" gorm:"foreignKey:Uom_Code;references:Code"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code" gorm:"size:10"`
Infra *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code" gorm:"size:50"`
Item *ei.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
}
+14 -13
View File
@@ -16,9 +16,9 @@ type CreateDto struct {
MedicineMethod_Code *string `json:"medicineMethod_code" validate:"maxLength=10"`
Uom_Code *string `json:"uom_code" validate:"maxLength=10"`
Dose uint8 `json:"dose"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code"`
}
type ReadListDto struct {
@@ -35,25 +35,26 @@ type FilterDto struct {
MedicineMethod_Code *string `json:"medicineMethod-code"`
Uom_Code *string `json:"uom-code"`
Dose uint8 `json:"dose"`
Infra_Id *uint16 `json:"infra-id"`
Infra_Code *string `json:"infra-code"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item-id"`
Item_Code *string `json:"item-code"`
Search string `json:"search" gormhelper:"searchColumns=Code,Name"`
}
type ReadDetailDto struct {
Id uint16 `json:"id"`
Code *string `json:"code"`
Item_Id *uint `json:"item_id"`
Id *uint16 `json:"id"`
Code *string `json:"code"`
Item_Code *uint `json:"item_code"`
}
type UpdateDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
CreateDto
}
type DeleteDto struct {
Id uint `json:"id"`
Id *uint `json:"id"`
Code *string `json:"code"`
}
type MetaDto struct {
@@ -73,10 +74,10 @@ type ResponseDto struct {
Uom_Code *string `json:"uom_code"`
Uom *eu.Uom `json:"uom"`
Dose uint8 `json:"dose"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code"`
Infra *ein.Infra `json:"infra,omitempty"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code"`
Item *eit.Item `json:"item,omitempty"`
}
@@ -91,10 +92,10 @@ func (d Medicine) ToResponse() ResponseDto {
Uom_Code: d.Uom_Code,
Uom: d.Uom,
Dose: d.Dose,
Infra_Id: d.Infra_Id,
Infra_Code: d.Infra_Code,
Infra: d.Infra,
Stock: d.Stock,
Item_Id: d.Item_Id,
Item_Code: d.Item_Code,
Item: d.Item,
}
resp.Main = d.Main
@@ -21,8 +21,10 @@ type Medicine struct {
Uom *eu.Uom `json:"uom" gorm:"foreignKey:Uom_Code;references:Code"`
Dose uint8 `json:"dose"`
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code" gorm:"size:10"`
Infra *ein.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id;references:Id"`
Stock *int `json:"stock"`
Item_Id *uint `json:"item_id"`
Item_Code *string `json:"item_code" gorm:"size:50"`
Item *eit.Item `json:"item,omitempty" gorm:"foreignKey:Item_Id;references:Id"`
}
@@ -9,17 +9,13 @@ import (
type Basic struct {
ecore.SmallMain // adjust this according to the needs
Infra_Id *uint16 `json:"infra_id"`
Infra_Code *string `json:"infra_code" gorm:"size:10"`
Unit_Id *uint16 `json:"unit_id"`
Unit_Code *string `json:"unit_code" gorm:"size:10"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Id"`
Specialist_Id *uint16 `json:"specialist_id"`
Unit *eu.Unit `json:"unit,omitempty" gorm:"foreignKey:Unit_Code;references:Code"`
Specialist_Code *string `json:"specialist_code" gorm:"size:10"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Id"`
Subspecialist_Id *uint16 `json:"subspecialist_id"`
Specialist *es.Specialist `json:"specialist,omitempty" gorm:"foreignKey:Specialist_Code;references:Code"`
Subspecialist_Code *string `json:"subspecialist_code" gorm:"size:10"`
Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Id"`
Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty" gorm:"foreignKey:Subspecialist_Code;references:Code"`
}
func (Basic) TableName() string {
+24 -24
View File
@@ -9,10 +9,10 @@ import (
)
type CreateDto struct {
Infra_Id *uint16 `json:"infra_id"`
Unit_Id *uint16 `json:"unit_id"`
Specialist_Id *uint16 `json:"specialist_id"`
Subspecialist_Id *uint16 `json:"subspecialist_id"`
Infra_Code *string `json:"infra_code"`
Unit_Code *string `json:"unit_code"`
Specialist_Code *string `json:"specialist_code"`
Subspecialist_Code *string `json:"subspecialist_code"`
}
type ReadListDto struct {
@@ -22,10 +22,10 @@ type ReadListDto struct {
}
type FilterDto struct {
Infra_Id *uint16 `json:"infra-id"`
Unit_Id *uint16 `json:"unit-id"`
Specialist_Id *uint16 `json:"specialist-id"`
Subspecialist_Id *uint16 `json:"subspecialist-id"`
Infra_Code *string `json:"infra-code"`
Unit_Code *string `json:"unit-code"`
Specialist_Code *string `json:"specialist-code"`
Subspecialist_Code *string `json:"subspecialist-code"`
}
type ReadDetailDto struct {
@@ -49,26 +49,26 @@ type MetaDto struct {
type ResponseDto struct {
ecore.SmallMain
Infra_Id *uint16 `json:"infra_id"`
Infra *ei.Infra `json:"infra,omitempty"`
Unit_Id *uint16 `json:"unit_id"`
Unit *eu.Unit `json:"unit,omitempty"`
Specialist_Id *uint16 `json:"specialist_id"`
Specialist *es.Specialist `json:"specialist,omitempty"`
Subspecialist_Id *uint16 `json:"subspecialist_id"`
Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"`
Infra_Code *string `json:"infra_code"`
Infra *ei.Infra `json:"infra,omitempty"`
Unit_Code *string `json:"unit_code"`
Unit *eu.Unit `json:"unit,omitempty"`
Specialist_Code *string `json:"specialist_code"`
Specialist *es.Specialist `json:"specialist,omitempty"`
Subspecialist_Code *string `json:"subspecialist_code"`
Subspecialist *ess.Subspecialist `json:"subspecialist,omitempty"`
}
func (d Room) ToResponse() ResponseDto {
resp := ResponseDto{
Infra_Id: d.Infra_Id,
Infra: d.Infra,
Unit_Id: d.Unit_Id,
Unit: d.Unit,
Specialist_Id: d.Specialist_Id,
Specialist: d.Specialist,
Subspecialist_Id: d.Subspecialist_Id,
Subspecialist: d.Subspecialist,
Infra_Code: d.Infra_Code,
Infra: d.Infra,
Unit_Code: d.Unit_Code,
Unit: d.Unit,
Specialist_Code: d.Specialist_Code,
Specialist: d.Specialist,
Subspecialist_Code: d.Subspecialist_Code,
Subspecialist: d.Subspecialist,
}
resp.SmallMain = d.SmallMain
return resp
+1 -1
View File
@@ -7,5 +7,5 @@ import (
type Room struct {
ebase.Basic
Infra *ei.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Id"`
Infra *ei.Infra `json:"infra,omitempty" gorm:"foreignKey:Infra_Code;references:Code"`
}
@@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.ReadDetailDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
@@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
dto.Id = uint(id)
dto.Code = code
res, err := u.Update(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.DeleteDto{}
dto.Id = uint(id)
dto.Code = &code
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
@@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.ReadDetailDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
@@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
dto.Id = uint16(id)
dto.Code = code
res, err := u.Update(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.DeleteDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
@@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.ReadDetailDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
@@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
dto.Id = uint(id)
dto.Code = code
res, err := u.Update(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.DeleteDto{}
dto.Id = uint(id)
dto.Code = &code
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
@@ -304,22 +304,22 @@ func SetRoutes() http.Handler {
hc.RegCrudByCode(r, "/v1/subspecialist", subspecialist.O)
hc.RegCrudByCode(r, "/v1/specialist-position", specialistposition.O)
hc.RegCrudByCode(r, "/v1/subspecialist-position", subspecialistposition.O)
hc.RegCrudByCode(r, "/v1/infra", infra.O)
hc.RegCrud(r, "/v1/pharmacy-company", pharmacycompany.O)
hc.RegCrud(r, "/v1/diagnose-src", diagnosesrc.O)
hc.RegCrud(r, "/v1/procedure-src", proceduresrc.O)
hc.RegCrud(r, "/v1/uom", uom.O)
hc.RegCrud(r, "/v1/item", item.O)
hc.RegCrudByCode(r, "/v1/item", item.O)
hc.RegCrud(r, "/v1/item-price", itemprice.O)
hc.RegCrud(r, "/v1/infra", infra.O)
hc.RegCrud(r, "/v1/medicine-group", medicinegroup.O)
hc.RegCrud(r, "/v1/medicine-method", medicinemethod.O)
hc.RegCrud(r, "/v1/mcu-src-category", mcusrccategory.O)
hc.RegCrud(r, "/v1/mcu-src", mcusrc.O)
hc.RegCrud(r, "/v1/ethnic", ethnic.O)
hc.RegCrud(r, "/v1/insurance-company", insurancecompany.O)
hc.RegCrud(r, "/v1/medicine", medicine.O)
hc.RegCrud(r, "/v1/device", device.O)
hc.RegCrud(r, "/v1/material", material.O)
hc.RegCrudByCode(r, "/v1/medicine", medicine.O)
hc.RegCrudByCode(r, "/v1/device", device.O)
hc.RegCrudByCode(r, "/v1/material", material.O)
hc.RegCrud(r, "/v1/doctor-fee", doctorfee.O)
hc.RegCrud(r, "/v1/medical-action-src", medicalactionsrc.O)
hc.RegCrud(r, "/v1/medical-action-src-item", medicalactionsrcitem.O)
@@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.ReadDetailDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
@@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
dto.Id = uint(id)
dto.Code = code
res, err := u.Update(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.DeleteDto{}
dto.Id = uint(id)
dto.Code = &code
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
@@ -33,19 +33,19 @@ func (obj myBase) GetList(w http.ResponseWriter, r *http.Request) {
}
func (obj myBase) GetDetail(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.ReadDetailDto{}
dto.Id = uint16(id)
dto.Code = &code
res, err := u.ReadDetail(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
@@ -53,19 +53,19 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) {
if res := rw.ValidateStructByIOR(w, r.Body, &dto); !res {
return
}
dto.Id = uint(id)
dto.Code = code
res, err := u.Update(dto)
rw.DataResponse(w, res, err)
}
func (obj myBase) Delete(w http.ResponseWriter, r *http.Request) {
id := rw.ValidateInt(w, "id", r.PathValue("id"))
if id <= 0 {
code := rw.ValidateString(w, "code", r.PathValue("code"))
if code == "" {
return
}
dto := e.DeleteDto{}
dto.Id = uint(id)
dto.Code = &code
res, err := u.Delete(dto)
rw.DataResponse(w, res, err)
}
@@ -169,7 +169,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
}
func Update(input e.UpdateDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: &input.Code}
var data *e.Device
var err error
@@ -225,7 +225,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
}
func Delete(input e.DeleteDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.Device
var err error
@@ -30,8 +30,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Device) {
data.Code = inputSrc.Code
data.Name = inputSrc.Name
data.Uom_Code = inputSrc.Uom_Code
data.Item_Id = inputSrc.Item_Id
data.Infra_Id = inputSrc.Infra_Id
data.Item_Code = inputSrc.Item_Code
data.Infra_Code = inputSrc.Infra_Code
}
func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
@@ -40,13 +40,13 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
Name: input.Name,
ItemGroup_Code: ero.ITGCDevice,
Uom_Code: &input.Uom_Code,
Infra_Id: input.Infra_Id,
Infra_Code: input.Infra_Code,
}
item, err := ui.CreateData(itemCreate, event, tx)
if err != nil {
return err
}
input.Item_Id = &item.Id
input.Item_Code = &item.Code
return nil
}
@@ -81,6 +81,13 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if input.Code != nil {
tx = tx.Where("\"Code\" = ?", *input.Code)
}
if input.Id != nil {
tx = tx.Where("\"Id\" = ?", *input.Id)
}
if err := tx.First(&data, input.Id).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
@@ -52,7 +52,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.Di
EXISTS (
SELECT 1
FROM "Division" c
WHERE c."Parent_Id" = "Division"."Id"
WHERE c."Parent_Code" = "Division"."Code"
)
`)
}
@@ -38,12 +38,12 @@ func Create(input e.CreateDto) (*d.Data, error) {
}
if input.InfraGroup_Code == ero.IFGCRoom {
if input.Parent_Id == nil {
if input.Parent_Code == nil {
event.Status = "failed"
event.ErrInfo = pl.ErrorInfo{
Code: "data-create-fail",
Detail: "parent_id is required",
Raw: errors.New("parent_id is required"),
Detail: "parent_code is required",
Raw: errors.New("parent_code is required"),
}
return pl.SetLogError(&event, input)
@@ -59,7 +59,7 @@ func Create(input e.CreateDto) (*d.Data, error) {
}
if input.InfraGroup_Code == ero.IFGCRoom {
input.Infra_Id = &data.Id
input.Infra_Code = &data.Code
if err := createRoom(&input, &event, tx); err != nil {
return err
}
@@ -29,7 +29,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Infra) {
data.Code = inputSrc.Code
data.Name = inputSrc.Name
data.InfraGroup_Code = inputSrc.InfraGroup_Code
data.Parent_Id = inputSrc.Parent_Id
data.Parent_Code = inputSrc.Parent_Code
data.Item_Id = inputSrc.Item_Id
}
@@ -42,7 +42,7 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
tmp := "unit"
return &tmp
}(),
Infra_Id: input.Parent_Id,
Infra_Code: input.Parent_Code,
}
item, err := ui.CreateData(itemCreate, event, tx)
if err != nil {
@@ -55,10 +55,10 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
func createRoom(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
roomCreate := er.CreateDto{
Infra_Id: input.Infra_Id,
Unit_Id: input.Unit_Id,
Specialist_Id: input.Specialist_Id,
Subspecialist_Id: input.Subspecialist_Id,
Infra_Code: input.Infra_Code,
Unit_Code: input.Unit_Code,
Specialist_Code: input.Specialist_Code,
Subspecialist_Code: input.Subspecialist_Code,
}
_, err := ur.CreateData(roomCreate, event, tx)
if err != nil {
+9 -2
View File
@@ -52,7 +52,7 @@ func ReadListData(input e.ReadListDto, event *pl.Event, dbx ...*gorm.DB) ([]e.In
EXISTS (
SELECT 1
FROM "Infra" c
WHERE c."Parent_Id" = "Infra"."Id"
WHERE c."Parent_Code" = "Infra"."Code"
)
`)
}
@@ -91,6 +91,13 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if input.Code != nil {
tx = tx.Where("\"Code\" = ?", *input.Code)
}
if input.Id != nil {
tx = tx.Where("\"Id\" = ?", *input.Id)
}
tx = tx.Preload("Parent").
Preload("Childrens").
Preload("Item").
@@ -99,7 +106,7 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
Preload("Rooms.Subspecialist").
Preload("Rooms.Unit")
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.First(&data).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
+2 -2
View File
@@ -166,7 +166,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
}
func Update(input e.UpdateDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: &input.Code}
var data *e.Item
var err error
@@ -222,7 +222,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
}
func Delete(input e.DeleteDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.Item
var err error
@@ -21,6 +21,6 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Item) {
data.Name = inputSrc.Name
data.ItemGroup_Code = inputSrc.ItemGroup_Code
data.Uom_Code = inputSrc.Uom_Code
data.Infra_Id = inputSrc.Infra_Id
data.Infra_Code = inputSrc.Infra_Code
data.Stock = inputSrc.Stock
}
@@ -169,7 +169,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
}
func Update(input e.UpdateDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: &input.Code}
var data *e.Material
var err error
@@ -225,7 +225,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
}
func Delete(input e.DeleteDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.Material
var err error
@@ -30,8 +30,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Material) {
data.Name = inputSrc.Name
data.Uom_Code = inputSrc.Uom_Code
data.Stock = inputSrc.Stock
data.Item_Id = inputSrc.Item_Id
data.Infra_Id = inputSrc.Infra_Id
data.Item_Code = inputSrc.Item_Code
data.Infra_Code = inputSrc.Infra_Code
}
func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
@@ -40,7 +40,7 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
Name: input.Name,
ItemGroup_Code: ero.ITGCMaterial,
Uom_Code: &input.Uom_Code,
Infra_Id: input.Infra_Id,
Infra_Code: input.Infra_Code,
Stock: input.Stock,
}
item, err := ui.CreateData(itemCreate, event, tx)
@@ -48,6 +48,6 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
return err
}
input.Item_Id = &item.Id
input.Item_Code = &item.Code
return nil
}
@@ -169,7 +169,7 @@ func ReadDetail(input e.ReadDetailDto) (*d.Data, error) {
}
func Update(input e.UpdateDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: &input.Code}
var data *e.Medicine
var err error
@@ -225,7 +225,7 @@ func Update(input e.UpdateDto) (*d.Data, error) {
}
func Delete(input e.DeleteDto) (*d.Data, error) {
rdDto := e.ReadDetailDto{Id: uint16(input.Id)}
rdDto := e.ReadDetailDto{Code: input.Code}
var data *e.Medicine
var err error
@@ -33,9 +33,9 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Medicine) {
data.MedicineMethod_Code = inputSrc.MedicineMethod_Code
data.Uom_Code = inputSrc.Uom_Code
data.Dose = inputSrc.Dose
data.Infra_Id = inputSrc.Infra_Id
data.Infra_Code = inputSrc.Infra_Code
data.Stock = inputSrc.Stock
data.Item_Id = inputSrc.Item_Id
data.Item_Code = inputSrc.Item_Code
}
func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
@@ -44,7 +44,7 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
Name: input.Name,
ItemGroup_Code: ero.ITGCMedicine,
Uom_Code: input.Uom_Code,
Infra_Id: input.Infra_Id,
Infra_Code: input.Infra_Code,
Stock: input.Stock,
}
item, err := ui.CreateData(itemCreate, event, tx)
@@ -52,6 +52,6 @@ func createItem(input *e.CreateDto, event *pl.Event, tx *gorm.DB) error {
return err
}
input.Item_Id = &item.Id
input.Item_Code = &item.Code
return nil
}
@@ -81,8 +81,15 @@ func ReadDetailData(input e.ReadDetailDto, event *pl.Event, dbx ...*gorm.DB) (*e
tx = dg.I
}
if input.Code != nil {
tx = tx.Where("\"Code\" = ?", *input.Code)
}
if input.Id != nil {
tx = tx.Where("\"Id\" = ?", *input.Id)
}
tx = tx.Preload("Item")
if err := tx.First(&data, input.Id).Error; err != nil {
if err := tx.First(&data).Error; err != nil {
if processedErr := pu.HandleReadError(err, event, source, input.Id, data); processedErr != nil {
return nil, processedErr
}
@@ -17,8 +17,8 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Room) {
inputSrc = &inputTemp.CreateDto
}
data.Infra_Id = inputSrc.Infra_Id
data.Unit_Id = inputSrc.Unit_Id
data.Specialist_Id = inputSrc.Specialist_Id
data.Subspecialist_Id = inputSrc.Subspecialist_Id
data.Infra_Code = inputSrc.Infra_Code
data.Unit_Code = inputSrc.Unit_Code
data.Specialist_Code = inputSrc.Specialist_Code
data.Subspecialist_Code = inputSrc.Subspecialist_Code
}