xiaoming_global 5 лет назад
Родитель
Сommit
8762e6e024

+ 5 - 0
controllers/site/router_collector.go Просмотреть файл

@@ -0,0 +1,5 @@
1
+package site
2
+
3
+func RegisterRouters() {
4
+	siteRouters()
5
+}

+ 234 - 0
controllers/site/site_controller.go Просмотреть файл

@@ -0,0 +1,234 @@
1
+package site
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+	"SCRM/controllers"
6
+	"fmt"
7
+	"encoding/json"
8
+	"SCRM/utils"
9
+	"SCRM/enums"
10
+	"strconv"
11
+	"SCRM/service/site_service"
12
+	"SCRM/models"
13
+	"time"
14
+)
15
+func siteRouters() {
16
+	beego.Router("/api/site/savehispital",&Microwebsite{},"Post:SaveHispital")
17
+	beego.Router("/api/site/addoffices",&Microwebsite{},"Post:AddOffices")
18
+	beego.Router("/api/site/adddoctor",&Microwebsite{},"Post:AddDoctor")
19
+	beego.Router("/api/site/adddoctorinfo",&Microwebsite{},"Post:AddDoctorInfo")
20
+}
21
+
22
+type Microwebsite struct {
23
+	controllers.BaseAuthAPIController
24
+}
25
+
26
+//医院介绍
27
+func (this *Microwebsite) SaveHispital()  {
28
+	adminUserInfo := this.GetAdminUserInfo()
29
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
30
+	dataBody := make(map[string]interface{}, 0)
31
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
32
+	fmt.Println("错误是什么呢",err)
33
+    fmt.Println("机构ID",userOrgID)
34
+	if err != nil {
35
+		utils.ErrorLog(err.Error())
36
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
37
+		return
38
+	}
39
+
40
+	title := dataBody["title"].(string)
41
+	if len(title) == 0 {
42
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
43
+		return
44
+	}
45
+	fmt.Println("姓名:",title)
46
+	sort := dataBody["sort"].(string)
47
+	if len(sort) == 0 {
48
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
49
+		return
50
+	}
51
+	sortt, err := strconv.ParseInt(sort, 10, 64)
52
+	fmt.Println("排序:",sortt)
53
+	introduction := dataBody["introduction"].(string)
54
+	if len(introduction) == 0 {
55
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医院介绍不能为空")
56
+		return
57
+	}
58
+	fmt.Println("姓名是什么?",title,"排序是什么",sortt,"医院介绍不能为空",introduction)
59
+
60
+	hospital := models.SgjPatientHospital{
61
+		Title:        title,
62
+		Sort:         sortt,
63
+		Introduction: introduction,
64
+		UserOrgId:userOrgID,
65
+		Ctime:time.Now().Unix(),
66
+	}
67
+	err = site_service.AddHispital(hospital)
68
+	if err !=nil{
69
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
70
+		return
71
+	}
72
+	this.ServeSuccessJSON(map[string]interface{}{
73
+		"hospital":hospital,
74
+	})
75
+}
76
+
77
+//添加科室
78
+func  (this *Microwebsite) AddOffices()  {
79
+	adminUserInfo := this.GetAdminUserInfo()
80
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
81
+	dataBody := make(map[string]interface{}, 0)
82
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
83
+	fmt.Println("错误是什么呢",err)
84
+	fmt.Println("机构ID",userOrgID)
85
+	if err != nil {
86
+		utils.ErrorLog(err.Error())
87
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
88
+		return
89
+	}
90
+
91
+	title := dataBody["title"].(string)
92
+	if len(title) == 0 {
93
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
94
+		return
95
+	}
96
+	fmt.Println("姓名:",title)
97
+	sort := dataBody["sort"].(string)
98
+	if len(sort) == 0 {
99
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
100
+		return
101
+	}
102
+	sortt, err := strconv.ParseInt(sort, 10, 64)
103
+	fmt.Println("排序:",sortt)
104
+	introduction := dataBody["introduction"].(string)
105
+	if len(introduction) == 0 {
106
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医院介绍不能为空")
107
+		return
108
+	}
109
+	fmt.Println("姓名是什么?",title,"排序是什么",sortt,"医院介绍不能为空",introduction)
110
+	offices := models.SgjPatientOffices{
111
+		Title:        title,
112
+		Sort:         sortt,
113
+		Introduction: introduction,
114
+		UserOrgId:    userOrgID,
115
+		Ctime:        time.Now().Unix(),
116
+	}
117
+	err = site_service.AddOffices(offices)
118
+	if err !=nil{
119
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
120
+		return
121
+	}
122
+	this.ServeSuccessJSON(map[string]interface{}{
123
+		"offices":offices,
124
+	})
125
+}
126
+
127
+//添加名医
128
+func (this *Microwebsite) AddDoctor()  {
129
+	adminUserInfo := this.GetAdminUserInfo()
130
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
131
+	dataBody := make(map[string]interface{}, 0)
132
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
133
+	fmt.Println("错误是什么呢",err)
134
+	fmt.Println("机构ID",userOrgID)
135
+	if err != nil {
136
+		utils.ErrorLog(err.Error())
137
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
138
+		return
139
+	}
140
+
141
+	title := dataBody["title"].(string)
142
+	if len(title) == 0 {
143
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "模块标题不能为空")
144
+		return
145
+	}
146
+	fmt.Println("姓名:",title)
147
+	sort := dataBody["sort"].(string)
148
+	if len(sort) == 0 {
149
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "排序值不能为空")
150
+		return
151
+	}
152
+	sortt, err := strconv.ParseInt(sort, 10, 64)
153
+	fmt.Println("排序:",sortt)
154
+	image := dataBody["image"].(string)
155
+	if len(image) == 0 {
156
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医院介绍不能为空")
157
+		return
158
+	}
159
+	fmt.Println("姓名是什么?",title,"排序是什么",sortt,"医院介绍不能为空",image)
160
+
161
+	doctor := models.SgjPatientDoctor{
162
+		Title:  title,
163
+		Sort:   sortt,
164
+		Images: image,
165
+		UserOrgId:userOrgID,
166
+		Ctime:time.Now().Unix(),
167
+	}
168
+
169
+	err = site_service.AddDoctor(doctor)
170
+	if err !=nil{
171
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医院失败")
172
+		return
173
+	}
174
+	this.ServeSuccessJSON(map[string]interface{}{
175
+		"doctor":doctor,
176
+	})
177
+}
178
+
179
+//添加名医介绍
180
+func (this *Microwebsite) AddDoctorInfo()  {
181
+	adminUserInfo := this.GetAdminUserInfo()
182
+	userOrgID := int64(adminUserInfo.CurrentOrgId)
183
+	dataBody := make(map[string]interface{}, 0)
184
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
185
+	fmt.Println("错误是什么呢",err)
186
+	fmt.Println("机构ID",userOrgID)
187
+	if err != nil {
188
+		utils.ErrorLog(err.Error())
189
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
190
+		return
191
+	}
192
+
193
+	docname := dataBody["docname"].(string)
194
+	if len(docname) == 0 {
195
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生姓名不能为空")
196
+		return
197
+	}
198
+	fmt.Println("医生姓名:",docname)
199
+	docHead := dataBody["docHead"].(string)
200
+	if len(docHead) == 0 {
201
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生头像不能为空")
202
+		return
203
+	}
204
+	fmt.Println("医生头像:",docHead)
205
+	docpositional := dataBody["docpositional"].(string)
206
+	if len(docpositional) == 0 {
207
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生职位不能为空")
208
+		return
209
+	}
210
+	fmt.Println("医生职位",docpositional)
211
+	docintroduction := dataBody["docintroduction"].(string)
212
+	fmt.Println("医生简介",docintroduction)
213
+	if len(docintroduction) == 0 {
214
+		this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "医生简介不能为空")
215
+		return
216
+	}
217
+	fmt.Println("医生姓名",docname,"医生职位",docpositional,"医生头像",docHead,"医生简介",docintroduction)
218
+	doctor := models.SgjPatientDoctor{
219
+		Dochead:         docHead,
220
+		Docname:         docname,
221
+		Docintroduction: docintroduction,
222
+		Docpositional:   docpositional,
223
+		UserOrgId:userOrgID,
224
+		Ctime:time.Now().Unix(),
225
+	}
226
+	err = site_service.AddDoctorInfo(doctor)
227
+	if err !=nil{
228
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加医生失败")
229
+		return
230
+	}
231
+	this.ServeSuccessJSON(map[string]interface{}{
232
+		"doctor":doctor,
233
+	})
234
+}

