44 lines
906 B
Go
44 lines
906 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
"yintai-api/app/common/service"
|
|
)
|
|
|
|
type Process struct {
|
|
ID int64
|
|
CreateTime int64
|
|
UpdateTime int64
|
|
}
|
|
|
|
type ProcessPage struct {
|
|
Process
|
|
ProcessTranslations
|
|
CategoryID int64
|
|
CategoryName string
|
|
CategoryEn string
|
|
}
|
|
|
|
func (r *ProcessPage) Format() map[string]any {
|
|
res := make(map[string]any)
|
|
images := make([]string, 0)
|
|
_ = json.Unmarshal([]byte(r.Images), &images)
|
|
for _, img := range images {
|
|
img = service.NewQiniu().QuarterUrl(img)
|
|
images = append(images, img)
|
|
}
|
|
res["images"] = images
|
|
res["id"] = r.ID
|
|
res["create_time"] = time.Unix(r.CreateTime, 0).Format("2006-01-02 15:04:05")
|
|
res["lang"] = r.Lang
|
|
res["title"] = r.Title
|
|
res["content"] = r.Content
|
|
res["process_time"] = r.ProcessTime
|
|
res["category_id"] = r.CategoryID
|
|
res["category_name"] = r.CategoryName
|
|
res["category_name_en"] = r.CategoryEn
|
|
|
|
return res
|
|
}
|