diff --git a/docs/docs.go b/docs/docs.go index 8bac215..48dec40 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -8340,7 +8340,7 @@ const docTemplate = `{ "type": "boolean" }, "address": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "billingPassword": { "type": "string" @@ -8367,7 +8367,7 @@ const docTemplate = `{ "type": "string" }, "name": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "phoneNumbers": { "type": "string" @@ -8383,20 +8383,6 @@ const docTemplate = `{ } } }, - "branches.LocalizedText": { - "type": "object", - "properties": { - "en": { - "type": "string" - }, - "ru": { - "type": "string" - }, - "tm": { - "type": "string" - } - } - }, "branches.UpdateBranchDTO": { "type": "object", "required": [ @@ -8409,7 +8395,7 @@ const docTemplate = `{ "type": "boolean" }, "address": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "billingPassword": { "type": "string" @@ -8436,7 +8422,7 @@ const docTemplate = `{ "type": "string" }, "name": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "phoneNumbers": { "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index e7bd552..b0bcd5b 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -8334,7 +8334,7 @@ "type": "boolean" }, "address": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "billingPassword": { "type": "string" @@ -8361,7 +8361,7 @@ "type": "string" }, "name": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "phoneNumbers": { "type": "string" @@ -8377,20 +8377,6 @@ } } }, - "branches.LocalizedText": { - "type": "object", - "properties": { - "en": { - "type": "string" - }, - "ru": { - "type": "string" - }, - "tm": { - "type": "string" - } - } - }, "branches.UpdateBranchDTO": { "type": "object", "required": [ @@ -8403,7 +8389,7 @@ "type": "boolean" }, "address": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "billingPassword": { "type": "string" @@ -8430,7 +8416,7 @@ "type": "string" }, "name": { - "$ref": "#/definitions/branches.LocalizedText" + "$ref": "#/definitions/shared.LocalizedText" }, "phoneNumbers": { "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 68127dc..36a90ae 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -112,7 +112,7 @@ definitions: active: type: boolean address: - $ref: '#/definitions/branches.LocalizedText' + $ref: '#/definitions/shared.LocalizedText' billingPassword: type: string billingSberPassword: @@ -130,7 +130,7 @@ definitions: billingVisaMasterUsername: type: string name: - $ref: '#/definitions/branches.LocalizedText' + $ref: '#/definitions/shared.LocalizedText' phoneNumbers: type: string provinceId: @@ -145,21 +145,12 @@ definitions: - region - uniqueCode type: object - branches.LocalizedText: - properties: - en: - type: string - ru: - type: string - tm: - type: string - type: object branches.UpdateBranchDTO: properties: active: type: boolean address: - $ref: '#/definitions/branches.LocalizedText' + $ref: '#/definitions/shared.LocalizedText' billingPassword: type: string billingSberPassword: @@ -177,7 +168,7 @@ definitions: billingVisaMasterUsername: type: string name: - $ref: '#/definitions/branches.LocalizedText' + $ref: '#/definitions/shared.LocalizedText' phoneNumbers: type: string provinceId: diff --git a/internal/identity/auth/dto.go b/internal/identity/auth/dto.go index f06b418..9f0edef 100755 --- a/internal/identity/auth/dto.go +++ b/internal/identity/auth/dto.go @@ -1,6 +1,10 @@ package auth -import "time" +import ( + "time" + + "online-back/internal/shared" +) type LoginDTO struct { Name string `json:"name"` @@ -12,12 +16,6 @@ type RefreshTokenDTO struct { RefreshToken string `json:"refreshToken" binding:"required"` } -type LocalizedText struct { - En string `json:"en"` - Ru string `json:"ru"` - Tm string `json:"tm"` -} - type ProfileRoleDTO struct { Id int64 `json:"id"` Code string `json:"code"` @@ -27,9 +25,9 @@ type ProfileRoleDTO struct { } type ProfileBranchDTO struct { - Id int64 `json:"id"` - UniqueCode string `json:"uniqueCode"` - Name LocalizedText `json:"name"` + Id int64 `json:"id"` + UniqueCode string `json:"uniqueCode"` + Name shared.LocalizedText `json:"name"` } // ProfilePermissionDTO is one module the caller can open; the front-end diff --git a/internal/identity/user/dto.go b/internal/identity/user/dto.go index 9178758..cae54a7 100644 --- a/internal/identity/user/dto.go +++ b/internal/identity/user/dto.go @@ -1,17 +1,15 @@ package user -import "time" +import ( + "time" -type LocalizedText struct { - En string `json:"en"` - Ru string `json:"ru"` - Tm string `json:"tm"` -} + "online-back/internal/shared" +) type StaffBranchDTO struct { - Id int64 `json:"id"` - UniqueCode string `json:"uniqueCode"` - Name LocalizedText `json:"name"` + Id int64 `json:"id"` + UniqueCode string `json:"uniqueCode"` + Name shared.LocalizedText `json:"name"` } type UserPermissionDTO struct { diff --git a/internal/identity/userbranch/dto.go b/internal/identity/userbranch/dto.go index e9106cd..27860af 100644 --- a/internal/identity/userbranch/dto.go +++ b/internal/identity/userbranch/dto.go @@ -1,21 +1,19 @@ package userbranch -import "time" +import ( + "time" -type LocalizedText struct { - En string `json:"en"` - Ru string `json:"ru"` - Tm string `json:"tm"` -} + "online-back/internal/shared" +) type UserBranchDTO struct { - Id int64 `json:"id"` - UserId int64 `json:"userId"` - UserName string `json:"userName"` - BranchId int64 `json:"branchId"` - BranchName LocalizedText `json:"branchName"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + Id int64 `json:"id"` + UserId int64 `json:"userId"` + UserName string `json:"userName"` + BranchId int64 `json:"branchId"` + BranchName shared.LocalizedText `json:"branchName"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } type CreateUserBranchDTO struct { diff --git a/internal/org/branches/db/postgresql.go b/internal/org/branches/db/postgresql.go index ea3f46f..6b4e6f4 100644 --- a/internal/org/branches/db/postgresql.go +++ b/internal/org/branches/db/postgresql.go @@ -273,7 +273,7 @@ func (r *repository) ensureProvince(ctx context.Context, provinceID *int64) erro return err } -func marshalBranchJSON(name, address branches.LocalizedText) ([]byte, []byte, error) { +func marshalBranchJSON(name, address shared.LocalizedText) ([]byte, []byte, error) { nameJSON, err := json.Marshal(name) if err != nil { return nil, nil, err diff --git a/internal/org/branches/dto.go b/internal/org/branches/dto.go index 7bbf5d4..f88ae43 100644 --- a/internal/org/branches/dto.go +++ b/internal/org/branches/dto.go @@ -1,64 +1,60 @@ package branches -type LocalizedText struct { - En string `json:"en"` - Ru string `json:"ru"` - Tm string `json:"tm"` -} +import "online-back/internal/shared" type BranchDTO struct { - Id int64 `json:"id"` - UniqueCode string `json:"uniqueCode"` - Name LocalizedText `json:"name"` - Address LocalizedText `json:"address"` - Region string `json:"region"` - ProvinceId *int64 `json:"provinceId"` - ProvinceName LocalizedText `json:"provinceName"` - PhoneNumbers string `json:"phoneNumbers"` - BillingUsername string `json:"billingUsername"` - BillingPassword string `json:"billingPassword"` - BillingSberUsername string `json:"billingSberUsername"` - BillingSberPassword string `json:"billingSberPassword"` - BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` - BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` - BillingSwiftUsername string `json:"billingSwiftUsername"` - BillingSwiftPassword string `json:"billingSwiftPassword"` - Active bool `json:"active"` + Id int64 `json:"id"` + UniqueCode string `json:"uniqueCode"` + Name shared.LocalizedText `json:"name"` + Address shared.LocalizedText `json:"address"` + Region string `json:"region"` + ProvinceId *int64 `json:"provinceId"` + ProvinceName shared.LocalizedText `json:"provinceName"` + PhoneNumbers string `json:"phoneNumbers"` + BillingUsername string `json:"billingUsername"` + BillingPassword string `json:"billingPassword"` + BillingSberUsername string `json:"billingSberUsername"` + BillingSberPassword string `json:"billingSberPassword"` + BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` + BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` + BillingSwiftUsername string `json:"billingSwiftUsername"` + BillingSwiftPassword string `json:"billingSwiftPassword"` + Active bool `json:"active"` } type CreateBranchDTO struct { - UniqueCode string `json:"uniqueCode" binding:"required,numeric,len=4"` - Name LocalizedText `json:"name" binding:"required"` - Address LocalizedText `json:"address" binding:"required"` - Region string `json:"region" binding:"required"` - ProvinceId *int64 `json:"provinceId"` - PhoneNumbers string `json:"phoneNumbers"` - BillingUsername string `json:"billingUsername"` - BillingPassword string `json:"billingPassword"` - BillingSberUsername string `json:"billingSberUsername"` - BillingSberPassword string `json:"billingSberPassword"` - BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` - BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` - BillingSwiftUsername string `json:"billingSwiftUsername"` - BillingSwiftPassword string `json:"billingSwiftPassword"` - Active *bool `json:"active"` + UniqueCode string `json:"uniqueCode" binding:"required,numeric,len=4"` + Name shared.LocalizedText `json:"name" binding:"required"` + Address shared.LocalizedText `json:"address" binding:"required"` + Region string `json:"region" binding:"required"` + ProvinceId *int64 `json:"provinceId"` + PhoneNumbers string `json:"phoneNumbers"` + BillingUsername string `json:"billingUsername"` + BillingPassword string `json:"billingPassword"` + BillingSberUsername string `json:"billingSberUsername"` + BillingSberPassword string `json:"billingSberPassword"` + BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` + BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` + BillingSwiftUsername string `json:"billingSwiftUsername"` + BillingSwiftPassword string `json:"billingSwiftPassword"` + Active *bool `json:"active"` } type UpdateBranchDTO struct { - Name LocalizedText `json:"name" binding:"required"` - Address LocalizedText `json:"address" binding:"required"` - Region string `json:"region" binding:"required"` - ProvinceId *int64 `json:"provinceId"` - PhoneNumbers string `json:"phoneNumbers"` - BillingUsername string `json:"billingUsername"` - BillingPassword string `json:"billingPassword"` - BillingSberUsername string `json:"billingSberUsername"` - BillingSberPassword string `json:"billingSberPassword"` - BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` - BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` - BillingSwiftUsername string `json:"billingSwiftUsername"` - BillingSwiftPassword string `json:"billingSwiftPassword"` - Active bool `json:"active"` + Name shared.LocalizedText `json:"name" binding:"required"` + Address shared.LocalizedText `json:"address" binding:"required"` + Region string `json:"region" binding:"required"` + ProvinceId *int64 `json:"provinceId"` + PhoneNumbers string `json:"phoneNumbers"` + BillingUsername string `json:"billingUsername"` + BillingPassword string `json:"billingPassword"` + BillingSberUsername string `json:"billingSberUsername"` + BillingSberPassword string `json:"billingSberPassword"` + BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` + BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` + BillingSwiftUsername string `json:"billingSwiftUsername"` + BillingSwiftPassword string `json:"billingSwiftPassword"` + Active bool `json:"active"` } type ListFilter struct { @@ -74,12 +70,12 @@ type ListFilter struct { // BranchListItemDTO is the list row; address, region and billing credentials // come from GET /branches/:id. type BranchListItemDTO struct { - Id int64 `json:"id"` - UniqueCode string `json:"uniqueCode"` - Name LocalizedText `json:"name"` - ProvinceName LocalizedText `json:"provinceName"` - PhoneNumbers string `json:"phoneNumbers"` - Active bool `json:"active"` + Id int64 `json:"id"` + UniqueCode string `json:"uniqueCode"` + Name shared.LocalizedText `json:"name"` + ProvinceName shared.LocalizedText `json:"provinceName"` + PhoneNumbers string `json:"phoneNumbers"` + Active bool `json:"active"` } type ListBranchDTO struct {