Explorar el Código

修复登录不跳转最后一次登录的平台的 bug

庄逸洲 hace 5 años
padre
commit
67343ed9a7
Se han modificado 3 ficheros con 17 adiciones y 8 borrados
  1. 3 3
      conf/app.conf
  2. 7 4
      controllers/login_controller.go
  3. 7 1
      service/login_service.go

+ 3 - 3
conf/app.conf Ver fichero

@@ -1,6 +1,6 @@
1 1
 appname = 酷医
2 2
 httpport = 8091
3
-runmode = prod
3
+runmode = dev
4 4
 copyrequestbody = true
5 5
 
6 6
 is_sso_use_session_id_key = true
@@ -101,13 +101,13 @@ readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
101 101
 readmysqlport = 3306
102 102
 readmysqluser = root
103 103
 readmysqlpass = 1Q2W3e4r!@#$
104
-readmysqlname = sgj_xt
104
+readmysqlname = sgj_patient
105 105
 
106 106
 writemysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
107 107
 writemysqlport = 3306
108 108
 writemysqluser = root
109 109
 writemysqlpass = 1Q2W3e4r!@#$
110
-writemysqlname = sgj_xt
110
+writemysqlname = sgj_patient
111 111
 
112 112
 readuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
113 113
 readuserport = 3306

+ 7 - 4
controllers/login_controller.go Ver fichero

@@ -31,7 +31,7 @@ func (this *LoginController) PwdLogin() {
31 31
 	}
32 32
 
33 33
 	if url := service.GetAppURLWithAppType(appType); len(url) == 0 {
34
-		appType = 1
34
+		appType = 0
35 35
 		returnURL = ""
36 36
 	}
37 37
 	utils.TraceLog("login token: %v", token)
@@ -62,7 +62,7 @@ func (this *LoginController) CodeLogin() {
62 62
 	appType, _ := this.GetInt("app_type")
63 63
 
64 64
 	if url := service.GetAppURLWithAppType(appType); len(url) == 0 {
65
-		appType = 1
65
+		appType = 0
66 66
 		returnURL = ""
67 67
 	}
68 68
 	utils.TraceLog("login token: %v", token)
@@ -102,8 +102,10 @@ func (this *LoginController) CodeLogin() {
102 102
 func (this *LoginController) PwdLoginSubmit() {
103 103
 	appType, _ := this.GetInt("app_type")
104 104
 
105
+	utils.TraceLog("login app_type=%v", appType)
105 106
 	if url := service.GetAppURLWithAppType(appType); len(url) == 0 {
106
-		appType = 1
107
+		utils.TraceLog("login app_type not exist")
108
+		appType = 0
107 109
 	}
108 110
 	mobile := this.GetString("mobile")
109 111
 	password := this.GetString("password")
@@ -158,7 +160,7 @@ func (this *LoginController) PwdLoginSubmit() {
158 160
 func (this *LoginController) CodeLoginSubmit() {
159 161
 	appType, _ := this.GetInt("app_type")
160 162
 	if url := service.GetAppURLWithAppType(appType); len(url) == 0 {
161
-		appType = 1
163
+		appType = 0
162 164
 	}
163 165
 	mobile := this.GetString("mobile")
164 166
 	code := this.GetString("code")
@@ -261,6 +263,7 @@ func (this *LoginController) getRedirectURL(app_type int, mobile string, returnU
261 263
 			url := this.appendTokenParamToReturnURL(returnURL, token)
262 264
 			return url, nil, admin
263 265
 		}
266
+		utils.TraceLog("login redirect url: app_type=%v", app_type)
264 267
 		// 普通管理员用户
265 268
 		// 如果有登录记录,则前往最近登录记录中的应用
266 269
 		lastLoginLog, getLastLoginLogErr := service.GetAdminUserLastLoginLog(admin.Id, app_type)

+ 7 - 1
service/login_service.go Ver fichero

@@ -59,7 +59,13 @@ func DidAdminUserOrgCreateApp(adminUserID int, appType int) (bool, error) {
59 59
 
60 60
 func GetAdminUserLastLoginLog(adminUserID int, appType int) (*models.AdminUserLoginLog, error) {
61 61
 	var record models.AdminUserLoginLog
62
-	err := readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2 AND app_type = ?", adminUserID, appType).Error
62
+	var err error
63
+	if appType > 0 {
64
+		err = readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2 AND app_type = ?", adminUserID, appType).Error
65
+	} else {
66
+		err = readUserDb.Last(&record, "admin_user_id = ? AND operate_type <> 2", adminUserID).Error
67
+	}
68
+
63 69
 	if err == gorm.ErrRecordNotFound {
64 70
 		return nil, nil
65 71
 	}