From 0934f8136f12abf763c05b076bad60c9d488e2a5 Mon Sep 17 00:00:00 2001 From: DeniskaRediska Date: Fri, 22 Apr 2022 17:05:36 +0400 Subject: [PATCH] MSP-623 split entity --- entity/access_list.go | 7 +++++ entity/application.go | 15 ++++++++++ entity/domain.go | 14 +++++++++ entity/entity.go | 67 ------------------------------------------- entity/service.go | 14 +++++++++ entity/token.go | 12 ++++++++ 6 files changed, 62 insertions(+), 67 deletions(-) create mode 100644 entity/access_list.go create mode 100644 entity/application.go create mode 100644 entity/domain.go delete mode 100644 entity/entity.go create mode 100644 entity/service.go create mode 100644 entity/token.go diff --git a/entity/access_list.go b/entity/access_list.go new file mode 100644 index 0000000..c0fc80a --- /dev/null +++ b/entity/access_list.go @@ -0,0 +1,7 @@ +package entity + +type AccessList struct { + AppId int + Method string + Value bool +} diff --git a/entity/application.go b/entity/application.go new file mode 100644 index 0000000..4d38c74 --- /dev/null +++ b/entity/application.go @@ -0,0 +1,15 @@ +package entity + +import ( + "time" +) + +type Application struct { + Id int + Name string + Description *string + ServiceId int + Type string + CreatedAt time.Time + UpdatedAt time.Time +} diff --git a/entity/domain.go b/entity/domain.go new file mode 100644 index 0000000..08dc9e8 --- /dev/null +++ b/entity/domain.go @@ -0,0 +1,14 @@ +package entity + +import ( + "time" +) + +type Domain struct { + Id int + Name string + Description *string + SystemId int + CreatedAt time.Time + UpdatedAt time.Time +} diff --git a/entity/entity.go b/entity/entity.go deleted file mode 100644 index 53bb777..0000000 --- a/entity/entity.go +++ /dev/null @@ -1,67 +0,0 @@ -package entity - -import "time" - -const ( - RootAdminApplicationId = 1 -) - -const ( - AppTypeSystem = "SYSTEM" - AppTypeMobile = "MOBILE" -) - -type System struct { - tableName string `pg:"system_service.system" json:"-"` //nolint - Id int32 - Name string `valid:"required~Required"` - Description string - CreatedAt time.Time - UpdatedAt time.Time -} - -type Domain struct { - tableName string `pg:"system_service.domain" json:"-"` //nolint - Name string `valid:"required~Required"` - Id int32 - SystemId int32 - Description string - CreatedAt time.Time - UpdatedAt time.Time -} - -type Service struct { - tableName string `pg:"system_service.service" json:"-"` //nolint - Id int32 - DomainId int32 `valid:"required~Required"` - Name string `valid:"required~Required"` - Description string - CreatedAt time.Time - UpdatedAt time.Time -} - -type Application struct { - tableName string `pg:"system_service.application" json:"-"` //nolint - Name string `valid:"required~Required"` - Description string - Type string `valid:"required~Required,in(SYSTEM|MOBILE)"` - ServiceId int32 `valid:"required~Required"` - Id int32 - CreatedAt time.Time - UpdatedAt time.Time -} - -type Token struct { - tableName string `pg:"system_service.token" json:"-"` //nolint - Token string `valid:"required~Required" pg:"pk:token"` - AppId int32 `valid:"required~Required"` - ExpireTime int64 - CreatedAt time.Time -} - -type AccessList struct { - tableName string `pg:"system_service.access_list" json:"-"` //nolint - Method string `pg:",pk"` - AppId int32 `pg:",pk"` - Value bool -} diff --git a/entity/service.go b/entity/service.go new file mode 100644 index 0000000..9a791d9 --- /dev/null +++ b/entity/service.go @@ -0,0 +1,14 @@ +package entity + +import ( + "time" +) + +type Service struct { + Id int + Name string + Description *string + DomainId int + CreatedAt time.Time + UpdatedAt time.Time +} diff --git a/entity/token.go b/entity/token.go new file mode 100644 index 0000000..50a553f --- /dev/null +++ b/entity/token.go @@ -0,0 +1,12 @@ +package entity + +import ( + "time" +) + +type Token struct { + Token string + AppId int + ExpireTime int + CreatedAt time.Time +}