43 lines
973 B
Go
43 lines
973 B
Go
package dto
|
|
|
|
import (
|
|
"fmt"
|
|
"knowledge/api/model"
|
|
"knowledge/utils"
|
|
)
|
|
|
|
type StaticDto struct {
|
|
Name string `json:"name"` // 名称
|
|
Total int `json:"total"` // 数量
|
|
}
|
|
|
|
// GetStaticListDto 问答题库列表
|
|
func GetStaticListDto(m []*model.QuestionQa) []*QuestionQaDto {
|
|
// 处理返回值
|
|
responses := make([]*QuestionQaDto, len(m))
|
|
|
|
if len(m) > 0 {
|
|
for i, v := range m {
|
|
response := &QuestionQaDto{
|
|
QaId: fmt.Sprintf("%d", v.QaId),
|
|
QaName: v.QaName,
|
|
QaQuantity: v.QaQuantity,
|
|
QaStatus: v.QaStatus,
|
|
QaRuleContent: v.QaRuleContent,
|
|
QaDisplayType: v.QaDisplayType,
|
|
QaExpireTime: v.QaExpireTime,
|
|
QaShareId: utils.AddDomain(v.QaShareId),
|
|
Image: utils.AddOssDomain(v.Image),
|
|
OpenNumber: v.OpenNumber,
|
|
CreatedAt: v.CreatedAt,
|
|
UpdatedAt: v.UpdatedAt,
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
responses[i] = response
|
|
}
|
|
}
|
|
|
|
return responses
|
|
}
|