90 lines
2.6 KiB
Go
90 lines
2.6 KiB
Go
package dao
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hospital-open-api/api/model"
|
|
"hospital-open-api/global"
|
|
)
|
|
|
|
type DoctorExpertiseDao struct {
|
|
}
|
|
|
|
// GetDoctorExpertiseByDoctorId 获取医生专长数据-医生id
|
|
func (r *DoctorExpertiseDao) GetDoctorExpertiseByDoctorId(doctorId int64) (m *model.DoctorExpertise, err error) {
|
|
err = global.Db.Where("doctor_id = ?", doctorId).First(&m).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// GetDoctorExpertiseListByDoctorId 获取医生专长数据列表-医生id
|
|
func (r *DoctorExpertiseDao) GetDoctorExpertiseListByDoctorId(doctorId int64) (m []*model.DoctorExpertise, err error) {
|
|
err = global.Db.Where("doctor_id = ?", doctorId).Find(&m).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// DeleteDoctorExpertise 删除医生专长
|
|
func (r *DoctorExpertiseDao) DeleteDoctorExpertise(tx *gorm.DB, maps interface{}) error {
|
|
err := tx.Where(maps).Delete(&model.DoctorExpertise{}).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EditDoctorExpertise 修改医生专长
|
|
func (r *DoctorExpertiseDao) EditDoctorExpertise(tx *gorm.DB, maps interface{}, data interface{}) error {
|
|
err := tx.Model(&model.DoctorExpertise{}).Where(maps).Updates(data).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EditDoctorExpertiseById 修改医生专长-医生id
|
|
func (r *DoctorExpertiseDao) EditDoctorExpertiseById(tx *gorm.DB, doctorId int64, data interface{}) error {
|
|
err := tx.Model(&model.DoctorExpertise{}).Where("doctor_id = ?", doctorId).Updates(data).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetDoctorExpertiseList 获取医生专长列表
|
|
func (r *DoctorExpertiseDao) GetDoctorExpertiseList(maps interface{}) (m []*model.DoctorExpertise, err error) {
|
|
err = global.Db.Where(maps).Find(&m).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// AddDoctorExpertise 新增医生专长
|
|
func (r *DoctorExpertiseDao) AddDoctorExpertise(tx *gorm.DB, model *model.DoctorExpertise) (*model.DoctorExpertise, error) {
|
|
if err := tx.Create(model).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return model, nil
|
|
}
|
|
|
|
// AddDoctorExpertises 新增医生专长-多
|
|
func (r *DoctorExpertiseDao) AddDoctorExpertises(tx *gorm.DB, models []model.DoctorExpertise) error {
|
|
if err := tx.Create(&models).Error; err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// AddDoctorExpertiseByMap 新增医生专长-map
|
|
func (r *DoctorExpertiseDao) AddDoctorExpertiseByMap(tx *gorm.DB, data map[string]interface{}) (*model.DoctorExpertise, error) {
|
|
userDoctorInfo := &model.DoctorExpertise{}
|
|
if err := tx.Model(&model.DoctorExpertise{}).Create(data).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return userDoctorInfo, nil
|
|
}
|