|
@@ -3,11 +3,13 @@ package login
|
3
|
3
|
import (
|
4
|
4
|
base_ctl "SCRM/controllers"
|
5
|
5
|
"SCRM/enums"
|
|
6
|
+ "SCRM/models"
|
6
|
7
|
"SCRM/service/admin_service"
|
7
|
|
- "SCRM/service/org_service"
|
8
|
8
|
"SCRM/utils"
|
9
|
9
|
"fmt"
|
10
|
10
|
"net/url"
|
|
11
|
+ "strconv"
|
|
12
|
+ "strings"
|
11
|
13
|
|
12
|
14
|
"github.com/astaxie/beego"
|
13
|
15
|
)
|
|
@@ -72,18 +74,18 @@ func (this *VerifyUserLoginAPIController) VerifyToken() {
|
72
|
74
|
ip := utils.GetIP(this.Ctx.Request)
|
73
|
75
|
sessionID := this.Ctx.GetCookie("s")
|
74
|
76
|
utils.TraceLog("cookie session id: %v %v", ip, sessionID)
|
75
|
|
- adminUserInfo, err, errCode := admin_service.VerifyToken(token, ip, sessionID)
|
|
77
|
+ adminUserInfo, err, _ := admin_service.VerifyToken(token, ip, sessionID)
|
76
|
78
|
if err != nil {
|
77
|
|
- if errCode == 903 { // 未创建应用
|
78
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNeverCreateTypeApp)
|
79
|
|
-
|
80
|
|
- } else if errCode == 904 { // 联系超管来开通
|
81
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeContactSuperAdminCreateTypeApp)
|
82
|
|
-
|
83
|
|
- } else {
|
84
|
|
- utils.ErrorLog("令牌验证失败:%v", err)
|
85
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInvalidToken)
|
86
|
|
- }
|
|
79
|
+ //if errCode == 903 { // 未创建应用
|
|
80
|
+ // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNeverCreateTypeApp)
|
|
81
|
+ //
|
|
82
|
+ //} else if errCode == 904 { // 联系超管来开通
|
|
83
|
+ // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeContactSuperAdminCreateTypeApp)
|
|
84
|
+ //
|
|
85
|
+ //} else {
|
|
86
|
+ utils.ErrorLog("令牌验证失败:%v", err)
|
|
87
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInvalidToken)
|
|
88
|
+ //}
|
87
|
89
|
return
|
88
|
90
|
|
89
|
91
|
} else {
|
|
@@ -112,41 +114,54 @@ func (this *VerifyUserLoginAPIController) VerifyToken() {
|
112
|
114
|
"district": curOrg.District,
|
113
|
115
|
"address": curOrg.Address,
|
114
|
116
|
}
|
115
|
|
- curAppUrlfors := adminUserInfo.AppUrlfors[adminUserInfo.CurrentAppId]
|
116
|
117
|
|
117
|
|
- subscibe := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
|
118
|
|
- if err := org_service.GetOrgSubscibeState(subscibe); err != nil {
|
119
|
|
- this.ErrorLog("没有机构订阅信息,数据有误")
|
120
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
121
|
|
- return
|
122
|
|
- }
|
|
118
|
+ var pruviews []*models.Purview
|
|
119
|
+ var curAppUrlfors []string
|
123
|
120
|
|
124
|
|
- orgApps := adminUserInfo.OrgApps[curOrg.Id]
|
125
|
|
- didRegistedForXT := false
|
126
|
|
- didRegistedForMall := false
|
127
|
|
- didRegistedForCDM := false
|
128
|
|
- for _, app := range orgApps {
|
129
|
|
- if app.AppType == 3 && app.OpenStatus == 1 {
|
130
|
|
- didRegistedForXT = true
|
131
|
|
- }
|
132
|
|
- if app.AppType == 4 && app.OpenStatus == 1 {
|
133
|
|
- didRegistedForCDM = true
|
|
121
|
+ if len(curAppUrlfors) == 0 {
|
|
122
|
+ if adminUser.Id == curOrg.Creator { //超级管理员
|
|
123
|
+ urlfors, _, _ := admin_service.GetSuperAdminUsersPurviewTreeAndUrlfors(6)
|
|
124
|
+ curAppUrlfors = urlfors
|
134
|
125
|
}
|
135
|
|
- if app.AppType == 5 && app.OpenStatus == 1 {
|
136
|
|
- didRegistedForMall = true
|
|
126
|
+
|
|
127
|
+ } else {
|
|
128
|
+ appRole, _ := admin_service.FindAdminUserIDA(appRole.Id)
|
|
129
|
+ if appRole.Id > 0 && len(appRole.RoleIds) > 0 {
|
|
130
|
+ role_arr := strings.Split(appRole.RoleIds, ",")
|
|
131
|
+ var ids string
|
|
132
|
+ for _, role_id := range role_arr {
|
|
133
|
+ id, _ := strconv.ParseInt(role_id, 10, 64)
|
|
134
|
+ purview_ids, _ := admin_service.GetRolePurviewIds(id)
|
|
135
|
+ if len(ids) == 0 {
|
|
136
|
+ ids = purview_ids
|
|
137
|
+ } else {
|
|
138
|
+ ids = ids + "," + purview_ids
|
|
139
|
+ }
|
|
140
|
+ }
|
|
141
|
+ if len(ids) != 0 {
|
|
142
|
+ pruviews, _ = admin_service.GetPurviewById(ids)
|
|
143
|
+ for _, item := range pruviews {
|
|
144
|
+ if item.Module == 3 && item.Parentid > 0 {
|
|
145
|
+ fmt.Println(item.Urlfor)
|
|
146
|
+ curAppUrlfors = append(curAppUrlfors, item.Urlfor)
|
|
147
|
+ }
|
|
148
|
+ }
|
|
149
|
+ } else {
|
|
150
|
+ curAppUrlfors = append(curAppUrlfors, "")
|
|
151
|
+ }
|
|
152
|
+ } else {
|
|
153
|
+ curAppUrlfors = append(curAppUrlfors, "")
|
137
|
154
|
}
|
138
|
155
|
}
|
139
|
156
|
|
|
157
|
+ subscibe, _ := admin_service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
|
140
|
158
|
this.ServeSuccessJSON(map[string]interface{}{
|
141
|
|
- "user": userInfo,
|
142
|
|
- "org": org,
|
143
|
|
- "urlfors": curAppUrlfors,
|
144
|
|
- "current_org_id": adminUserInfo.CurrentOrgId,
|
145
|
|
- "current_app_id": adminUserInfo.CurrentAppId,
|
146
|
|
- "subscibe": subscibe,
|
147
|
|
- "xt_role_exist": didRegistedForXT,
|
148
|
|
- "cdm_role_exist": didRegistedForCDM,
|
149
|
|
- "mall_role_exist": didRegistedForMall,
|
|
159
|
+ "user": userInfo,
|
|
160
|
+ "org": org,
|
|
161
|
+ "urlfors": curAppUrlfors,
|
|
162
|
+ "current_org_id": adminUserInfo.CurrentOrgId,
|
|
163
|
+ "current_app_id": adminUserInfo.CurrentAppId,
|
|
164
|
+ "subscibe": subscibe,
|
150
|
165
|
})
|
151
|
166
|
return
|
152
|
167
|
}
|