| | |
| | | import com.moral.api.entity.ManageLog; |
| | | import com.moral.api.mapper.ManageLogMapper; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.service.UnitConversionService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | |
| | | @Component |
| | | public class LogUtils { |
| | | |
| | | @Autowired |
| | | private ManageLogMapper manageLogMapper; |
| | | private static ManageLogMapper manageLogMapper; |
| | | |
| | | public void saveOperationForManage(String content,String type){ |
| | | @Autowired |
| | | public void setManageLogMapper(ManageLogMapper manageLogMapper){LogUtils.manageLogMapper = manageLogMapper;} |
| | | |
| | | public static void saveOperationForManage(String content,String type){ |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | saveOperationForManage(request,content,type); |
| | | } |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/8 |
| | | */ |
| | | @Transactional |
| | | public void saveOperationForManage(HttpServletRequest request, String content,String type) { |
| | | public static void saveOperationForManage(HttpServletRequest request, String content,String type) { |
| | | String token = request.getHeader("token"); |
| | | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); |
| | | ManageAccount manageAccount = accountInfoDTO.getAccount(); |
| | |
| | | String userName = manageAccount.getUserName(); |
| | | String account = manageAccount.getAccount(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | |
| | | ManageLog log = new ManageLog(); |
| | | log.setType(type); |
| | | log.setUserName(userName); |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/8 |
| | | */ |
| | | @Transactional |
| | | public void saveLoginForManage(HttpServletRequest request,String content,ManageAccount account,String userName){ |
| | | public static void saveLoginForManage(HttpServletRequest request,String content,ManageAccount account,String userName){ |
| | | ManageLog log = new ManageLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | log.setAccountId(account.getId()); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 存储token解析失败的日志 |
| | | * @Param: [request, content] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/10/8 |
| | | */ |
| | | public static void saveFailedRequestForManage(HttpServletRequest request,String content){ |
| | | ManageLog log = new ManageLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | log.setAccountId(0); |
| | | log.setAccount("null"); |
| | | log.setUserName("null"); |
| | | log.setIp(ip); |
| | | log.setContent(content); |
| | | log.setType(Constants.LOGIN_OPERTATE_TYPE); |
| | | manageLogMapper.insert(log); |
| | | } |
| | | |
| | | |
| | | } |