增加了题库不允许重复的业务逻辑4
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"knowledge/global"
|
||||
"knowledge/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -90,7 +91,6 @@ func (r *QuestionQaService) AddQuestionQa(req requests.AddQuestionQa) (bool, err
|
||||
RoundNum: nil,
|
||||
QaDisplayType: req.QaDisplayType,
|
||||
IsTurnTimer: req.IsTurnTimer,
|
||||
IsRepeat: req.IsRepeat,
|
||||
QaExpireTime: model.LocalTime(qaExpireTime),
|
||||
QaPassword: req.QaPassword,
|
||||
OpenNumber: 0,
|
||||
@@ -217,10 +217,10 @@ func (r *QuestionQaService) AddQuestionQa(req requests.AddQuestionQa) (bool, err
|
||||
questionQaItemDao := dao.QuestionQaItemDao{}
|
||||
|
||||
var notQuestionIds []int64 // 处理需排除的题目id
|
||||
if req.IsRepeat == 1 {
|
||||
if req.RepeatQaId != "" {
|
||||
// 获取正常题库的明细列表
|
||||
maps := make(map[string]interface{})
|
||||
questionQaItems, _ := questionQaItemDao.GetAllNormalQuestionQaItemWhereList(maps)
|
||||
repeatQaId := strings.Split(req.RepeatQaId, ",")
|
||||
questionQaItems, _ := questionQaItemDao.GetQuestionQaItemListByQaIdDistinctQuestionId(repeatQaId)
|
||||
if len(questionQaItems) > 0 {
|
||||
for _, item := range questionQaItems {
|
||||
notQuestionIds = append(notQuestionIds, item.QuestionId)
|
||||
@@ -361,8 +361,8 @@ func (r *QuestionQaService) PutQuestionQa(qaId int64, req requests.PutQuestionQa
|
||||
}
|
||||
|
||||
// 是否允许重复
|
||||
if req.IsRepeat != questionQa.IsRepeat {
|
||||
questionQaData["is_repeat"] = req.IsRepeat
|
||||
if req.RepeatQaId != questionQa.RepeatQaId {
|
||||
questionQaData["repeat_qa_id"] = req.RepeatQaId
|
||||
}
|
||||
|
||||
// 背景图
|
||||
@@ -424,10 +424,10 @@ func (r *QuestionQaService) PutQuestionQa(qaId int64, req requests.PutQuestionQa
|
||||
}
|
||||
|
||||
var notQuestionIds []int64 // 处理需排除的题目id
|
||||
if req.IsRepeat == 1 {
|
||||
if req.RepeatQaId != "" {
|
||||
// 获取正常题库的明细列表
|
||||
maps := make(map[string]interface{})
|
||||
questionQaItems, _ := questionQaItemDao.GetAllNormalQuestionQaItemWhereList(maps)
|
||||
repeatQaId := strings.Split(req.RepeatQaId, ",")
|
||||
questionQaItems, _ := questionQaItemDao.GetQuestionQaItemListByQaIdDistinctQuestionId(repeatQaId)
|
||||
if len(questionQaItems) > 0 {
|
||||
for _, item := range questionQaItems {
|
||||
notQuestionIds = append(notQuestionIds, item.QuestionId)
|
||||
|
||||
Reference in New Issue
Block a user