shared: use one LocalizedText type everywhere
Some checks failed
CI/CD / Deploy binary to server (push) Has been cancelled
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled

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:
2026-10-24 14:19:59 +05:00
parent c6540a658b
commit 72a5ac52b0
8 changed files with 92 additions and 139 deletions

View File

@@ -8340,7 +8340,7 @@ const docTemplate = `{
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8367,7 +8367,7 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"
@@ -8383,20 +8383,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": [
@@ -8409,7 +8395,7 @@ const docTemplate = `{
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8436,7 +8422,7 @@ const docTemplate = `{
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"

View File

@@ -8334,7 +8334,7 @@
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8361,7 +8361,7 @@
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"
@@ -8377,20 +8377,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": [
@@ -8403,7 +8389,7 @@
"type": "boolean" "type": "boolean"
}, },
"address": { "address": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"billingPassword": { "billingPassword": {
"type": "string" "type": "string"
@@ -8430,7 +8416,7 @@
"type": "string" "type": "string"
}, },
"name": { "name": {
"$ref": "#/definitions/branches.LocalizedText" "$ref": "#/definitions/shared.LocalizedText"
}, },
"phoneNumbers": { "phoneNumbers": {
"type": "string" "type": "string"

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:

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

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 {

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 {

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

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 {