Procházet zdrojové kódy

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx před 4 roky
rodič
revize
ad3a0cfd51

+ 3 - 3
conf/app.conf Zobrazit soubor

@@ -44,14 +44,14 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
44 44
 
45 45
 
46 46
 [prod]
47
-org_id = 10028
47
+org_id = 9504
48 48
 mobile_token_expiration_second = 86400
49 49
 httpdomain = https://api.xt.kuyicloud.com
50 50
 sso_domain = https://sso.kuyicloud.com
51 51
 call_domain = https://hf.sgjyun.com
52 52
 front_end_domain = "https://xt.kuyicloud.com/#"
53
-url  = "http://192.168.1.228:17001/szsi-portal/transData"
54
-#url = "http://192.168.1.88:6666/szsi-portal/transData"
53
+#url  = "http://192.168.1.228:17001/szsi-portal/transData"
54
+url = "http://192.168.1.88:6666/szsi-portal/transData"
55 55
 readmysqlhost = shengws1.mysql.rds.aliyuncs.com
56 56
 readmysqlport = 3306
57 57
 readmysqluser = syh

+ 95 - 79
controllers/base_api_controller.go Zobrazit soubor

@@ -4,7 +4,6 @@ import (
4 4
 	"gdyb/enums"
5 5
 	"gdyb/models"
6 6
 	"github.com/astaxie/beego"
7
-
8 7
 	//"XT_New/models"
9 8
 
10 9
 	//"XT_New/models"
@@ -96,83 +95,65 @@ func (this *BaseAuthAPIController) Prepare() {
96 95
 		adminUserInfo.CurrentAppId = 8642
97 96
 		adminUserInfo.AdminUser = &userAdmin
98 97
 		this.SetSession("admin_user_info", &adminUserInfo)
99
-
100 98
 	}
101 99
 
102
-	//if this.Ctx.Request.Method != "GET" {
103
-	//	adminUserInfo := this.GetAdminUserInfo()
104
-	//
105
-	//	err := service.GetOrgSubscibeState(adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId])
106
-	//	if err != nil || adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId].State == 3 {
107
-	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
108
-	//		this.StopRun()
109
-	//	}
110
-	//}
111
-
112
-	//if this.Ctx.Request.Header.Get("Permission") == "1" {
113
-	//	isPermission := false
114
-	//
115
-	//	//adminUserInfo := this.GetAdminUserInfo()
116
-	//
117
-	//	//service.GetUserAllRole(adminUserInfo.CurrentOrgId)
118
-	//
119
-	//
120
-	//
100
+	//if this.Ctx.Request.Header.Get("Permission") == "5" { //医保相关权限
101
+	//	org_id, _ := beego.AppConfig.Int64("org_id")
102
+	//	org, _ := service.GetOrgById(org_id)
103
+	//	admin_user_id, _ := this.GetInt64("admin_user_id")
104
+	//	if admin_user_id != org.Creator { //超级管理员不受此限制
105
+	//		isPermission := false
106
+	//		//该机构下该用户有多少个
107
+	//		role, _ := service.GetUserAllRole(org_id, admin_user_id)
108
+	//		var roles []string
109
+	//		if len(role.RoleIds) <= 0 { //该用户没有设置角色
121 110
 	//
122
-	//	roles := []int64{1,2}		//模拟该用户有多少角色
123
-	//	var targetRole models.RolePurview
124
-	//	var userRolePurview []string
125
-	//
126
-	//	//用户角色1对应的权限
127
-	//	role1 := models.RolePurview{PurviewIds:"11,12,13"}
128
-	//
129
-	//	//用户角色2对应的权限
130
-	//	role2 := models.RolePurview{PurviewIds:"11,15,16"}
131
-	//
132
-	//
133
-	//	//模拟角色2
134
-	//	//判断该用户有多少个角色,合并最大角色权限
135
-	//	if len(roles) == 1{ //单个
136
-	//		targetRole = role1
137
-	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
138
-	//
139
-	//	}else{ //多个
140
-	//		targetRole = role1
141
-	//		targetRole.PurviewIds = targetRole.PurviewIds + "," + role2.PurviewIds
142
-	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
143
-	//	}
144
-	//
145
-	//	userRolePurview = RemoveRepeatedElement2(userRolePurview)
111
+	//		} else {
112
+	//			roles = strings.Split(role.RoleIds, ",")
113
+	//		}
114
+	//		fmt.Println(roles)
146 115
 	//
147
-	//	fmt.Println(userRolePurview)
148
-	//	//所有权限列表
149
-	//	allPermission := []models.Purview{{Id:10,Urlfor:"/m/api/dialysis/dialysisPrescription-/api/dialysis/prescription"},
150
-	//		{Id:11,Urlfor:"/m/api/dialysis/dialysisPrescription1-/api/dialysis/prescription1"},
151
-	//		{Id:12,Urlfor:"/m/api/dialysis/dialysisPrescription2-/api/dialysis/prescription2"},
152
-	//		{Id:13,Urlfor:"/m/api/dialysis/dialysisPrescription3-/api/dialysis/prescription3"},
153
-	//		{Id:14,Urlfor:"/m/api/dialysis/dialysisPrescription4-/api/dialysis/prescription4"},
154
-	//		{Id:15,Urlfor:"/m/api/dialysis/dialysisPrescription5-/api/dialysis/prescription5"},
155
-	//		{Id:16,Urlfor:"/m/api/dialysis/dialysisPrescription6-/api/dialysis/prescription6"}}
156
-	//	for _, item := range allPermission {
157
-	//		//判断当前路由是否在权限路由列表里面
158
-	//		if strings.Split(item.Urlfor, "-")[1] == strings.Split(this.Ctx.Request.RequestURI , "?")[0]{
159
-	//			fmt.Println(strings.Split(this.Ctx.Request.RequestURI , "?")[0])
116
+	//		//获取该用户下所有角色的权限总集
117
+	//		var userRolePurviews string
118
+	//		var userRolePurviewsArr []string
119
+	//		for _, item := range roles {
120
+	//			role_id, _ := strconv.ParseInt(item, 10, 64)
121
+	//			purviews, _ := service.GetRoleFuncPurviewIds(role_id)
122
+	//			if len(userRolePurviews) == 0 {
123
+	//				userRolePurviews = purviews
124
+	//			} else {
125
+	//				userRolePurviews = userRolePurviews + "," + purviews
126
+	//			}
127
+	//		}
128
+	//		//该用户所拥有角色的权限的总集
129
+	//		userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
130
+	//		fmt.Println(userRolePurviewsArr)
131
+	//		//系统所记录的权限列表
132
+	//		allPermission, _ := service.GetAllFunctionPurview()
160 133
 	//
134
+	//		for _, item := range allPermission {
161 135
 	//			//获取该角色的所有权限
162
-	//			for _, items := range userRolePurview{
136
+	//			for _, items := range userRolePurviewsArr {
163 137
 	//				id, _ := strconv.ParseInt(items, 10, 64)
164
-	//				if id == item.Id{
138
+	//				if id == item.ID {
165 139
 	//					isPermission = true
166 140
 	//				}
167 141
 	//			}
168
-	//			if !isPermission{
169
-	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreExist)
142
+	//			if !isPermission {
143
+	//				msg, _ := service.FindErrorMsgByStr(item.ID)
144
+	//				json := make(map[string]interface{})
145
+	//				json["msg"] = msg
146
+	//				json["code"] = 0
147
+	//				json["state"] = 0
148
+	//				this.Data["json"] = json
149
+	//				this.ServeJSON()
170 150
 	//				this.StopRun()
