|
@@ -81,6 +81,10 @@ func (this *OrgController) Create() {
|
81
|
81
|
// @param business_time?:string
|
82
|
82
|
// @param business_state?:int
|
83
|
83
|
// @param org_pics?:string (url1@@url2@@url3)
|
|
84
|
+// @param open_xt?:bool 是否开启血透系统
|
|
85
|
+// @param open_cdm?:bool 是否开启慢病系统
|
|
86
|
+// @param open_scrm?:bool 是否开启SCRM
|
|
87
|
+// @param open_mall?:bool 是否开启Mall
|
84
|
88
|
func (this *OrgController) CreateSubmit() {
|
85
|
89
|
adminUserObj := this.GetSession("admin_user")
|
86
|
90
|
if adminUserObj == nil {
|
|
@@ -116,7 +120,11 @@ func (this *OrgController) CreateSubmit() {
|
116
|
120
|
ill := this.GetString("ill")
|
117
|
121
|
category, _ := this.GetInt64("category")
|
118
|
122
|
contactName := this.GetString("contact_name")
|
119
|
|
- if len(name) == 0 || len(shortName) == 0 || len(contactName) == 0 || len(address) == 0 || province <= 0 || city <= 0 || district <= 0 || category <= 0 {
|
|
123
|
+ openXT, _ := this.GetBool("open_xt")
|
|
124
|
+ openCDM, _ := this.GetBool("open_cdm")
|
|
125
|
+ openSCRM, _ := this.GetBool("open_scrm")
|
|
126
|
+ openMall, _ := this.GetBool("open_mall")
|
|
127
|
+ if len(name) == 0 || len(shortName) == 0 || len(contactName) == 0 || len(address) == 0 || province <= 0 || city <= 0 || district <= 0 || category <= 0 || (!openXT && !openCDM && !openSCRM && !openMall) {
|
120
|
128
|
this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
121
|
129
|
this.ServeJSON()
|
122
|
130
|
return
|
|
@@ -163,13 +171,15 @@ func (this *OrgController) CreateSubmit() {
|
163
|
171
|
CreateTime: time.Now().Unix(),
|
164
|
172
|
ModifyTime: time.Now().Unix(),
|
165
|
173
|
}
|
166
|
|
- createErr := service.CreateOrg(&org, adminUser.Mobile) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
|
|
174
|
+
|
|
175
|
+ createErr := service.CreateOrg(&org, adminUser.Mobile, openXT, openCDM, openSCRM, openMall) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
|
167
|
176
|
if createErr != nil {
|
168
|
177
|
utils.ErrorLog("mobile=%v的超级管理员创建机构失败:%v", adminUser.Mobile, createErr)
|
169
|
178
|
this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
|
170
|
179
|
this.ServeJSON()
|
171
|
180
|
} else {
|
172
|
|
- redirectURL := beego.AppConfig.String("submodule_domain_dialysis_manage")
|
|
181
|
+ redirectURL := "" // beego.AppConfig.String("submodule_domain_dialysis_manage")
|
|
182
|
+
|
173
|
183
|
this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
|
174
|
184
|
"url": redirectURL,
|
175
|
185
|
})
|
|
@@ -233,7 +243,7 @@ func (this *OrgController) CreateApp() {
|
233
|
243
|
|
234
|
244
|
// 自动创建所有应用
|
235
|
245
|
if did_patient_manage_create == false {
|
236
|
|
- err := service.CreateOrgApp(adminUser.Id, org.Id, 1)
|
|
246
|
+ err := service.CreateOrgApp(adminUser.Id, org.Id, 1, true)
|
237
|
247
|
if err != nil {
|
238
|
248
|
utils.ErrorLog("自动创建酷医聚客应用失败:%v", err)
|
239
|
249
|
this.Abort("404")
|
|
@@ -241,7 +251,7 @@ func (this *OrgController) CreateApp() {
|
241
|
251
|
}
|
242
|
252
|
}
|
243
|
253
|
if did_dialysis_manage_create == false {
|
244
|
|
- err := service.CreateOrgApp(adminUser.Id, org.Id, 3)
|
|
254
|
+ err := service.CreateOrgApp(adminUser.Id, org.Id, 3, true)
|
245
|
255
|
if err != nil {
|
246
|
256
|
utils.ErrorLog("自动创建透析管理应用失败:%v", err)
|
247
|
257
|
this.Abort("404")
|
|
@@ -249,7 +259,7 @@ func (this *OrgController) CreateApp() {
|
249
|
259
|
}
|
250
|
260
|
}
|
251
|
261
|
if did_cdm_manage_create == false {
|
252
|
|
- err := service.CreateOrgApp(adminUser.Id, org.Id, 4)
|
|
262
|
+ err := service.CreateOrgApp(adminUser.Id, org.Id, 4, true)
|
253
|
263
|
if err != nil {
|
254
|
264
|
utils.ErrorLog("自动创建慢病管理应用失败:%v", err)
|
255
|
265
|
this.Abort("404")
|
|
@@ -257,7 +267,7 @@ func (this *OrgController) CreateApp() {
|
257
|
267
|
}
|
258
|
268
|
}
|
259
|
269
|
if did_mall_manage_create == false {
|
260
|
|
- err := service.CreateOrgApp(adminUser.Id, org.Id, 5)
|
|
270
|
+ err := service.CreateOrgApp(adminUser.Id, org.Id, 5, true)
|
261
|
271
|
if err != nil {
|
262
|
272
|
utils.ErrorLog("自动创建微商城应用失败:%v", err)
|
263
|
273
|
this.Abort("404")
|
|
@@ -303,38 +313,33 @@ func (this *OrgController) ViewApps() {
|
303
|
313
|
}
|
304
|
314
|
return
|
305
|
315
|
} else {
|
306
|
|
- this.Data["avatar"] = org.OrgLogo //"/static/images/userData.png"
|
307
|
|
- this.Data["user_name"] = org.OrgShortName //adminUser.Mobile
|
|
316
|
+ this.Data["avatar"] = org.OrgLogo
|
|
317
|
+ this.Data["user_name"] = org.OrgShortName
|
|
318
|
+ this.Data["is_super_admin"] = adminUser.IsSuperAdmin
|
|
319
|
+ this.Data["org_id"] = org.Id
|
308
|
320
|
|
309
|
|
- if adminUser.IsSuperAdmin {
|
310
|
|
- this.Data["scrm_role_exist"] = true
|
311
|
|
- this.Data["xt_role_exist"] = true
|
312
|
|
- this.Data["cdm_role_exist"] = true
|
313
|
|
- this.Data["mall_role_exist"] = true
|
314
|
|
- } else {
|
315
|
|
- apps, getAppsErr := service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
|
316
|
|
- if getAppsErr != nil {
|
317
|
|
- utils.ErrorLog("获取 id = %v,org_id = %v 的用户有权限的应用时出错:%v", adminUser.Id, org.Id, getOrgErr)
|
318
|
|
- this.Abort("404")
|
319
|
|
- return
|
|
321
|
+ apps, getAppsErr := service.GetAdminUserAllOrgApp(adminUser.Id, org.Id)
|
|
322
|
+ if getAppsErr != nil {
|
|
323
|
+ utils.ErrorLog("获取 id = %v,org_id = %v 的用户有权限的应用时出错:%v", adminUser.Id, org.Id, getOrgErr)
|
|
324
|
+ this.Abort("404")
|
|
325
|
+ return
|
|
326
|
+ }
|
|
327
|
+ this.Data["scrm_role_exist"] = false
|
|
328
|
+ this.Data["xt_role_exist"] = false
|
|
329
|
+ this.Data["cdm_role_exist"] = false
|
|
330
|
+ this.Data["mall_role_exist"] = false
|
|
331
|
+ for _, app := range apps {
|
|
332
|
+ if app.AppType == 1 && app.OpenStatus == 1 {
|
|
333
|
+ this.Data["scrm_role_exist"] = true
|
320
|
334
|
}
|
321
|
|
- this.Data["scrm_role_exist"] = false
|
322
|
|
- this.Data["xt_role_exist"] = false
|
323
|
|
- this.Data["cdm_role_exist"] = false
|
324
|
|
- this.Data["mall_role_exist"] = false
|
325
|
|
- for _, app := range apps {
|
326
|
|
- if app.AppType == 1 {
|
327
|
|
- this.Data["scrm_role_exist"] = true
|
328
|
|
- }
|
329
|
|
- if app.AppType == 3 {
|
330
|
|
- this.Data["xt_role_exist"] = true
|
331
|
|
- }
|
332
|
|
- if app.AppType == 4 {
|
333
|
|
- this.Data["cdm_role_exist"] = true
|
334
|
|
- }
|
335
|
|
- if app.AppType == 5 {
|
336
|
|
- this.Data["mall_role_exist"] = true
|
337
|
|
- }
|
|
335
|
+ if app.AppType == 3 && app.OpenStatus == 1 {
|
|
336
|
+ this.Data["xt_role_exist"] = true
|
|
337
|
+ }
|
|
338
|
+ if app.AppType == 4 && app.OpenStatus == 1 {
|
|
339
|
+ this.Data["cdm_role_exist"] = true
|
|
340
|
+ }
|
|
341
|
+ if app.AppType == 5 && app.OpenStatus == 1 {
|
|
342
|
+ this.Data["mall_role_exist"] = true
|
338
|
343
|
}
|
339
|
344
|
}
|
340
|
345
|
|
|
@@ -347,7 +352,79 @@ func (this *OrgController) ViewApps() {
|
347
|
352
|
}
|
348
|
353
|
}
|
349
|
354
|
|
350
|
|
-// /org/app/create/submit [post]
|
|
355
|
+// /app/open [post]
|
|
356
|
+// @param type:int
|
|
357
|
+func (this *OrgController) OpenAppSubmit() {
|
|
358
|
+ adminUserObj := this.GetSession("admin_user")
|
|
359
|
+ if adminUserObj == nil {
|
|
360
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeLoginTimeout)
|
|
361
|
+ this.ServeJSON()
|
|
362
|
+ return
|
|
363
|
+ }
|
|
364
|
+ adminUser := adminUserObj.(*models.AdminUser)
|
|
365
|
+ if !adminUser.IsSuperAdmin {
|
|
366
|
+ utils.ErrorLog("用户%v不是超级管理员,没有权限启用应用", adminUser.Mobile)
|
|
367
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
|
|
368
|
+ this.ServeJSON()
|
|
369
|
+ return
|
|
370
|
+ }
|
|
371
|
+
|
|
372
|
+ appType, _ := this.GetInt("type")
|
|
373
|
+ if url := service.GetAppURLWithAppType(appType); len(url) == 0 {
|
|
374
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
375
|
+ this.ServeJSON()
|
|
376
|
+ return
|
|
377
|
+ }
|
|
378
|
+
|
|
379
|
+ org, getOrgErr := service.GetOrgWithAdminUserID(adminUser.Id)
|
|
380
|
+ if getOrgErr != nil {
|
|
381
|
+ utils.ErrorLog("获取id = %v的用户创建的机构时出错:%v", adminUser.Id, getOrgErr)
|
|
382
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
383
|
+ this.ServeJSON()
|
|
384
|
+ return
|
|
385
|
+ } else {
|
|
386
|
+ if org == nil {
|
|
387
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMissingOrg)
|
|
388
|
+ this.ServeJSON()
|
|
389
|
+ return
|
|
390
|
+ } else {
|
|
391
|
+ app, getAppErr := service.GetOrgAppWithType(adminUser.Id, org.Id, appType)
|
|
392
|
+ if getAppErr != nil {
|
|
393
|
+ utils.ErrorLog("获取 id=%v 的用户的类型为%v的应用时失败:%v", adminUser.Id, appType)
|
|
394
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
395
|
+ this.ServeJSON()
|
|
396
|
+ return
|
|
397
|
+ }
|
|
398
|
+ if app == nil {
|
|
399
|
+ createAppErr := service.CreateOrgApp(adminUser.Id, org.Id, appType, true)
|
|
400
|
+ if createAppErr != nil {
|
|
401
|
+ utils.ErrorLog("id=%v的超级管理员创建类型为%v的应用时失败:%v", adminUser.Id, appType, createAppErr)
|
|
402
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
|
|
403
|
+ this.ServeJSON()
|
|
404
|
+ } else {
|
|
405
|
+ this.Data["json"] = enums.MakeSuccessResponseJSON(nil)
|
|
406
|
+ this.ServeJSON()
|
|
407
|
+ }
|
|
408
|
+ } else {
|
|
409
|
+ if app.OpenStatus != 1 {
|
|
410
|
+ app.OpenStatus = 1
|
|
411
|
+ app.ModifyTime = time.Now().Unix()
|
|
412
|
+ updateErr := service.SaveOrgApp(app)
|
|
413
|
+ if updateErr != nil {
|
|
414
|
+ utils.ErrorLog("id=%v的超级管理员开启类型为%v的应用时失败:%v", adminUser.Id, appType, updateErr)
|
|
415
|
+ this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
|
|
416
|
+ this.ServeJSON()
|
|
417
|
+ return
|
|
418
|
+ }
|
|
419
|
+ }
|
|
420
|
+ this.Data["json"] = enums.MakeSuccessResponseJSON(nil)
|
|
421
|
+ this.ServeJSON()
|
|
422
|
+ }
|
|
423
|
+ }
|
|
424
|
+ }
|
|
425
|
+}
|
|
426
|
+
|
|
427
|
+// /org/app/create/submit [post] 已废弃
|
351
|
428
|
// @param app_type:int
|
352
|
429
|
func (this *OrgController) CreateAppSubmit() {
|
353
|
430
|
adminUserObj := this.GetSession("admin_user")
|
|
@@ -400,7 +477,7 @@ func (this *OrgController) CreateAppSubmit() {
|
400
|
477
|
}
|
401
|
478
|
|
402
|
479
|
// 创建应用
|
403
|
|
- if createErr := service.CreateOrgApp(adminUser.Id, org.Id, appType); createErr != nil {
|
|
480
|
+ if createErr := service.CreateOrgApp(adminUser.Id, org.Id, appType, false); createErr != nil {
|
404
|
481
|
utils.ErrorLog("id=%v的超级管理员创建类型为%v的应用时失败:%v", adminUser.Id, appType, createErr)
|
405
|
482
|
this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
|
406
|
483
|
this.ServeJSON()
|