kefu/service/learn.go

25 lines
468 B
Go
Raw Normal View History

2024-12-10 02:50:12 +00:00
package service
import (
"kefu/models"
"kefu/types"
)
//插入或更新学习库
func AddUpdateLearn(entId, content string) {
learn := models.FindLearn("ent_id = ? and content = ?", entId, content)
if learn.ID != 0 {
learn.Score += 1
learn.SaveLearn("ent_id = ? and content = ?", entId, content)
} else {
m := &models.Learn{
EntId: entId,
Content: content,
CreatedAt: types.Time{},
Score: 1,
Finshed: 1,
}
m.AddLearn()
}
}