瀏覽代碼

科室环境模块

xiaoming_global 5 年之前
父節點
當前提交
b37924d585

+ 2 - 0
controllers/article/article_controller.go 查看文件

@@ -260,6 +260,8 @@ func (this *ArticleManage) AddCategory(){
260 260
 	timenow := time.Now().Unix()
261 261
 	adminUserInfo := this.GetAdminUserInfo()
262 262
 	userOrgID := adminUserInfo.CurrentOrgId
263
+
264
+
263 265
 	category := models.ArticleCategory{
264 266
 		Name:    name,
265 267
 		Summary: content,

+ 194 - 0
controllers/site/site_controller.go 查看文件

@@ -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
 }

+ 36 - 1
models/site_models.go 查看文件

@@ -1,5 +1,21 @@
1 1
 package models
2 2
 
3
+//轮播图
4
+type SgjPatientRotation struct {
5
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
6
+	Title string `gorm:"column:title" json:"title" form:"title"`
7
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
8
+	RotationImages string `gorm:"column:rotation_images" json:"rotation_images" form:"rotation_images"`
9
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
10
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
11
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
12
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
13
+}
14
+
15
+func (SgjPatientRotation) TableName() string {
16
+	return "sgj_patient_rotation"
17
+}
18
+
3 19
 //医院介绍
4 20
 type SgjPatientHospital struct {
5 21
 	ID int64 `gorm:"column:id" json:"id" form:"id"`
@@ -9,6 +25,7 @@ type SgjPatientHospital struct {
9 25
 	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
10 26
 	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
11 27
 	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
28
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
12 29
 }
13 30
 
14 31
 func (SgjPatientHospital) TableName() string {
@@ -24,6 +41,7 @@ type SgjPatientOffices struct {
24 41
 	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
25 42
 	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
26 43
 	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
44
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
27 45
 }
28 46
 
29 47
 func (SgjPatientOffices)TableName() string  {
@@ -43,8 +61,25 @@ type SgjPatientDoctor struct {
43 61
 	Dochead string `gorm:"column:dochead" json:"dochead" form:"dochead"`
44 62
 	Docpositional string `gorm:"column:docpositional" json:"docpositional" form:"docpositional"`
45 63
 	Docintroduction string `gorm:"column:docintroduction" json:"docintroduction" form:"docintroduction"`
64
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
46 65
 }
47 66
 
48 67
 func (SgjPatientDoctor) TableName() string {
49 68
 	return "sgj_patient_doctor"
50
-}
69
+}
70
+
71
+// 科室环境
72
+type SgjPatientOffenvironment struct {
73
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
74
+	Title string `gorm:"column:title" json:"title" form:"title"`
75
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
76
+	Keimages string `gorm:"column:keimages" json:"keimages" form:"keimages"`
77
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
78
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
79
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
80
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
81
+}
82
+
83
+func (SgjPatientOffenvironment) TableName() string {
84
+	return "sgj_patient_offenvironment"
85
+}

+ 45 - 0
service/site_service/site_microwebsite_service.go 查看文件

@@ -3,8 +3,14 @@ package site_service
3 3
 import (
4 4
 	"SCRM/models"
5 5
 	"SCRM/service"
6
+	"fmt"
6 7
 )
7 8
 
9
+func AddRotationChart(rotation models.SgjPatientRotation) error {
10
+	err := service.PatientWriteDB().Create(&rotation).Error
11
+	return  err
12
+}
13
+
8 14
 func AddHispital(hospital models.SgjPatientHospital) error {
9 15
 	err := service.PatientWriteDB().Create(&hospital).Error
10 16
 	return  err
@@ -23,4 +29,43 @@ func AddDoctor(doctor models.SgjPatientDoctor) error {
23 29
 func AddDoctorInfo(doctor models.SgjPatientDoctor) error{
24 30
 	err := service.PatientWriteDB().Create(&doctor).Error
25 31
 	return  err
32
+}
33
+
34
+func AddOffEnvironment(offenvironment models.SgjPatientOffenvironment) error {
35
+	err := service.PatientWriteDB().Create(&offenvironment).Error
36
+	return  err
37
+}
38
+
39
+func GetRationImages(orgID int64)( models.SgjPatientRotation,error){
40
+	rotation := models.SgjPatientRotation{}
41
+	err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&rotation).Error
42
+	fmt.Println("错误是什么",err)
43
+	return rotation,err
44
+}
45
+
46
+func GetHospitalInfo(orgID int64)(models.SgjPatientHospital,error)  {
47
+	hospital := models.SgjPatientHospital{}
48
+	err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&hospital).Error
49
+	fmt.Println("错误是什么",err)
50
+	return  hospital,err
51
+}
52
+
53
+func GetOfficeInfo(orgID int64)(models.SgjPatientOffices,error)  {
54
+	offices := models.SgjPatientOffices{}
55
+	err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offices).Error
56
+	fmt.Println("错误是什么",err)
57
+	return  offices,err
58
+}
59
+
60
+func GetDoctorInfo(orgID int64)(doc []*models.SgjPatientDoctor,err  error)  {
61
+	err = service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Limit(2).Find(&doc).Error
62
+	fmt.Println("错误是什么",err)
63
+	return
64
+}
65
+
66
+func GetOffEnvironment(orgID int64)(models.SgjPatientOffenvironment,error) {
67
+	offenvironment := models.SgjPatientOffenvironment{}
68
+	err := service.PatientReadDB().Where("user_org_id = ? AND status = ?", orgID, 1).Last(&offenvironment).Error
69
+	fmt.Println("错误是什么",err)
70
+	return  offenvironment,err
26 71
 }