增加 记录问答题库打开次数

This commit is contained in:
2024-09-29 17:03:46 +08:00
parent c7daf18830
commit f91fb16996
3 changed files with 36 additions and 0 deletions
+18
View File
@@ -188,3 +188,21 @@ func (r *QuestionQaDao) GetQuestionQaPageSearch(req requests.GetQuestionQaPage,
}
return m, totalRecords, nil
}
// Inc 自增
func (r *QuestionQaDao) Inc(tx *gorm.DB, qaId int64, field string, numeral int) error {
err := tx.Model(&model.QuestionQa{}).Where("qa_id = ?", qaId).UpdateColumn(field, gorm.Expr(field+" + ?", numeral)).Error
if err != nil {
return err
}
return nil
}
// Dec 自减
func (r *QuestionQaDao) Dec(tx *gorm.DB, qaId int64, field string, numeral int) error {
err := tx.Model(&model.QuestionQa{}).Where("qa_id = ?", qaId).UpdateColumn(field, gorm.Expr(field+" - ?", numeral)).Error
if err != nil {
return err
}
return nil
}