ai work
This commit is contained in:
@@ -9,20 +9,20 @@ import (
|
||||
type Work struct {
|
||||
ID int
|
||||
Name string
|
||||
RequiredLevel int
|
||||
MoneyIncome decimal.Decimal
|
||||
MinExp int
|
||||
MaxExp int
|
||||
RequiredLevel int `db:"required_level"`
|
||||
MoneyIncome decimal.Decimal `db:"money_income"`
|
||||
MinExp int `db:"min_exp"`
|
||||
MaxExp int `db:"max_exp"`
|
||||
}
|
||||
|
||||
func GetWorkById(id int) (*Work, error) {
|
||||
work := new(Work)
|
||||
tx := database.PostgresDatabase.First(work, id)
|
||||
return work, tx.Error
|
||||
func GetWorkById(id int) (Work, error) {
|
||||
work := Work{}
|
||||
err := database.PostgresDatabase.Get(&work, "SELECT * FROM works WHERE id = $1;", id)
|
||||
return work, err
|
||||
}
|
||||
|
||||
func GetAllWorks() ([]*Work, error) {
|
||||
works := make([]*Work, 0)
|
||||
tx := database.PostgresDatabase.Order("id").Find(&works)
|
||||
return works, tx.Error
|
||||
func GetAllWorks() ([]Work, error) {
|
||||
works := make([]Work, 0)
|
||||
err := database.PostgresDatabase.Select(&works, "SELECT * FROM works;")
|
||||
return works, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user