feat: getusertitles now must return all the title info

This commit is contained in:
Iron_Felix 2025-11-22 07:09:30 +03:00
parent 258eb749d9
commit ba68b5ee04
3 changed files with 14 additions and 14 deletions

View file

@ -424,9 +424,8 @@ components:
user_id:
type: integer
format: int64
title_id:
type: integer
format: int64
title:
$ref: '#/components/schemas/Title'
status:
$ref: '#/components/schemas/UserTitleStatus'
rate:

View file

@ -143,7 +143,7 @@ type UserTitle struct {
// Status User's title status
Status UserTitleStatus `json:"status"`
TitleId int64 `json:"title_id"`
Title *Title `json:"title,omitempty"`
UserId int64 `json:"user_id"`
AdditionalProperties map[string]interface{} `json:"-"`
}
@ -493,12 +493,12 @@ func (a *UserTitle) UnmarshalJSON(b []byte) error {
delete(object, "status")
}
if raw, found := object["title_id"]; found {
err = json.Unmarshal(raw, &a.TitleId)
if raw, found := object["title"]; found {
err = json.Unmarshal(raw, &a.Title)
if err != nil {
return fmt.Errorf("error reading 'title_id': %w", err)
return fmt.Errorf("error reading 'title': %w", err)
}
delete(object, "title_id")
delete(object, "title")
}
if raw, found := object["user_id"]; found {
@ -554,9 +554,11 @@ func (a UserTitle) MarshalJSON() ([]byte, error) {
return nil, fmt.Errorf("error marshaling 'status': %w", err)
}
object["title_id"], err = json.Marshal(a.TitleId)
if err != nil {
return nil, fmt.Errorf("error marshaling 'title_id': %w", err)
if a.Title != nil {
object["title"], err = json.Marshal(a.Title)
if err != nil {
return nil, fmt.Errorf("error marshaling 'title': %w", err)
}
}
object["user_id"], err = json.Marshal(a.UserId)

View file

@ -7,9 +7,8 @@ properties:
user_id:
type: integer
format: int64
title_id:
type: integer
format: int64
title:
$ref: ./Title.yaml
status:
$ref: ./enums/UserTitleStatus.yaml
rate: