package service import ( "cc-officialweb/models" "cc-officialweb/utils" ) // GetServicesByID 根据id获得最外层服务 func GetServicesByID(id int) models.Products { var products models.Products tx := utils.DB.Where("id = ?", id).Where("type=?", "serve").First(&products) if tx.Error != nil { return products } return products } func GetServices() models.Products { var products models.Products tx := utils.DB.Where("type=?", "serve").First(&products) if tx.Error != nil { return products } return products } // GetService 根据id获得内层服务 func GetService(productId int) []models.Server { var services []models.Server tx := utils.DB.Where("product_id=?", productId).Find(&services) if tx.Error != nil { return services } return services } // GetServiceDetail 根据id获得服务详情 func GetServiceDetail(serId int) models.Server { var servicesDetail models.Server tx := utils.DB.Where("id=?", serId).First(&servicesDetail) if tx.Error != nil { return servicesDetail } return servicesDetail } // AddService 添加服务信息 func AddService(serve models.Server) bool { tx := utils.DB.Create(&serve) if tx.RowsAffected > 0 { return true } return false }