增加了题库不允许重复的业务逻辑
This commit is contained in:
+3
-3
@@ -253,13 +253,13 @@ func (r *QuestionDao) GetQuestionCountSearch(req requests.GetQuestionCount) (tot
|
||||
}
|
||||
|
||||
// GetQuestionNotInListRand 获取列表-随机-排除
|
||||
func (r *QuestionDao) GetQuestionNotInListRand(maps interface{}, notQuestionId []int64, limit int) (m []*model.Question, err error) {
|
||||
func (r *QuestionDao) GetQuestionNotInListRand(maps interface{}, notQuestionIds []int64, limit int) (m []*model.Question, err error) {
|
||||
query := global.Db.Model(&model.Question{})
|
||||
query = query.Where(maps)
|
||||
|
||||
// 排除选项
|
||||
if len(notQuestionId) > 0 {
|
||||
query = query.Where("question_id not in (?)", notQuestionId)
|
||||
if len(notQuestionIds) > 0 {
|
||||
query = query.Where("question_id not in (?)", notQuestionIds)
|
||||
}
|
||||
|
||||
query = query.Limit(limit).Order("rand()")
|
||||
|
||||
@@ -347,3 +347,23 @@ func (r *QuestionQaItemDao) GetQuestionQaItemListByQuestionIdDistinctQaId(questi
|
||||
//query = query.Where("EXISTS (?)", subQuery)
|
||||
//
|
||||
//query = query.Limit(limit).Order("rand()")
|
||||
|
||||
// GetAllNormalQuestionQaItemWhereList 获取正常题库的明细列表
|
||||
func (r *QuestionQaItemDao) GetAllNormalQuestionQaItemWhereList(maps interface{}) (m []*model.QuestionQaItem, err error) {
|
||||
query := global.Db.Model(&model.QuestionQaItem{})
|
||||
query = query.Where(maps)
|
||||
|
||||
query = query.Preload("QuestionQa")
|
||||
|
||||
subQuery := global.Db.Model(&model.QuestionQa{}).
|
||||
Where("qa_status = ?", 1).
|
||||
Select("qa_id")
|
||||
|
||||
query = query.Where("qa_id IN (?)", subQuery)
|
||||
|
||||
err = query.Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user