Browse Source

机构功能相关接口

csx 5 years ago
parent
commit
9872c3742f

+ 2 - 4
conf/app.conf View File

43
 
43
 
44
 [prod]
44
 [prod]
45
 httpdomain = http://api.szjkhd.com
45
 httpdomain = http://api.szjkhd.com
46
-sso_domain = https://sso.kuyicloud.com
47
-front_end_domain = "https://xt.kuyicloud.com/#"
46
+
48
 
47
 
49
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
48
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
50
 readmysqlport = 3306
49
 readmysqlport = 3306
82
 
81
 
83
 [dev]
82
 [dev]
84
 httpdomain = http://api.szjkhd.com
83
 httpdomain = http://api.szjkhd.com
85
-sso_domain = https://testsso.sgjyun.com
86
-front_end_domain = "http://xt.test.sgjyun.com/#"
84
+
87
 
85
 
88
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
86
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
89
 readmysqlport = 3306
87
 readmysqlport = 3306

+ 7 - 7
controllers/admin_api_controllers/admin_api_router_register.go View File

6
 func AdminAPIControllersRegisterRouters() {
6
 func AdminAPIControllersRegisterRouters() {
7
 	beego.Router("/admin/api/login/pwd", &LoginAPIController{}, "post:LoginByPwd")
7
 	beego.Router("/admin/api/login/pwd", &LoginAPIController{}, "post:LoginByPwd")
8
 
8
 
9
-	beego.Router("/admin/api/org/regist", &AnalysisAPIController{}, "get:RegistOrg")
10
-	beego.Router("/admin/api/org/active", &AnalysisAPIController{}, "get:ActiveOrg")
11
-	beego.Router("/admin/api/user/active", &AnalysisAPIController{}, "get:ActiveUser")
12
-	beego.Router("/admin/api/org/expiring", &AnalysisAPIController{}, "get:ExpiringOrg")
13
-	beego.Router("/admin/api/dialysis/analysis", &AnalysisAPIController{}, "get:DialysisAnalysis")
14
-	beego.Router("/admin/api/monitor/analysis", &AnalysisAPIController{}, "get:MonitorAnalysis")
15
-	beego.Router("/admin/api/patient/analysis", &AnalysisAPIController{}, "get:PatientAnalysis")
9
+	//beego.Router("/admin/api/org/regist", &AnalysisAPIController{}, "get:RegistOrg")
10
+	//beego.Router("/admin/api/org/active", &AnalysisAPIController{}, "get:ActiveOrg")
11
+	//beego.Router("/admin/api/user/active", &AnalysisAPIController{}, "get:ActiveUser")
12
+	//beego.Router("/admin/api/org/expiring", &AnalysisAPIController{}, "get:ExpiringOrg")
13
+	//beego.Router("/admin/api/dialysis/analysis", &AnalysisAPIController{}, "get:DialysisAnalysis")
14
+	//beego.Router("/admin/api/monitor/analysis", &AnalysisAPIController{}, "get:MonitorAnalysis")
15
+	//beego.Router("/admin/api/patient/analysis", &AnalysisAPIController{}, "get:PatientAnalysis")
16
 	beego.Router("/admin/api/home/statistics", &AnalysisAPIController{}, "get:HomeStatistics")
16
 	beego.Router("/admin/api/home/statistics", &AnalysisAPIController{}, "get:HomeStatistics")
17
 	beego.Router("/admin/api/getdistrictsbyupid", &OrgAPIController{}, "get:GetDistrictsByUpid")
17
 	beego.Router("/admin/api/getdistrictsbyupid", &OrgAPIController{}, "get:GetDistrictsByUpid")
18
 	beego.Router("/admin/api/org", &OrgAPIController{}, "get:GetOrgList")
18
 	beego.Router("/admin/api/org", &OrgAPIController{}, "get:GetOrgList")

+ 7 - 11
controllers/admin_api_controllers/org_api_controller.go View File

55
 		endTime = theTime.Unix()
55
 		endTime = theTime.Unix()
56
 	}
56
 	}
57
 
57
 
58
-	adminInfo := this.GetAdminInfo()
59
-	if adminInfo.Admin.IsSuperAdmin == 1 {
60
-		list, err, total := service.GetAllOrgList(active_status, depth_active_status, startTime, endTime, province, city, district, follow, keyword, page, limit)
61
-		if err != nil {
58
+	list, err, total := service.GetAllOrgList(active_status, depth_active_status, startTime, endTime, province, city, district, follow, keyword, page, limit)
59
+	if err != nil {
62
 
60
 
63
-		} else {
64
-			this.ServeSuccessJSON(map[string]interface{}{
65
-				"list":  list,
66
-				"total": total,
67
-			})
68
-		}
69
 	} else {
61
 	} else {
70
-
62
+		this.ServeSuccessJSON(map[string]interface{}{
63
+			"list":  list,
64
+			"total": total,
65
+		})
71
 	}
66
 	}
