shared: use one LocalizedText type everywhere

auth, user, userbranch and org/branches each declared their own identical
{en, ru, tm} struct; they now use shared.LocalizedText. No JSON change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
guwandykandClaude Opus 5.5 committed 2026-10-24 14:19:59 +05:00
1 parent 75b551e281
commit 90e160bdb2
8 files changed
+92 -139

No files matched your search

+4 -18
View File
@@ -8154,7 +8154,7 @@ const docTemplate = `{
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8181,7 +8181,7 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"
@@ -8197,20 +8197,6 @@ const docTemplate = `{
} }
} }
}, },
"branches.LocalizedText": {
"type": "object",
"properties": {
"en": {
"type": "string"
},
"ru": {
"type": "string"
},
"tm": {
"type": "string"
}
}
},
"branches.UpdateBranchDTO": { "branches.UpdateBranchDTO": {
"type": "object", "type": "object",
"required": [ "required": [
@@ -8223,7 +8209,7 @@ const docTemplate = `{
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8250,7 +8236,7 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"
+4 -18
View File
@@ -8148,7 +8148,7 @@
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8175,7 +8175,7 @@
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"
@@ -8191,20 +8191,6 @@
} }
} }
}, },
"branches.LocalizedText": {
"type": "object",
"properties": {
"en": {
"type": "string"
},
"ru": {
"type": "string"
},
"tm": {
"type": "string"
}
}
},
"branches.UpdateBranchDTO": { "branches.UpdateBranchDTO": {
"type": "object", "type": "object",
"required": [ "required": [
@@ -8217,7 +8203,7 @@
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8244,7 +8230,7 @@
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"
+4 -13
View File
@@ -112,7 +112,7 @@ definitions:
active: active:
type: boolean type: boolean
address: address:
$ref: '#/definitions/branches.LocalizedText' $ref: '#/definitions/shared.LocalizedText'
billingPassword: billingPassword:
type: string type: string
billingSberPassword: billingSberPassword:
@@ -130,7 +130,7 @@ definitions:
billingVisaMasterUsername: billingVisaMasterUsername:
type: string type: string
name: name:
$ref: '#/definitions/branches.LocalizedText' $ref: '#/definitions/shared.LocalizedText'
phoneNumbers: phoneNumbers:
type: string type: string
provinceId: provinceId:
@@ -145,21 +145,12 @@ definitions:
- region - region
- uniqueCode - uniqueCode
type: object type: object
branches.LocalizedText:
properties:
en:
type: string
ru:
type: string
tm:
type: string
type: object
branches.UpdateBranchDTO: branches.UpdateBranchDTO:
properties: properties:
active: active:
type: boolean type: boolean
address: address:
$ref: '#/definitions/branches.LocalizedText' $ref: '#/definitions/shared.LocalizedText'
billingPassword: billingPassword:
type: string type: string
billingSberPassword: billingSberPassword:
@@ -177,7 +168,7 @@ definitions:
billingVisaMasterUsername: billingVisaMasterUsername:
type: string type: string
name: name:
$ref: '#/definitions/branches.LocalizedText' $ref: '#/definitions/shared.LocalizedText'
phoneNumbers: phoneNumbers:
type: string type: string
provinceId: provinceId:
+8 -10
View File
@@ -1,6 +1,10 @@
package auth package auth
import "time" import (
"time"
"online-back/internal/shared"
)
type LoginDTO struct { type LoginDTO struct {
Name string `json:"name"` Name string `json:"name"`
@@ -12,12 +16,6 @@ type RefreshTokenDTO struct {
RefreshToken string `json:"refreshToken" binding:"required"` RefreshToken string `json:"refreshToken" binding:"required"`
} }
type LocalizedText struct {
En string `json:"en"`
Ru string `json:"ru"`
Tm string `json:"tm"`
}
type ProfileRoleDTO struct { type ProfileRoleDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Code string `json:"code"` Code string `json:"code"`
@@ -27,9 +25,9 @@ type ProfileRoleDTO struct {
} }
type ProfileBranchDTO struct { type ProfileBranchDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"` UniqueCode string `json:"uniqueCode"`
Name LocalizedText `json:"name"` Name shared.LocalizedText `json:"name"`
} }
// ProfilePermissionDTO is one module the caller can open; the front-end // ProfilePermissionDTO is one module the caller can open; the front-end
+7 -9
View File
@@ -1,17 +1,15 @@
package user package user
import "time" import (
"time"
type LocalizedText struct { "online-back/internal/shared"
En string `json:"en"` )
Ru string `json:"ru"`
Tm string `json:"tm"`
}
type StaffBranchDTO struct { type StaffBranchDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"` UniqueCode string `json:"uniqueCode"`
Name LocalizedText `json:"name"` Name shared.LocalizedText `json:"name"`
} }
type UserPermissionDTO struct { type UserPermissionDTO struct {
+11 -13
View File
@@ -1,21 +1,19 @@
package userbranch package userbranch
import "time" import (
"time"
type LocalizedText struct { "online-back/internal/shared"
En string `json:"en"` )
Ru string `json:"ru"`
Tm string `json:"tm"`
}
type UserBranchDTO struct { type UserBranchDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
UserId int64 `json:"userId"` UserId int64 `json:"userId"`
UserName string `json:"userName"` UserName string `json:"userName"`
BranchId int64 `json:"branchId"` BranchId int64 `json:"branchId"`
BranchName LocalizedText `json:"branchName"` BranchName shared.LocalizedText `json:"branchName"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }
type CreateUserBranchDTO struct { type CreateUserBranchDTO struct {
+1 -1
View File
@@ -273,7 +273,7 @@ func (r *repository) ensureProvince(ctx context.Context, provinceID *int64) erro
return err 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) nameJSON, err := json.Marshal(name)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
+53 -57
View File
@@ -1,64 +1,60 @@
package branches package branches
type LocalizedText struct { import "online-back/internal/shared"
En string `json:"en"`
Ru string `json:"ru"`
Tm string `json:"tm"`
}
type BranchDTO struct { type BranchDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"` UniqueCode string `json:"uniqueCode"`
Name LocalizedText `json:"name"` Name shared.LocalizedText `json:"name"`
Address LocalizedText `json:"address"` Address shared.LocalizedText `json:"address"`
Region string `json:"region"` Region string `json:"region"`
ProvinceId *int64 `json:"provinceId"` ProvinceId *int64 `json:"provinceId"`
ProvinceName LocalizedText `json:"provinceName"` ProvinceName shared.LocalizedText `json:"provinceName"`
PhoneNumbers string `json:"phoneNumbers"` PhoneNumbers string `json:"phoneNumbers"`
BillingUsername string `json:"billingUsername"` BillingUsername string `json:"billingUsername"`
BillingPassword string `json:"billingPassword"` BillingPassword string `json:"billingPassword"`
BillingSberUsername string `json:"billingSberUsername"` BillingSberUsername string `json:"billingSberUsername"`
BillingSberPassword string `json:"billingSberPassword"` BillingSberPassword string `json:"billingSberPassword"`
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
BillingSwiftUsername string `json:"billingSwiftUsername"` BillingSwiftUsername string `json:"billingSwiftUsername"`
BillingSwiftPassword string `json:"billingSwiftPassword"` BillingSwiftPassword string `json:"billingSwiftPassword"`
Active bool `json:"active"` Active bool `json:"active"`
} }
type CreateBranchDTO struct { type CreateBranchDTO struct {
UniqueCode string `json:"uniqueCode" binding:"required,numeric,len=4"` UniqueCode string `json:"uniqueCode" binding:"required,numeric,len=4"`
Name LocalizedText `json:"name" binding:"required"` Name shared.LocalizedText `json:"name" binding:"required"`
Address LocalizedText `json:"address" binding:"required"` Address shared.LocalizedText `json:"address" binding:"required"`
Region string `json:"region" binding:"required"` Region string `json:"region" binding:"required"`
ProvinceId *int64 `json:"provinceId"` ProvinceId *int64 `json:"provinceId"`
PhoneNumbers string `json:"phoneNumbers"` PhoneNumbers string `json:"phoneNumbers"`
BillingUsername string `json:"billingUsername"` BillingUsername string `json:"billingUsername"`
BillingPassword string `json:"billingPassword"` BillingPassword string `json:"billingPassword"`
BillingSberUsername string `json:"billingSberUsername"` BillingSberUsername string `json:"billingSberUsername"`
BillingSberPassword string `json:"billingSberPassword"` BillingSberPassword string `json:"billingSberPassword"`
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
BillingSwiftUsername string `json:"billingSwiftUsername"` BillingSwiftUsername string `json:"billingSwiftUsername"`
BillingSwiftPassword string `json:"billingSwiftPassword"` BillingSwiftPassword string `json:"billingSwiftPassword"`
Active *bool `json:"active"` Active *bool `json:"active"`
} }
type UpdateBranchDTO struct { type UpdateBranchDTO struct {
Name LocalizedText `json:"name" binding:"required"` Name shared.LocalizedText `json:"name" binding:"required"`
Address LocalizedText `json:"address" binding:"required"` Address shared.LocalizedText `json:"address" binding:"required"`
Region string `json:"region" binding:"required"` Region string `json:"region" binding:"required"`
ProvinceId *int64 `json:"provinceId"` ProvinceId *int64 `json:"provinceId"`
PhoneNumbers string `json:"phoneNumbers"` PhoneNumbers string `json:"phoneNumbers"`
BillingUsername string `json:"billingUsername"` BillingUsername string `json:"billingUsername"`
BillingPassword string `json:"billingPassword"` BillingPassword string `json:"billingPassword"`
BillingSberUsername string `json:"billingSberUsername"` BillingSberUsername string `json:"billingSberUsername"`
BillingSberPassword string `json:"billingSberPassword"` BillingSberPassword string `json:"billingSberPassword"`
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"` BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"` BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
BillingSwiftUsername string `json:"billingSwiftUsername"` BillingSwiftUsername string `json:"billingSwiftUsername"`
BillingSwiftPassword string `json:"billingSwiftPassword"` BillingSwiftPassword string `json:"billingSwiftPassword"`
Active bool `json:"active"` Active bool `json:"active"`
} }
type ListFilter struct { type ListFilter struct {
@@ -74,12 +70,12 @@ type ListFilter struct {
// BranchListItemDTO is the list row; address, region and billing credentials // BranchListItemDTO is the list row; address, region and billing credentials
// come from GET /branches/:id. // come from GET /branches/:id.
type BranchListItemDTO struct { type BranchListItemDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
UniqueCode string `json:"uniqueCode"` UniqueCode string `json:"uniqueCode"`
Name LocalizedText `json:"name"` Name shared.LocalizedText `json:"name"`
ProvinceName LocalizedText `json:"provinceName"` ProvinceName shared.LocalizedText `json:"provinceName"`
PhoneNumbers string `json:"phoneNumbers"` PhoneNumbers string `json:"phoneNumbers"`
Active bool `json:"active"` Active bool `json:"active"`
} }
type ListBranchDTO struct { type ListBranchDTO struct {