83 lines
2.7 KiB
Go
83 lines
2.7 KiB
Go
package dao
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"hospital-admin-api/api/model"
|
|
"hospital-admin-api/global"
|
|
)
|
|
|
|
type DoctorIntroductionRecordDao struct {
|
|
}
|
|
|
|
// GetDoctorIntroductionRecordByDoctorId 获取医生简介审核数据-医生id
|
|
func (r *DoctorIntroductionRecordDao) GetDoctorIntroductionRecordByDoctorId(doctorId int64) (m *model.DoctorIntroductionRecord, err error) {
|
|
err = global.Db.Where("doctor_id = ?", doctorId).First(&m).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// GetDoctorIntroductionRecordPreloadById 获取医生简介审核数据-加载全部关联-医生id
|
|
func (r *DoctorIntroductionRecordDao) GetDoctorIntroductionRecordPreloadById(doctorId int64) (m *model.DoctorIntroductionRecord, err error) {
|
|
err = global.Db.Preload(clause.Associations).First(&m, doctorId).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// EditDoctorIntroductionRecord 修改医生简介审核
|
|
func (r *DoctorIntroductionRecordDao) EditDoctorIntroductionRecord(tx *gorm.DB, maps interface{}, data interface{}) error {
|
|
err := tx.Model(&model.DoctorIntroductionRecord{}).Where(maps).Updates(data).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EditDoctorIntroductionRecordById 修改医生简介审核-医生id
|
|
func (r *DoctorIntroductionRecordDao) EditDoctorIntroductionRecordById(tx *gorm.DB, doctorId int64, data interface{}) error {
|
|
err := tx.Model(&model.DoctorIntroductionRecord{}).Where("doctor_id = ?", doctorId).Updates(data).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetDoctorIntroductionRecordList 获取医生简介审核列表
|
|
func (r *DoctorIntroductionRecordDao) GetDoctorIntroductionRecordList(maps interface{}) (m []*model.DoctorIntroductionRecord, err error) {
|
|
err = global.Db.Where(maps).Find(&m).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// AddDoctorIntroductionRecord 新增医生简介审核
|
|
func (r *DoctorIntroductionRecordDao) AddDoctorIntroductionRecord(tx *gorm.DB, model *model.DoctorIntroductionRecord) (*model.DoctorIntroductionRecord, error) {
|
|
if err := tx.Create(model).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return model, nil
|
|
}
|
|
|
|
// GetDoctorIntroductionRecordLast 获取医生简介审核最后一条数据
|
|
func (r *DoctorIntroductionRecordDao) GetDoctorIntroductionRecordLast(maps interface{}) (m *model.DoctorIntroductionRecord, err error) {
|
|
err = global.Db.Where(maps).Last(&m).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
// DeleteDoctorIntroductionRecord 删除
|
|
func (r *DoctorIntroductionRecordDao) DeleteDoctorIntroductionRecord(tx *gorm.DB, maps interface{}) error {
|
|
err := tx.Where(maps).Delete(&model.DoctorIntroductionRecord{}).Error
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|