|
@@ -11,18 +11,80 @@ import (
|
11
|
11
|
"SCRM/service/site_service"
|
12
|
12
|
"SCRM/models"
|
13
|
13
|
"time"
|
|
14
|
+ "strings"
|
14
|
15
|
)
|
15
|
16
|
func siteRouters() {
|
|
17
|
+ beego.Router("/api/site/addrotationchart",&Microwebsite{},"Post:AddRotaionChart")
|
16
|
18
|
beego.Router("/api/site/savehispital",&Microwebsite{},"Post:SaveHispital")
|
17
|
19
|
beego.Router("/api/site/addoffices",&Microwebsite{},"Post:AddOffices")
|
18
|
20
|
beego.Router("/api/site/adddoctor",&Microwebsite{},"Post:AddDoctor")
|
19
|
21
|
beego.Router("/api/site/adddoctorinfo",&Microwebsite{},"Post:AddDoctorInfo")
|
|
22
|
+ beego.Router("/api/site/getrationimages",&Microwebsite{},"Get:GetRationImages")
|
|
23
|
+ beego.Router("/api/site/gethospitalinfo",&Microwebsite{},"Get:GetHospitalinfo")
|
|
24
|
+ beego.Router("/api/site/getofficeinfo",&Microwebsite{},"Get:GetOfficeInfo")
|
|
25
|
+ beego.Router("/api/site/getdoctorinfo",&Microwebsite{},"Get:GetDoctorInfo")
|
|
26
|
+ beego.Router("/api/site/keenvironment",&Microwebsite{},"Post:AddKeEnvironment")
|
|
27
|
+ beego.Router("/api/site/getOffEnvironment",&Microwebsite{},"Get:GetOffEnvironment")
|
20
|
28
|
}
|
21
|
29
|
|
22
|
30
|
type Microwebsite struct {
|
23
|
31
|
controllers.BaseAuthAPIController
|
24
|
32
|
}
|
25
|
33
|
|
|
34
|
+//轮播图
|
|
35
|
+func (this *Microwebsite) AddRotaionChart() {
|
|
36
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
37
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
38
|
+ dataBody := make(map[string]interface{}, 0)
|
|
39
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
40
|
+ fmt.Println("错误是什么呢",err)
|
|
41
|
+ fmt.Println("机构ID",userOrgID)
|
|
42
|
+ if err != nil {
|
|
43
|
+ utils.ErrorLog(err.Error())
|
|
44
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
|
|
45
|
+ return
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ title := dataBody["title"].(string)
|
|
49
|
+ if len(title) == 0 {
|
|
50
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
|
|
51
|
+ return
|
|
52
|
+ }
|
|
53
|
+ fmt.Println("姓名:",title)
|
|
54
|
+ sort := dataBody["sort"].(string)
|
|
55
|
+ if len(sort) == 0 {
|
|
56
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
|
|
57
|
+ return
|
|
58
|
+ }
|
|
59
|
+ sortt, err := strconv.ParseInt(sort, 10, 64)
|
|
60
|
+ fmt.Println("排序:",sortt)
|
|
61
|
+ rotationImages := dataBody["rotationImages"]
|
|
62
|
+ //图片数组转为字符串保存到数据库
|
|
63
|
+ replace := strings.Replace(strings.Trim(fmt.Sprint(rotationImages), "[]"), " ", ",", -1)
|
|
64
|
+ fmt.Println("姓名:",rotationImages)
|
|
65
|
+ fmt.Println("字符串",replace)
|
|
66
|
+
|
|
67
|
+ rotation := models.SgjPatientRotation{
|
|
68
|
+ Title: title,
|
|
69
|
+ Sort: sortt,
|
|
70
|
+ RotationImages:replace,
|
|
71
|
+ UserOrgId: userOrgID,
|
|
72
|
+ Status:1,
|
|
73
|
+ Ctime: time.Now().Unix(),
|
|
74
|
+ }
|
|
75
|
+ err = site_service.AddRotationChart(rotation)
|
|
76
|
+ if err !=nil{
|
|
77
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
|
|
78
|
+ return
|
|
79
|
+ }
|
|
80
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
81
|
+ "rotation":rotation,
|
|
82
|
+ })
|
|
83
|
+}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
26
|
88
|
//医院介绍
|
27
|
89
|
func (this *Microwebsite) SaveHispital() {
|
28
|
90
|
adminUserInfo := this.GetAdminUserInfo()
|
|
@@ -63,6 +125,8 @@ func (this *Microwebsite) SaveHispital() {
|
63
|
125
|
Introduction: introduction,
|
64
|
126
|
UserOrgId:userOrgID,
|
65
|
127
|
Ctime:time.Now().Unix(),
|
|
128
|
+ Status:1,
|
|
129
|
+
|
66
|
130
|
}
|
67
|
131
|
err = site_service.AddHispital(hospital)
|
68
|
132
|
if err !=nil{
|
|
@@ -113,6 +177,7 @@ func (this *Microwebsite) AddOffices() {
|
113
|
177
|
Introduction: introduction,
|
114
|
178
|
UserOrgId: userOrgID,
|
115
|
179
|
Ctime: time.Now().Unix(),
|
|
180
|
+ Status: 1,
|
116
|
181
|
}
|
117
|
182
|
err = site_service.AddOffices(offices)
|
118
|
183
|
if err !=nil{
|
|
@@ -164,6 +229,7 @@ func (this *Microwebsite) AddDoctor() {
|
164
|
229
|
Images: image,
|
165
|
230
|
UserOrgId:userOrgID,
|
166
|
231
|
Ctime:time.Now().Unix(),
|
|
232
|
+ Status:1,
|
167
|
233
|
}
|
168
|
234
|
|
169
|
235
|
err = site_service.AddDoctor(doctor)
|
|
@@ -222,6 +288,7 @@ func (this *Microwebsite) AddDoctorInfo() {
|
222
|
288
|
Docpositional: docpositional,
|
223
|
289
|
UserOrgId:userOrgID,
|
224
|
290
|
Ctime:time.Now().Unix(),
|
|
291
|
+ Status:1,
|
225
|
292
|
}
|
226
|
293
|
err = site_service.AddDoctorInfo(doctor)
|
227
|
294
|
if err !=nil{
|
|
@@ -231,4 +298,131 @@ func (this *Microwebsite) AddDoctorInfo() {
|
231
|
298
|
this.ServeSuccessJSON(map[string]interface{}{
|
232
|
299
|
"doctor":doctor,
|
233
|
300
|
})
|
|
301
|
+}
|
|
302
|
+
|
|
303
|
+//新增科室环境
|
|
304
|
+func (this *Microwebsite) AddKeEnvironment() {
|
|
305
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
306
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
307
|
+ dataBody := make(map[string]interface{}, 0)
|
|
308
|
+ err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
|
309
|
+ fmt.Println("错误是什么呢",err)
|
|
310
|
+ fmt.Println("机构ID",userOrgID)
|
|
311
|
+ if err != nil {
|
|
312
|
+ utils.ErrorLog(err.Error())
|
|
313
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
|
|
314
|
+ return
|
|
315
|
+ }
|
|
316
|
+
|
|
317
|
+ title := dataBody["title"].(string)
|
|
318
|
+ if len(title) == 0 {
|
|
319
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
|
|
320
|
+ return
|
|
321
|
+ }
|
|
322
|
+ fmt.Println("标题:",title)
|
|
323
|
+ sort := dataBody["sort"].(string)
|
|
324
|
+ if len(sort) == 0 {
|
|
325
|
+ this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
|
|
326
|
+ return
|
|
327
|
+ }
|
|
328
|
+ sortt, err := strconv.ParseInt(sort, 10, 64)
|
|
329
|
+ fmt.Println("排序:",sortt)
|
|
330
|
+ keImages := dataBody["keImages"]
|
|
331
|
+ //图片数组转为字符串保存到数据库
|
|
332
|
+ replace := strings.Replace(strings.Trim(fmt.Sprint(keImages), "[]"), " ", ",", -1)
|
|
333
|
+ fmt.Println("图片:",keImages)
|
|
334
|
+ fmt.Println("字符串",replace)
|
|
335
|
+ offenvironment := models.SgjPatientOffenvironment{
|
|
336
|
+ Title: title,
|
|
337
|
+ Sort: sortt,
|
|
338
|
+ Keimages: replace,
|
|
339
|
+ Mtime: time.Now().Unix(),
|
|
340
|
+ UserOrgId: userOrgID,
|
|
341
|
+ Status: 1,
|
|
342
|
+ }
|
|
343
|
+ err = site_service.AddOffEnvironment(offenvironment)
|
|
344
|
+ if err !=nil{
|
|
345
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加科室环境失败")
|
|
346
|
+ return
|
|
347
|
+ }
|
|
348
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
349
|
+ "offenvironment":offenvironment,
|
|
350
|
+ })
|
|
351
|
+}
|
|
352
|
+
|
|
353
|
+//获取轮播图
|
|
354
|
+func (this *Microwebsite) GetRationImages() {
|
|
355
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
356
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
357
|
+ rotation, err := site_service.GetRationImages(userOrgID)
|
|
358
|
+ if err !=nil{
|
|
359
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取轮播图失败")
|
|
360
|
+ return
|
|
361
|
+ }
|
|
362
|
+ fmt.Println("错误是什么",err)
|
|
363
|
+ fmt.Println("获取的数据",rotation)
|
|
364
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
365
|
+ "rotationImages":rotation,
|
|
366
|
+ })
|
|
367
|
+}
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+//获取医院信息
|
|
371
|
+func (this * Microwebsite) GetHospitalinfo() {
|
|
372
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
373
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
374
|
+ hospital, err := site_service.GetHospitalInfo(userOrgID)
|
|
375
|
+ fmt.Println("数据是什么",hospital)
|
|
376
|
+ if err !=nil{
|
|
377
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取轮播图失败")
|
|
378
|
+ return
|
|
379
|
+ }
|
|
380
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
381
|
+ "hospital":hospital,
|
|
382
|
+ })
|
|
383
|
+}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+//获取科室信息
|
|
387
|
+func (this * Microwebsite) GetOfficeInfo() {
|
|
388
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
389
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
390
|
+ offices, err := site_service.GetOfficeInfo(userOrgID)
|
|
391
|
+ fmt.Println("科室介绍数据是什么",offices)
|
|
392
|
+ if err !=nil{
|
|
393
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取轮播图失败")
|
|
394
|
+ return
|
|
395
|
+ }
|
|
396
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
397
|
+ "offices":offices,
|
|
398
|
+ })
|
|
399
|
+}
|
|
400
|
+
|
|
401
|
+//获取名医介绍
|
|
402
|
+func (this * Microwebsite) GetDoctorInfo() {
|
|
403
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
404
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
405
|
+ doc, err := site_service.GetDoctorInfo(userOrgID)
|
|
406
|
+ fmt.Println("doc是什么",doc)
|
|
407
|
+ if err !=nil{
|
|
408
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
|
|
409
|
+ return
|
|
410
|
+ }
|
|
411
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
412
|
+ "doctor":doc,
|
|
413
|
+ })
|
|
414
|
+}
|
|
415
|
+
|
|
416
|
+//获取科室环境
|
|
417
|
+func (this * Microwebsite) GetOffEnvironment() {
|
|
418
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
419
|
+ userOrgID := int64(adminUserInfo.CurrentOrgId)
|
|
420
|
+ offenvironment, err := site_service.GetOffEnvironment(userOrgID)
|
|
421
|
+ if err !=nil{
|
|
422
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取名医介绍失败")
|
|
423
|
+ return
|
|
424
|
+ }
|
|
425
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
426
|
+ "offenvironment":offenvironment,
|
|
427
|
+ })
|
234
|
428
|
}
|