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