25 lines
460 B
Go
25 lines
460 B
Go
package database
|
|
|
|
import "github.com/shopspring/decimal"
|
|
|
|
type Work struct {
|
|
ID int
|
|
Name string
|
|
RequiredLevel int
|
|
MoneyIncome decimal.Decimal
|
|
MinExp int
|
|
MaxExp int
|
|
}
|
|
|
|
func GetWorkById(id int) (*Work, error) {
|
|
work := new(Work)
|
|
tx := Database.First(work, id)
|
|
return work, tx.Error
|
|
}
|
|
|
|
func GetAllWorks() ([]*Work, error) {
|
|
works := make([]*Work, 0)
|
|
tx := Database.Order("id").Find(&works)
|
|
return works, tx.Error
|
|
}
|