新增简介审核-医生详情、简介审核-审核医生
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
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
|
||||
}
|
||||
@@ -555,3 +555,53 @@ func (r *UserDoctorDao) GetUserDoctorExportListSearch(req requests.UserDoctorExp
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// GetDoctorIntroductionPageSearch 简介审核-获取医生列表-分页
|
||||
func (r *UserDoctorDao) GetDoctorIntroductionPageSearch(req requests.GetDoctorIntroductionPage, page, pageSize int) (m []*model.UserDoctor, total int64, err error) {
|
||||
var totalRecords int64
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.UserDoctor{}).Omit("open_id", "union_id", "wx_session_key")
|
||||
|
||||
// 用户
|
||||
query = query.Preload("User", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("user_password", "salt")
|
||||
})
|
||||
|
||||
// 医院
|
||||
query = query.Preload("Hospital", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Select("hospital_id,hospital_name,hospital_level_name")
|
||||
})
|
||||
|
||||
// 手机号
|
||||
if req.Mobile != "" {
|
||||
subQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile LIKE ?", "%"+req.Mobile+"%")
|
||||
|
||||
query = query.Where(gorm.Expr("user_id IN (?)", subQuery))
|
||||
}
|
||||
|
||||
// 用户名称
|
||||
if req.UserName != "" {
|
||||
query = query.Where("user_name LIKE ?", "%"+req.UserName+"%")
|
||||
}
|
||||
|
||||
// 个人简介审核状态
|
||||
if req.IntroductionStatus == nil {
|
||||
query = query.Where("introduction_status in (?)", []string{"2"})
|
||||
} else {
|
||||
query = query.Where("introduction_status = ?", req.IntroductionStatus)
|
||||
}
|
||||
|
||||
// 查询总数量
|
||||
if err := query.Count(&totalRecords).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
err = query.Scopes(model.Paginate(page, pageSize)).Find(&m).Error
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
return m, totalRecords, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user