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"
},
"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"

View File

@@ -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"

View File

@@ -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:

View File

@@ -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

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 {