package site_service import ( "SCRM/models" "SCRM/service" "SCRM/utils" "fmt" "github.com/jinzhu/gorm" "github.com/robfig/cron" "strconv" "time" ) // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html var createDefalutDataCronJob *cron.Cron func BeginAutoCreateDefalutData() { createDefalutDataCronJob.Start() } func init() { utils.InfoLog("开启自动排班定时任务") createDefalutDataCronJob = cron.New() spec := "*/5 * * * * ?" // 每隔5秒执行一次 createDefalutDataCronJob.AddFunc(spec, func() { AutoCreateDefalutSchedules() }) } func AutoCreateDefalutSchedules() { utils.TraceLog("自动添加数据任务开始执行") //获取是10分前的时间 var orginfo []*models.OrgInfo nowtime := time.Now().Unix() fmt.Println("当前时间", nowtime) timebefor := time.Now().Add(-time.Minute * 10).Unix() fmt.Println("10分钟之前时间", timebefor) //1570653733 //1570654333 err := service.PatientReadDB().Raw("select * from sgj_users.sgj_user_org as u where u.ctime>=? AND u.ctime<= ?", timebefor, nowtime).Scan(&orginfo).Error fmt.Println("err", err) fmt.Println("orginfo", orginfo) for i := 0; i < len(orginfo); i++ { userOrgID := orginfo[i].ID orgintroduction := orginfo[i].OrgIntroduction telephone := orginfo[i].Telephone address := orginfo[i].Address fmt.Println("ID是设么", userOrgID) navigation, err := GetPatientNavigation(userOrgID) fmt.Println("err", err) if len(navigation) == 0 { patientNavigation := models.SgjPatientNavigation{ Navtitle: "首页", Navimages: "https://images.shengws.com/2089_o_1571990714383.png", Status: 1, UserOrgId: userOrgID, Nonavimages: "https://images.shengws.com/2105_o_1571990730785.png", Linktype: 1, Ctime: time.Now().Unix(), } err := AddNavgation(&patientNavigation) fmt.Println("err", err) patientnavigationthree := models.SgjPatientNavigation{ Navtitle: "客服", Navimages: "https://images.shengws.com/2101_o_1571990903053.png", Status: 1, UserOrgId: userOrgID, Nonavimages: "https://images.shengws.com/2113_o_1571990915581.png", Linktype: 2, Ctime: time.Now().Unix(), } err = AddNavgation(&patientnavigationthree) patientnavigationtwo := models.SgjPatientNavigation{ Navtitle: "电话", Navimages: "https://images.shengws.com/2092_o_1571990776921.png", Status: 1, UserOrgId: userOrgID, Linktype: 3, Nonavimages: "https://images.shengws.com/2100_o_1571990784845.png", Ctime: time.Now().Unix(), } err = AddNavgation(&patientnavigationtwo) sgjPatientNavigation := models.SgjPatientNavigation{ Navtitle: "联系我们", Navimages: "https://images.shengws.com/2124_o_1571990749565.png", Status: 1, UserOrgId: userOrgID, Nonavimages: "https://images.shengws.com/2079_o_1571990763549.png", Linktype: 4, Ctime: time.Now().Unix(), } err = AddNavgation(&sgjPatientNavigation) fmt.Println("err", err) } model, err := GetData(userOrgID) if len(model) == 0 { patientModel := models.SgjPatientModel{ Title: "轮播图", Sort: 1, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 1, } err := AddPatientModelTwo(&patientModel) fmt.Println("err", err) sgjPatientModel, err := GetQueryModelByLastData(userOrgID) editpiclink := models.SgjPatientEditpiclink{ Images: "https://images.shengws.com/2124_o_1570607834870.png", Sort: 1, UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjPatientModel.ID, } err = AddPatientEdit(&editpiclink) fmt.Println("err", err) patientmodefour := models.SgjPatientModel{ Title: "魔方导航", Sort: 2, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 8, } err = AddPatientModelTwo(&patientmodefour) sgjpatietnmodelfour, err := GetQueryModelByLastData(userOrgID) ID := int64(sgjpatietnmodelfour.ID + 1) fmt.Println("ID是多少", ID) modeid := strconv.FormatInt(ID, 10) magiclink := models.SgjPatientMagiclink{ UserOrgId: userOrgID, Linktype: 2, Instationlink: ID, Ctime: time.Now().Unix(), Status: 1, } AddMacLinkAddress(&magiclink) patientMagiclink, err := GetMacLinkAddressByLastData(userOrgID) orgid := strconv.FormatInt(userOrgID, 10) KeID := int64(sgjpatietnmodelfour.ID + 3) OfficeID := strconv.FormatInt(KeID, 10) magiclinktwo := models.SgjPatientMagiclink{ UserOrgId: userOrgID, Linktype: 2, Instationlink: KeID, Ctime: time.Now().Unix(), Status: 1, } AddMacLinkAddress(&magiclinktwo) patientMagiclinktwo, err := GetMacLinkAddressByLastData(userOrgID) ActiID := int64(sgjpatietnmodelfour.ID + 5) magiclinkthree := models.SgjPatientMagiclink{ UserOrgId: userOrgID, Linktype: 2, Instationlink: ActiID, Ctime: time.Now().Unix(), Status: 1, } AddMacLinkAddress(&magiclinkthree) patientMagiclinkthree, err := GetMacLinkAddressByLastData(userOrgID) ActisID := strconv.FormatInt(ActiID, 10) ActivID := int64(sgjpatietnmodelfour.ID + 6) magiclinkfour := models.SgjPatientMagiclink{ UserOrgId: userOrgID, Linktype: 2, Instationlink: ActivID, Ctime: time.Now().Unix(), Status: 1, } AddMacLinkAddress(&magiclinkfour) patientMagiclinkfour, err := GetMacLinkAddressByLastData(userOrgID) ActivsID := strconv.FormatInt(ActivID, 10) EnviID := int64(sgjpatietnmodelfour.ID + 4) magiclinkfive := models.SgjPatientMagiclink{ UserOrgId: userOrgID, Linktype: 2, Instationlink: EnviID, Ctime: time.Now().Unix(), Status: 1, } AddMacLinkAddress(&magiclinkfive) patientMagiclinkfive, err := GetMacLinkAddressByLastData(userOrgID) EniviIDs := strconv.FormatInt(EnviID, 10) editmargin := models.SgjPatientEditmargin{ Margtitle: "医院介绍", Margimage: "https://images.shengws.com/2162_o_1571992616722.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, //Marginaddress:"http://jk.test.sgjyun.com/#/hospitalIntroduction?id="+modeid+"&orgid="+orgid , Linkid: patientMagiclink.ID, Marginaddress: "http://microweb.kuyicloud.com/#/hospitalIntroduction?id=" + modeid + "&orgid=" + orgid, } err = AddEditMargin(&editmargin) patientEditmargin := models.SgjPatientEditmargin{ Margtitle: "医护团队", Margimage: "https://images.shengws.com/2121_o_1571992634289.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, //Marginaddress:"http://jk.test.sgjyun.com/#/medicalTeam?id="+OfficeID+"&orgid="+orgid, Marginaddress: "http://microweb.kuyicloud.com/#/medicalTeam?id=" + OfficeID + "&orgid=" + orgid, Linkid: patientMagiclinktwo.ID, } err = AddEditMargin(&patientEditmargin) sgjPatientEditmargin := models.SgjPatientEditmargin{ Margtitle: "医院动态", Margimage: "https://images.shengws.com/2163_o_1571992676180.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, //Marginaddress:"http://jk.test.sgjyun.com/#/news?id="+ActisID+"&orgid="+orgid, Marginaddress: "http://microweb.kuyicloud.com/#/news?id=" + ActisID + "&orgid=" + orgid, Linkid: patientMagiclinkthree.ID, } AddEditMargin(&sgjPatientEditmargin) patienteditmarginfour := models.SgjPatientEditmargin{ Margtitle: "医院活动", Margimage: "https://images.shengws.com/2117_o_1571992689392.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, //Marginaddress:"http://jk.test.sgjyun.com/#/activity?id="+ActivsID+"&orgid="+orgid, Marginaddress: "http://microweb.kuyicloud.com/#/activity?id=" + ActivsID + "&orgid=" + orgid, Linkid: patientMagiclinkfour.ID, } AddEditMargin(&patienteditmarginfour) patienteditmarginfive := models.SgjPatientEditmargin{ Margtitle: "医院环境", Margimage: "https://images.shengws.com/2130_o_1571992702226.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, //Marginaddress:"http://jk.test.sgjyun.com/#/departmentEnvironment?id="+EniviIDs+"&orgid="+orgid, Marginaddress: "http://microweb.kuyicloud.com/#/departmentEnvironment?id=" + EniviIDs + "&orgid=" + orgid, Linkid: patientMagiclinkfive.ID, } AddEditMargin(&patienteditmarginfive) patienteditmarginsix := models.SgjPatientEditmargin{ Margtitle: "咨询客服", Margimage: "https://images.shengws.com/2149_o_1571992721076.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, } AddEditMargin(&patienteditmarginsix) patienteditmarginserven := models.SgjPatientEditmargin{ Margtitle: "加入会员", Margimage: "https://images.shengws.com/2165_o_1571992737567.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, Jumpset: 1, } AddEditMargin(&patienteditmarginserven) patienteditmargineghit := models.SgjPatientEditmargin{ Margtitle: "联系我们", Margimage: "https://images.shengws.com/2122_o_1571992753168.png", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Modeid: sgjpatietnmodelfour.ID, } AddEditMargin(&patienteditmargineghit) patientModelTwo := models.SgjPatientModel{ Title: "医院介绍", Sort: 4, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 2, } AddPatientModelTwo(&patientModelTwo) sgjPatientModelTwo, err := GetQueryModelByLastData(userOrgID) hospital := models.SgjPatientHospital{ Title: "医院介绍", Sort: 4, Introduction: orgintroduction, UserOrgId: userOrgID, Modleid: sgjPatientModelTwo.ID, Status: 1, Ctime: time.Now().Unix(), } AddHospital(&hospital) Sgjpatientmodelthree := models.SgjPatientModel{ Title: "科室介绍", Sort: 8, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 3, } AddPatientModelTwo(&Sgjpatientmodelthree) datathree, err := GetQueryModelByLastData(userOrgID) offices := models.SgjPatientOffices{ Title: "科室介绍", Sort: 8, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, Modleid: datathree.ID, Introduction: "", } AddPatientOffices(&offices) patientModelFive := models.SgjPatientModel{ Title: "医护团队", Sort: 5, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 4, } AddPatientModelTwo(&patientModelFive) data, err := GetQueryModelByLastData(userOrgID) editdoctor := models.SgjPatientEditdoctor{ Dochead: "https://images.shengws.com/2062_o_1570608303729.png", DocSort: 1, Docintroduction: "", UserOrgId: userOrgID, Modleid: data.ID, Status: 1, Ctime: time.Now().Unix(), DocPostion: 1, } AddEditDoctor(&editdoctor) modelserven := models.SgjPatientModel{ Title: "医院环境", Sort: 6, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 5, } AddPatientModelTwo(&modelserven) lastData, err := GetQueryModelByLastData(userOrgID) enviroimages := models.SgjPatientEnviroimages{ Enviroimages: "https://images.shengws.com/2076_o_1572602899145.jpg", Sort: 1, UserOrgId: userOrgID, Status: 1, Modeid: lastData.ID, Ctime: time.Now().Unix(), } AddImages(&enviroimages) modelArticles := models.SgjPatientModel{ Title: "医院动态", Sort: 3, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 6, } AddPatientModelTwo(&modelArticles) articleslist, err := GetQueryModelByLastData(userOrgID) fmt.Println("articleslist", articleslist) fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh") articlelist := models.SgjPatientArticlelist{ Title: "医院动态", Sort: 3, UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), Number: 1, Modeid: articleslist.ID, } AddActiclelist(&articlelist) fmt.Println("我爱你中国法阿发法阿凡达阿凡达阿道夫阿道夫阿道夫阿发阿凡达暗室逢灯阿斯蒂芬暗室逢灯") articles, err := GetAritclesData(userOrgID) if len(articles) == 0 { articles := models.Articles{ Title: "", Content: "", Imgs: "https://images.shengws.com/2062_o_1570608303729.png", Status: 1, Ctime: time.Now().Unix(), UserOrgId: userOrgID, ArticleStatus: 1, } AddActicles(&articles) } modelActivitis := models.SgjPatientModel{ Title: "医院活动", Sort: 7, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, ModeType: 7, } AddPatientModelTwo(&modelActivitis) activtiys, err := GetQueryModelByLastData(userOrgID) addactivity := models.SgjPatientAddactivity{ Title: "医院活动", Sort: 7, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, Modeid: activtiys.ID, Number: 1, } AddActivity(&addactivity) activity, err := GetArititys(userOrgID) if len(activity) == 0 { activity := models.Activity{ Title: "医院活动", PosterPhoto: "https://images.shengws.com/2062_o_1570608303729.png", UserOrgId: userOrgID, CreateTime: time.Now().Unix(), Status: 1, } AddActivitys(&activity) } } oldmodels, err := GetContactUsModel(userOrgID) fmt.Println("orgmodels是设么", oldmodels) if len(oldmodels) == 0 { ordmodel := models.PatientOrdmodel{ Title: "轮播图", UserOrgId: userOrgID, Sort: 1, ModeType: 1, Status: 1, Ctime: time.Now().Unix(), } err := AddPatientOrdModel(ºodel) fmt.Println("错误是设么", err) patientOrdmodel, err := GetPatientOrdModelByLastData(userOrgID) conrotation := models.SgjPatientConrotation{ Images: "https://images.shengws.com/2124_o_1570607834870.png", Sort: 1, Modeid: patientOrdmodel.ID, UserOrgId: userOrgID, Ctime: time.Now().Unix(), Status: 1, Piclink: 1, } AddConRotation(&conrotation) ordmodelOne := models.PatientOrdmodel{ Title: "医院地址", UserOrgId: userOrgID, Sort: 2, ModeType: 2, Status: 1, Ctime: time.Now().Unix(), } AddPatientOrdModel(ºodelOne) patientOrdmodelOne, err := GetPatientOrdModelByLastData(userOrgID) hosaddress := models.SgjPatientHosaddress{ Title: "医院地址", UserOrgId: userOrgID, Address: address, Ctime: time.Now().Unix(), Status: 1, Modeid: patientOrdmodelOne.ID, } AddHosAddress(&hosaddress) ordmodeltwo := models.PatientOrdmodel{ Title: "联系方式", UserOrgId: userOrgID, Sort: 3, ModeType: 3, Status: 1, Ctime: time.Now().Unix(), } AddPatientOrdModel(ºodeltwo) patientOrdmodelTwo, err := GetPatientOrdModelByLastData(userOrgID) connectway := models.SgjPatientConnectway{ Title: "联系方式", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), ModeId: patientOrdmodelTwo.ID, } AddConnecWay(&connectway) connection := models.SgjPatientConnection{ Title: "电话", Connecway: 1, Content: telephone, Status: 1, UserOrgId: userOrgID, } AddConnetion(connection) ordmodelthree := models.PatientOrdmodel{ Title: "工作时间", UserOrgId: userOrgID, Sort: 4, ModeType: 4, Status: 1, Ctime: time.Now().Unix(), } AddPatientOrdModel(ºodelthree) patientOrdmodelThree, err := GetPatientOrdModelByLastData(userOrgID) worktime := models.SgjPatientWorktime{ Title: "工作时间", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), ModeId: patientOrdmodelThree.ID, Worktime: "暂无数据", } AddWorkTime(&worktime) ordmodelfour := models.PatientOrdmodel{ Title: "乘车方式", UserOrgId: userOrgID, Sort: 5, ModeType: 5, Status: 1, Ctime: time.Now().Unix(), } AddPatientOrdModel(ºodelfour) patientOrdmodelfour, err := GetPatientOrdModelByLastData(userOrgID) rideway := models.SgjPatientRideway{ Title: "乘车方式", UserOrgId: userOrgID, Status: 1, Ctime: time.Now().Unix(), ModeId: patientOrdmodelfour.ID, RideWay: "暂无数据", } AddRideWay(rideway) } } } func AddPatientModel(model *models.SgjPatientModel) error { err := service.PatientWriteDB().Create(&model).Error fmt.Println("插入错误", err) return err } func QueryModel(orgID int64) (models.SgjPatientModel, error) { model := models.SgjPatientModel{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&model).Error return model, err } func UpdateEditpicLink(orgID int64, ids []int64, editpiclink models.SgjPatientEditpiclink) (err error) { if len(ids) == 1 { err = service.PatientWriteDB().Model(&models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ? ", ids[0], orgID).Update(map[string]interface{}{"modeid": editpiclink.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } else { err = service.PatientWriteDB().Model(&models.SgjPatientEditpiclink{}).Where("id IN(?) and user_org_id = ? ", ids, orgID).Update(map[string]interface{}{"modeid": editpiclink.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } return } func AddRotation(rotation models.SgjPatientRotation) error { err := service.PatientWriteDB().Create(&rotation).Error fmt.Println("插入数据", err) return err } func GetRotationByLastData(orgid int64) (models.SgjPatientRotation, error) { rotation := models.SgjPatientRotation{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&rotation).Error return rotation, err } func AddRotationUpload(connecmodel *models.SgjPatientConnecmodel) error { err := service.PatientWriteDB().Create(&connecmodel).Error fmt.Println("错误是什么,err", err) return err } func AddHispital(newmodel models.SgjPatientHospital) error { err := service.PatientWriteDB().Create(&newmodel).Error return err } func AddOffices(offices models.SgjPatientOffices) error { err := service.PatientWriteDB().Create(&offices).Error return err } func AddDoctor(doctor models.SgjPatientDocinfo) error { err := service.PatientWriteDB().Create(&doctor).Error return err } func AddDoctorInfo(doctor models.SgjPatientEditdoctor) error { err := service.PatientWriteDB().Create(&doctor).Error return err } func AddImages(enviroimages *models.SgjPatientEnviroimages) error { err := service.PatientWriteDB().Create(&enviroimages).Error return err } func AddOffEnvironment(officenviroment models.SgjPatientOffenvironment) error { err := service.PatientWriteDB().Create(&officenviroment).Error return err } func GetRationImages(orgID int64) (rot []*models.SgjPatientRotation, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Order("sort").Find(&rot).Error fmt.Println("错误是什么", err) return } func GetHospitalInfo(orgID int64) (models.SgjPatientHospital, error) { hospital := models.SgjPatientHospital{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&hospital).Error fmt.Println("错误是什么", err) return hospital, err } func GetOfficeInfo(orgID int64) (models.SgjPatientOffices, error) { offices := models.SgjPatientOffices{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offices).Error fmt.Println("错误是什么", err) return offices, err } func GetQueryDocInfo(orgID int64) (doc []*models.SgjUserStaffInfo, err error) { err = service.UserReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&doc).Error fmt.Println("错误是什么", err) return } func GetQueryDocHead(orgID int64) (doc []*models.SgjPatientEditdoctor, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ? AND img_show = ?", orgID, 1, 1).Order("doc_sort").Find(&doc).Error return } func GetOffEnvironment(orgID int64) (models.SgjPatientOffenvironment, error) { offenvironment := models.SgjPatientOffenvironment{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offenvironment).Error fmt.Println("错误是什么", err) return offenvironment, err } func AddWorkTime(connecmodel *models.SgjPatientWorktime) error { err := service.PatientWriteDB().Create(&connecmodel).Error return err } func AddRideWay(connecmodel models.SgjPatientRideway) error { err := service.PatientWriteDB().Create(&connecmodel).Error return err } func AddConnetion(connection models.SgjPatientConnection) error { err := service.PatientWriteDB().Create(&connection).Error return err } func GetQueryConnection(orgID int64) (conection []*models.SgjPatientConnection, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&conection).Error return } func DeleteRideWay(orgid int64, id int64) error { err := service.PatientWriteDB().Model(&models.SgjPatientRideway{}).Where("user_org_id =? AND mode_id = ?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteConnecWay(orgid int64, id int64) error { err := service.PatientWriteDB().Model(&models.SgjPatientConnection{}).Where("user_org_id = ? AND id =?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteWorkTime(orgid int64, id int64) error { err := service.PatientWriteDB().Model(models.SgjPatientWorktime{}).Where("user_org_id = ? AND mode_id = ?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func EditConnecWay(orgid int64, id int64) (models.SgjPatientConnection, error) { sgj := models.SgjPatientConnection{} err := service.PatientReadDB().Model(&sgj).Where("user_org_id = ? AND id =?", orgid, id).Find(&sgj).Error return sgj, err } func UpadateConnec(connection *models.SgjPatientConnection, orgID int64, id int64) { service.PatientWriteDB().Model(connection).Where("user_org_id = ? AND id = ? AND status = ?", orgID, id, 1).Update(map[string]interface{}{"title": connection.Title, "connecway": connection.Connecway, "content": connection.Content}) } func GetUserModel(orgid int64) (model []*models.SgjPatientOrdmodel, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error return } func GetQueryNewModel(orgid int64) (model []*models.SgjPatientModel, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error fmt.Println("错误是什么", err) return } func GetEditModel(orgid int64, id int64) (models.SgjPatientWorktime, error) { worktime := models.SgjPatientWorktime{} err := service.PatientReadDB().Model(&worktime).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&worktime).Error return worktime, err } func GetEditRideWay(orgid int64, id int64) (models.SgjPatientRideway, error) { rideway := models.SgjPatientRideway{} err := service.PatientReadDB().Model(&rideway).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&rideway).Error return rideway, err } func UpdateWorkTime(mid int64, orgID int64, worktime models.SgjPatientWorktime) error { err := service.PatientWriteDB().Model(worktime).Where("id = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Update(map[string]interface{}{"title": worktime.Title, "sort": worktime.Sort, "worktime": worktime.Worktime, "mtime": time.Now().Unix()}).Error return err } func UpdateOrdeModel(id int64, orgID int64, ordmodel models.SgjPatientOrdmodel) error { err := service.PatientWriteDB().Model(ordmodel).Where("id = ? AND user_org_id = ? AND status = ?", id, orgID, 1).Update(map[string]interface{}{"title": ordmodel.Title, "sort": ordmodel.Sort, "mtime": time.Now().Unix()}).Error return err } func UpdateRideWay(id int64, orgID int64, rideway models.SgjPatientRideway) error { err := service.PatientWriteDB().Model(rideway).Where("id = ? AND user_org_id = ? AND status =?", id, orgID, 1).Update(map[string]interface{}{"title": rideway.Title, "sort": rideway.Sort, "ride_way": rideway.RideWay, "mtime": time.Now().Unix()}).Error return err } func QueryDocById(orgID int64, id int64) (models.SgjUserStaffInfo, error) { info := models.SgjUserStaffInfo{} err := service.UserWriteDB().Model(&info).Where("user_org_id = ? AND id = ?", orgID, id).Find(&info).Error return info, err } func DeleteDoctor(id int64, orgID int64) error { err := service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "img_show": 0, "modleid": 0, "mtime": time.Now().Unix()}).Error return err } func EditHospital(mid int64, orgID int64) (models.SgjPatientHospital, error) { hospital := models.SgjPatientHospital{} err := service.PatientReadDB().Model(&hospital).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Find(&hospital).Error return hospital, err } func UpdateHospital(id int64, OrgId int64, hospital models.SgjPatientHospital) error { err := service.PatientWriteDB().Model(hospital).Where("id = ? AND user_org_id = ? AND status = ?", id, OrgId, 1).Update(map[string]interface{}{"title": hospital.Title, "sort": hospital.Sort, "introduction": hospital.Introduction, "mtime": time.Now().Unix()}).Error return err } func UpdateModel(modelid int64, orgId int64, model models.SgjPatientModel) error { err := service.PatientWriteDB().Model(model).Where("id = ? AND user_org_id = ? AND status = ?", modelid, orgId, 1).Update(map[string]interface{}{"title": model.Title, "sort": model.Sort, "mtime": time.Now().Unix()}).Error return err } func EditOffice(mid int64, orgID int64) (models.SgjPatientOffices, error) { offices := models.SgjPatientOffices{} err := service.PatientReadDB().Model(&offices).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgID, 1).Find(&offices).Error return offices, err } func DeletemodleById(id int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientModel{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteHospitalByModelid(mid int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientHospital{}).Where("modleid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteOfficeByModelid(mid int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientOffices{}).Where("modleid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteEditPicLinkByModelid(mid int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteEnviroments(mid int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEnviroimages{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteConrotation(mid int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientConrotation{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "img_show": 0, "mtime": time.Now().Unix()}).Error return err } func DeletePatentEditMargin(mid int64, orgID int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditmargin{}).Where("modeid = ? AND user_org_id = ?", mid, orgID).Update(map[string]interface{}{"status": 0, "img_show": 0, "mtime": time.Now().Unix()}).Error return err } func UpdateOffices(id int64, orgID int64, offices models.SgjPatientOffices) error { err := service.PatientWriteDB().Model(offices).Where("id = ? AND user_org_id = ? AND status = ?", id, orgID, 1).Update(map[string]interface{}{"title": offices.Title, "sort": offices.Sort, "introduction": offices.Introduction, "mtime": time.Now().Unix()}).Error return err } func GetHospital(Orgid int64) (hostital []*models.SgjPatientHospital, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", Orgid, 1).Order("sort").Find(&hostital).Error return } 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 fmt.Println("err二二err二二err二二err二二err二二err", err) return } func GetPatientNavigation(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 AddNavgation(navigation *models.SgjPatientNavigation) error { err := service.PatientReadDB().Create(&navigation).Error return err } func UpdateDoctorsInfo(orgID int64, ids []int64, editdoctor models.SgjPatientEditdoctor) (err error) { if len(ids) == 1 { err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? and user_org_id = ?", ids[0], orgID).Update(map[string]interface{}{"modleid": editdoctor.Modleid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } else { err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id IN(?) and user_org_id = ?", ids, orgID).Update(map[string]interface{}{"modleid": editdoctor.Modleid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } return } func QueryEditDoc(mid int64, orgid int64) (models.SgjPatientDocinfo, error) { editdotor := models.SgjPatientDocinfo{} err := service.PatientReadDB().Model(&editdotor).Where("modelid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdotor).Error return editdotor, err } func QueryModelByid(id int64, orgid int64) (models.SgjPatientModel, error) { model := models.SgjPatientModel{} err := service.PatientReadDB().Model(&model).Where("id = ? AND user_org_id = ? AND status =?", id, orgid, 1).Find(&model).Error return model, err } func QuerEditDocByModleid(mid int64, orgid int64) (editdoctor []models.SgjPatientEditdoctor, err error) { err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdoctor).Error return editdoctor, err } func QuerEditDocByid(mid int64, orgid int64) (editdoctor []*models.SgjPatientEditdoctor, err error) { err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("doc_sort").Find(&editdoctor).Error return } func QueryEditImages(orgid int64, id int64) (models.SgjPatientEditdoctor, error) { editdoctor := models.SgjPatientEditdoctor{} err := service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editdoctor).Error return editdoctor, err } func QueryEditDoctor(id int64, orgid int64) (models.SgjPatientEditdoctor, error) { docinfo := models.SgjPatientEditdoctor{} err := service.PatientReadDB().Model(&docinfo).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&docinfo).Error return docinfo, err } func UpDateEditdoctor(id int64, orgid int64, editdoctor models.SgjPatientEditdoctor) error { err := service.PatientWriteDB().Model(editdoctor).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"doc_name": editdoctor.DocName, "doc_postion": editdoctor.DocPostion, "dochead": editdoctor.Dochead, "doc_sort": editdoctor.DocSort, "docintroduction": editdoctor.Docintroduction, "mtime": time.Now().Unix()}).Error return err } func Upadatedocdata(orgid int64, id int64, docinfo models.SgjPatientDocinfo) error { err := service.PatientWriteDB().Model(docinfo).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Update(map[string]interface{}{"title": docinfo.Title, "sort": docinfo.Sort, "docimages": docinfo.Docimages, "mtime": time.Now().Unix()}).Error return err } func GetQueryModel(id, orgid int64) (models.SgjPatientModel, error) { model := models.SgjPatientModel{} err := service.PatientReadDB().Model(&model).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&model).Error return model, err } func QuerOfficeEnviroment(id int64, orgid int64) (models.SgjPatientOffenvironment, error) { offenvironment := models.SgjPatientOffenvironment{} err := service.PatientReadDB().Model(&offenvironment).Where("modelid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error return offenvironment, err } func QueryOfficeformById(modeid int64, orgid int64) (patientenviroimages []*models.SgjPatientEnviroimages, err error) { err = service.PatientReadDB().Model(&patientenviroimages).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&patientenviroimages).Error return } func UpdateOfficeEnvironment(id int64, orgid int64) (models.SgjPatientOffenvironment, error) { offenvironment := models.SgjPatientOffenvironment{} err := service.PatientReadDB().Model(&offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error return offenvironment, err } func UpdatePatientOffenvironment(id int64, orgid int64, offenvironment models.SgjPatientOffenvironment) error { err := service.PatientWriteDB().Model(offenvironment).Where("id= ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": offenvironment.Title, "sort": offenvironment.Sort, "keimages": offenvironment.Keimages, "mtime": time.Now().Unix()}).Error return 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 AddNavigation(navigation *models.SgjPatientNavigation) error { err := service.PatientWriteDB().Create(&navigation).Error return err } func GetNavigationList(orgid int64) (navigation []*models.SgjPatientNavigation, err error) { err = service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error return } func AddShareInfo(share *models.SgjPatientShare) error { err := service.PatientWriteDB().Create(&share).Error return err } func GetShareInfo(orgid int64) (models.SgjPatientShare, error) { share := models.SgjPatientShare{} err := service.PatientReadDB().Model(&share).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&share).Error return share, err } func DeleteNavitionById(orgID int64, id int64) error { err := service.PatientWriteDB().Model(models.SgjPatientNavigation{}).Where("user_org_id = ? AND id = ?", orgID, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func AddConnecWay(connectway *models.SgjPatientConnectway) error { err := service.PatientWriteDB().Create(&connectway).Error return err } func AddOrdModel(ordmodel *models.SgjPatientOrdmodel) error { err := service.PatientWriteDB().Create(ºodel).Error return err } func AddPatientOrdModel(ordmodel *models.PatientOrdmodel) error { err := service.PatientWriteDB().Create(ºodel).Error return err } func AddHosAddress(hosaddress *models.SgjPatientHosaddress) error { err := service.PatientWriteDB().Create(&hosaddress).Error return err } func QueryOrdeModelByID(orgid int64) (models.SgjPatientOrdmodel, error) { ordmodel := models.SgjPatientOrdmodel{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ? ", orgid, 1).Last(ºodel).Error return ordmodel, err } func UpdateConrotaions(orgid int64, ids []int64, conrotation models.SgjPatientConrotation) (err error) { if len(ids) == 1 { err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id = ? and user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "mtime": time.Now().Unix()}).Error } else { err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id IN(?) and user_org_id = ?", ids, orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "mtime": time.Now().Unix()}).Error } return } func DeleteModle(orgid int64, id int64) error { err := service.PatientWriteDB().Model(models.SgjPatientOrdmodel{}).Where("user_org_id = ? AND id = ?", orgid, id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteModleByModeID(orgid int64, mid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientConnectway{}).Where("user_org_id = ? AND mode_id = ?", orgid, mid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func GetOrederModel(orgid int64) (model []*models.SgjPatientOrdmodel, err error) { db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1) con := service.PatientReadDB().Table("sgj_patient_conrotation as s") if orgid > 0 { db = db.Where("user_org_id = ?", orgid) } err = db.Preload("Hosaddress").Preload("Connectway").Preload("Worktime").Preload("Rideway").Preload("Oldration").Preload("Conrotation", func(db *gorm.DB) *gorm.DB { return con.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("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error fmt.Println("sql错误是什么", err) return } func AddRotationpic(conrotation models.SgjPatientConrotation) error { err := service.PatientWriteDB().Create(&conrotation).Error return err } func GetRotationImages(orgid int64) (conrotation []models.SgjPatientConrotation, err error) { err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1, 1).Order("sort").Find(&conrotation).Error return conrotation, err } func AddrotationImage(oldrotation *models.SgjPatientOldrotation) error { err := service.PatientWriteDB().Create(&oldrotation).Error return err } func UpdateConrotation(orgid int64, ids []int64, conrotation models.SgjPatientConrotation) (err error) { if len(ids) == 1 { err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id = ? AND user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } else { err = service.PatientWriteDB().Model(&models.SgjPatientConrotation{}).Where("id IN(?) and user_org_id = ?", ids, orgid).Update(map[string]interface{}{"modeid": conrotation.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } return } func AddImageslink(editpiclink *models.SgjPatientEditpiclink) error { err := service.PatientWriteDB().Create(&editpiclink).Error return err } func GetEnImages(orgid int64) (enviroimages []models.SgjPatientEnviroimages, err error) { err = service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND status = ? AND imgshow = ? ", orgid, 1, 1).Order("sort").Find(&enviroimages).Error return enviroimages, err } func UpdateImages(orgid int64, ids []int64, enviroimages models.SgjPatientEnviroimages) (err error) { if len(ids) == 1 { err = service.PatientWriteDB().Model(&models.SgjPatientEnviroimages{}).Where("id = ? AND user_org_id = ? ", ids[0], orgid).Update(map[string]interface{}{"modeid": enviroimages.Modeid, "status": 1, "imgshow": 0, "mtime": time.Now().Unix()}).Error } else { err = service.PatientWriteDB().Model(&models.SgjPatientEnviroimages{}).Where("id IN(?) and user_org_id = ? ", ids, orgid).Update(map[string]interface{}{"modeid": enviroimages.Modeid, "status": 1, "imgshow": 0, "mtime": time.Now().Unix()}).Error } return } func GetEditEnvirimagesById(orgid int64, id int64) (models.SgjPatientEnviroimages, error) { enviroimages := models.SgjPatientEnviroimages{} err := service.PatientReadDB().Model(&enviroimages).Where("user_org_id = ? AND id =? AND status = ?", orgid, id, 1).Find(&enviroimages).Error return enviroimages, err } func UpdateEnviroimages(id int64, orgid int64, enviroimages models.SgjPatientEnviroimages) (err error) { err = service.PatientReadDB().Model(&enviroimages).Where("id = ? AND user_org_id = ? AND status =?", id, orgid, 1).Update(map[string]interface{}{"enviroimages": enviroimages.Enviroimages, "sort": enviroimages.Sort, "mtime": time.Now().Unix()}).Error return err } func GetEditImages(orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) { err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1, 1).Order("sort").Find(&editpiclink).Error return editpiclink, err } func AddMagicNavi(editmargin *models.SgjPatientEditmargin) error { err := service.PatientWriteDB().Create(&editmargin).Error return err } func GetMagicImages(orgid int64) (editmargin []models.SgjPatientEditmargin, err error) { err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND img_show = ?", orgid, 1, 1).Find(&editmargin).Error return editmargin, err } func AddMarginChart(macnavigation *models.SgjPatientMacnavigation) error { err := service.PatientWriteDB().Create(&macnavigation).Error return err } func DeleteRotations(id int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ? ", id, orgid).Update(map[string]interface{}{"status": 0, "img_show": 0, "mtime": time.Now().Unix()}).Error return err } func UpdateRotationImages(orgid int64, id int64) (models.SgjPatientEditpiclink, error) { editpiclink := models.SgjPatientEditpiclink{} err := service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editpiclink).Error return editpiclink, err } func SaveRotationImages(id int64, orgid int64, editpiclink models.SgjPatientEditpiclink) error { err := service.PatientWriteDB().Model(editpiclink).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"images": editpiclink.Images, "sort": editpiclink.Sort, "piclink": editpiclink.Piclink, "linkaddress": editpiclink.Linkaddress, "mtime": time.Now().Unix()}).Error return err } func EditNavigation(orgid int64, id int64) (models.SgjPatientNavigation, error) { navigation := models.SgjPatientNavigation{} err := service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&navigation).Error return navigation, err } func UpdateNavtion(id int64, orgid int64, navigation models.SgjPatientNavigation) error { err := service.PatientWriteDB().Model(navigation).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"navtitle": navigation.Navtitle, "navimages": navigation.Navimages, "nonavimages": navigation.Nonavimages, "jumpset": navigation.Jumpset, "navaddress": navigation.Navaddress, "linkid": navigation.Linkid, "linktype": navigation.Linktype, "mtime": time.Now().Unix()}).Error return err } func DeleteImages(id int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientConrotation{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "modeid": 0, "img_show": 0, "mtime": time.Now().Unix()}).Error return err } func DeleteSingleImages(id int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "modeid": 0, "img_show": 0, "mtime": time.Now().Unix()}).Error return err } func AddActivity(addactivity *models.SgjPatientAddactivity) error { err := service.PatientWriteDB().Create(&addactivity).Error return err } func QueryActivity(id int64, orgid int64) (models.SgjPatientAddactivity, error) { addactivity := models.SgjPatientAddactivity{} err := service.PatientReadDB().Model(addactivity).Where("modeid = ? AND user_org_id = ?", id, orgid).Find(&addactivity).Error return addactivity, err } func UpdateActivit(id int64, orgid int64, addactivity models.SgjPatientAddactivity) error { err := service.PatientWriteDB().Model(addactivity).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": addactivity.Title, "sort": addactivity.Sort, "number": addactivity.Number, "mtime": time.Now().Unix()}).Error return err } func DeleteMargin(id int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditmargin{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error return err } func GetEditRotationImages(id int64, orgid int64) (models.SgjPatientOrdmodel, error) { oldrotation := models.SgjPatientOrdmodel{} err := service.PatientReadDB().Model(oldrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&oldrotation).Error return oldrotation, err } func GetEditConrotion(id int64, orgid int64) (conrotation []models.SgjPatientConrotation, err error) { err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&conrotation).Error return conrotation, err } func EditVisibleById(id int64, orgid int64) (models.SgjPatientConrotation, error) { conrotation := models.SgjPatientConrotation{} err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error return conrotation, err } func UpdatedConAddress(id int64, orgid int64) (models.SgjPatientConlinkaddress, error) { conlinkaddress := models.SgjPatientConlinkaddress{} err := service.PatientWriteDB().Model(&conlinkaddress).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"defineaddress": ""}).Error return conlinkaddress, err } func UpdateEditpic(id int64, orgid int64, conrotation models.SgjPatientConrotation) error { err := service.PatientWriteDB().Model(conrotation).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"images": conrotation.Images, "sort": conrotation.Sort, "piclink": conrotation.Piclink, "linkaddress": conrotation.Linkaddress, "linkid": conrotation.Linkid}).Error return err } func GetPatientConrotationLast(orgid int64) (models.SgjPatientConrotation, error) { conrotation := models.SgjPatientConrotation{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conrotation).Error return conrotation, err } func UpdateConLinkAddress(orgid int64, conid int64, conlinkaddress models.SgjPatientConlinkaddress) error { err := service.PatientWriteDB().Model(&conlinkaddress).Where("user_org_id = ? and status = ? and con_id = ?", orgid, 1, conid).Update(map[string]interface{}{"mtime": time.Now().Unix()}).Error return err } func AddEditpic(conrotation *models.SgjPatientConrotation) error { err := service.PatientWriteDB().Create(&conrotation).Error return err } func QueryOldrotion(id int64, orgid int64) (models.SgjPatientOldrotation, error) { conrotation := models.SgjPatientOldrotation{} err := service.PatientReadDB().Model(conrotation).Where("id = ? AND user_org_id = ? ", id, orgid).Order("sort").Find(&conrotation).Error return conrotation, err } func QueryConRotation(mid int64, orgid int64) (conrotation []models.SgjPatientConrotation, err error) { err = service.PatientReadDB().Model(conrotation).Where("modeid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("sort").Find(&conrotation).Error return conrotation, err } func UpdateConrotaionById(id int64, orgid int64, oldrotation models.SgjPatientOldrotation) error { err := service.PatientWriteDB().Model(oldrotation).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": oldrotation.Title, "sort": oldrotation.Sort, "rotation_images": oldrotation.RotationImages, "mtime": time.Now().Unix()}).Error return err } func GetPatientRotaion(id int64, orgid int64) (models.SgjPatientRotation, error) { rotation := models.SgjPatientRotation{} err := service.PatientReadDB().Model(&rotation).Where("model_id = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&rotation).Error return rotation, err } func GetPatientModel(id int64, orgid int64) (models.SgjPatientModel, error) { model := models.SgjPatientModel{} err := service.PatientReadDB().Model(&model).Where("id = ? AND user_org_id = ?", id, orgid).Order("sort").Find(&model).Error return model, err } func GetPatientRotationById(id int64, orgid int64) (models.SgjPatientRotation, error) { rotation := models.SgjPatientRotation{} err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id =?", id, orgid).Find(&rotation).Error return rotation, err } func QueryEditpiclink(id int64, orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) { err = service.PatientReadDB().Model(editpiclink).Where("modeid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Order("sort").Find(&editpiclink).Error return editpiclink, err } func GetEditSingleVisible(id int64, orgid int64) (models.SgjPatientEditpiclink, error) { editpiclink := models.SgjPatientEditpiclink{} err := service.PatientReadDB().Model(&editpiclink).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error return editpiclink, err } func GetQueryEditpiclink(modeid int64, orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) { err = service.PatientReadDB().Model(&editpiclink).Where("modeid=? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Order("sort").Find(&editpiclink).Error return editpiclink, err } func UpdatedPatientLinkAddress(id int64, orgid int64) (models.SgjPatientLinkaddress, error) { linkaddress := models.SgjPatientLinkaddress{} err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"defineaddress": "", "status": 0}).Error return linkaddress, err } func UpdateEditPatPicLink(id int64, orgid int64, editpiclink models.SgjPatientEditpiclink) error { err := service.PatientWriteDB().Model(editpiclink).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"images": editpiclink.Images, "sort": editpiclink.Sort, "piclink": editpiclink.Piclink, "linkaddress": editpiclink.Linkaddress, "linkid": editpiclink.Linkid, "mtime": time.Now().Unix()}).Error return err } func UpdateEditPicLinkTwo(moid int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditpiclink{}).Where("modeid = ? AND user_org_id = ? AND status = ?", moid, orgid, 1).Update(map[string]interface{}{"img_show": 0}).Error return err } func GetPatientRotations(id int64, orgid int64) (models.SgjPatientRotation, error) { rotation := models.SgjPatientRotation{} err := service.PatientReadDB().Model(&rotation).Where("id = ? AND user_org_id = ?", id, orgid).Find(&rotation).Error return rotation, err } func UpdateRotationByid(id int64, orgid int64, rotation models.SgjPatientRotation) error { err := service.PatientWriteDB().Model(rotation).Where("id=? AND user_org_id = ? AND status =?", id, orgid, 1).Update(map[string]interface{}{"title": rotation.Title, "sort": rotation.Sort, "rotation_images": rotation.RotationImages, "mtime": time.Now().Unix()}).Error return err } func UpdateModelById(id int64, orgid int64, model models.SgjPatientModel) error { err := service.PatientWriteDB().Model(model).Where("id=? AND user_org_id =? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": model.Title, "sort": model.Sort, "mtime": time.Now().Unix()}).Error return err } func QuerEditMarginById(id int64, orgid int64) (models.SgjPatientEditmargin, error) { editmargin := models.SgjPatientEditmargin{} err := service.PatientReadDB().Model(editmargin).Where("id = ? AND user_org_id =? AND status = ?", id, orgid, 1).Find(&editmargin).Error return editmargin, err } func UpdateMarginById(id int64, orgid int64, editmargin models.SgjPatientEditmargin) error { err := service.PatientWriteDB().Model(editmargin).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"margintitle": editmargin.Margtitle, "margimage": editmargin.Margimage, "marginaddress": editmargin.Marginaddress}).Error return 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 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 GetArticleType(orgid int64) (category []models.ArticleCategory, err error) { err = service.PatientReadDB().Model(category).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&category).Error return category, err } func AddActiclelist(articlelist *models.SgjPatientArticlelist) error { err := service.PatientWriteDB().Model(articlelist).Create(&articlelist).Error return err } 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 GetAllArticles(orgid int64, limit int64) (articlelist []models.Articles, err error) { err = service.PatientReadDB().Model(articlelist).Where("user_org_id = ? AND Status = ? AND article_status = ?", orgid, 1, 1).Order("ctime desc").Limit(limit).Find(&articlelist).Error return } 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 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 UpdateArticeDetail(id int64, orgid int64, articlelist models.SgjPatientArticlelist) error { err := service.PatientWriteDB().Model(articlelist).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": articlelist.Title, "sort": articlelist.Sort, "number": articlelist.Number, "mtime": time.Now().Unix()}).Error return err } func GetMacImagesByModeid(modeid int64, orgid int64) (macnavigation []models.SgjPatientEditmargin, err error) { err = service.PatientReadDB().Model(macnavigation).Where("modeid = ? AND user_org_id = ? AND status = ?", modeid, orgid, 1).Find(&macnavigation).Error return macnavigation, err } func GetModelById(id int64, orgid int64) (models.SgjPatientModel, error) { model := models.SgjPatientModel{} err := service.PatientReadDB().Model(model).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&model).Error return model, err } func GetOffENvironmentById(id int64, orgid int64) (models.SgjPatientOffenvironment, error) { offenvironment := models.SgjPatientOffenvironment{} err := service.PatientReadDB().Model(offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error return offenvironment, err } func AddOfficeThree(enviroimages *models.SgjPatientEnviroimages) error { err := service.PatientWriteDB().Model(&enviroimages).Create(&enviroimages).Error return err } func GetQueryImages(mid int64, orgid int64) (enviroimages []models.SgjPatientEnviroimages, err error) { err = service.PatientReadDB().Model(enviroimages).Where("modeid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("sort").Find(&enviroimages).Error return enviroimages, err } func GetOfficeTwoVisible(orgid int64, id int64) (models.SgjPatientEnviroimages, error) { enviroimages := models.SgjPatientEnviroimages{} err := service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&enviroimages).Error return enviroimages, err } func UpdateOfficeTwo(orgid int64, id int64, enviroimages models.SgjPatientEnviroimages) error { err := service.PatientWriteDB().Model(&enviroimages).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Update(map[string]interface{}{"enviroimages": enviroimages.Enviroimages, "sort": enviroimages.Sort, "mtime": time.Now().Unix()}).Error return err } func GetQueryEnviroimage(orgid int64, mid int64) (enviroimages []models.SgjPatientEnviroimages, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, mid, 1).Find(&enviroimages).Error return enviroimages, err } func DeleteOfficeById(id int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEnviroimages{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "modeid": 0, "mtime": time.Now().Unix()}).Error return err } func GetArticleById(classid int64, orgid int64) (articlelist []models.Articles, err error) { err = service.PatientReadDB().Model(models.Articles{}).Where("class_id = ? AND user_org_id = ? AND status = ?", classid, orgid, 1).Find(&articlelist).Error return } func GetAllActivity(orgid int64) (activtity []models.Activity, err error) { err = service.PatientReadDB().Model(models.Activity{}).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&activtity).Error return } //func AddLinkAddress(linkaddress *models.SgjPatientLinkaddress) error { // err := service.PatientWriteDB().Create(&linkaddress).Error // return err //} func AddLinkAddress(linkaddress *models.SgjPatientLinkaddress) error { err := service.PatientWriteDB().Create(&linkaddress).Error return err } func GetLinkAddress(orgid int64, id int64) (models.SgjPatientLinkaddress, error) { linkaddress := models.SgjPatientLinkaddress{} err := service.PatientReadDB().Model(&linkaddress).Where("user_org_id = ? AND id = ? AND status = ? ", orgid, id, 1).Find(&linkaddress).Error return linkaddress, err } func QuerylinkAddress(id int64, orgid int64) (models.SgjPatientLinkaddress, error) { linkaddress := models.SgjPatientLinkaddress{} err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&linkaddress).Error return linkaddress, err } 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 GetConnecway(orgid int64, id int64) (models.SgjPatientOrdmodel, error) { ordmodel := models.SgjPatientOrdmodel{} err := service.PatientReadDB().Model(ºodel).Where("user_org_id = ? AND status = ? AND id = ?", orgid, 1, id).Find(ºodel).Error return ordmodel, err } func GetConnecwayById(orgid int64, id int64) (models.SgjPatientConnection, error) { connection := models.SgjPatientConnection{} err := service.PatientReadDB().Model(&connection).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&connection).Error return connection, err } func UpdateConnectway(id int64, orgid int64, connection models.SgjPatientConnection) error { err := service.PatientWriteDB().Model(&connection).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": connection.Title, "connecway": connection.Connecway, "content": connection.Content, "mtime": time.Now().Unix()}).Error return err } func AddConnectways(connection *models.SgjPatientConnection) error { err := service.PatientWriteDB().Create(&connection).Error return err } func UpdateConnectways(id int64, orgid int64, connectway models.SgjPatientConnectway) error { err := service.PatientWriteDB().Model(&connectway).Where("mode_id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": connectway.Title, "sort": connectway.Sort, "ctime": time.Now().Unix()}).Error return err } func GetHostpitalIntroduction(orgid int64, id int64) (models.SgjPatientOrdmodel, error) { ordmodel := models.SgjPatientOrdmodel{} err := service.PatientReadDB().Model(ºodel).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(ºodel).Error return ordmodel, err } func GetHostpitaAddress(orgid int64, moid int64) (models.SgjPatientHosaddress, error) { hosaddress := models.SgjPatientHosaddress{} err := service.PatientReadDB().Model(&hosaddress).Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, moid, 1).Find(&hosaddress).Error return hosaddress, err } func UpdateHosAddress(id int64, orgid int64, hosaddress models.SgjPatientHosaddress) error { err := service.PatientWriteDB().Model(&hosaddress).Where("modeid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Update(map[string]interface{}{"title": hosaddress.Title, "sort": hosaddress.Sort, "address": hosaddress.Address, "mtime": time.Now().Unix()}).Error return err } func AddConlinkaddress(conlinkaddress *models.SgjPatientConlinkaddress) error { err := service.PatientWriteDB().Create(&conlinkaddress).Error return err } func GetConLinkAddressById(orgid int64) (models.SgjPatientConlinkaddress, error) { conlinkaddress := models.SgjPatientConlinkaddress{} err := service.PatientReadDB().Model(&conlinkaddress).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&conlinkaddress).Error return conlinkaddress, err } func GetLinkAddressDetail(orgid int64, id int64) (models.SgjPatientConlinkaddress, error) { conlinkaddress := models.SgjPatientConlinkaddress{} err := service.PatientReadDB().Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&conlinkaddress).Error return conlinkaddress, err } //func UpdatePicFformThree(orgid int64,id int64,conlinkaddress models.SgjPatientConlinkaddress) error { // // err := service.PatientReadDB().Model(&conlinkaddress).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Update(map[string]interface{}{"linktype": conlinkaddress.Linktype, "linktypetwo": conlinkaddress.Linktypetwo, "linktypethree": conlinkaddress.Linktypethree, "linktypefour": conlinkaddress.Linktypefour,"linkaddress":conlinkaddress.Linkaddress,"defineaddress":conlinkaddress.Defineaddress}).Error // return err //} func GetEnImagesTwo(orgid int64) (editpiclink []models.SgjPatientEditpiclink, err error) { err = service.PatientReadDB().Model(&editpiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&editpiclink).Error return editpiclink, err } func GetEnImagesThree(orgid int64) (conrotation []models.SgjPatientConrotation, err error) { err = service.PatientReadDB().Model(&conrotation).Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&conrotation).Error return conrotation, err } func AddMagiclinkData(magiclink *models.SgjPatientMagiclink) error { err := service.PatientWriteDB().Create(&magiclink).Error return err } func GetPatienModelByModelId(id int64, orgid int64) (models.PatientModel, error) { model := models.PatientModel{} err := service.PatientReadDB().Model(&model).Where("id=? AND user_org_id = ?", id, orgid).Find(&model).Error return model, err } func GetMacLinkAddressTwo(orgid int64) (patientMagiclink []models.SgjPatientMagiclink, err error) { err = service.PatientReadDB().Model(&patientMagiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&patientMagiclink).Error return patientMagiclink, err } func UpdateEditMagin(orgid int64, ids []int64, editmargin models.SgjPatientEditmargin) (err error) { if len(ids) == 1 { err = service.PatientWriteDB().Model(&models.SgjPatientEditmargin{}).Where("id= ? AND user_org_id = ?", ids[0], orgid).Update(map[string]interface{}{"modeid": editmargin.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } else { err = service.PatientWriteDB().Model(&models.SgjPatientEditmargin{}).Where("id IN(?) and user_org_id = ? ", ids, orgid).Update(map[string]interface{}{"modeid": editmargin.Modeid, "status": 1, "img_show": 0, "mtime": time.Now().Unix()}).Error } return } func AddMacgicform(editmargin *models.SgjPatientEditmargin) error { err := service.PatientWriteDB().Create(&editmargin).Error return err } func GetMacImagesDetail(orgid int64, modeid int64) (editmargin []models.SgjPatientEditmargin, err error) { err = service.PatientReadDB().Model(&editmargin).Where("user_org_id = ? AND status = ? AND modeid = ?", orgid, 1, modeid).Find(&editmargin).Error return editmargin, err } func DeletMacImagesDetail(id int64, orgid int64) error { err := service.PatientWriteDB().Model(models.SgjPatientEditmargin{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"status": 0, "modeid": 0, "mtime": time.Now().Unix()}).Error return err } func GetEditMacImageDetailById(orgid int64, id int64) (models.SgjPatientEditmargin, error) { editmargin := models.SgjPatientEditmargin{} err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, id).Find(&editmargin).Error return editmargin, err } func UpdateEditMacFormById(id int64, orgid int64, editmargin models.SgjPatientEditmargin) (err error) { err = service.PatientWriteDB().Model(&models.SgjPatientEditmargin{}).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"margtitle": editmargin.Margtitle, "margimage": editmargin.Margimage, "jumpset": editmargin.Jumpset, "marginaddress": editmargin.Marginaddress, "mtime": time.Now().Unix()}).Error return err } func GetLikeMacAddressById(orgid int64, id int64) (models.SgjPatientMagiclink, error) { magiclink := models.SgjPatientMagiclink{} err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, id).Find(&magiclink).Error return magiclink, err } func GetAllArticeList(orgid int64) (articles []models.Articles, err error) { err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&articles).Error return articles, err } func AddActicles(articles *models.Articles) error { err := service.PatientWriteDB().Create(&articles).Error return err } func UpdateLinkAddress(id int64, orgid int64, magiclink models.SgjPatientMagiclink) error { err := service.PatientWriteDB().Model(&models.SgjPatientMagiclink{}).Where("id = ? AND user_org_id = ? ", id, orgid).Update(map[string]interface{}{"linktype": magiclink.Linktype, "instationlink": magiclink.Instationlink, "phone": magiclink.Phone, "outstationlink": magiclink.Outstationlink, "linkaddress": magiclink.Linkaddress, "mtime": time.Now().Unix()}).Error return err } func GetUpdateLinkAddress(id int64, orgid int64) (models.SgjPatientMagiclink, error) { editpiclink := models.SgjPatientMagiclink{} err := service.PatientReadDB().Model(&editpiclink).Where("id = ? AND user_org_id = ?", id, orgid).Find(&editpiclink).Error return editpiclink, err } func GetMacLinkAddress(orgid int64) (magiclink []models.SgjPatientMagiclink, err error) { err = service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND status =?", orgid, 1).Find(&magiclink).Error return magiclink, err } func AddMacLinkAddress(magiclink *models.SgjPatientMagiclink) error { err := service.PatientWriteDB().Create(&magiclink).Error return err } func GetMacLinkAddressByLastData(orgid int64) (models.SgjPatientMagiclink, error) { magiclink := models.SgjPatientMagiclink{} err := service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&magiclink).Error return magiclink, err } func AddNavitaionLinkAddress(navgationlink *models.PatientNavgationlink) error { err := service.PatientWriteDB().Create(&navgationlink).Error return err } func GetPatientLinkAddress(id int64, orgid int64) (models.SgjPatientLinkaddress, error) { linkaddress := models.SgjPatientLinkaddress{} err := service.PatientReadDB().Where(" id = ? AND user_org_id = ?", id, orgid).Find(&linkaddress).Error return linkaddress, err } func GetCountImages(orgid int64) (edipiclink []models.SgjPatientEditpiclink, total int64, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND img_show = ? AND status = ?", orgid, 1, 1).Find(&edipiclink).Count(&total).Error return edipiclink, total, err } func GetDeleteImages(orgid int64, modeid int64) (edipiclink []models.SgjPatientEditpiclink, total int64, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Find(&edipiclink).Count(&total).Error return edipiclink, total, err } func GetTotalCount(orgid int64) (conrotation []models.SgjPatientConrotation, total int64, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND img_show = ? AND status = ?", orgid, 1, 1).Find(&conrotation).Count(&total).Error return conrotation, total, err } func GetCountPicImages(orgid int64, modeid int64) (edipiclink []models.SgjPatientEditpiclink, total int64, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Find(&edipiclink).Count(&total).Error return edipiclink, total, err } func GetPicImages(orgid int64, modeid int64) (editpiclink []models.SgjPatientEditpiclink, err error) { err = service.PatientReadDB().Where("user_org_id = ? AND modeid = ? AND status = ?", orgid, modeid, 1).Order("sort").Find(&editpiclink).Error return editpiclink, err } func QueryEditpiclinkCount(mid int64, orgid int64) (editpiclink []models.SgjPatientEditpiclink, total int64, err error) { err = service.PatientWriteDB().Where("modeid = ? AND user_org_id =? AND status = ?", mid, orgid, 1).Find(&editpiclink).Count(&total).Error return editpiclink, total, err } func AddNavgationlink(navgationlink *models.PatientNavgationlink) error { err := service.PatientWriteDB().Create(&navgationlink).Error return err } func GetNavgationlinkLastData(orgid int64) (models.PatientNavgationlink, error) { navgationlink := models.PatientNavgationlink{} err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Last(&navgationlink).Error return navgationlink, err } func GetNavgationlinkAddressBylinkId(orgid int64, linkid int64) (models.PatientNavgationlink, error) { navgationlink := models.PatientNavgationlink{} err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, linkid).Find(&navgationlink).Error return navgationlink, err } func GetNavgationLinkById(id int64, orgid int64) (*models.PatientNavgationlink, error) { var pat models.PatientNavgationlink var err error err = service.PatientReadDB().Model(&models.PatientNavgationlink{}).Where(" id = ? AND user_org_id = ?", id, orgid).Find(&pat).Error if err == gorm.ErrRecordNotFound { return nil, err } if err != nil { return nil, err } return &pat, nil } func AddNavigationlink(navgationlink *models.PatientNavgationlink) error { err := service.PatientWriteDB().Create(&navgationlink).Error return err } func UpdateditnavigationLink(id int64, orgid int64, navgationlink models.PatientNavgationlink) error { err := service.PatientWriteDB().Model(&navgationlink).Where("id = ? AND user_org_id =?", id, orgid).Update(map[string]interface{}{"linktype": navgationlink.Linktype, "navitionlinktype": navgationlink.Navitionlinktype, "phone": navgationlink.Phone, "outstationlink": navgationlink.Outstationlink, "linkaddress": navgationlink.Linkaddress, "mtime": time.Now().Unix()}).Error return err } func AddEditDoctor(editdoctor *models.SgjPatientEditdoctor) error { err := service.PatientWriteDB().Create(&editdoctor).Error return err } func QuerEditDoctorInfo(mid int64, orgid int64) (editdoctor []models.SgjPatientEditdoctor, err error) { err = service.PatientWriteDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdoctor).Error return editdoctor, err } func GetModel(orgid int64) (*models.SgjPatientModel, error) { var model models.SgjPatientModel var err error err = service.PatientReadDB().Model(&models.SgjPatientModel{}).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&model).Error if err == gorm.ErrRecordNotFound { return nil, err } if err != nil { return nil, err } return &model, nil } func AddPatientModelTwo(model *models.SgjPatientModel) error { err := service.PatientWriteDB().Create(&model).Error return err } func GetQueryModelByLastData(orgid int64) (models.SgjPatientModel, error) { model := models.SgjPatientModel{} err := service.PatientReadDB().Model(&model).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&model).Error return model, err } func AddPatientEdit(editpiclink *models.SgjPatientEditpiclink) error { err := service.PatientWriteDB().Create(&editpiclink).Error return err } func AddHospital(hospital *models.SgjPatientHospital) error { err := service.PatientWriteDB().Create(&hospital).Error return err } func AddEditMargin(editmargin *models.SgjPatientEditmargin) error { err := service.PatientWriteDB().Create(&editmargin).Error return err } func AddPatientOffices(offices *models.SgjPatientOffices) error { err := service.PatientWriteDB().Create(&offices).Error return err } func GetDefaultNavigation(orgid int64) (navigation []models.SgjPatientNavigation, err error) { err = service.PatientReadDB().Model(navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error return navigation, err } func AddDefaultData(navigation *models.SgjPatientNavigation) error { err := service.PatientWriteDB().Create(&navigation).Error return err } func GetAllModelTitle(orgid int64) (models []models.SgjPatientModel, err error) { err = service.PatientReadDB().Model(models).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&models).Error return models, err } func GetDoctorDetailInfo(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 GetArticleListDetail(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 GetActivitiesListDetail(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 GetLinkAddressByLinkId(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 GetMagicLinkAddressById(orgid int64, linkid int64) (models.SgjPatientMagiclink, error) { magiclink := models.SgjPatientMagiclink{} err := service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&magiclink).Error return magiclink, err } func GetMagicClickByLinkID(orgid int64, linkid int64) (models.SgjPatientMagiclink, error) { magiclink := models.SgjPatientMagiclink{} err := service.PatientReadDB().Model(&magiclink).Where("user_org_id = ? AND id = ? AND status = ?", orgid, linkid, 1).Find(&magiclink).Error return magiclink, err } func GetEditRotationEmages(id int64, orgid int64) (models.SgjPatientConrotation, error) { conrotation := models.SgjPatientConrotation{} err := service.PatientReadDB().Where("id = ? AND user_org_id = ?", id, orgid).Find(&conrotation).Error return conrotation, err } func GetOutRotationLink(orgid int64, linkid int64) (models.SgjPatientConlinkaddress, error) { conlinkaddress := models.SgjPatientConlinkaddress{} err := service.PatientReadDB().Where("user_org_id = ? AND id = ?", orgid, linkid).Find(&conlinkaddress).Error return conlinkaddress, err } func UpdatedConlinkAddress(id int64, orgid int64, conlinkaddress models.SgjPatientConlinkaddress) error { err := service.PatientReadDB().Model(&conlinkaddress).Where("id=? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"defineaddress": conlinkaddress.Defineaddress, "mtime": time.Now().Unix()}).Error return err } func AddConlinkAddress(conlinkaddress *models.SgjPatientConlinkaddress) error { err := service.PatientWriteDB().Create(&conlinkaddress).Error return err } func UpdatedConrotation(id int64, orgid int64, conrotation models.SgjPatientConrotation) error { err := service.PatientReadDB().Model(&conrotation).Where("id=? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"images": conrotation.Images, "sort": conrotation.Sort, "piclink": conrotation.Piclink, "linkaddress": conrotation.Linkaddress, "mtime": time.Now().Unix()}).Error return err } func GetRotationVisibleByLinkId(id int64, orgid int64) (models.SgjPatientLinkaddress, error) { conlinkaddress := models.SgjPatientLinkaddress{} err := service.PatientReadDB().Where("id = ? AND user_org_id = ?", id, orgid).Find(&conlinkaddress).Error return conlinkaddress, err } func UpdatedRotationVisble(id int64, orgid int64, linkaddress models.SgjPatientLinkaddress) error { err := service.PatientReadDB().Model(&linkaddress).Where("id = ? AND user_org_id = ?", id, orgid).Update(map[string]interface{}{"defineaddress": linkaddress.Defineaddress, "mtime": time.Now().Unix()}).Error return err } func GetAritclesData(orgid int64) (articles []models.Articles, err error) { err = service.PatientReadDB().Model(&articles).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&articles).Error return articles, err } func GetArititys(orgid int64) (activity []models.Activity, err error) { err = service.PatientReadDB().Model(&activity).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&activity).Error return activity, err } func AddActivitys(activity *models.Activity) error { err := service.PatientReadDB().Create(&activity).Error return err } func GetContactUsModel(orgid int64) (oldmodels []models.PatientOrdmodel, err error) { err = service.PatientReadDB().Model(&oldmodels).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&oldmodels).Error return oldmodels, err } func GetPatientOrdModelByLastData(orgid int64) (models.PatientOrdmodel, error) { ordmodel := models.PatientOrdmodel{} err := service.PatientReadDB().Model(ºodel).Where("user_org_id = ? AND status = ?", orgid, 1).Last(ºodel).Error return ordmodel, err } func AddConRotation(conrotation *models.SgjPatientConrotation) error { err := service.PatientWriteDB().Create(&conrotation).Error return err } func GetOrgName(orgid int64) (models.Org, error) { org := models.Org{} err := service.UserReadDB().Model(&org).Where("id= ? and status = 1", orgid).Find(&org).Error return org, err }