search/service/domain-service.go

32 lines
671 B
Go

package service
import (
"time"
"myschools.me/suguo/search/exceptionless"
"myschools.me/suguo/search/model"
"myschools.me/suguo/search/mysql"
)
func domainAnalyze(domain *model.Domain) {
if domain.Status != 0 && domain.UpdatedAt.After(time.Now().Add(10*time.Minute)) {
return
}
db, err := mysql.New()
if err != nil {
exceptionless.SubmitAppError("domainAnalyze", "mysql.New", nil, err)
return
}
if domain.Current >= uint8(250-len(domain.Root)) {
domain.Current = 1
}
domain.Status = 1 //置状态处理中
if err := db.Updates(domain).Error; err != nil {
exceptionless.SubmitAppError("domainAnalyze", "mysql.Updates", nil, err)
return
}
}