+ 50 - 0
models/site_models.go Просмотреть файл

@@ -0,0 +1,50 @@
1
+package models
2
+
3
+//医院介绍
4
+type SgjPatientHospital 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
+	Introduction string `gorm:"column:introduction" json:"introduction" form:"introduction"`
9
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
10
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
11
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
12
+}
13
+
14
+func (SgjPatientHospital) TableName() string {
15
+	return "sgj_patient_hospital"
16
+}
17
+
18
+//科室介绍
19
+type SgjPatientOffices struct {
20
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
21
+	Title string `gorm:"column:title" json:"title" form:"title"`
22
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
23
+	Introduction string `gorm:"column:introduction" json:"introduction" form:"introduction"`
24
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
25
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
26
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
27
+}
28
+
29
+func (SgjPatientOffices)TableName() string  {
30
+	return "sgj_patient_offices"
31
+}
32
+
33
+//名医介绍
34
+type SgjPatientDoctor struct {
35
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
36
+	Title string `gorm:"column:title" json:"title" form:"title"`
37
+	Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
38
+	Images string `gorm:"column:images" json:"images" form:"images"`
39
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
40
+	Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
41
+	Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
42
+	Docname string `gorm:"column:docname" json:"docname" form:"docname"`
43
+	Dochead string `gorm:"column:dochead" json:"dochead" form:"dochead"`
44
+	Docpositional string `gorm:"column:docpositional" json:"docpositional" form:"docpositional"`
45
+	Docintroduction string `gorm:"column:docintroduction" json:"docintroduction" form:"docintroduction"`
46
+}
47
+
48
+func (SgjPatientDoctor) TableName() string {
49
+	return "sgj_patient_doctor"
50
+}

+ 2 - 0
routers/router.go Просмотреть файл

@@ -15,6 +15,7 @@ import (
15 15
 
16 16
 	"github.com/astaxie/beego"
17 17
 	"github.com/astaxie/beego/plugins/cors"
18
+	"SCRM/controllers/site"
18 19
 )
19 20
 
20 21
 func init() {
@@ -37,4 +38,5 @@ func init() {
37 38
 	sms.RegisterRouters()
38 39
 	staff.RegisterRouters()
39 40
 	kefu.RegisterRouters()
41
+	site.RegisterRouters()
40 42
 }

+ 26 - 0
service/site_service/site_microwebsite_service.go Просмотреть файл

@@ -0,0 +1,26 @@
1
+package site_service
2
+
3
+import (
4
+	"SCRM/models"
5
+	"SCRM/service"
6
+)
7
+
8
+func AddHispital(hospital models.SgjPatientHospital) error {
9
+	err := service.PatientWriteDB().Create(&hospital).Error
10
+	return  err
11
+}
12
+
13
+func AddOffices(offices models.SgjPatientOffices) error  {
14
+	err := service.PatientWriteDB().Create(&offices).Error
15
+	return  err
16
+}
17
+
18
+func AddDoctor(doctor models.SgjPatientDoctor) error {
19
+	err := service.PatientWriteDB().Create(&doctor).Error
20
+	return err
21
+}
22
+
23
+func AddDoctorInfo(doctor models.SgjPatientDoctor) error{
24
+	err := service.PatientWriteDB().Create(&doctor).Error
25
+	return  err
26
+}