67
+
72
 }
68
 }
73
 
69
 
74
 func (this *OrgAPIController) GetOrgInfo() {
70
 func (this *OrgAPIController) GetOrgInfo() {

+ 50 - 22
controllers/admin_api_controllers/system_api_controller.go View File

7
 	"XT_Admin_Api/service"
7
 	"XT_Admin_Api/service"
8
 	"XT_Admin_Api/utils"
8
 	"XT_Admin_Api/utils"
9
 	"encoding/json"
9
 	"encoding/json"
10
-	"github.com/jinzhu/gorm"
10
+	"fmt"
11
 	"reflect"
11
 	"reflect"
12
 	"time"
12
 	"time"
13
 )
13
 )
111
 	FollowOrgs, err := service.FindFollowOrg(id)
111
 	FollowOrgs, err := service.FindFollowOrg(id)
112
 	unFollow, _ := service.FindUnFollowOrgByIds(id)
112
 	unFollow, _ := service.FindUnFollowOrgByIds(id)
113
 
113
 
114
+	fmt.Println(FollowOrgs)
115
+	fmt.Println(unFollow)
116
+
114
 	if err == nil {
117
 	if err == nil {
115
 		this.ServeSuccessJSON(map[string]interface{}{
118
 		this.ServeSuccessJSON(map[string]interface{}{
116
 			"follows":  FollowOrgs,
119
 			"follows":  FollowOrgs,
281
 		OrgId:       org_id,
284
 		OrgId:       org_id,
282
 		AdminUserId: info.AdminUserId,
285
 		AdminUserId: info.AdminUserId,
283
 	}
286
 	}
284
-	service.UpdateFollow(follow)
287
+	err := service.UpdateFollow(follow)
288
+	if err == nil {
289
+		this.ServeSuccessJSON(map[string]interface{}{
290
+			"msg": "删除成功",
291
+		})
292
+	}
293
+
285
 }
294
 }
286
 
295
 
287
 func (this *SystemApiController) ModifyFollowInfo() {
296
 func (this *SystemApiController) ModifyFollowInfo() {
288
-	org_id, _ := this.GetInt64("org_id")
289
 	time := time.Now().Unix()
297
 	time := time.Now().Unix()
290
-
291
 	var orgFollow []*models.OrgFollow
298
 	var orgFollow []*models.OrgFollow
292
-
293
 	dataBody := make(map[string]interface{}, 0)
299
 	dataBody := make(map[string]interface{}, 0)
294
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
300
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
295
 	if err != nil {
301
 	if err != nil {
309
 					return
315
 					return
310
 				}
316
 				}
311
 				admin_user_id := int64(items["admin_user_id"].(float64))
317
 				admin_user_id := int64(items["admin_user_id"].(float64))
312
-				follow := &models.OrgFollow{
313
-					Mtime:       time,
314
-					Status:      1,
315
-					Ctime:       time,
316
-					OrgId:       org_id,
317
-					AdminUserId: admin_user_id,
318
+
319
+				if items["org_id"] == nil || reflect.TypeOf(items["org_id"]).String() != "float64" {
320
+					utils.ErrorLog("org_id")
321
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
322
+					return
323
+				}
324
+				org_id := int64(items["org_id"].(float64))
325
+
326
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
327
+					utils.ErrorLog("id")
328
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
329
+					return
330
+				}
331
+				id := int64(items["id"].(float64))
332
+
333
+				if id == 0 {
334
+					follow := &models.OrgFollow{
335
+						Mtime:       time,
336
+						Status:      1,
337
+						Ctime:       time,
338
+						OrgId:       org_id,
339
+						AdminUserId: admin_user_id,
340
+					}
341
+					orgFollow = append(orgFollow, follow)
318
 				}
342
 				}
319
-				orgFollow = append(orgFollow, follow)
320
 			}
343
 			}
321
 		}
344
 		}
322
 	}
345
 	}
323
 
346
 
347
+	fmt.Println(orgFollow)
348
+
324
 	//防止数据冗余,先查出之前被删的数据是否存在,存在则直接改变删除状态,不插入新数据
349
 	//防止数据冗余,先查出之前被删的数据是否存在,存在则直接改变删除状态,不插入新数据
