You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
51 lines
1.6 KiB
1 year ago
|
package request
|
||
|
|
||
|
import (
|
||
|
"sorbet/internal/entities"
|
||
|
"sorbet/pkg/db"
|
||
|
)
|
||
|
|
||
|
type ConfigUpsertRequest struct {
|
||
|
ID uint `json:"id" xml:"id" form:"id" path:"id"`
|
||
|
GroupID uint `json:"group_id" xml:"group_id" form:"group_id"`
|
||
|
Name string `json:"name" xml:"name" form:"name"`
|
||
|
Title string `json:"title" xml:"title" form:"title"`
|
||
|
Description string `json:"description" xml:"description" form:"description"`
|
||
|
DataType string `json:"data_type" xml:"data_type" form:"data_type"`
|
||
|
Attributes map[string]any `json:"attributes" xml:"attributes" form:"attributes"`
|
||
|
Value any `json:"value" xml:"value" form:"value"`
|
||
|
Sort int32 `json:"sort" xml:"sort" form:"sort"`
|
||
|
}
|
||
|
|
||
|
func (c *ConfigUpsertRequest) GetID() any {
|
||
|
return c.ID
|
||
|
}
|
||
|
|
||
|
func (c *ConfigUpsertRequest) ToEntity() *entities.Config {
|
||
|
return &entities.Config{
|
||
|
ID: c.ID,
|
||
|
GroupID: c.GroupID,
|
||
|
Name: c.Name,
|
||
|
Title: c.Title,
|
||
|
Description: c.Description,
|
||
|
DataType: c.DataType,
|
||
|
Attributes: c.Attributes,
|
||
|
Value: c.Value,
|
||
|
Sort: c.Sort,
|
||
|
Version: db.Version{Int64: 1, Valid: true},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (c *ConfigUpsertRequest) ToMap() map[string]any {
|
||
|
return map[string]any{
|
||
|
"group_id": c.GroupID,
|
||
|
"name": c.Name,
|
||
|
"title": c.Title,
|
||
|
"description": c.Description,
|
||
|
"data_type": c.DataType,
|
||
|
"attributes": c.Attributes,
|
||
|
"value": c.Value,
|
||
|
"sort": c.Sort,
|
||
|
}
|
||
|
}
|