+85
@@ -0,0 +1,85 @@
|
||||
package quicksearchdata
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/quicksearchmod"
|
||||
)
|
||||
|
||||
// AppData 需要组装返回的数据
|
||||
type AppData struct {
|
||||
BaseInfo *quicksearchmod.QuickSearchInfo `json:"baseInfo"` // 基础信息
|
||||
}
|
||||
|
||||
// FormatAppDataList 格式化app列表数据
|
||||
func FormatAppDataList(origin []quicksearchmod.QuickSearch) (res []AppData) {
|
||||
res = make([]AppData, len(origin))
|
||||
if len(origin) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 组装返回数据
|
||||
for i, item := range origin {
|
||||
res[i] = FormatAppData(item)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FormatAppData 格式化app数据
|
||||
func FormatAppData(item quicksearchmod.QuickSearch) (res AppData) {
|
||||
if item.ID.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// 组装返回数据
|
||||
res.BaseInfo = &quicksearchmod.QuickSearchInfo{
|
||||
ID: item.ID,
|
||||
Enabled: item.Enabled,
|
||||
Title: item.Title,
|
||||
SearchKeyword: item.SearchKeyword,
|
||||
Link: item.Link,
|
||||
Type: item.Type,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AppSimpleData 仅返回基础数据
|
||||
type AppSimpleData *quicksearchmod.QuickSearchInfo
|
||||
|
||||
// FormatAppSimpleDataList 格式化app列表数据
|
||||
func FormatAppSimpleDataList(origin []quicksearchmod.QuickSearch) (res []AppSimpleData) {
|
||||
res = make([]AppSimpleData, len(origin))
|
||||
if len(origin) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 组装返回数据
|
||||
for i, item := range origin {
|
||||
res[i] = FormatAppSimpleData(item)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FormatAppSimpleData 格式化app数据
|
||||
func FormatAppSimpleData(item quicksearchmod.QuickSearch) (res AppSimpleData) {
|
||||
if item.ID.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// 组装返回数据
|
||||
res = &quicksearchmod.QuickSearchInfo{
|
||||
ID: item.ID,
|
||||
Enabled: item.Enabled,
|
||||
Title: item.Title,
|
||||
SearchKeyword: item.SearchKeyword,
|
||||
Link: item.Link,
|
||||
Type: item.Type,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user