瀏覽代碼

联系我们模块的更新

xiaoming_global 5 年之前
父節點
當前提交
b9cb085e70
共有 3 個文件被更改,包括 1001 次插入190 次删除
  1. 681 145
      controllers/site/site_controller.go
  2. 135 10
      models/site_models.go
  3. 185 35
      service/site_service/site_microwebsite_service.go

文件差異過大導致無法顯示
+ 681 - 145
controllers/site/site_controller.go


+ 135 - 10
models/site_models.go 查看文件

@@ -28,6 +28,10 @@ type SgjPatientModel struct {
28 28
 	ModeType int64 `gorm:"column:mode_type" json:"mode_type" form:"mode_type"`
29 29
 	Hospitals     SgjPatientHospital `gorm:"ForeignKey:Modleid"`
30 30
 	Offices     SgjPatientOffices `gorm:"ForeignKey:Modleid"`
31
+	Doctors     SgjPatientDocinfo `gorm:"ForeignKey:Modelid"`
32
+	OfficeEnviroment   []SgjPatientOffenvironment  `gorm:"ForeignKey:Modelid"`
33
+	Editdoctor   []SgjPatientEditdoctor  `gorm:"ForeignKey:Modleid"`
34
+
31 35
 }
32 36
 func (SgjPatientModel) TableName() string{
33 37
 	return "sgj_patient_model"
@@ -44,6 +48,7 @@ type SgjPatientHospital struct {
44 48
 	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
45 49
 	Status int64 `gorm:"column:status" json:"status" form:"status"`
46 50
 	Modleid int64 `gorm:"column:modleid" json:"modleid" form:"modleid"`
51
+
47 52
 }
48 53
 
49 54
 func (SgjPatientHospital) TableName() string {
@@ -60,7 +65,7 @@ type SgjPatientOffices struct {
60 65
 	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
61 66
 	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
62 67
 	Status int64 `gorm:"column:status" json:"status" form:"status"`
63
-	Modleid int64 `gorm:"column:modleid" json:"modleid" form:"modleid"`
68
+	Modleid int64 `gorm:"column:modleid" json:"modelid" form:"modelid"`
64 69
 }
65 70
 
66 71
 func (SgjPatientOffices)TableName() string  {
@@ -68,25 +73,41 @@ func (SgjPatientOffices)TableName() string  {
68 73
 }
69 74
 
70 75
 //名医介绍
71
-type SgjPatientDoctor struct {
76
+type SgjPatientDocinfo struct {
72 77
 	ID int64 `gorm:"column:id" json:"id" form:"id"`
73 78
 	Title string `gorm:"column:title" json:"title" form:"title"`
74 79
 	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
75
-	Images string `gorm:"column:images" json:"images" form:"images"`
76
-	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
80
+	Docimages string `gorm:"column:docimages" json:"docimages" form:"docimages"`
77 81
 	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
78 82
 	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
79
-	Docname string `gorm:"column:docname" json:"docname" form:"docname"`
83
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
84
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
85
+	Modelid int64 `gorm:"column:modelid" json:"modelid" form:"modelid"`
86
+}
87
+
88
+func (SgjPatientDocinfo) TableName() string {
89
+
90
+	return "sgj_patient_docinfo"
91
+}
92
+
93
+//编辑名医介绍
94
+type SgjPatientEditdoctor struct {
95
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
96
+	DocPostion int64 `gorm:"column:doc_postion" json:"doc_postion" form:"doc_postion"`
80 97
 	Dochead string `gorm:"column:dochead" json:"dochead" form:"dochead"`
81
-	DocPosition int64 `gorm:"column:doc_position" json:"doc_position" form:"doc_position"`
98
+	DocSort int64 `gorm:"column:doc_sort" json:"doc_sort" form:"doc_sort"`
82 99
 	Docintroduction string `gorm:"column:docintroduction" json:"docintroduction" form:"docintroduction"`
100
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
101
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
102
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
83 103
 	Status int64 `gorm:"column:status" json:"status" form:"status"`
84
-	DocSort int64 `gorm:"column:doc_sort" json:"doc_sort" form:"doc_sort"`
85
-	Modelid int64 `gorm:"column:modelid" json:"modelid" form:"modelid"`
104
+	DocName string `gorm:"column:doc_name" json:"doc_name" form:"doc_name"`
105
+	Modleid int64 `gorm:"column:modleid" json:"modleid" form:"modleid"`
86 106
 }
87 107
 
88
-func (SgjPatientDoctor) TableName() string {
89
-	return "sgj_patient_doctor"
108
+func (SgjPatientEditdoctor) TableName() string  {
109
+
110
+	return "sgj_patient_editdoctor"
90 111
 }
91 112
 
92 113
 // 科室环境
@@ -165,4 +186,108 @@ func (SgjPatientNewmodel) TableName() string {
165 186
 
166 187
 	return "sgj_patient_newmodel"
167 188
 
189
+}
190
+
191
+type SgjPatientNavigation struct {
192
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
193
+	Navtitle string `gorm:"column:navtitle" json:"navtitle" form:"navtitle"`
194
+	Navimages string `gorm:"column:navimages" json:"navimages" form:"navimages"`
195
+	Jumpset int64 `gorm:"column:jumpset" json:"jumpset" form:"jumpset"`
196
+	Navaddress string `gorm:"column:navaddress" json:"navaddress" form:"navaddress"`
197
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
198
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
199
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
200
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
201
+}
202
+
203
+func (SgjPatientNavigation) TableName() string  {
204
+
205
+	return "sgj_patient_navigation"
206
+}
207
+
208
+type SgjPatientShare struct {
209
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
210
+	ShareTitle string `gorm:"column:share_title" json:"share_title" form:"share_title"`
211
+	ShareIntroduction string `gorm:"column:share_introduction" json:"share_introduction" form:"share_introduction"`
212
+	ShareImages string `gorm:"column:share_images" json:"share_images" form:"share_images"`
213
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
214
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
215
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
216
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
217
+}
218
+
219
+func (SgjPatientShare) TableName() string {
220
+
221
+	return "sgj_patient_share"
222
+}
223
+
224
+type SgjPatientOrdmodel struct {
225
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
226
+	Title string `gorm:"column:title" json:"title" form:"title"`
227
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
228
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
229
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
230
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
231
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
232
+	ModeType int64 `gorm:"column:mode_type" json:"mode_type" form:"mode_type"`
233
+	Connectway     []SgjPatientConnectway `gorm:"ForeignKey:ModeId"`
234
+	Worktime     SgjPatientWorktime `gorm:"ForeignKey:ModeId"`
235
+	Rideway  SgjPatientRideway `gorm:"ForeignKey:ModeId"`
236
+
237
+}
238
+
239
+func (SgjPatientOrdmodel) TableName() string  {
240
+
241
+	return "sgj_patient_ordmodel"
242
+}
243
+
244
+type SgjPatientConnectway struct {
245
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
246
+	Title string `gorm:"column:title" json:"title" form:"title"`
247
+	ConnectWayId string `gorm:"column:connect_way_id" json:"connect_way_id" form:"connect_way_id"`
248
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
249
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
250
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
251
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
252
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
253
+	ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
254
+}
255
+
256
+func (SgjPatientConnectway)  TableName() string {
257
+
258
+	return "sgj_patient_connectway"
259
+}
260
+
261
+type SgjPatientWorktime struct {
262
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
263
+	Title string `gorm:"column:title" json:"title" form:"title"`
264
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
265
+	Worktime string `gorm:"column:worktime" json:"worktime" form:"worktime"`
266
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
267
+	ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
268
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
269
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
270
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
271
+}
272
+
273
+func (SgjPatientWorktime) TableName() string {
274
+
275
+	return "sgj_patient_worktime"
276
+}
277
+
278
+type SgjPatientRideway struct {
279
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
280
+	Title string `gorm:"column:title" json:"title" form:"title"`
281
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
282
+	RideWay string `gorm:"column:ride_way" json:"ride_way" form:"ride_way"`
283
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
284
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
285
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
286
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
287
+	ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
288
+}
289
+
290
+func (SgjPatientRideway)TableName() string{
291
+
292
+	return "sgj_patient_rideway"
168 293
 }

+ 185 - 35
service/site_service/site_microwebsite_service.go 查看文件

@@ -41,12 +41,12 @@ func AddOffices(offices models.SgjPatientOffices) error  {
41 41
 	return  err
42 42
 }
43 43
 
44
-func AddDoctor(doctor models.SgjPatientDoctor) error {
44
+func AddDoctor(doctor models.SgjPatientDocinfo) error {
45 45
 	err := service.PatientWriteDB().Create(&doctor).Error
46 46
 	return err
47 47
 }
48 48
 
49
-func AddDoctorInfo(doctor models.SgjPatientDoctor) error{
49
+func AddDoctorInfo(doctor models.SgjPatientEditdoctor) error{
50 50
 	err := service.PatientWriteDB().Create(&doctor).Error
51 51
 	return  err
52 52
 }
@@ -76,19 +76,13 @@ func GetOfficeInfo(orgID int64)(models.SgjPatientOffices,error)  {
76 76
 	return  offices,err
77 77
 }
78 78
 
79
-func GetDoctorInfo(orgID int64)(doc []*models.SgjPatientDoctor,err  error)  {
80
-	err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Limit(2).Find(&doc).Error
81
-	fmt.Println("错误是什么",err)
82
-	return
83
-}
84
-
85 79
 func GetQueryDocInfo(orgID int64)(doc []*models.SgjUserStaffInfo,err error)  {
86 80
 	err = service.UserReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Find(&doc).Error
87 81
 	fmt.Println("错误是什么",err)
88 82
 	return
89 83
 }
90 84
 
91
-func GetQueryDocHead(orgID int64) (doc []*models.SgjPatientDoctor,err error) {
85
+func GetQueryDocHead(orgID int64) (doc []*models.SgjPatientEditdoctor,err error) {
92 86
 	err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Order("doc_sort").Find(&doc).Error
93 87
 	return
94 88
 }
@@ -100,12 +94,12 @@ func GetOffEnvironment(orgID int64)(models.SgjPatientOffenvironment,error) {
100 94
 	return  offenvironment,err
101 95
 }
102 96
 
103
-func AddWorkTime(connecmodel models.SgjPatientConnecmodel) error  {
97
+func AddWorkTime(connecmodel *models.SgjPatientWorktime) error  {
104 98
 	err := service.PatientWriteDB().Create(&connecmodel).Error
105 99
 	return err
106 100
 }
107 101
 
108
-func AddRideWay(connecmodel models.SgjPatientConnecmodel) error {
102
+func AddRideWay(connecmodel models.SgjPatientRideway) error {
109 103
 	err := service.PatientWriteDB().Create(&connecmodel).Error
110 104
 	return  err
111 105
 }
@@ -120,11 +114,21 @@ func GetQueryConnection( orgID int64)(conection []*models.SgjPatientConnection,e
120 114
 	return
121 115
 }
122 116
 
123
-func DeleteConnecWay(orgid int64,id int64)(error){
124
-	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
117
+func DeleteRideWay(orgid int64,id int64)(error){
118
+	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
125 119
 	return  err
126 120
 }
127 121
 
122
+func DeleteConnecWay(orgid int64,id int64)(error)  {
123
+	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
124
+	return err
125
+}
126
+
127
+func DeleteWorkTime(orgid int64,id int64)(error)  {
128
+	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
129
+	return err
130
+}
131
+
128 132
 func EditConnecWay(orgid int64,id int64)(models.SgjPatientConnection,error){
129 133
     sgj  := models.SgjPatientConnection{}
130 134
 	err := service.PatientReadDB().Model(&sgj).Where("user_org_id = ? AND id =?", orgid, id).Find(&sgj).Error
@@ -135,7 +139,7 @@ func UpadateConnec(connection *models.SgjPatientConnection,orgID int64,id int64)
135 139
 	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,})
136 140
 }
137 141
 
138
-func GetUserModel(orgid int64)(model []*models.SgjPatientConnecmodel,err error){
142
+func GetUserModel(orgid int64)(model []*models.SgjPatientOrdmodel,err error){
139 143
 	err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgid, 1).Order("sort").Find(&model).Error
140 144
 	return
141 145
 }
@@ -146,18 +150,30 @@ func GetQueryNewModel(orgid int64)(model []*models.SgjPatientModel,err error)  {
146 150
 	return
147 151
 }
148 152
 
149
-func GetEditModel(orgid int64,id int64)(models.SgjPatientConnecmodel,error){
150
-	connecmodel := models.SgjPatientConnecmodel{}
151
-	err := service.PatientReadDB().Model(&connecmodel).Where("user_org_id = ? AND id = ?", orgid, id).Find(&connecmodel).Error
152
-	return connecmodel,err;
153
+func GetEditModel(orgid int64,id int64)(models.SgjPatientWorktime,error){
154
+	worktime := models.SgjPatientWorktime{}
155
+	err := service.PatientReadDB().Model(&worktime).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&worktime).Error
156
+	return worktime,err;
153 157
 }
154 158
 
155
-func UpdateWorkTime(id int64,orgID int64,connecmodel models.SgjPatientConnecmodel)  {
156
-	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()})
159
+func GetEditRideWay(orgid int64,id int64)(models.SgjPatientRideway,error)  {
160
+	rideway := models.SgjPatientRideway{}
161
+	err := service.PatientReadDB().Model(&rideway).Where("user_org_id = ? AND mode_id = ?", orgid, id).Find(&rideway).Error
162
+	return rideway,err;
157 163
 }
158 164
 
159
-func UpdateRideWay(id int64,orgID int64,connecmodel models.SgjPatientConnecmodel) error {
160
-	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
165
+func UpdateWorkTime(mid int64,orgID int64,worktime models.SgjPatientWorktime) error {
166
+	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
167
+	return err
168
+}
169
+
170
+func UpdateOrdeModel(id int64,orgID int64,ordmodel models.SgjPatientOrdmodel) error {
171
+	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
172
+	return err
173
+}
174
+
175
+func UpdateRideWay(id int64,orgID int64,rideway models.SgjPatientRideway) error {
176
+	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, "rideway": rideway.RideWay, "mtime": time.Now().Unix()}).Error
161 177
 	return  err
162 178
 }
163 179
 
@@ -167,19 +183,8 @@ func QueryDocById(orgID int64,id int64)(models.SgjUserStaffInfo,error)  {
167 183
 	return  info,err
168 184
 }
169 185
 
170
-func  EditDoctorInfo(id int64,orgID int64)(models.SgjPatientDoctor,error)  {
171
-	doctor := models.SgjPatientDoctor{}
172
-	err := service.PatientReadDB().Model(&doctor).Where("id = ? AND user_org_id = ?", id, orgID).Find(&doctor).Error
173
-	return doctor,err
174
-}
175
-
176
-func UpdateDocInfo(id int64,orgID int64,doctor models.SgjPatientDoctor) error {
177
-	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
178
-	return  err
179
-}
180
-
181 186
 func DeleteDoctor(id int64,orgID int64)(error) {
182
-	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
187
+	err := service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? AND user_org_id = ?", id, orgID).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
183 188
 	return err
184 189
 }
185 190
 
@@ -234,8 +239,153 @@ func GetData(orgid int64)(model []*models.SgjPatientModel,err error)  {
234 239
 	if(orgid > 0){
235 240
 		db = db.Where("user_org_id = ? ", orgid)
236 241
 	}
237
-	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
242
+	err = db.Preload("Hospitals").Preload("Offices").Preload("Doctors").Preload("OfficeEnviroment").Preload("Editdoctor").
243
+		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
244
+	return
245
+}
246
+
247
+func UpdateDoctorsInfo(orgID int64,ids[] int64,editdoctor models.SgjPatientEditdoctor)(err error)  {
248
+	if(len(ids)==1){
249
+		err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id = ? and user_org_id = ?", ids[0], orgID).Update(map[string]interface{}{ "modleid": editdoctor.Modleid, "status": 1, "mtime": time.Now().Unix()}).Error
250
+	}else {
251
+		err = service.PatientWriteDB().Model(&models.SgjPatientEditdoctor{}).Where("id IN(?) and user_org_id = ?", ids, orgID).Update(map[string]interface{}{"modleid": editdoctor.Modleid, "status": 1, "mtime": time.Now().Unix()}).Error
252
+	}
253
+	return
254
+}
255
+
256
+func QueryEditDoc(mid int64,orgid int64)(models.SgjPatientDocinfo,  error)  {
257
+	editdotor := models.SgjPatientDocinfo{}
258
+	err := service.PatientReadDB().Model(&editdotor).Where("modelid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Find(&editdotor).Error
259
+	return editdotor,err
260
+}
261
+
262
+func QuerEditDocByid(mid int64,orgid int64)(editdoctor []*models.SgjPatientEditdoctor,err error)  {
263
+	err = service.PatientReadDB().Model(&editdoctor).Where("modleid = ? AND user_org_id = ? AND status = ?", mid, orgid, 1).Order("doc_sort").Find(&editdoctor).Error
264
+	return
265
+}
266
+
267
+func QueryEditImages(orgid int64,id int64)(models.SgjPatientEditdoctor,error)  {
268
+	editdoctor := models.SgjPatientEditdoctor{}
269
+	err := service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND id = ? AND status = ?", orgid, id, 1).Find(&editdoctor).Error
270
+	return editdoctor,err
271
+}
272
+
273
+func QueryEditDoctor(id int64,orgid int64)(models.SgjPatientEditdoctor,error)  {
274
+	docinfo := models.SgjPatientEditdoctor{}
275
+	err := service.PatientReadDB().Model(&docinfo).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&docinfo).Error
276
+	return  docinfo,err
277
+}
278
+
279
+func UpDateEditdoctor(id int64,orgid int64,editdoctor models.SgjPatientEditdoctor) error  {
280
+	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
281
+	return  err
282
+}
283
+
284
+func Upadatedocdata(orgid int64,id int64,docinfo models.SgjPatientDocinfo) error {
285
+	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
286
+	return  err
287
+}
288
+
289
+func QuerOfficeEnviroment(id int64,orgid int64)(models.SgjPatientOffenvironment,error)  {
290
+	offenvironment := models.SgjPatientOffenvironment{}
291
+	err := service.PatientReadDB().Model(&offenvironment).Where("modelid = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
292
+	return offenvironment,err
293
+}
294
+
295
+func UpdateOfficeEnvironment(id int64,orgid int64,offenvironment models.SgjPatientOffenvironment) error {
296
+	err := service.PatientReadDB().Model(&offenvironment).Where("id = ? AND user_org_id = ? AND status = ?", id, orgid, 1).Find(&offenvironment).Error
297
+	return err
298
+}
299
+
300
+func QueryHispitalDetail(orgid int64,id int64)(models.SgjPatientHospital,error)  {
301
+	hospital := models.SgjPatientHospital{}
302
+	err := service.PatientReadDB().Model(&hospital).Where("user_org_id = ?  AND modleid = ? AND status = ?", orgid, id, 1).Find(&hospital).Error
303
+	return  hospital,err
304
+}
305
+
306
+func GetOfficeDetail(orgid int64,id int64)(models.SgjPatientOffices,error) {
307
+	offices := models.SgjPatientOffices{}
308
+	err := service.PatientReadDB().Model(&offices).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Find(&offices).Error
309
+	return offices,err
310
+}
311
+
312
+func GetDoctorDetail(orgid int64,id int64)(editdoctor []*models.SgjPatientEditdoctor,err error)  {
313
+	err = service.PatientReadDB().Model(&editdoctor).Where("user_org_id = ? AND modleid = ? AND status = ?", orgid, id, 1).Order("doc_sort").Find(&editdoctor).Error
314
+	return
315
+}
316
+
317
+func AddNavigation(navigation *models.SgjPatientNavigation)error  {
318
+	err := service.PatientWriteDB().Create(&navigation).Error
319
+	return err
320
+}
321
+
322
+func GetNavigationList(orgid int64)(navigation []*models.SgjPatientNavigation,err error)  {
323
+	err = service.PatientReadDB().Model(&navigation).Where("user_org_id = ? AND status = ?", orgid, 1).Find(&navigation).Error
324
+	return
325
+}
326
+
327
+func AddShareInfo(share *models.SgjPatientShare) error {
328
+	err := service.PatientWriteDB().Create(&share).Error
329
+
330
+	return err
331
+}
332
+
333
+func GetShareInfo(orgid int64)(models.SgjPatientShare,error)  {
334
+	share := models.SgjPatientShare{}
335
+	err := service.PatientReadDB().Model(&share).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&share).Error
336
+	return share,err
337
+}
338
+
339
+func DeleteNavitionById(orgID int64,id int64)(error)  {
340
+	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
341
+	return  err
342
+}
343
+
344
+func AddConnecWay(connectway *models.SgjPatientConnectway) error {
345
+	err := service.PatientWriteDB().Create(&connectway).Error
346
+	return  err
347
+}
348
+
349
+func AddOrdModel(ordmodel *models.SgjPatientOrdmodel)error  {
350
+	err := service.PatientWriteDB().Create(&ordmodel).Error
351
+	return err
352
+}
353
+
354
+func QueryOrdeModelByID(orgid int64)(models.SgjPatientOrdmodel,error)  {
355
+	ordmodel := models.SgjPatientOrdmodel{}
356
+	err := service.PatientReadDB().Where("user_org_id = ? AND status = ? ", orgid, 1).Last(&ordmodel).Error
357
+	return ordmodel,err
358
+}
359
+
360
+func DeleteModle(orgid int64,id int64)(error) {
361
+	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
362
+	return  err
363
+}
364
+
365
+func DeleteModleByModeID(orgid int64,mid int64)(error)  {
366
+	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
367
+	return err
368
+}
369
+
370
+func GetOrederModel(orgid int64)(model []*models.SgjPatientOrdmodel,err error)  {
371
+	db := service.PatientReadDB().Table("sgj_patient_ordmodel as o").Where("o.status = ?", 1)
372
+	if(orgid > 0){
373
+		db = db.Where("user_org_id = ?", orgid)
374
+	}
375
+	err = db.Preload("Connectway").Preload("Worktime").Preload("Rideway").
376
+		Select("o.id,o.title,o.sort,o.ctime,o.mtime,o.mode_type").Order("sort").Find(&model).Error
377
+    fmt.Println("sql错误是什么",err)
238 378
 	return
379
+
239 380
 }
240 381
 
382
+//func GetData(orgid int64)(model []*models.SgjPatientModel,err error)  {
383
+//	db := service.PatientReadDB().Table("sgj_patient_model as m").Where(" m.status = ?", 1)
384
+//	if(orgid > 0){
385
+//		db = db.Where("user_org_id = ? ", orgid)
386
+//	}
387
+//	err = db.Preload("Hospitals").Preload("Offices").Preload("Doctors").Preload("OfficeEnviroment").Preload("Editdoctor").
388
+//		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
389
+//	return
390
+//}
241 391