681 lines
17 KiB
Go
681 lines
17 KiB
Go
package service
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"github.com/goccy/go-json"
|
|
"gorm.io/gorm"
|
|
"knowledge/api/dao"
|
|
"knowledge/api/model"
|
|
"knowledge/api/requests"
|
|
"knowledge/global"
|
|
"knowledge/utils"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
type QuestionQaService struct {
|
|
}
|
|
|
|
// AddQuestionQa 新增问答题库
|
|
func (r *QuestionQaService) AddQuestionQa(req requests.AddQuestionQa) (bool, error) {
|
|
// 处理图片
|
|
if req.Image != "" {
|
|
req.Image = utils.RemoveOssDomain(req.Image)
|
|
}
|
|
|
|
// 验证过期时间
|
|
now := time.Now()
|
|
// 1:绝对时效
|
|
// 获取本地时区
|
|
location, err := time.LoadLocation("Local")
|
|
if err != nil {
|
|
return false, errors.New("新增失败")
|
|
}
|
|
|
|
qaExpireTime, err := time.ParseInLocation("2006-01-02 15:04", req.QaExpireTime, location)
|
|
if err != nil {
|
|
return false, errors.New("过期时间错误")
|
|
}
|
|
|
|
if qaExpireTime.Before(now) {
|
|
return false, errors.New("过期时间需大于当前时间")
|
|
}
|
|
|
|
// 处理明细选题规则
|
|
questionQaItemContent, err := json.Marshal(req.QuestionQaItem)
|
|
if err != nil {
|
|
return false, errors.New("明细题目错误")
|
|
}
|
|
|
|
// 选择的明细数量 += QuestionQaItem.Quantity
|
|
itemQuantity := 0
|
|
for _, item := range req.QuestionQaItem {
|
|
itemQuantity = itemQuantity + item.Quantity
|
|
}
|
|
|
|
// 题目总数量
|
|
qaQuantity := req.QaQuantity
|
|
|
|
// 常规模式
|
|
if req.QaType == 1 {
|
|
// 总数量 需大于 选择的明细数量
|
|
if qaQuantity > itemQuantity {
|
|
return false, errors.New("明细题目数量需超过题库所需题目总数量")
|
|
}
|
|
}
|
|
|
|
// 固定套题模式
|
|
if req.QaType == 2 {
|
|
// 计算飞花令题目数量
|
|
tokenQuestionQuantity := 0
|
|
for _, content := range req.TokenQuestionContent {
|
|
tokenQuestionQuantity = tokenQuestionQuantity + content.Quantity
|
|
}
|
|
|
|
// 总数量 = 飞花令题目数量 * 飞花令数量
|
|
qaQuantity = tokenQuestionQuantity * *req.TokenNum
|
|
if qaQuantity > itemQuantity {
|
|
return false, errors.New("明细题目数量需超过题库所需题目总数量")
|
|
}
|
|
|
|
// 单个类型总数量 = 单一题目类型数量 * 飞花令数量
|
|
for _, content := range req.TokenQuestionContent {
|
|
for _, item := range req.QuestionQaItem {
|
|
if content.QuestionType == item.QuestionType {
|
|
quantity := content.Quantity * *req.TokenNum
|
|
if quantity > item.Quantity {
|
|
return false, errors.New(utils.QuestionType(content.QuestionType) + "数量不足")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 多轮固定题型模式
|
|
if req.QaType == 3 {
|
|
// 计算飞花令题目数量
|
|
tokenQuestionQuantity := 0
|
|
for _, content := range req.TokenQuestionContent {
|
|
tokenQuestionQuantity = tokenQuestionQuantity + content.Quantity
|
|
}
|
|
|
|
// 总数量 = 飞花令题目数量 * 飞花令数量 * 轮次
|
|
qaQuantity = tokenQuestionQuantity * *req.TokenNum * *req.RoundNum
|
|
if qaQuantity > itemQuantity {
|
|
return false, errors.New("明细题目数量需超过题库所需题目总数量")
|
|
}
|
|
|
|
// 单个类型总数量 = 单一题目类型数量 * 飞花令数量 * 轮次
|
|
for _, content := range req.TokenQuestionContent {
|
|
for _, item := range req.QuestionQaItem {
|
|
if content.QuestionType == item.QuestionType {
|
|
quantity := content.Quantity * *req.TokenNum * *req.RoundNum
|
|
if quantity > item.Quantity {
|
|
return false, errors.New(utils.QuestionType(content.QuestionType) + "数量不足")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 开始事务
|
|
tx := global.Db.Begin()
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
tx.Rollback()
|
|
}
|
|
}()
|
|
|
|
// 新增题目
|
|
questionQa := &model.QuestionQa{
|
|
QaName: req.QaName,
|
|
QaQuantity: qaQuantity,
|
|
QaStatus: 1,
|
|
QaRuleContent: req.QaRuleContent,
|
|
QaDisplayType: req.QaDisplayType,
|
|
QaExpireTime: model.LocalTime(qaExpireTime),
|
|
QaPassword: req.QaPassword,
|
|
OpenNumber: 0,
|
|
Image: req.Image,
|
|
ItemContent: string(questionQaItemContent),
|
|
}
|
|
|
|
// 固定套题模式-飞花令数量
|
|
if req.QaType == 2 {
|
|
questionQa.TokenNum = req.TokenNum
|
|
} else {
|
|
questionQa.TokenNum = nil
|
|
}
|
|
|
|
// 多轮固定题型模式-飞花令数量、轮次数量
|
|
if req.QaType == 3 {
|
|
questionQa.TokenNum = req.TokenNum
|
|
questionQa.RoundNum = req.RoundNum
|
|
} else {
|
|
questionQa.TokenNum = nil
|
|
questionQa.RoundNum = nil
|
|
}
|
|
|
|
if req.QaType == 2 || req.QaType == 3 {
|
|
// 处理飞花令题目数量规则
|
|
tokenQuestionContent, err := json.Marshal(req.TokenQuestionContent)
|
|
if err != nil {
|
|
return false, errors.New("飞花令题目数量错误")
|
|
}
|
|
|
|
questionQa.TokenQuestionContent = string(tokenQuestionContent)
|
|
}
|
|
|
|
questionQaDao := dao.QuestionQaDao{}
|
|
questionQa, err = questionQaDao.AddQuestionQa(tx, questionQa)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New("新增失败")
|
|
}
|
|
|
|
// 生成分享链接
|
|
questionQaData := make(map[string]interface{})
|
|
questionQaData["qa_share_id"] = utils.HashString(fmt.Sprintf("%d", questionQa.QaId))
|
|
err = questionQaDao.EditQuestionQaById(tx, questionQa.QaId, questionQaData)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New("新增失败")
|
|
}
|
|
|
|
// 新增问答题库题目列表
|
|
questionDao := dao.QuestionDao{}
|
|
questionQaItemDao := dao.QuestionQaItemDao{}
|
|
for _, item := range req.QuestionQaItem {
|
|
// 验证数量
|
|
maps := make(map[string]interface{})
|
|
maps["question_type"] = item.QuestionType
|
|
maps["question_status"] = 1
|
|
maps["is_delete"] = 0
|
|
maps["question_source"] = 1
|
|
if item.Difficulty != nil {
|
|
maps["difficulty"] = item.Difficulty
|
|
}
|
|
maps["first_label_id"] = item.FirstLabelId
|
|
if item.SecondLabelId != "" {
|
|
maps["second_label_id"] = item.SecondLabelId
|
|
}
|
|
|
|
// 获取随机明细题目
|
|
questions, err := questionDao.GetQuestionListRand(maps, item.Quantity)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
if len(questions) < item.Quantity {
|
|
tx.Rollback()
|
|
return false, errors.New("选题超出可选择题目数量")
|
|
}
|
|
|
|
// 新增明细题目
|
|
for _, question := range questions {
|
|
questionQaItem := &model.QuestionQaItem{
|
|
QaId: questionQa.QaId,
|
|
QuestionId: question.QuestionId,
|
|
}
|
|
questionQaItem, err := questionQaItemDao.AddQuestionQaItem(tx, questionQaItem)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New("新增失败")
|
|
}
|
|
}
|
|
}
|
|
|
|
// 新增飞花令标签数据
|
|
if req.QaDisplayType == 2 {
|
|
questionQaTokenDao := dao.QuestionQaTokenDao{}
|
|
baseTokenDao := dao.BaseTokenDao{}
|
|
for i, item := range req.BaseTokenItem {
|
|
tokenId, err := strconv.ParseInt(item.TokenId, 10, 64)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
// 检测飞花令基础数据
|
|
_, err = baseTokenDao.GetBaseTokenById(tokenId)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
questionQaToken := &model.QuestionQaToken{
|
|
QaId: questionQa.QaId,
|
|
TokenId: tokenId,
|
|
Sort: i + 1,
|
|
}
|
|
|
|
questionQaToken, err = questionQaTokenDao.AddQuestionQaToken(tx, questionQaToken)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
}
|
|
}
|
|
|
|
tx.Commit()
|
|
return true, nil
|
|
}
|
|
|
|
// PutQuestionQa 修改题目题库
|
|
func (r *QuestionQaService) PutQuestionQa(qaId int64, req requests.PutQuestionQa) (bool, error) {
|
|
questionQaDao := dao.QuestionQaDao{}
|
|
questionDao := dao.QuestionDao{}
|
|
|
|
questionQa, err := questionQaDao.GetQuestionQaById(qaId)
|
|
if err != nil {
|
|
return false, errors.New("题库不存在")
|
|
}
|
|
|
|
if questionQa.QaStatus == 2 {
|
|
return false, errors.New("题库已失效,请重新创建")
|
|
}
|
|
|
|
// 开始事务
|
|
tx := global.Db.Begin()
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
tx.Rollback()
|
|
}
|
|
}()
|
|
|
|
questionQaData := make(map[string]interface{})
|
|
|
|
// 名称
|
|
if req.QaName != questionQa.QaName {
|
|
questionQaData["qa_name"] = req.QaName
|
|
}
|
|
|
|
// 规则解释
|
|
if req.QaRuleContent != questionQa.QaRuleContent {
|
|
questionQaData["qa_rule_content"] = req.QaRuleContent
|
|
}
|
|
|
|
// 展示类型
|
|
if req.QaDisplayType != questionQa.QaDisplayType {
|
|
questionQaData["qa_display_type"] = req.QaDisplayType
|
|
}
|
|
|
|
// 验证过期时间
|
|
now := time.Now()
|
|
// 1:绝对时效
|
|
// 获取本地时区
|
|
location, err := time.LoadLocation("Local")
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New("新增失败")
|
|
}
|
|
|
|
qaExpireTime, err := time.ParseInLocation("2006-01-02 15:04", req.QaExpireTime, location)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New("过期时间错误")
|
|
}
|
|
|
|
if qaExpireTime.Before(now) {
|
|
tx.Rollback()
|
|
return false, errors.New("过期时间需大于当前时间")
|
|
}
|
|
|
|
// 分享密码
|
|
if req.QaPassword != questionQa.QaPassword {
|
|
questionQaData["qa_password"] = req.QaPassword
|
|
}
|
|
|
|
// 背景图
|
|
image := utils.RemoveOssDomain(req.Image)
|
|
if image != questionQa.Image {
|
|
questionQaData["image"] = image
|
|
}
|
|
|
|
// 处理飞花令题目数量规则
|
|
tokenQuestionContent, _ := json.Marshal(req.TokenQuestionContent)
|
|
if string(tokenQuestionContent) != questionQa.TokenQuestionContent {
|
|
questionQaData["token_question_content"] = string(tokenQuestionContent)
|
|
}
|
|
|
|
// 题目数量
|
|
if req.QaQuantity != questionQa.QaQuantity {
|
|
if req.Action == 1 {
|
|
tx.Rollback()
|
|
return false, errors.New("您修改了题目数量,无法正常修改该题库,请重新生成")
|
|
}
|
|
|
|
// 选择的明细数量 += QuestionQaItem.Quantity
|
|
itemQuantity := 0
|
|
for _, item := range req.QuestionQaItem {
|
|
itemQuantity = itemQuantity + item.Quantity
|
|
}
|
|
|
|
// 题目总数量
|
|
qaQuantity := req.QaQuantity
|
|
|
|
// 常规模式
|
|
if req.QaType == 1 {
|
|
// 总数量 需大于 选择的明细数量
|
|
if qaQuantity > itemQuantity {
|
|
tx.Rollback()
|
|
return false, errors.New("明细题目数量需超过题库所需题目总数量")
|
|
}
|
|
}
|
|
|
|
// 固定套题模式
|
|
if req.QaType == 2 {
|
|
// 计算飞花令题目数量
|
|
tokenQuestionQuantity := 0
|
|
for _, content := range req.TokenQuestionContent {
|
|
tokenQuestionQuantity = tokenQuestionQuantity + content.Quantity
|
|
}
|
|
|
|
// 总数量 = 飞花令题目数量 * 飞花令数量
|
|
qaQuantity = tokenQuestionQuantity * *req.TokenNum
|
|
if qaQuantity > itemQuantity {
|
|
tx.Rollback()
|
|
return false, errors.New("明细题目数量需超过题库所需题目总数量")
|
|
}
|
|
|
|
// 单个类型总数量 = 单一题目类型数量 * 飞花令数量
|
|
for _, content := range req.TokenQuestionContent {
|
|
for _, item := range req.QuestionQaItem {
|
|
if content.QuestionType == item.QuestionType {
|
|
quantity := content.Quantity * *req.TokenNum
|
|
if quantity > item.Quantity {
|
|
tx.Rollback()
|
|
return false, errors.New(utils.QuestionType(content.QuestionType) + "数量不足")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 多轮固定题型模式
|
|
if req.QaType == 3 {
|
|
// 计算飞花令题目数量
|
|
tokenQuestionQuantity := 0
|
|
for _, content := range req.TokenQuestionContent {
|
|
tokenQuestionQuantity = tokenQuestionQuantity + content.Quantity
|
|
}
|
|
|
|
// 总数量 = 飞花令题目数量 * 飞花令数量 * 轮次
|
|
qaQuantity = tokenQuestionQuantity * *req.TokenNum * *req.RoundNum
|
|
if qaQuantity > itemQuantity {
|
|
tx.Rollback()
|
|
return false, errors.New("明细题目数量需超过题库所需题目总数量")
|
|
}
|
|
|
|
// 单个类型总数量 = 单一题目类型数量 * 飞花令数量 * 轮次
|
|
for _, content := range req.TokenQuestionContent {
|
|
for _, item := range req.QuestionQaItem {
|
|
if content.QuestionType == item.QuestionType {
|
|
quantity := content.Quantity * *req.TokenNum * *req.RoundNum
|
|
if quantity > item.Quantity {
|
|
tx.Rollback()
|
|
return false, errors.New(utils.QuestionType(content.QuestionType) + "数量不足")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
questionQaData["qa_quantity"] = req.QaQuantity
|
|
}
|
|
|
|
// 处理题库明细-需重新生成时才会检测明细
|
|
if req.Action == 2 {
|
|
// 删除所有明细
|
|
questionQaItemDao := dao.QuestionQaItemDao{}
|
|
err := questionQaItemDao.DeleteQuestionQaItemByQaId(tx, questionQa.QaId)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
for _, item := range req.QuestionQaItem {
|
|
// 验证数量
|
|
maps := make(map[string]interface{})
|
|
maps["question_type"] = item.QuestionType
|
|
maps["question_status"] = 1
|
|
maps["is_delete"] = 0
|
|
maps["question_source"] = 1
|
|
if item.Difficulty != nil {
|
|
maps["difficulty"] = item.Difficulty
|
|
}
|
|
maps["first_label_id"] = item.FirstLabelId
|
|
if item.SecondLabelId != "" {
|
|
maps["second_label_id"] = item.SecondLabelId
|
|
}
|
|
|
|
// 获取随机明细题目
|
|
questions, err := questionDao.GetQuestionListRand(maps, item.Quantity)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
if len(questions) < item.Quantity {
|
|
tx.Rollback()
|
|
return false, errors.New("选题超出现有题目数量")
|
|
}
|
|
|
|
for _, question := range questions {
|
|
questionQaItem := &model.QuestionQaItem{
|
|
QaId: questionQa.QaId,
|
|
QuestionId: question.QuestionId,
|
|
}
|
|
questionQaItem, err := questionQaItemDao.AddQuestionQaItem(tx, questionQaItem)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New("新增失败")
|
|
}
|
|
}
|
|
}
|
|
|
|
// 处理明细选题规则
|
|
questionQaItemContent, err := json.Marshal(req.QuestionQaItem)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
if string(questionQaItemContent) != questionQa.ItemContent {
|
|
questionQaData["item_content"] = string(questionQaItemContent)
|
|
}
|
|
}
|
|
|
|
if len(questionQaData) > 0 {
|
|
err = questionQaDao.EditQuestionQaById(tx, questionQa.QaId, questionQaData)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New(err.Error())
|
|
}
|
|
}
|
|
|
|
// 删除飞花令
|
|
questionQaTokenDao := dao.QuestionQaTokenDao{}
|
|
maps := make(map[string]interface{})
|
|
maps["qa_id"] = questionQa.QaId
|
|
err = questionQaTokenDao.DeleteQuestionQaToken(tx, maps)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New(err.Error())
|
|
}
|
|
|
|
// 新增飞花令
|
|
if req.QaDisplayType == 2 {
|
|
baseTokenDao := dao.BaseTokenDao{}
|
|
for i, item := range req.BaseTokenItem {
|
|
tokenId, err := strconv.ParseInt(item.TokenId, 10, 64)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
// 检测飞花令基础数据
|
|
_, err = baseTokenDao.GetBaseTokenById(tokenId)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
|
|
questionQaToken := &model.QuestionQaToken{
|
|
QaId: questionQa.QaId,
|
|
TokenId: tokenId,
|
|
Sort: i + 1,
|
|
}
|
|
|
|
questionQaToken, err = questionQaTokenDao.AddQuestionQaToken(tx, questionQaToken)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, err
|
|
}
|
|
}
|
|
}
|
|
|
|
tx.Commit()
|
|
return true, nil
|
|
}
|
|
|
|
// PutQuestionQaPassword 修改题目题库密码
|
|
func (r *QuestionQaService) PutQuestionQaPassword(qaId int64, req requests.PutQuestionQaPassword) (bool, error) {
|
|
questionQaDao := dao.QuestionQaDao{}
|
|
questionQa, err := questionQaDao.GetQuestionQaById(qaId)
|
|
if err != nil {
|
|
return false, errors.New("题库不存在")
|
|
}
|
|
|
|
if questionQa.QaStatus == 2 {
|
|
return false, errors.New("题库已失效")
|
|
}
|
|
|
|
// 分享密码
|
|
if req.QaPassword == questionQa.QaPassword {
|
|
return true, nil
|
|
}
|
|
|
|
// 开始事务
|
|
tx := global.Db.Begin()
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
tx.Rollback()
|
|
}
|
|
}()
|
|
|
|
questionQaData := make(map[string]interface{})
|
|
questionQaData["qa_password"] = req.QaPassword
|
|
|
|
err = questionQaDao.EditQuestionQaById(tx, questionQa.QaId, questionQaData)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New(err.Error())
|
|
}
|
|
|
|
tx.Commit()
|
|
return true, nil
|
|
}
|
|
|
|
// PutQuestionQaExpire 修改问答题库有效期
|
|
func (r *QuestionQaService) PutQuestionQaExpire(qaId int64, req requests.PutQuestionQaExpire) (bool, error) {
|
|
questionQaDao := dao.QuestionQaDao{}
|
|
questionQa, err := questionQaDao.GetQuestionQaById(qaId)
|
|
if err != nil {
|
|
return false, errors.New("题库不存在")
|
|
}
|
|
|
|
if questionQa.QaStatus == 2 {
|
|
return false, errors.New("题库已失效")
|
|
}
|
|
|
|
// 验证过期时间
|
|
now := time.Now()
|
|
|
|
// 获取本地时区
|
|
location, err := time.LoadLocation("Local")
|
|
if err != nil {
|
|
return false, errors.New("修改失败")
|
|
}
|
|
|
|
qaExpireTime, err := time.ParseInLocation("2006-01-02 15:04", req.QaExpireTime, location)
|
|
if err != nil {
|
|
return false, errors.New("过期时间错误")
|
|
}
|
|
|
|
if qaExpireTime.Before(now) {
|
|
return false, errors.New("过期时间需大于当前时间")
|
|
}
|
|
|
|
// 开始事务
|
|
tx := global.Db.Begin()
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
tx.Rollback()
|
|
}
|
|
}()
|
|
|
|
questionQaData := make(map[string]interface{})
|
|
questionQaData["qa_expire_time"] = qaExpireTime
|
|
|
|
err = questionQaDao.EditQuestionQaById(tx, questionQa.QaId, questionQaData)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New(err.Error())
|
|
}
|
|
|
|
tx.Commit()
|
|
return true, nil
|
|
}
|
|
|
|
// PutQuestionQaRule 修改问答题库规则解释
|
|
func (r *QuestionQaService) PutQuestionQaRule(qaId int64, req requests.PutQuestionQaRule) (bool, error) {
|
|
questionQaDao := dao.QuestionQaDao{}
|
|
questionQa, err := questionQaDao.GetQuestionQaById(qaId)
|
|
if err != nil {
|
|
return false, errors.New("题库不存在")
|
|
}
|
|
|
|
if questionQa.QaStatus == 2 {
|
|
return false, errors.New("题库已失效")
|
|
}
|
|
|
|
// 分享密码
|
|
if req.QaRuleContent == questionQa.QaRuleContent {
|
|
return true, nil
|
|
}
|
|
|
|
// 开始事务
|
|
tx := global.Db.Begin()
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
tx.Rollback()
|
|
}
|
|
}()
|
|
|
|
questionQaData := make(map[string]interface{})
|
|
questionQaData["qa_rule_content"] = req.QaRuleContent
|
|
|
|
err = questionQaDao.EditQuestionQaById(tx, questionQa.QaId, questionQaData)
|
|
if err != nil {
|
|
tx.Rollback()
|
|
return false, errors.New(err.Error())
|
|
}
|
|
|
|
tx.Commit()
|
|
return true, nil
|
|
}
|
|
|
|
// RecordQuestionQaOpenNum 记录问答题库打开次数
|
|
func (r *QuestionQaService) RecordQuestionQaOpenNum(tx *gorm.DB, qaId int64) error {
|
|
questionQaDao := dao.QuestionQaDao{}
|
|
err := questionQaDao.Inc(tx, qaId, "open_number", 1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|