增加 记录问答题库打开次数
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user