package micro_service import ( "SCRM/models" "SCRM/service" "fmt" "github.com/jinzhu/gorm" ) func GetData(orgid int64) (model []*models.SgjPatientModel, err error) { db := service.PatientReadDB().Table("sgj_patient_model as m").Where(" m.status = ?", 1) dbs := service.PatientReadDB().Table("sgj_patient_editpiclink as s") fmt.Println("db是什么?", db) if orgid > 0 { db = db.Where("user_org_id = ? ", orgid) } err = db.Preload("Hospitals").Preload("Offices").Preload("OfficeEnviroment"). Preload("Editdoctor").Preload("Editmargin").Preload("Enviroimages").Preload("PatientEditpiclink", func(db *gorm.DB) *gorm.DB { return dbs.Select("s.id,s.images,s.sort,s.piclink,s.linkaddress,s.user_org_id,s.status,s.ctime,s.mtime,s.modeid,s.img_show,s.linkid").Order("sort") }).Select("m.id,m.title,m.sort,m.ctime,m.mtime,m.user_org_id,m.status,m.mode_type").Order("sort").Find(&model).Error return } func GetArticlelist(orgid int64) (models.SgjPatientArticlelist, error) { articlelist := models.SgjPatientArticlelist{} err := service.PatientReadDB().Where("user_org_id = ? AND Status = ?", orgid, 1).Last(&articlelist).Error fmt.Println("错误", err) return articlelist, err } //func GetArticlelistlimit(orgid int64)(models.SgjPatientArticlelist,error) { // articlelist := models.SgjPatientArticlelist{} // service.PatientReadDB().Model(&articlelist).Where("") //} func GetlastLimit(orgid int64) (models.SgjPatientArticlelist, error) { articlelist := models.SgjPatientArticlelist{} err := service.PatientReadDB().Model(&articlelist).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&articlelist).Error return articlelist, err } func GetAllArticeList(orgid int64, limit int64) (articles []models.Articles, err error) { err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ? AND article_status = ?", orgid, 1, 1).Limit(limit).Order("ctime desc").Find(&articles).Error return articles, err } func GetActivitiesById(orgid int64) (models.SgjPatientAddactivity, error) { addactivity := models.SgjPatientAddactivity{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error fmt.Println("查询活动列表错误", err) return addactivity, err } func GetLastActivitiesLast(orgid int64) (models.SgjPatientAddactivity, error) { addactivity := models.SgjPatientAddactivity{} err := service.PatientReadDB().Model(&addactivity).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addactivity).Error return addactivity, err } func GetAllActivities(orgid int64, limit int64) (activity []models.Activity, err error) { err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Limit(limit).Find(&activity).Error return } func GetAllActivitiestwo(orgid int64) (activity []models.Activity, err error) { err = service.PatientReadDB().Model(activity).Where("user_org_id = ? AND status = ?", orgid, 1).Order("ctime desc").Find(&activity).Error return activity, err } func QueryHispitalDetail(orgid int64, id int64) (models.SgjPatientHospital, error) { hospital := models.SgjPatientHospital{} err := service.PatientReadDB().Model(&hospital).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&hospital).Error return hospital, err } func GetOfficeDetail(orgid int64, id int64) (models.SgjPatientOffices, error) { offices := models.SgjPatientOffices{} err := service.PatientReadDB().Model(&offices).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&offices).Error return offices, err } func GetDoctorDetail(orgid int64, id int64) (editdoctor []*models.SgjPatientEditdoctor, err error) { err = service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Order("doc_sort").Find(&editdoctor).Error return } func GetOfficEnviromentDetail(orgid int64, id int64) (offenvironment []models.SgjPatientEnviroimages, err error) { err = service.PatientReadDB().Model(&offenvironment).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, id, 1).Order("sort").Find(&offenvironment).Error return offenvironment, err } func GetArticlelistById(modeid int64, orgID int64) (models.SgjPatientArticlelist, error) { articlelist := models.SgjPatientArticlelist{} err := service.PatientReadDB().Model(articlelist).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&articlelist).Error return articlelist, err } func GetAllArticles(orgid int64, limit int64) (articlelist []models.Articles, err error) { err = service.PatientReadDB().Model(articlelist).Where("user_org_id = ? AND Status = ?", orgid, 1).Limit(limit).Find(&articlelist).Error return } func GetAllPushArticles(orgid int64) (articleslist []models.Articles, err error) { err = service.PatientReadDB().Model(articleslist).Where("user_org_id = ? AND article_status = ? AND status = ?", orgid, 1, 1).Order("ctime desc").Find(&articleslist).Error return } func GetAllActivitiById(modeid int64, orgID int64) (models.SgjPatientAddactivity, error) { addactivity := models.SgjPatientAddactivity{} err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ? AND Status = ?", modeid, orgID, 1).Find(&addactivity).Error return addactivity, err } func GetDefalutNavigationData(orgid int64) (navigation []models.SgjPatientNavigation, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error return navigation, err } func GetOrederModel(orgid int64) (model []*models.SgjPatientOrdmodel, err error) { db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1) if orgid > 0 { db = db.Where("user_org_id = ?", orgid) } err = db.Preload("Hosaddress").Preload("Connectway").Preload("Worktime").Preload("Rideway").Preload("Oldration").Preload("Conrotation"). Select("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error fmt.Println("sql错误是什么", err) return } func GetAllConnecway(orgid int64) (connect []models.SgjPatientConnection, err error) { err = service.PatientReadDB().Model(&connect).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&connect).Error return } func GetActivitDetail(id int64, orgid int64) (models.Activity, error) { activity := models.Activity{} err := service.PatientReadDB().Model(&activity).Where(" id = ? AND user_org_id = ?", id, orgid).Find(&activity).Error return activity, err } func GetArticlesDetail(id int64, orgid int64) (models.Articles, error) { articles := models.Articles{} err := service.PatientReadDB().Model(&articles).Where("id = ? AND user_org_id = ?", id, orgid).Find(&articles).Error return articles, err } //func GetDoctorInfo(id int64,orgid int64)(models.SgjPatientEditdoctor,error) { // editdoctor := models.SgjPatientEditdoctor{} // err := service.PatientReadDB().Model(&editdoctor).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editdoctor).Error // return editdoctor,err //} func GetDoctorInfo(id int64, orgid int64) (models.SgjUserStaffInfo, error) { info := models.SgjUserStaffInfo{} err := service.UserReadDB().Model(&info).Where("id = ? AND user_org_id = ?", id, orgid).Find(&info).Error return info, err } func GetRotationLinkAddress(orgid int64, linkid int64) (models.SgjPatientLinkaddress, error) { linkaddress := models.SgjPatientLinkaddress{} err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&linkaddress).Error return linkaddress, err } func GetNavigationLinkAddressById(id int64, orgid int64) (models.SgjPatientEditmargin, error) { editmargin := models.SgjPatientEditmargin{} err := service.PatientReadDB().Model(&editmargin).Where("id=? and user_org_id = ?", id, orgid).Find(&editmargin).Error return editmargin, err } func GetEnviromentImages(mid int64, orgid int64) (enviro []models.SgjPatientEnviroimages, err error) { err = service.PatientReadDB().Model(&enviro).Where(" modeid = ? AND user_org_id = ?", mid, orgid).Find(&enviro).Error return } func GetAllDoctors(orgid int64) (staff []models.SgjUserStaffInfo, err error) { err = service.UserReadDB().Model(&staff).Where("user_org_id = ? AND status = ? AND user_type <> ? AND user_title <> ? AND user_title <> ?", orgid, 1, 3, 12, 13).Find(&staff).Error return staff, err }