+89
@@ -0,0 +1,89 @@
|
||||
package signrecorddata
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/signrecordmod"
|
||||
)
|
||||
|
||||
// AppData 需要组装返回的数据
|
||||
type AppData struct {
|
||||
BaseInfo *signrecordmod.SignRecordInfo `json:"baseInfo"` // 基础信息
|
||||
}
|
||||
|
||||
// FormatAppDataList 格式化app列表数据
|
||||
func FormatAppDataList(origin []signrecordmod.SignRecord) (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 signrecordmod.SignRecord) (res AppData) {
|
||||
if item.ID.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// 组装返回数据
|
||||
res.BaseInfo = &signrecordmod.SignRecordInfo{
|
||||
ID: item.ID,
|
||||
PID: item.PID,
|
||||
UID: item.UID,
|
||||
TotalDays: item.TotalDays,
|
||||
CurrentSignDays: item.CurrentSignDays,
|
||||
ForgetSignDays: item.ForgetSignDays,
|
||||
RenewalSignDays: item.RenewalSignDays,
|
||||
SignTime: item.SignTime,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdateTime: item.UpdateTime,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// AppSimpleData 仅返回基础数据
|
||||
type AppSimpleData *signrecordmod.SignRecordInfo
|
||||
|
||||
// FormatAppSimpleDataList 格式化app列表数据
|
||||
func FormatAppSimpleDataList(origin []signrecordmod.SignRecord) (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 signrecordmod.SignRecord) (res AppSimpleData) {
|
||||
if item.ID.IsZero() {
|
||||
return
|
||||
}
|
||||
|
||||
// 组装返回数据
|
||||
res = &signrecordmod.SignRecordInfo{
|
||||
ID: item.ID,
|
||||
PID: item.PID,
|
||||
UID: item.UID,
|
||||
TotalDays: item.TotalDays,
|
||||
CurrentSignDays: item.CurrentSignDays,
|
||||
ForgetSignDays: item.ForgetSignDays,
|
||||
RenewalSignDays: item.RenewalSignDays,
|
||||
SignTime: item.SignTime,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdateTime: item.UpdateTime,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user