25 lines
468 B
Go
25 lines
468 B
Go
|
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()
|
||
|
}
|
||
|
}
|