
Some checks failed
Deploy to Server (Docker) / deploy (push) Failing after 1m0s
2 +- 3 4 5
36 lines
624 B
Go
36 lines
624 B
Go
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/jinzhu/gorm"
|
|
u "gocommunity.ru/workshop/internal/utils"
|
|
)
|
|
|
|
type Service struct {
|
|
gorm.Model
|
|
Price int32 `json:"price"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
|
|
func (service *Service) CreateService() map[string]interface{} {
|
|
|
|
GetDB().Create(service)
|
|
|
|
resp := u.Message(true, "success")
|
|
resp["service"] = service
|
|
return resp
|
|
}
|
|
|
|
func GetServices() []*Service {
|
|
|
|
servicesSlice := make([]*Service, 0)
|
|
err := GetDB().Table("services").Find(&servicesSlice).Error
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return nil
|
|
}
|
|
|
|
return servicesSlice
|
|
} |