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

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 {