325
 	for index, follow := range orgFollow {
350
 	for index, follow := range orgFollow {
326
 		info, err := service.FindFollowRecordByID(follow)
351
 		info, err := service.FindFollowRecordByID(follow)
327
-		if err == gorm.ErrRecordNotFound { //不存在,过滤掉该数据
352
+
353
+		if err == nil { //存在,则修改删除状态
328
 			orgFollow = append(orgFollow[:index], orgFollow[index+1:]...)
354
 			orgFollow = append(orgFollow[:index], orgFollow[index+1:]...)
329
-		} else if err == nil { //存在,则修改删除状态
330
-			follow := &models.OrgFollow{
331
-				ID:          info.ID,
332
-				Mtime:       info.Mtime,
333
-				Status:      1,
334
-				Ctime:       info.Ctime,
335
-				OrgId:       info.OrgId,
336
-				AdminUserId: info.AdminUserId,
355
+			if info.Status == 0 {
356
+				follow := &models.OrgFollow{
357
+					ID:          info.ID,
358
+					Mtime:       info.Mtime,
359
+					Status:      1,
360
+					Ctime:       info.Ctime,
361
+					OrgId:       info.OrgId,
362
+					AdminUserId: info.AdminUserId,
363
+				}
364
+				service.UpdateFollow(follow)
337
 			}
365
 			}
338
-			service.UpdateFollow(follow)
366
+
339
 		}
367
 		}
340
 	}
368
 	}
341
 
369
 

+ 2 - 3
routers/router.go View File

10
 func init() {
10
 func init() {
11
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
11
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
12
 		// AllowAllOrigins:  true,
12
 		// AllowAllOrigins:  true,
13
-		AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9527", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com"},
13
+		AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9527", "http://xt.test.shengws.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://api.szjkhd.com"},
14
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
14
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
15
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
15
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
19
 
19
 
20
 	// beego.Router("/", &controllers.MainController{})
20
 	// beego.Router("/", &controllers.MainController{})
21
 
21
 
22
-
23
 	admin_api.AdminAPIControllersRegisterRouters()
22
 	admin_api.AdminAPIControllersRegisterRouters()
24
-    function_api.FunctionAPIControllersRegisterRouters()
23
+	function_api.FunctionAPIControllersRegisterRouters()
25
 }
24
 }

+ 9 - 4
service/admin_service.go View File

757
 	return vms, nil
757
 	return vms, nil
758
 }
758
 }
759
 
759
 
760
-func FindUnFollowOrgByIds(id int64) (org []*models.Org, err error) {
761
-	err = readUserDb.Raw("Select id, org_name From  sgj_user_org  Where NOT EXISTS (Select id, org_name FROM sgj_org_follow Where sgj_org_follow.org_id = sgj_user_org.id AND sgj_org_follow.admin_user_id = ? AND sgj_org_follow.status = 1)", id).Scan(&org).Error
760
+type OrgViewModel struct {
761
+	Id      int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // 机构 ID
762
+	OrgName string `gorm:"column:org_name" json:"org_name"`
763
+}
764
+
765
+func FindUnFollowOrgByIds(id int64) (orgViewModel []*OrgViewModel, err error) {
766
+	err = readUserDb.Raw("Select id, org_name From  sgj_user_org  Where NOT EXISTS (Select id, org_name FROM sgj_org_follow Where sgj_org_follow.org_id = sgj_user_org.id AND sgj_org_follow.admin_user_id = ? AND sgj_org_follow.status = 1)", id).Scan(&orgViewModel).Error
762
 	return
767
 	return
763
 
768
 
764
 }
769
 }
791
 
796
 
792
 }
797
 }
793
 
798
 
794
-func UpdateFollow(follow *models.OrgFollow) {
795
-	readUserDb.Model(&models.OrgFollow{}).Save(follow)
799
+func UpdateFollow(follow *models.OrgFollow) (err error) {
800
+	err = readUserDb.Model(&models.OrgFollow{}).Save(follow).Error
796
 	return
801
 	return
797
 }
802
 }
798
 
803
 

+ 0 - 6
service/db.go View File

96
 
96
 
97
 }
97
 }
98
 
98
 
99
-//func DisconnectDB() {
100
-//	if err := readDb.Close(); nil != err {
101
-//		beego.Error("Disconnect from database failed: " + err.Error())
102
-//	}
103
-//}
104
-
105
 func XTReadDB() *gorm.DB {
99
 func XTReadDB() *gorm.DB {
106
 	return readDb
100
 	return readDb
107
 }
101
 }