ソースを参照

机构功能相关接口

csx 4 年 前
コミット
9872c3742f

+ 2 - 4
conf/app.conf ファイルの表示

@@ -43,8 +43,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
43 43
 
44 44
 [prod]
45 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 48
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
50 49
 readmysqlport = 3306
@@ -82,8 +81,7 @@ redisdb = 0
82 81
 
83 82
 [dev]
84 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 86
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
89 87
 readmysqlport = 3306

+ 7 - 7
controllers/admin_api_controllers/admin_api_router_register.go ファイルの表示

@@ -6,13 +6,13 @@ import "github.com/astaxie/beego"
6 6
 func AdminAPIControllersRegisterRouters() {
7 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 16
 	beego.Router("/admin/api/home/statistics", &AnalysisAPIController{}, "get:HomeStatistics")
17 17
 	beego.Router("/admin/api/getdistrictsbyupid", &OrgAPIController{}, "get:GetDistrictsByUpid")
18 18
 	beego.Router("/admin/api/org", &OrgAPIController{}, "get:GetOrgList")

+ 7 - 11
controllers/admin_api_controllers/org_api_controller.go ファイルの表示

@@ -55,20 +55,16 @@ func (this *OrgAPIController) GetOrgList() {
55 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 61
 	} else {
70
-
62
+		this.ServeSuccessJSON(map[string]interface{}{
63
+			"list":  list,
64
+			"total": total,
65
+		})
71 66
 	}
67
+
72 68
 }
73 69
 
74 70
 func (this *OrgAPIController) GetOrgInfo() {

+ 50 - 22
controllers/admin_api_controllers/system_api_controller.go ファイルの表示

@@ -7,7 +7,7 @@ import (
7 7
 	"XT_Admin_Api/service"
8 8
 	"XT_Admin_Api/utils"
9 9
 	"encoding/json"
10
-	"github.com/jinzhu/gorm"
10
+	"fmt"
11 11
 	"reflect"
12 12
 	"time"
13 13
 )
@@ -111,6 +111,9 @@ func (this *SystemApiController) GetFollowOrg() {
111 111
 	FollowOrgs, err := service.FindFollowOrg(id)
112 112
 	unFollow, _ := service.FindUnFollowOrgByIds(id)
113 113
 
114
+	fmt.Println(FollowOrgs)
115
+	fmt.Println(unFollow)
116
+
114 117
 	if err == nil {
115 118
 		this.ServeSuccessJSON(map[string]interface{}{
116 119
 			"follows":  FollowOrgs,
@@ -281,15 +284,18 @@ func (this *SystemApiController) PostUnFollow() {
281 284
 		OrgId:       org_id,
282 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 296
 func (this *SystemApiController) ModifyFollowInfo() {
288
-	org_id, _ := this.GetInt64("org_id")
289 297
 	time := time.Now().Unix()
290
-
291 298
 	var orgFollow []*models.OrgFollow
292
-
293 299
 	dataBody := make(map[string]interface{}, 0)
294 300
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
295 301
 	if err != nil {
@@ -309,33 +315,55 @@ func (this *SystemApiController) ModifyFollowInfo() {
309 315
 					return
310 316
 				}
311 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 350
 	for index, follow := range orgFollow {
326 351
 		info, err := service.FindFollowRecordByID(follow)
327
-		if err == gorm.ErrRecordNotFound { //不存在,过滤掉该数据
352
+
353
+		if err == nil { //存在,则修改删除状态
328 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 ファイルの表示

@@ -10,7 +10,7 @@ import (
10 10
 func init() {
11 11
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
12 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 14
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
15 15
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16 16
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
@@ -19,7 +19,6 @@ func init() {
19 19
 
20 20
 	// beego.Router("/", &controllers.MainController{})
21 21
 
22
-
23 22
 	admin_api.AdminAPIControllersRegisterRouters()
24
-    function_api.FunctionAPIControllersRegisterRouters()
23
+	function_api.FunctionAPIControllersRegisterRouters()
25 24
 }

+ 9 - 4
service/admin_service.go ファイルの表示

@@ -757,8 +757,13 @@ func FindFollowOrg(admin_id int64) ([]*FollowViewModel, error) {
757 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 767
 	return
763 768
 
764 769
 }
@@ -791,8 +796,8 @@ func CreateFollowInfo(Follows []*models.OrgFollow) (err error) {
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 801
 	return
797 802
 }
798 803
 

+ 0 - 6
service/db.go ファイルの表示

@@ -96,12 +96,6 @@ func ConnectDB() {
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 99
 func XTReadDB() *gorm.DB {
106 100
 	return readDb
107 101
 }