From 0d62b3f72515bbfa81ed75878157bc757addac9e Mon Sep 17 00:00:00 2001 From: dpurbosakti Date: Wed, 27 Aug 2025 10:20:40 +0700 Subject: [PATCH] update infragroup --- cmd/migration/migrations/20250827024311.sql | 2 ++ cmd/migration/migrations/atlas.sum | 11 ++++---- .../domain/main-entities/infra-group/dto.go | 27 +++++++++++-------- .../main-entities/infra-group/entity.go | 5 ++-- 4 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 cmd/migration/migrations/20250827024311.sql diff --git a/cmd/migration/migrations/20250827024311.sql b/cmd/migration/migrations/20250827024311.sql new file mode 100644 index 00000000..8ac1d2a6 --- /dev/null +++ b/cmd/migration/migrations/20250827024311.sql @@ -0,0 +1,2 @@ +-- Modify "InfraGroup" table +ALTER TABLE "public"."InfraGroup" ALTER COLUMN "Code" TYPE character varying(10), ALTER COLUMN "Name" TYPE character varying(50), ADD COLUMN "Level" smallint NULL; diff --git a/cmd/migration/migrations/atlas.sum b/cmd/migration/migrations/atlas.sum index 1d5fbd8b..46aee6d6 100644 --- a/cmd/migration/migrations/atlas.sum +++ b/cmd/migration/migrations/atlas.sum @@ -1,7 +1,8 @@ -h1:aACpl+MgcGmQ5IgTQGQ4o6+1pT9L8KphrWlGlKBguHc= +h1:4uryCUq0L2CJ7E8H5cdmioR5WZgsBsOYyeEo78COgs0= 20250825054027.sql h1:zRUeuuP4bDLf96Cb38D/l9ivBAQC745XRao0rxbzdVI= 20250825060522.sql h1:NiE1fVzydcg8Y8ytSHgt0DkkauQFveNXv42BoG5m+bI= -20250825102900.sql h1:Xaz9cAKDx6ZjDByRBSNrX/d2/s8Xid2zhirWk62xKjQ= -20250825103029.sql h1:YkM0KTRRawcObTUOG3epXzBOW4wFyHIOlnh99FaVgPk= -20250827015551.sql h1:iaN+FNEPyYn8pbc16yt1Jwo1Bf6jRePhKvoZht+RxdI= -20250827021904.sql h1:jxCNgxPGAHqU3z/tQBww7/9PnJQYl2Is2NFV5ZEeHIU= +20250825102900.sql h1:OAUnj87Wz7mrHykX14idePckUmRYa5UH0LylYDL76RI= +20250825103029.sql h1:iuZFrfUjNQM5kRpEwdYR8qinSp8SIkoJc3Dr8rD8BuI= +20250827015551.sql h1:Jq/RkXSWHEWuNigLunLzIrYgiyroSVD7J0waDMvdzvg= +20250827021904.sql h1:pgjwmQS1TxZ977a1tIXKq6pZnGauPrOUxLUTclV+fE4= +20250827024311.sql h1:6Wt8nK7R2qaTUvP8dZFwwqxAMdAhHAChxFRiI8BlzQo= diff --git a/internal/domain/main-entities/infra-group/dto.go b/internal/domain/main-entities/infra-group/dto.go index 9b10d189..e33e92b1 100644 --- a/internal/domain/main-entities/infra-group/dto.go +++ b/internal/domain/main-entities/infra-group/dto.go @@ -5,13 +5,15 @@ import ( ) type CreateDto struct { - Code string `json:"code"` - Name string `json:"name"` + Code string `json:"code"` + Name string `json:"name"` + Level uint8 `json:"level"` } type ReadListDto struct { - Code string `json:"code"` - Name string `json:"name"` + Code string `json:"code"` + Name string `json:"name"` + Level uint8 `json:"level"` Page int `json:"page"` PageSize int `json:"page_size"` @@ -19,9 +21,10 @@ type ReadListDto struct { } type ReadDetailDto struct { - Id uint16 `json:"id"` - Code string `json:"code"` - Name string `json:"name"` + Id uint16 `json:"id"` + Code string `json:"code"` + Name string `json:"name"` + Level uint8 `json:"level"` } type UpdateDto struct { @@ -41,14 +44,16 @@ type MetaDto struct { type ResponseDto struct { ecore.Main - Code string `json:"code"` - Name string `json:"name"` + Code string `json:"code"` + Name string `json:"name"` + Level uint8 `json:"level"` } func (d InfraGroup) ToResponse() ResponseDto { resp := ResponseDto{ - Code: d.Code, - Name: d.Name, + Code: d.Code, + Name: d.Name, + Level: d.Level, } resp.Main = d.Main return resp diff --git a/internal/domain/main-entities/infra-group/entity.go b/internal/domain/main-entities/infra-group/entity.go index f749030a..812c27f1 100644 --- a/internal/domain/main-entities/infra-group/entity.go +++ b/internal/domain/main-entities/infra-group/entity.go @@ -6,6 +6,7 @@ import ( type InfraGroup struct { ecore.Main // adjust this according to the needs - Code string `json:"code" gorm:"unique;size:50"` - Name string `json:"name" gorm:"size:100"` + Code string `json:"code" gorm:"unique;size:10"` + Name string `json:"name" gorm:"size:50"` + Level uint8 `json:"level"` }