JM-WechatMini/service/system/hospital.go

38 lines
1.1 KiB
Go
Raw Normal View History

2023-11-02 04:34:46 +08:00
package system
import (
"miniapp/global"
"miniapp/model/common"
"miniapp/model/common/request"
)
type HospitalService struct {
}
// GetHospitalList 获取医院列表
func (h HospitalService) GetHospitalList(p request.PageInfo) (list []common.Hospital, total int64, err error) {
err = global.GVA_DB.Scopes(Page(p.Page, p.PageSize)).Preload("Notes").Preload("Todos").Find(&list).Offset(-1).Limit(-1).Count(&total).Error
return
}
// CreateHospital 创建医院
func (h HospitalService) CreateHospital(hospital *common.Hospital) (err error) {
return global.GVA_DB.Create(&hospital).Error
}
// UpdateHospital 更新医院
func (h HospitalService) UpdateHospital(hospital *common.Hospital) (err error) {
return global.GVA_DB.Updates(&hospital).Error
}
// DeleteHospital 删除医院
func (h HospitalService) DeleteHospital(hospital *common.Hospital) (err error) {
return global.GVA_DB.Select("Notes").Delete(&hospital).Error
}
// GetHospitalById 根据id获取医院
func (h HospitalService) GetHospitalById(id uint) (hospital *common.Hospital, err error) {
err = global.GVA_DB.Where("id = ?", id).Preload("Notes").Preload("Todos").First(&hospital).Error
return
}