wideesg-report-api/Models/user.go

34 lines
604 B
Go
Raw Normal View History

2021-11-24 14:49:24 +08:00
package Models
import (
"ESG/Databases"
)
type List struct{
ID int `gorm:"primary_key"`
Title string `gorm:"column:title"`
Cover string `gorm:"column:cover"`
Picture string `gorm:"column:picture"`
}
//查询列表数据库
func (l *List) GetList() []List{
var list []List
Databases.Db.Find(&list)
return list
}
//查询单个数据库
func (l *List) GetDetails(id string) List{
Databases.Db.Where("id = ?",id).Find(&l)
return *l
}
func (l *List) SetNews() string{
result := Databases.Db.Create(&l)
if result.RowsAffected == 0{
return "发布失败"
}else{
return "发布成功"
}
}