171 151
 	//			}
172
-	//		}
173 152
 	//
153
+	//		}
174 154
 	//	}
175 155
 	//}
156
+
176 157
 }
177 158
 
178 159
 type BaseServeAPIController struct {
@@ -182,16 +163,10 @@ type BaseServeAPIController struct {
182 163
 func (this *BaseServeAPIController) Prepare() {
183 164
 	this.BaseAPIController.Prepare()
184 165
 	if this.GetAdminUserInfo() == nil {
185
-		//org_id, _ := beego.AppConfig.Int64("org_id")
186 166
 		org_id, _ := beego.AppConfig.Int64("org_id")
187
-
188
-		//org_id, _ := this.GetInt64("org_id")
189 167
 		var userAdmin models.AdminUser
190 168
 		userAdmin.Id = 1448
191 169
 		userAdmin.Mobile = "13318599895"
192
-
193
-		//userAdmin.Id = 597
194
-		//userAdmin.Mobile = "19874122664"
195 170
 		userAdmin.IsSuperAdmin = false
196 171
 		userAdmin.Status = 1
197 172
 		userAdmin.CreateTime = 1530786071
@@ -213,21 +188,62 @@ func (this *BaseServeAPIController) Prepare() {
213 188
 		this.SetSession("admin_user_info", &adminUserInfo)
214 189
 	}
215 190
 
216
-	//if adminUserInfo.AppRole != nil {
217
-	//	if adminUserInfo.AppRole.Id > 0 {
218
-	//		app_role, _ := service.FindAppRoleById(adminUserInfo.AppRole.Id)
219
-	//		if app_role != nil {
220
-	//			if app_role.Status != 1 {
221
-	//				this.DelSession("mobile_admin_user_info")
222
-	//				this.Ctx.SetCookie("token_cookie", "")
223
-	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeForbidden)
191
+	//if this.Ctx.Request.Header.Get("Permission") == "5" { //医保相关权限
192
+	//	org_id, _ := beego.AppConfig.Int64("org_id")
193
+	//	org, _ := service.GetOrgById(org_id)
194
+	//	admin_user_id, _ := this.GetInt64("admin_user_id")
195
+	//	if admin_user_id != org.Creator { //超级管理员不受此限制
196
+	//		isPermission := false
197
+	//		//该机构下该用户有多少个
198
+	//		role, _ := service.GetUserAllRole(org_id, admin_user_id)
199
+	//		var roles []string
200
+	//		if len(role.RoleIds) <= 0 { //该用户没有设置角色
201
+	//
202
+	//		} else {
203
+	//			roles = strings.Split(role.RoleIds, ",")
204
+	//		}
205
+	//		fmt.Println(roles)
206
+	//
207
+	//		//获取该用户下所有角色的权限总集
208
+	//		var userRolePurviews string
209
+	//		var userRolePurviewsArr []string
210
+	//		for _, item := range roles {
211
+	//			role_id, _ := strconv.ParseInt(item, 10, 64)
212
+	//			purviews, _ := service.GetRoleFuncPurviewIds(role_id)
213
+	//			if len(userRolePurviews) == 0 {
214
+	//				userRolePurviews = purviews
215
+	//			} else {
216
+	//				userRolePurviews = userRolePurviews + "," + purviews
217
+	//			}
218
+	//		}
219
+	//		//该用户所拥有角色的权限的总集
220
+	//		userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
221
+	//		fmt.Println(userRolePurviewsArr)
222
+	//		//系统所记录的权限列表
223
+	//		allPermission, _ := service.GetAllFunctionPurview()
224
+	//
225
+	//		for _, item := range allPermission {
226
+	//			//获取该角色的所有权限
227
+	//			for _, items := range userRolePurviewsArr {
228
+	//				id, _ := strconv.ParseInt(items, 10, 64)
229
+	//				if id == item.ID {
230
+	//					isPermission = true
231
+	//				}
232
+	//			}
233
+	//			if !isPermission {
234
+	//				msg, _ := service.FindErrorMsgByStr(item.ID)
235
+	//				json := make(map[string]interface{})
236
+	//				json["msg"] = msg
237
+	//				json["code"] = 0
238
+	//				json["state"] = 0
239
+	//				this.Data["json"] = json
240
+	//				this.ServeJSON()
224 241
 	//				this.StopRun()
225 242
 	//			}
243
+	//
226 244
 	//		}
227 245
 	//	}
228
-	//
229 246
 	//}
230
-	//fmt.Println("222222222")
231 247
 
232 248
 }
233 249
 

+ 6 - 1
models/gdyb_models.go Zobrazit soubor

@@ -9,7 +9,12 @@ type GdybPsnRecord struct {
9 9
 	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
10 10
 	Status        int64  `gorm:"column:status" json:"status" form:"status"`
11 11
 	IsCancel      int64  `gorm:"column:is_cancel" json:"is_cancel" form:"is_cancel"`
12
-	TrtDclaDetlSn string `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
12
+	TrtDclaDetlSn int64  `gorm:"column:trt_dcla_detl_sn" json:"trt_dcla_detl_sn" form:"trt_dcla_detl_sn"`
13
+	DoctorId      int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
14
+	DepartmentId  int64  `gorm:"column:department_id" json:"department_id" form:"department_id"`
15
+	Insutype      string `gorm:"column:insutype" json:"insutype" form:"insutype"`
16
+	SickType      int64  `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
17
+	OrgName       string `gorm:"column:org_name" json:"org_name" form:"org_name"`
13 18
 }
14 19
 
15 20
 func (GdybPsnRecord) TableName() string {

+ 1 - 1
service/sz_his_service.go Zobrazit soubor

@@ -762,7 +762,7 @@ func SetSZDrugMessage(doctor string, doctor_code string, fixmedins_code string)
762 762
 	inputMessage["transReturnCode"] = ""                                           //
763 763
 	inputMessage["transReturnMessage"] = ""                                        //
764 764
 	inputMessage["transTime"] = year + month + day + hour + min + sec + ":" + msec //
765
-	inputMessage["transVersion"] = "V0.3"                                          //   //
765
+	inputMessage["transVersion"] = "V0.2"                                          //   //
766 766
 	inputMessage["transChannel"] = "10"                                            //
767 767
 
768 768
 	return inputMessage

+ 44 - 0
service/user_service.go Zobrazit soubor

@@ -164,3 +164,47 @@ func GetAllHisDoctor(orgid int64) (appRole []*models.App_Role, err error) {
164 164
 	err = UserReadDB().Where("org_id = ?  AND status = 1 AND  (user_type = ? OR user_type = ?) ", orgid, 2, 1).Find(&appRole).Error
165 165
 	return appRole, err
166 166
 }
167
+
168
+func GetOrgById(orgID int64) (*models.Org, error) {
169
+	var org models.Org
170
+	err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
171
+	if err != nil {
172
+		if err == gorm.ErrRecordNotFound {
173
+			return nil, nil
174
+		} else {
175
+			return nil, err
176
+		}
177
+	}
178
+	return &org, nil
179
+}
180
+
181
+func GetUserAllRole(org_id int64, admin_user_id int64) (role models.App_Role, err error) {
182
+	err = readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
183
+	return
184
+}
185
+
186
+func GetAllFunctionPurview() (purview []models.SgjUserOperatePurview, err error) {
187
+	err = readUserDb.Model(&models.SgjUserOperatePurview{}).Where("status = 1 ").Order("number asc").Find(&purview).Error
188
+	return
189
+}
190
+
191
+func GetRoleFuncPurviewIds(roleID int64) (string, error) {
192
+	var rolePurview models.SgjUserRoleFuncPurview
193
+	err := readUserDb.Where("role_id = ?", roleID).First(&rolePurview).Error
194
+	if err != nil {
195
+		if err == gorm.ErrRecordNotFound {
196
+			return "", nil
197
+		} else {
198
+			return "", err
199
+		}
200
+	}
201
+	return rolePurview.PurviewIds, nil
202
+}
203
+
204
+func FindErrorMsgByStr(id int64) (string, error) {
205
+	var purview models.SgjUserOperatePurview
206
+	var err error
207
+	err = readUserDb.Model(&models.SgjUserOperatePurview{}).Where("id = ?", id).First(&purview).Error
208
+	return purview.ErrorMsg, err
209
+
210
+}