56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
package dto
|
||
|
||
import (
|
||
"fmt"
|
||
"knowledge/api/model"
|
||
)
|
||
|
||
// QuestionQaTimerDto 知识问答-计时设置
|
||
type QuestionQaTimerDto struct {
|
||
TimerId string `json:"timer_id"` // 主键id
|
||
QaId string `json:"qa_id"` // 知识问答id
|
||
QuestionType int `json:"question_type"` // 题目类型(1:单选 2:多选 3:问答 4:判断)
|
||
TimerRule int `json:"timer_rule"` // 计时规则(1:正计时 2:倒计时)
|
||
Duration int `json:"duration"` // 时长(秒)
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// GetQuestionQaTimerDto 详情
|
||
func GetQuestionQaTimerDto(m *model.QuestionQaTimer) *QuestionQaTimerDto {
|
||
return &QuestionQaTimerDto{
|
||
TimerId: fmt.Sprintf("%d", m.TimerId),
|
||
QaId: fmt.Sprintf("%d", m.QaId),
|
||
QuestionType: m.QuestionType,
|
||
TimerRule: m.TimerRule,
|
||
Duration: m.Duration,
|
||
CreatedAt: m.CreatedAt,
|
||
UpdatedAt: m.UpdatedAt,
|
||
}
|
||
}
|
||
|
||
// GetQuestionQaTimerListDto 列表
|
||
func GetQuestionQaTimerListDto(m []*model.QuestionQaTimer) []*QuestionQaTimerDto {
|
||
// 处理返回值
|
||
responses := make([]*QuestionQaTimerDto, len(m))
|
||
|
||
if len(m) > 0 {
|
||
for i, v := range m {
|
||
response := &QuestionQaTimerDto{
|
||
TimerId: fmt.Sprintf("%d", v.TimerId),
|
||
QaId: fmt.Sprintf("%d", v.QaId),
|
||
QuestionType: v.QuestionType,
|
||
TimerRule: v.TimerRule,
|
||
Duration: v.Duration,
|
||
CreatedAt: v.CreatedAt,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
responses[i] = response
|
||
}
|
||
}
|
||
|
||
return responses
|
||
}
|