|
|
@@ -30,10 +30,10 @@ func NewLoginLogService(ctx context.Context) (svc *LoginLogService, err error) {
|
|
|
return svc, nil
|
|
|
}
|
|
|
|
|
|
-func (s *LoginLogService) Invoke(ctx context.Context, userName, msg string) {
|
|
|
+func (s *LoginLogService) Invoke(ctx context.Context, userName string, err error) {
|
|
|
s.Pool.Add(func() {
|
|
|
//写入日志数据
|
|
|
- s.Create(ctx, userName, msg)
|
|
|
+ s.Create(ctx, userName, err)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -81,7 +81,7 @@ func (s *LoginLogService) GetList(req *model.SysLoginLogSearchReq) (total int, l
|
|
|
}
|
|
|
|
|
|
// Create 记录登录日志
|
|
|
-func (s *LoginLogService) Create(ctx context.Context, userName, msg string) {
|
|
|
+func (s *LoginLogService) Create(ctx context.Context, userName string, loginErr error) {
|
|
|
clientIP, userAgent, err := micro_srv.GetBrowserInfo(ctx)
|
|
|
if err != nil {
|
|
|
// 非必要信息,只输出错误日志
|
|
|
@@ -90,10 +90,10 @@ func (s *LoginLogService) Create(ctx context.Context, userName, msg string) {
|
|
|
ua := user_agent.New(userAgent)
|
|
|
browser, _ := ua.Browser()
|
|
|
status := "10"
|
|
|
- if msg != "操作成功" {
|
|
|
+ msg := "登录成功"
|
|
|
+ if loginErr != nil {
|
|
|
status = "20"
|
|
|
- } else {
|
|
|
- msg = "登录成功"
|
|
|
+ msg = err.Error()
|
|
|
}
|
|
|
loginData := &model.SysLogin{
|
|
|
UserName: userName,
|