|
@@ -1,36 +1,42 @@
|
|
|
package cn.hnthyy.thmz.controller;
|
|
|
|
|
|
-import cn.hnthyy.thmz.Utils.*;
|
|
|
+import cn.hnthyy.thmz.Utils.DateUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.HttpUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.JsonUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.TokenUtil;
|
|
|
import cn.hnthyy.thmz.comment.UserLoginToken;
|
|
|
import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.Employee;
|
|
|
+import cn.hnthyy.thmz.entity.his.mz.MzLoginLog;
|
|
|
import cn.hnthyy.thmz.entity.thmz.EvaluateInfo;
|
|
|
-import cn.hnthyy.thmz.entity.thmz.LoginErr;
|
|
|
import cn.hnthyy.thmz.entity.thmz.User;
|
|
|
import cn.hnthyy.thmz.entity.thmz.UserControls;
|
|
|
import cn.hnthyy.thmz.entity.thmz.Windows;
|
|
|
import cn.hnthyy.thmz.enums.WorkingStatusEnum;
|
|
|
import cn.hnthyy.thmz.enums.YesNoEnum;
|
|
|
+import cn.hnthyy.thmz.mapper.his.mz.MzLoginLogMapper;
|
|
|
import cn.hnthyy.thmz.service.his.mz.EmployeeService;
|
|
|
import cn.hnthyy.thmz.service.his.zd.DictDataService;
|
|
|
import cn.hnthyy.thmz.service.thmz.EvaluationService;
|
|
|
-import cn.hnthyy.thmz.service.thmz.LoginErrService;
|
|
|
import cn.hnthyy.thmz.service.thmz.TokenService;
|
|
|
import cn.hnthyy.thmz.service.thmz.TsmzService;
|
|
|
import cn.hnthyy.thmz.service.thmz.UserService;
|
|
|
import cn.hnthyy.thmz.service.thmz.WindowsService;
|
|
|
-import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
-import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@Slf4j
|
|
@@ -53,6 +59,8 @@ public class LoginController {
|
|
|
private DictDataService dictDataService;
|
|
|
@Resource
|
|
|
private TsmzService tsmzService;
|
|
|
+ @Resource
|
|
|
+ private MzLoginLogMapper mzLoginLogMapper;
|
|
|
/**登录错误次数 锁定账户临界值*/
|
|
|
//private static final int LOGIN__ERR_COUNT = 10000;
|
|
|
//private static final int LOGIN__ERR_COUNT_TIME = 1;
|
|
@@ -175,6 +183,7 @@ public class LoginController {
|
|
|
.clientIp(HttpUtil.getIPAddress(request)).build());
|
|
|
Date deadTime = DateUtil.getDate(Constants.JWT_TTL);
|
|
|
String token =TokenUtil.createJWT(JsonUtil.object2Json(user),deadTime);
|
|
|
+ saveLoginLog(user);
|
|
|
resultMap.put("code", 0);
|
|
|
resultMap.put("token", token);
|
|
|
resultMap.put("userID", userParam.getUserCode());
|
|
@@ -185,7 +194,17 @@ public class LoginController {
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private void saveLoginLog(User user) {
|
|
|
+ try {
|
|
|
+ MzLoginLog loginLog = new MzLoginLog();
|
|
|
+ loginLog.setUserCode(user.getUserIdCode());
|
|
|
+ loginLog.setUserName(user.getUserName());
|
|
|
+ loginLog.setLoginTime(new Date());
|
|
|
+ mzLoginLogMapper.insert(loginLog);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("保存登录日志记录错误:{}",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|