Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
elearn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hqzhdj
elearn
Commits
63ab8ecc
Commit
63ab8ecc
authored
Jan 17, 2025
by
阳浪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
埋点优化
parent
1969c9ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
cloud-system/src/main/java/com/yizhi/system/application/controller/api/AuthController.java
+11
-9
No files found.
cloud-system/src/main/java/com/yizhi/system/application/controller/api/AuthController.java
View file @
63ab8ecc
...
@@ -61,6 +61,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -61,6 +61,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
...
@@ -260,7 +261,7 @@ public class AuthController {
...
@@ -260,7 +261,7 @@ public class AuthController {
@Extension
(
name
=
ReturnCode
.
API_SUB_FLAG
,
properties
=
{
@Extension
(
name
=
ReturnCode
.
API_SUB_FLAG
,
properties
=
{
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
login
(
HttpServletResponse
httpResponse
,
public
Response
<
String
>
login
(
HttpServletRe
quest
request
,
HttpServletRe
sponse
httpResponse
,
@ApiParam
(
required
=
true
,
value
=
"用户账号"
)
@RequestParam
(
required
=
true
)
String
account
,
@ApiParam
(
required
=
true
,
value
=
"用户账号"
)
@RequestParam
(
required
=
true
)
String
account
,
@ApiParam
(
required
=
true
,
value
=
"用户密码"
)
@RequestParam
(
required
=
true
)
String
password
,
@ApiParam
(
required
=
true
,
value
=
"用户密码"
)
@RequestParam
(
required
=
true
)
String
password
,
@ApiParam
(
required
=
true
,
value
=
"是否需要做首次登陆"
)
@RequestParam
(
required
=
true
,
defaultValue
=
"false"
)
Boolean
firstLoginFlg
,
@ApiParam
(
required
=
true
,
value
=
"是否需要做首次登陆"
)
@RequestParam
(
required
=
true
,
defaultValue
=
"false"
)
Boolean
firstLoginFlg
,
...
@@ -319,6 +320,7 @@ public class AuthController {
...
@@ -319,6 +320,7 @@ public class AuthController {
pointListenerClients
.
addPoint
(
"point_login"
,
Long
.
valueOf
(
shortDay
));
pointListenerClients
.
addPoint
(
"point_login"
,
Long
.
valueOf
(
shortDay
));
// 添加登录埋点
// 添加登录埋点
eventTrackApiClients
.
addEvent
(
"event_login"
,
context
.
getAccountId
());
eventTrackApiClients
.
addEvent
(
"event_login"
,
context
.
getAccountId
());
redisCache
.
set
(
request
.
getSession
().
getId
(),
terminalType
,
86400
);
}
}
ContextHolder
.
set
(
context
);
ContextHolder
.
set
(
context
);
logger
.
info
(
"登陆处理结束"
);
logger
.
info
(
"登陆处理结束"
);
...
@@ -441,7 +443,7 @@ public class AuthController {
...
@@ -441,7 +443,7 @@ public class AuthController {
@Extension
(
name
=
ReturnCode
.
API_SUB_FLAG
,
properties
=
{
@Extension
(
name
=
ReturnCode
.
API_SUB_FLAG
,
properties
=
{
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@RequestMapping
(
value
=
"/loginApp"
,
produces
=
{
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/loginApp"
,
produces
=
{
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
loginApp
(
HttpServletResponse
httpResponse
,
public
Response
<
String
>
loginApp
(
HttpServletRe
quest
request
,
HttpServletRe
sponse
httpResponse
,
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
LoginInfoVO
user
,
BindingResult
validResults
)
{
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
LoginInfoVO
user
,
BindingResult
validResults
)
{
if
(
validResults
.
hasFieldErrors
())
{
if
(
validResults
.
hasFieldErrors
())
{
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
...
@@ -469,7 +471,7 @@ public class AuthController {
...
@@ -469,7 +471,7 @@ public class AuthController {
return
Response
.
fail
(
Constants
.
SYSTEM_MSG_ACCOUNT_PWD_ERROR
.
getName
());
return
Response
.
fail
(
Constants
.
SYSTEM_MSG_ACCOUNT_PWD_ERROR
.
getName
());
}
}
}
}
Response
<
String
>
ret
=
login
(
httpResponse
,
accountName
,
passWord
,
false
,
user
.
getLanguageCode
(),
APP
);
Response
<
String
>
ret
=
login
(
request
,
httpResponse
,
accountName
,
passWord
,
false
,
user
.
getLanguageCode
(),
APP
);
RequestContext
context
=
ContextHolder
.
get
();
RequestContext
context
=
ContextHolder
.
get
();
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
logger
.
info
(
"手机APP端用户登录上下文="
+
JSON
.
toJSONString
(
ContextHolder
.
get
()));
logger
.
info
(
"手机APP端用户登录上下文="
+
JSON
.
toJSONString
(
ContextHolder
.
get
()));
...
@@ -491,7 +493,7 @@ public class AuthController {
...
@@ -491,7 +493,7 @@ public class AuthController {
@Extension
(
name
=
ReturnCode
.
API_SUB_FLAG
,
properties
=
{
@Extension
(
name
=
ReturnCode
.
API_SUB_FLAG
,
properties
=
{
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@RequestMapping
(
value
=
"/loginPc"
,
produces
=
{
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/loginPc"
,
produces
=
{
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
loginPc
(
HttpServletResponse
httpResponse
,
public
Response
<
String
>
loginPc
(
HttpServletRe
quest
request
,
HttpServletRe
sponse
httpResponse
,
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
LoginInfoVO
user
,
BindingResult
validResults
)
{
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
LoginInfoVO
user
,
BindingResult
validResults
)
{
if
(
validResults
.
hasFieldErrors
())
{
if
(
validResults
.
hasFieldErrors
())
{
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
...
@@ -515,7 +517,7 @@ public class AuthController {
...
@@ -515,7 +517,7 @@ public class AuthController {
if
(
null
==
accountName
)
{
if
(
null
==
accountName
)
{
return
Response
.
fail
(
Constants
.
SYSTEM_MSG_ACCOUNT_PWD_ERROR
.
getName
());
return
Response
.
fail
(
Constants
.
SYSTEM_MSG_ACCOUNT_PWD_ERROR
.
getName
());
}
}
Response
<
String
>
ret
=
login
(
httpResponse
,
accountName
,
passWord
,
true
,
user
.
getLanguageCode
(),
PC
);
Response
<
String
>
ret
=
login
(
request
,
httpResponse
,
accountName
,
passWord
,
true
,
user
.
getLanguageCode
(),
PC
);
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
RequestContext
rc
=
ContextHolder
.
get
();
RequestContext
rc
=
ContextHolder
.
get
();
logger
.
info
(
"学员pc端用户登录上下文="
+
JSON
.
toJSONString
(
rc
));
logger
.
info
(
"学员pc端用户登录上下文="
+
JSON
.
toJSONString
(
rc
));
...
@@ -536,7 +538,7 @@ public class AuthController {
...
@@ -536,7 +538,7 @@ public class AuthController {
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@ExtensionProperty
(
name
=
SecurityError
.
LOGIN_INFO_ERROR
,
value
=
SecurityError
.
LOGIN_INFO_ERROR_MSG
)})})
@RequestMapping
(
value
=
"/loginManage"
,
produces
=
{
@RequestMapping
(
value
=
"/loginManage"
,
produces
=
{
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
loginManage
(
HttpServletResponse
httpResponse
,
public
Response
<
String
>
loginManage
(
HttpServletRe
quest
request
,
HttpServletRe
sponse
httpResponse
,
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
LoginInfoVO
user
,
BindingResult
validResults
)
{
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
LoginInfoVO
user
,
BindingResult
validResults
)
{
if
(
validResults
.
hasFieldErrors
())
{
if
(
validResults
.
hasFieldErrors
())
{
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
...
@@ -560,7 +562,7 @@ public class AuthController {
...
@@ -560,7 +562,7 @@ public class AuthController {
if
(
null
==
accountName
)
{
if
(
null
==
accountName
)
{
return
Response
.
fail
(
"4000"
,
InternationalEnums
.
AUTHCONTROLLER2
.
getCode
(),
""
);
return
Response
.
fail
(
"4000"
,
InternationalEnums
.
AUTHCONTROLLER2
.
getCode
(),
""
);
}
}
Response
<
String
>
ret
=
login
(
httpResponse
,
accountName
,
passWord
,
false
,
user
.
getLanguageCode
(),
MANAGE
);
Response
<
String
>
ret
=
login
(
request
,
httpResponse
,
accountName
,
passWord
,
false
,
user
.
getLanguageCode
(),
MANAGE
);
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
logger
.
info
(
"管理登陆上下文="
+
JSON
.
toJSONString
(
ContextHolder
.
get
()));
logger
.
info
(
"管理登陆上下文="
+
JSON
.
toJSONString
(
ContextHolder
.
get
()));
...
@@ -595,14 +597,14 @@ public class AuthController {
...
@@ -595,14 +597,14 @@ public class AuthController {
@RequestMapping
(
value
=
"/loginWeChat"
,
produces
=
{
@RequestMapping
(
value
=
"/loginWeChat"
,
produces
=
{
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
"application/json;charset=utf-8"
},
method
=
RequestMethod
.
POST
)
public
Response
<
String
>
loginWechat
(
HttpServletResponse
httpResponse
,
public
Response
<
String
>
loginWechat
(
HttpServletRe
quest
request
,
HttpServletRe
sponse
httpResponse
,
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
WechatLoginInfoVO
user
,
BindingResult
validResults
)
{
@ApiParam
(
name
=
"user"
)
@RequestBody
@Valid
WechatLoginInfoVO
user
,
BindingResult
validResults
)
{
if
(
validResults
.
hasFieldErrors
())
{
if
(
validResults
.
hasFieldErrors
())
{
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
String
error
=
ValidUtil
.
convertParamError
(
validResults
.
getFieldErrors
());
logger
.
warn
(
"参数校验错误:{}"
+
error
);
logger
.
warn
(
"参数校验错误:{}"
+
error
);
return
Response
.
fail
(
Constants
.
MSG_REQUEST_ERROR
.
getName
());
return
Response
.
fail
(
Constants
.
MSG_REQUEST_ERROR
.
getName
());
}
}
Response
<
String
>
ret
=
login
(
httpResponse
,
user
.
getAccount
(),
user
.
getPassword
(),
false
,
user
.
getLanguageCode
(),
WECHAT
);
Response
<
String
>
ret
=
login
(
request
,
httpResponse
,
user
.
getAccount
(),
user
.
getPassword
(),
false
,
user
.
getLanguageCode
(),
WECHAT
);
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
if
(
ReturnCode
.
SUCCESS
.
getCode
().
equals
(
ret
.
getCode
()))
{
RequestContext
rc
=
ContextHolder
.
get
();
RequestContext
rc
=
ContextHolder
.
get
();
logger
.
info
(
"微信登陆上下文="
+
JSON
.
toJSONString
(
rc
));
logger
.
info
(
"微信登陆上下文="
+
JSON
.
toJSONString
(
rc
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment