增加了题库不允许重复的业务逻辑6
This commit is contained in:
@@ -217,9 +217,12 @@ func (r *QuestionQaService) AddQuestionQa(req requests.AddQuestionQa) (bool, err
|
||||
questionQaItemDao := dao.QuestionQaItemDao{}
|
||||
|
||||
var notQuestionIds []int64 // 处理需排除的题目id
|
||||
if req.RepeatQaId != "" {
|
||||
if len(req.RepeatQaId) > 0 {
|
||||
// 获取正常题库的明细列表
|
||||
repeatQaId := strings.Split(req.RepeatQaId, ",")
|
||||
var repeatQaId []string
|
||||
for _, item := range req.RepeatQaId {
|
||||
repeatQaId = append(repeatQaId, item.QaId)
|
||||
}
|
||||
questionQaItems, _ := questionQaItemDao.GetQuestionQaItemListByQaIdDistinctQuestionId(repeatQaId)
|
||||
if len(questionQaItems) > 0 {
|
||||
for _, item := range questionQaItems {
|
||||
@@ -361,8 +364,16 @@ func (r *QuestionQaService) PutQuestionQa(qaId int64, req requests.PutQuestionQa
|
||||
}
|
||||
|
||||
// 是否允许重复
|
||||
if req.RepeatQaId != questionQa.RepeatQaId {
|
||||
questionQaData["repeat_qa_id"] = req.RepeatQaId
|
||||
if len(req.RepeatQaId) > 0 {
|
||||
var repeatQaId []string
|
||||
for _, item := range req.RepeatQaId {
|
||||
repeatQaId = append(repeatQaId, item.QaId)
|
||||
}
|
||||
|
||||
repeatQaIdStr := strings.Join(repeatQaId, ",")
|
||||
if repeatQaIdStr != questionQa.RepeatQaId {
|
||||
questionQaData["repeat_qa_id"] = req.RepeatQaId
|
||||
}
|
||||
}
|
||||
|
||||
// 背景图
|
||||
@@ -424,9 +435,12 @@ func (r *QuestionQaService) PutQuestionQa(qaId int64, req requests.PutQuestionQa
|
||||
}
|
||||
|
||||
var notQuestionIds []int64 // 处理需排除的题目id
|
||||
if req.RepeatQaId != "" {
|
||||
if len(req.RepeatQaId) > 0 {
|
||||
// 获取正常题库的明细列表
|
||||
repeatQaId := strings.Split(req.RepeatQaId, ",")
|
||||
var repeatQaId []string
|
||||
for _, item := range req.RepeatQaId {
|
||||
repeatQaId = append(repeatQaId, item.QaId)
|
||||
}
|
||||
questionQaItems, _ := questionQaItemDao.GetQuestionQaItemListByQaIdDistinctQuestionId(repeatQaId)
|
||||
if len(questionQaItems) > 0 {
|
||||
for _, item := range questionQaItems {
|
||||
|
||||
Reference in New Issue
Block a user