mirror of
https://github.com/wahyd4/scraper.git
synced 2026-08-09 05:06:22 +10:00
25 lines
474 B
Go
25 lines
474 B
Go
package status
|
|
|
|
import "github.com/jinzhu/gorm"
|
|
|
|
type ResultStatus struct {
|
|
gorm.Model
|
|
Latest string
|
|
City string `gorm:"index:city"`
|
|
URL string `gorm:"index:url"`
|
|
}
|
|
|
|
type Handler struct {
|
|
DB *gorm.DB
|
|
}
|
|
|
|
func (handler *Handler) GetStatus(city, url string) *ResultStatus {
|
|
var status ResultStatus
|
|
handler.DB.First(&status, "city = ? and url = ?", city, url)
|
|
return &status
|
|
}
|
|
|
|
func (handler *Handler) SaveStatus(status *ResultStatus) {
|
|
handler.DB.Save(&status)
|
|
}
|