123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- package site_service
-
- import (
- "SCRM/models"
- "SCRM/service"
- "fmt"
- "time"
- )
-
- 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 AddRotation(rotation models.SgjPatientRotation) error {
- err := service.PatientWriteDB().Create(&rotation).Error
- fmt.Println("插入数据",err)
- return 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.SgjPatientDoctor) error {
- err := service.PatientWriteDB().Create(&doctor).Error
- return err
- }
-
- func AddDoctorInfo(doctor models.SgjPatientDoctor) error{
- err := service.PatientWriteDB().Create(&doctor).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 GetDoctorInfo(orgID int64)(doc []*models.SgjPatientDoctor,err error) {
- err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Limit(2).Find(&doc).Error
- fmt.Println("错误是什么",err)
- return
- }
-
- 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.SgjPatientDoctor,err error) {
- err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 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.SgjPatientConnecmodel) error {
- err := service.PatientWriteDB().Create(&connecmodel).Error
- return err
- }
-
- func AddRideWay(connecmodel models.SgjPatientConnecmodel) 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 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 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.SgjPatientConnecmodel,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.SgjPatientConnecmodel,error){
- connecmodel := models.SgjPatientConnecmodel{}
- err := service.PatientReadDB().Model(&connecmodel).Where("user_org_id = ? AND id = ?", orgid, id).Find(&connecmodel).Error
- return connecmodel,err;
- }
-
- func UpdateWorkTime(id int64,orgID int64,connecmodel models.SgjPatientConnecmodel) {
- service.PatientWriteDB().Model(connecmodel).Where("id = ? AND user_org_id = ? AND status = ?",id,orgID,1).Update(map[string]interface{}{"title":connecmodel.Title,"sort":connecmodel.Sort,"worktime":connecmodel.Worktime,"mtime":time.Now().Unix()})
- }
-
- func UpdateRideWay(id int64,orgID int64,connecmodel models.SgjPatientConnecmodel) error {
- err := service.PatientWriteDB().Model(connecmodel).Where("id = ? AND user_org_id = ? AND status =?", id, orgID, 1).Update(map[string]interface{}{"title": connecmodel.Title, "sort": connecmodel.Sort, "rideway": connecmodel.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 EditDoctorInfo(id int64,orgID int64)(models.SgjPatientDoctor,error) {
- doctor := models.SgjPatientDoctor{}
- err := service.PatientReadDB().Model(&doctor).Where("id = ? AND user_org_id = ?", id, orgID).Find(&doctor).Error
- return doctor,err
- }
-
- func UpdateDocInfo(id int64,orgID int64,doctor models.SgjPatientDoctor) error {
- err := service.PatientWriteDB().Model(doctor).Where("id = ? AND user_org_id = ? AND status = ?", id, orgID, 1).Update(map[string]interface{}{"docname": doctor.Docname, "doc_position": doctor.DocPosition, "dochead": doctor.Dochead, "doc_sort": doctor.DocSort, "docintroduction": doctor.Docintroduction, "mtime": time.Now().Unix()}).Error
- return err
- }
-
- func DeleteDoctor(id int64,orgID int64)(error) {
- err := service.PatientWriteDB().Model(&models.SgjPatientDoctor{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 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 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)
- if(orgid > 0){
- db = db.Where("user_org_id = ? ", orgid)
- }
- err = db.Preload("Hospitals").Preload("Offices").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
- }
-
-
|