update account.go, docs.go, service.go, swagger.json, swagger.yaml

This commit is contained in:
redtea committed 2024-10-23 12:00:00 +03:00
1 parent 47ea2eacd0
commit be5630cbd9
5 files changed
+1434

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
package esaccount
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
type ConfidentialType string
type ConfidentialSettings map[string]ConfidentialType
type Int64Slice []int64
const (
All ConfidentialType = "ALL"
Friends ConfidentialType = "FRIENDS"
Nobody ConfidentialType = "NOBODY"
)
type Account struct {
Id int64 `json:"id" gorm:"unique;primaryKey"`
Description string `json:"description"`
DateOfBirth string `json:"date_of_birth"`
Follows Int64Slice `json:"follows" gorm:"type:text"`
Followers Int64Slice `json:"followers" gorm:"type:text"`
Confidentials ConfidentialSettings `json:"confidentials" gorm:"type:text"`
}
// Implementing the driver.Valuer interface for Int64Slice
func (s Int64Slice) Value() (driver.Value, error) {
return json.Marshal(s)
}
// Implementing the sql.Scanner interface for Int64Slice
func (s *Int64Slice) Scan(value interface{}) error {
if err := json.Unmarshal(value.([]byte), s); err != nil {
return fmt.Errorf("failed to unmarshal Int64Slice: %w", err)
}
return nil
}
// Implementing the driver.Valuer interface for ConfidentialSettings
func (c ConfidentialSettings) Value() (driver.Value, error) {
return json.Marshal(c)
}
// Implementing the sql.Scanner interface for ConfidentialSettings
func (c *ConfidentialSettings) Scan(value interface{}) error {
if err := json.Unmarshal(value.([]byte), c); err != nil {
return fmt.Errorf("failed to unmarshal ConfidentialSettings: %w", err)
}
return nil
}