From 186eec8101b185a6b865fc8943a9a30cf0f53c10 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Sun, 7 Apr 2024 09:32:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bweb/controller/SecMenuController.java | 8 +- .../bweb/controller/SecUserController.java | 26 + .../com/hfkj/common/utils/AliyunService.java | 56 + .../com/hfkj/common/utils/HttpsUtils.java | 430 +----- .../com/hfkj/common/utils/RequestUtils.java | 39 +- .../com/hfkj/dao/SecUserLoginLogMapper.java | 139 ++ .../hfkj/dao/SecUserLoginLogMapperExt.java | 7 + .../hfkj/dao/SecUserLoginLogSqlProvider.java | 388 +++++ .../java/com/hfkj/entity/SecUserLoginLog.java | 296 ++++ .../hfkj/entity/SecUserLoginLogExample.java | 1303 +++++++++++++++++ .../hfkj/service/SecUserLoginLogService.java | 37 + .../impl/SecUserLoginLogServiceImpl.java | 98 ++ .../hfkj/service/impl/SecUserServiceImpl.java | 23 +- .../sysenum/SecUserLoginLogStatusEnum.java | 46 + 14 files changed, 2460 insertions(+), 436 deletions(-) create mode 100644 service/src/main/java/com/hfkj/common/utils/AliyunService.java create mode 100644 service/src/main/java/com/hfkj/dao/SecUserLoginLogMapper.java create mode 100644 service/src/main/java/com/hfkj/dao/SecUserLoginLogMapperExt.java create mode 100644 service/src/main/java/com/hfkj/dao/SecUserLoginLogSqlProvider.java create mode 100644 service/src/main/java/com/hfkj/entity/SecUserLoginLog.java create mode 100644 service/src/main/java/com/hfkj/entity/SecUserLoginLogExample.java create mode 100644 service/src/main/java/com/hfkj/service/SecUserLoginLogService.java create mode 100644 service/src/main/java/com/hfkj/service/impl/SecUserLoginLogServiceImpl.java create mode 100644 service/src/main/java/com/hfkj/sysenum/SecUserLoginLogStatusEnum.java diff --git a/bweb/src/main/java/com/bweb/controller/SecMenuController.java b/bweb/src/main/java/com/bweb/controller/SecMenuController.java index 6ce402c..4312a82 100644 --- a/bweb/src/main/java/com/bweb/controller/SecMenuController.java +++ b/bweb/src/main/java/com/bweb/controller/SecMenuController.java @@ -6,6 +6,8 @@ import com.github.pagehelper.PageInfo; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.HttpUtils; +import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.SecMenu; import com.hfkj.entity.SecRoleMenuRel; @@ -17,6 +19,8 @@ import com.hfkj.sysenum.SecMenuTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -216,8 +220,4 @@ public class SecMenuController { } return treeModelList; } - - - - } diff --git a/bweb/src/main/java/com/bweb/controller/SecUserController.java b/bweb/src/main/java/com/bweb/controller/SecUserController.java index 0c511b3..f2ad6f3 100644 --- a/bweb/src/main/java/com/bweb/controller/SecUserController.java +++ b/bweb/src/main/java/com/bweb/controller/SecUserController.java @@ -10,6 +10,7 @@ import com.hfkj.common.utils.MD5Util; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.SecUser; import com.hfkj.model.ResponseData; +import com.hfkj.service.SecUserLoginLogService; import com.hfkj.service.SecUserService; import com.hfkj.sysenum.SecUserStatusEnum; import io.swagger.annotations.Api; @@ -33,6 +34,8 @@ public class SecUserController { @Resource private SecUserService secUserService; + @Resource + private SecUserLoginLogService secUserLoginLogService; @RequestMapping(value="/create",method = RequestMethod.POST) @ResponseBody @@ -218,4 +221,27 @@ public class SecUserController { } + @RequestMapping(value="/queryList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询登录日志列表") + public ResponseData queryLoginLogList(@RequestParam(value = "userId", required = true) String userId, + @RequestParam(value = "status", required = false) Integer status, + @RequestParam(value = "pageNum", required = true) Integer pageNum, + @RequestParam(value = "pageSize", required = true) Integer pageSize) { + try { + + Map param = new HashMap<>(); + param.put("userId", userId); + param.put("status", status); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(secUserLoginLogService.getLogList(param)); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/service/src/main/java/com/hfkj/common/utils/AliyunService.java b/service/src/main/java/com/hfkj/common/utils/AliyunService.java new file mode 100644 index 0000000..2ced96b --- /dev/null +++ b/service/src/main/java/com/hfkj/common/utils/AliyunService.java @@ -0,0 +1,56 @@ +package com.hfkj.common.utils; + +import com.alibaba.fastjson.JSONObject; +import org.apache.http.HttpResponse; +import org.apache.http.util.EntityUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * 阿里云业务服务 + * @className: AliyunService + * @author: HuRui + * @date: 2024/4/3 + **/ +public class AliyunService { + + /** + * 查询ip地址 + * @param ip ip地址 + * @return + */ + public static JSONObject queryAddress(String ip) { + try { + String host = "https://ipaddquery.market.alicloudapi.com"; + String path = "/ip/address-query"; + String method = "POST"; + String appcode = "f9ace4c915054ca697a76fb9a4e1e8c0"; + + Map headers = new HashMap<>(); + headers.put("Authorization", "APPCODE " + appcode); + headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); + + Map bodys = new HashMap<>(); + bodys.put("ip", ip); + + HttpResponse response = HttpUtils.doPost(host, path, method, headers, new HashMap<>(), bodys); + JSONObject resObj = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); + if (resObj.getString("code").equals("200")) { + return resObj.getJSONObject("data"); + } + return null; + + } catch (Exception e) { + return null; + } + } + + public static void main(String[] args) { + try { + System.out.println(queryAddress("123.147.76.209")); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java index 41315bf..e8ff847 100644 --- a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java +++ b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java @@ -203,44 +203,6 @@ public class HttpsUtils { return null; } - public static JSONObject doWxGet(String url, Map params) { - String apiUrl = url; - StringBuffer param = new StringBuffer(); - int i = 0; - for (String key : params.keySet()) { - if (i == 0) - param.append("?"); - else - param.append("&"); - param.append(key).append("=").append(params.get(key)); - i++; - } - apiUrl += param + "#wechat_redirect"; - String result = null; - HttpClient httpClient = null; - try { - - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - - HttpGet httpGet = new HttpGet(apiUrl); - HttpResponse response = httpClient.execute(httpGet); - HttpEntity entity = response.getEntity(); - if (entity != null) { - InputStream instream = entity.getContent(); - result = IOUtils.toString(instream, "UTF-8"); - } - return JSON.parseObject(result); - } catch (Exception e) { - log.error(e.getMessage(),e); - } - return null; - } - /** * 发送 POST 请求(HTTP),不带输入数据 * @@ -297,54 +259,6 @@ public class HttpsUtils { return null; } - - /** - * 发送 POST 请求,K-V形式 - * - * @param apiUrl - * API接口URL - * @param params - * 参数map - * @return - */ - public static JSONObject doPostSendSms(String apiUrl, Map params) { - CloseableHttpClient httpClient = null; - - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - List pairList = new ArrayList<>(params.size()); - for (Map.Entry entry : params.entrySet()) { - NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue().toString()); - pairList.add(pair); - } - httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("UTF-8"))); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - /** * 发送 POST 请求,JSON形式 * @@ -389,80 +303,6 @@ public class HttpsUtils { return null; } - public static JSONObject doHuiLianTongPost(String apiUrl) { - CloseableHttpClient httpClient = null; - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - StringEntity stringEntity = new StringEntity("", "UTF-8");// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - stringEntity.setContentType("application/x-www-form-urlencoded"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - - public static JSONObject doWxPost(String apiUrl, Map body, Map header) { - CloseableHttpClient httpClient = null; - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - for (Map.Entry entry : header.entrySet()) { - httpPost.setHeader(entry.getKey(), entry.getValue().toString()); - } - StringEntity stringEntity = new StringEntity(JSON.toJSONString(body), "UTF-8");// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - stringEntity.setContentType("application/json"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - public static JSONObject doPost(String apiUrl, Map body, Map header) { CloseableHttpClient httpClient = null; if (apiUrl.startsWith("https")) { @@ -502,123 +342,6 @@ public class HttpsUtils { return null; } - public static JSONObject doPostForm(String apiUrl, String body, Map header) { - CloseableHttpClient httpClient = null; - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - for (Map.Entry entry : header.entrySet()) { - httpPost.setHeader(entry.getKey(), entry.getValue().toString()); - } - StringEntity stringEntity = new StringEntity(body,"UTF-8");// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - stringEntity.setContentType("application/x-www-form-urlencoded"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - - public static JSONObject doSmsPost(String apiUrl, Map body, Map header) { - CloseableHttpClient httpClient = null; - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - for (Map.Entry entry : header.entrySet()) { - httpPost.setHeader(entry.getKey(), entry.getValue().toString()); - } - StringEntity stringEntity = new StringEntity(body.get("from").toString());// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - stringEntity.setContentType("application/x-www-form-urlencoded"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - - public static JSONObject doWxH5PayPost(String apiUrl, Map body, Map header) { - CloseableHttpClient httpClient = null; - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - for (Map.Entry entry : header.entrySet()) { - httpPost.setHeader(entry.getKey(), entry.getValue().toString()); - } - StringEntity stringEntity = new StringEntity(body.get("from").toString());// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - stringEntity.setContentType("application/x-www-form-urlencoded"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - /** * 发送 POST 请求,JSON形式 * @@ -661,167 +384,22 @@ public class HttpsUtils { return null; } - public static JSONObject doPost(String apiUrl, String str, String token, String sign, Long ts) { - CloseableHttpClient httpClient = null; - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(apiUrl); - httpPost.setConfig(requestConfig); - httpPost.setHeader("token", token); - httpPost.setHeader("sign", sign); - httpPost.setHeader("ts", ts.toString()); - StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - stringEntity.setContentType("application/json"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - - /** - * @Author Sum1Dream - * @Description // 不带证书请求xml - * @Date 11:42 2021/6/8 - * @Param [url, str] - * @return com.alibaba.fastjson.JSONObject - **/ - public static JSONObject postData(String url, String str) { - CloseableHttpClient httpClient = null; - if (url.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(url); - httpPost.setConfig(requestConfig); - - StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - httpPost.addHeader("Content-Type", "text/xml"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - - /** - * @Author Sum1Dream - * @Description // 带证书请求 xml - * @Date 11:45 2021/6/8 - * @Param [url, mchId, str] - * @return com.alibaba.fastjson.JSONObject - **/ - public static JSONObject postData(String url, String mchId , String str) { - CloseableHttpClient httpClient = null; - if (url.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(readCertificate(mchId)) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - String httpStr = null; - CloseableHttpResponse response = null; - - try { - HttpPost httpPost = new HttpPost(url); - httpPost.setConfig(requestConfig); - - StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题 - stringEntity.setContentEncoding("UTF-8"); - httpPost.addHeader("Content-Type", "text/xml"); - httpPost.setEntity(stringEntity); - response = httpClient.execute(httpPost); - HttpEntity entity = response.getEntity(); - httpStr = EntityUtils.toString(entity, "UTF-8"); - return JSON.parseObject(httpStr); - } catch (Exception e) { - log.error(e.getMessage(),e); - } finally { - if (response != null) { - try { - EntityUtils.consume(response.getEntity()); - } catch (IOException e) { - log.error(e.getMessage(),e); - } - } - } - return null; - } - - public static SSLConnectionSocketFactory readCertificate(String mchId) { - try { - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - FileInputStream stream = new FileInputStream( "F:/mine/hai-server/hai-service/src/main/java/privatekey/apiclient_cert.p12"); - keyStore.load(stream , mchId.toCharArray()); - stream.close(); - SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, mchId.toCharArray()).build(); - return new SSLConnectionSocketFactory( - sslcontext, - new String[]{"TLSv1"}, - null, - SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); - } catch (Exception e) { - System.out.println("证书双向认证出现异常" + e); - } - return null; - } - /** * 创建SSL安全连接 - * + * * @return */ private static SSLConnectionSocketFactory createSSLConnSocketFactory() { SSLConnectionSocketFactory sslsf = null; try { SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { - + public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }).build(); sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() { - + @Override public boolean verify(String arg0, SSLSession arg1) { return true; @@ -832,5 +410,5 @@ public class HttpsUtils { } return sslsf; } - + } diff --git a/service/src/main/java/com/hfkj/common/utils/RequestUtils.java b/service/src/main/java/com/hfkj/common/utils/RequestUtils.java index 2454d4e..21f6ff1 100644 --- a/service/src/main/java/com/hfkj/common/utils/RequestUtils.java +++ b/service/src/main/java/com/hfkj/common/utils/RequestUtils.java @@ -1,10 +1,12 @@ package com.hfkj.common.utils; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; + import javax.servlet.http.HttpServletRequest; public class RequestUtils { public static String getIpAddress(HttpServletRequest request) { - // 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址 String ip = request.getHeader("X-Forwarded-For"); if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { @@ -35,4 +37,39 @@ public class RequestUtils { return ip; } + + /** + * 获取请求的ip + */ + public static String getRequestIp() { + + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + + if (requestAttributes == null) { + return null; + } + + // 从获取RequestAttributes中获取HttpServletRequest的信息 + HttpServletRequest request = (HttpServletRequest) requestAttributes.resolveReference(RequestAttributes.REFERENCE_REQUEST); + + String ip = request.getHeader("x-forwarded-for"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + + return ip; + } + } diff --git a/service/src/main/java/com/hfkj/dao/SecUserLoginLogMapper.java b/service/src/main/java/com/hfkj/dao/SecUserLoginLogMapper.java new file mode 100644 index 0000000..df64147 --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/SecUserLoginLogMapper.java @@ -0,0 +1,139 @@ +package com.hfkj.dao; + +import com.hfkj.entity.SecUserLoginLog; +import com.hfkj.entity.SecUserLoginLogExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface SecUserLoginLogMapper extends SecUserLoginLogMapperExt { + @SelectProvider(type=SecUserLoginLogSqlProvider.class, method="countByExample") + long countByExample(SecUserLoginLogExample example); + + @DeleteProvider(type=SecUserLoginLogSqlProvider.class, method="deleteByExample") + int deleteByExample(SecUserLoginLogExample example); + + @Delete({ + "delete from sec_user_login_log", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into sec_user_login_log (user_id, user_login_name, ", + "ip, country, region_id, ", + "region_name, city_id, ", + "city_name, isp, `status`, ", + "remark, create_time, ", + "ext_1, ext_2, ext_3)", + "values (#{userId,jdbcType=BIGINT}, #{userLoginName,jdbcType=VARCHAR}, ", + "#{ip,jdbcType=VARCHAR}, #{country,jdbcType=VARCHAR}, #{regionId,jdbcType=VARCHAR}, ", + "#{regionName,jdbcType=VARCHAR}, #{cityId,jdbcType=VARCHAR}, ", + "#{cityName,jdbcType=VARCHAR}, #{isp,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", + "#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(SecUserLoginLog record); + + @InsertProvider(type=SecUserLoginLogSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(SecUserLoginLog record); + + @SelectProvider(type=SecUserLoginLogSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="user_login_name", property="userLoginName", jdbcType=JdbcType.VARCHAR), + @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), + @Result(column="country", property="country", jdbcType=JdbcType.VARCHAR), + @Result(column="region_id", property="regionId", jdbcType=JdbcType.VARCHAR), + @Result(column="region_name", property="regionName", jdbcType=JdbcType.VARCHAR), + @Result(column="city_id", property="cityId", jdbcType=JdbcType.VARCHAR), + @Result(column="city_name", property="cityName", jdbcType=JdbcType.VARCHAR), + @Result(column="isp", property="isp", jdbcType=JdbcType.VARCHAR), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List selectByExample(SecUserLoginLogExample example); + + @Select({ + "select", + "id, user_id, user_login_name, ip, country, region_id, region_name, city_id, ", + "city_name, isp, `status`, remark, create_time, ext_1, ext_2, ext_3", + "from sec_user_login_log", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), + @Result(column="user_login_name", property="userLoginName", jdbcType=JdbcType.VARCHAR), + @Result(column="ip", property="ip", jdbcType=JdbcType.VARCHAR), + @Result(column="country", property="country", jdbcType=JdbcType.VARCHAR), + @Result(column="region_id", property="regionId", jdbcType=JdbcType.VARCHAR), + @Result(column="region_name", property="regionName", jdbcType=JdbcType.VARCHAR), + @Result(column="city_id", property="cityId", jdbcType=JdbcType.VARCHAR), + @Result(column="city_name", property="cityName", jdbcType=JdbcType.VARCHAR), + @Result(column="isp", property="isp", jdbcType=JdbcType.VARCHAR), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + SecUserLoginLog selectByPrimaryKey(Long id); + + @UpdateProvider(type=SecUserLoginLogSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") SecUserLoginLog record, @Param("example") SecUserLoginLogExample example); + + @UpdateProvider(type=SecUserLoginLogSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") SecUserLoginLog record, @Param("example") SecUserLoginLogExample example); + + @UpdateProvider(type=SecUserLoginLogSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(SecUserLoginLog record); + + @Update({ + "update sec_user_login_log", + "set user_id = #{userId,jdbcType=BIGINT},", + "user_login_name = #{userLoginName,jdbcType=VARCHAR},", + "ip = #{ip,jdbcType=VARCHAR},", + "country = #{country,jdbcType=VARCHAR},", + "region_id = #{regionId,jdbcType=VARCHAR},", + "region_name = #{regionName,jdbcType=VARCHAR},", + "city_id = #{cityId,jdbcType=VARCHAR},", + "city_name = #{cityName,jdbcType=VARCHAR},", + "isp = #{isp,jdbcType=VARCHAR},", + "`status` = #{status,jdbcType=INTEGER},", + "remark = #{remark,jdbcType=VARCHAR},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(SecUserLoginLog record); +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/SecUserLoginLogMapperExt.java b/service/src/main/java/com/hfkj/dao/SecUserLoginLogMapperExt.java new file mode 100644 index 0000000..48f457c --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/SecUserLoginLogMapperExt.java @@ -0,0 +1,7 @@ +package com.hfkj.dao; + +/** + * mapper扩展类 + */ +public interface SecUserLoginLogMapperExt { +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/dao/SecUserLoginLogSqlProvider.java b/service/src/main/java/com/hfkj/dao/SecUserLoginLogSqlProvider.java new file mode 100644 index 0000000..28ee0c6 --- /dev/null +++ b/service/src/main/java/com/hfkj/dao/SecUserLoginLogSqlProvider.java @@ -0,0 +1,388 @@ +package com.hfkj.dao; + +import com.hfkj.entity.SecUserLoginLog; +import com.hfkj.entity.SecUserLoginLogExample.Criteria; +import com.hfkj.entity.SecUserLoginLogExample.Criterion; +import com.hfkj.entity.SecUserLoginLogExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class SecUserLoginLogSqlProvider { + + public String countByExample(SecUserLoginLogExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("sec_user_login_log"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(SecUserLoginLogExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("sec_user_login_log"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(SecUserLoginLog record) { + SQL sql = new SQL(); + sql.INSERT_INTO("sec_user_login_log"); + + if (record.getUserId() != null) { + sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}"); + } + + if (record.getUserLoginName() != null) { + sql.VALUES("user_login_name", "#{userLoginName,jdbcType=VARCHAR}"); + } + + if (record.getIp() != null) { + sql.VALUES("ip", "#{ip,jdbcType=VARCHAR}"); + } + + if (record.getCountry() != null) { + sql.VALUES("country", "#{country,jdbcType=VARCHAR}"); + } + + if (record.getRegionId() != null) { + sql.VALUES("region_id", "#{regionId,jdbcType=VARCHAR}"); + } + + if (record.getRegionName() != null) { + sql.VALUES("region_name", "#{regionName,jdbcType=VARCHAR}"); + } + + if (record.getCityId() != null) { + sql.VALUES("city_id", "#{cityId,jdbcType=VARCHAR}"); + } + + if (record.getCityName() != null) { + sql.VALUES("city_name", "#{cityName,jdbcType=VARCHAR}"); + } + + if (record.getIsp() != null) { + sql.VALUES("isp", "#{isp,jdbcType=VARCHAR}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getRemark() != null) { + sql.VALUES("remark", "#{remark,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); + } + + return sql.toString(); + } + + public String selectByExample(SecUserLoginLogExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("user_id"); + sql.SELECT("user_login_name"); + sql.SELECT("ip"); + sql.SELECT("country"); + sql.SELECT("region_id"); + sql.SELECT("region_name"); + sql.SELECT("city_id"); + sql.SELECT("city_name"); + sql.SELECT("isp"); + sql.SELECT("`status`"); + sql.SELECT("remark"); + sql.SELECT("create_time"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("sec_user_login_log"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + SecUserLoginLog record = (SecUserLoginLog) parameter.get("record"); + SecUserLoginLogExample example = (SecUserLoginLogExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("sec_user_login_log"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getUserId() != null) { + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + } + + if (record.getUserLoginName() != null) { + sql.SET("user_login_name = #{record.userLoginName,jdbcType=VARCHAR}"); + } + + if (record.getIp() != null) { + sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); + } + + if (record.getCountry() != null) { + sql.SET("country = #{record.country,jdbcType=VARCHAR}"); + } + + if (record.getRegionId() != null) { + sql.SET("region_id = #{record.regionId,jdbcType=VARCHAR}"); + } + + if (record.getRegionName() != null) { + sql.SET("region_name = #{record.regionName,jdbcType=VARCHAR}"); + } + + if (record.getCityId() != null) { + sql.SET("city_id = #{record.cityId,jdbcType=VARCHAR}"); + } + + if (record.getCityName() != null) { + sql.SET("city_name = #{record.cityName,jdbcType=VARCHAR}"); + } + + if (record.getIsp() != null) { + sql.SET("isp = #{record.isp,jdbcType=VARCHAR}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getRemark() != null) { + sql.SET("remark = #{record.remark,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("sec_user_login_log"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); + sql.SET("user_login_name = #{record.userLoginName,jdbcType=VARCHAR}"); + sql.SET("ip = #{record.ip,jdbcType=VARCHAR}"); + sql.SET("country = #{record.country,jdbcType=VARCHAR}"); + sql.SET("region_id = #{record.regionId,jdbcType=VARCHAR}"); + sql.SET("region_name = #{record.regionName,jdbcType=VARCHAR}"); + sql.SET("city_id = #{record.cityId,jdbcType=VARCHAR}"); + sql.SET("city_name = #{record.cityName,jdbcType=VARCHAR}"); + sql.SET("isp = #{record.isp,jdbcType=VARCHAR}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("remark = #{record.remark,jdbcType=VARCHAR}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + SecUserLoginLogExample example = (SecUserLoginLogExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(SecUserLoginLog record) { + SQL sql = new SQL(); + sql.UPDATE("sec_user_login_log"); + + if (record.getUserId() != null) { + sql.SET("user_id = #{userId,jdbcType=BIGINT}"); + } + + if (record.getUserLoginName() != null) { + sql.SET("user_login_name = #{userLoginName,jdbcType=VARCHAR}"); + } + + if (record.getIp() != null) { + sql.SET("ip = #{ip,jdbcType=VARCHAR}"); + } + + if (record.getCountry() != null) { + sql.SET("country = #{country,jdbcType=VARCHAR}"); + } + + if (record.getRegionId() != null) { + sql.SET("region_id = #{regionId,jdbcType=VARCHAR}"); + } + + if (record.getRegionName() != null) { + sql.SET("region_name = #{regionName,jdbcType=VARCHAR}"); + } + + if (record.getCityId() != null) { + sql.SET("city_id = #{cityId,jdbcType=VARCHAR}"); + } + + if (record.getCityName() != null) { + sql.SET("city_name = #{cityName,jdbcType=VARCHAR}"); + } + + if (record.getIsp() != null) { + sql.SET("isp = #{isp,jdbcType=VARCHAR}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getRemark() != null) { + sql.SET("remark = #{remark,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, SecUserLoginLogExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/entity/SecUserLoginLog.java b/service/src/main/java/com/hfkj/entity/SecUserLoginLog.java new file mode 100644 index 0000000..a887289 --- /dev/null +++ b/service/src/main/java/com/hfkj/entity/SecUserLoginLog.java @@ -0,0 +1,296 @@ +package com.hfkj.entity; + +import java.io.Serializable; +import java.util.Date; + +/** + * sec_user_login_log + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class SecUserLoginLog implements Serializable { + /** + * 主键 + */ + private Long id; + + /** + * 登录账户id + */ + private Long userId; + + /** + * 登录账户 + */ + private String userLoginName; + + /** + * ip + */ + private String ip; + + /** + * 国家 + */ + private String country; + + /** + * 省份编号 + */ + private String regionId; + + /** + * 省份名称 + */ + private String regionName; + + /** + * 城市编号 + */ + private String cityId; + + /** + * 城市名称 + */ + private String cityName; + + /** + * 运营商 + */ + private String isp; + + /** + * 状态 1:正常 2:风险 + */ + private Integer status; + + /** + * 备注 + */ + private String remark; + + /** + * 创建时间 + */ + private Date createTime; + + private String ext1; + + private String ext2; + + private String ext3; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public String getUserLoginName() { + return userLoginName; + } + + public void setUserLoginName(String userLoginName) { + this.userLoginName = userLoginName; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getRegionName() { + return regionName; + } + + public void setRegionName(String regionName) { + this.regionName = regionName; + } + + public String getCityId() { + return cityId; + } + + public void setCityId(String cityId) { + this.cityId = cityId; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public String getIsp() { + return isp; + } + + public void setIsp(String isp) { + this.isp = isp; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getExt1() { + return ext1; + } + + public void setExt1(String ext1) { + this.ext1 = ext1; + } + + public String getExt2() { + return ext2; + } + + public void setExt2(String ext2) { + this.ext2 = ext2; + } + + public String getExt3() { + return ext3; + } + + public void setExt3(String ext3) { + this.ext3 = ext3; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + SecUserLoginLog other = (SecUserLoginLog) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) + && (this.getUserLoginName() == null ? other.getUserLoginName() == null : this.getUserLoginName().equals(other.getUserLoginName())) + && (this.getIp() == null ? other.getIp() == null : this.getIp().equals(other.getIp())) + && (this.getCountry() == null ? other.getCountry() == null : this.getCountry().equals(other.getCountry())) + && (this.getRegionId() == null ? other.getRegionId() == null : this.getRegionId().equals(other.getRegionId())) + && (this.getRegionName() == null ? other.getRegionName() == null : this.getRegionName().equals(other.getRegionName())) + && (this.getCityId() == null ? other.getCityId() == null : this.getCityId().equals(other.getCityId())) + && (this.getCityName() == null ? other.getCityName() == null : this.getCityName().equals(other.getCityName())) + && (this.getIsp() == null ? other.getIsp() == null : this.getIsp().equals(other.getIsp())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) + && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) + && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); + result = prime * result + ((getUserLoginName() == null) ? 0 : getUserLoginName().hashCode()); + result = prime * result + ((getIp() == null) ? 0 : getIp().hashCode()); + result = prime * result + ((getCountry() == null) ? 0 : getCountry().hashCode()); + result = prime * result + ((getRegionId() == null) ? 0 : getRegionId().hashCode()); + result = prime * result + ((getRegionName() == null) ? 0 : getRegionName().hashCode()); + result = prime * result + ((getCityId() == null) ? 0 : getCityId().hashCode()); + result = prime * result + ((getCityName() == null) ? 0 : getCityName().hashCode()); + result = prime * result + ((getIsp() == null) ? 0 : getIsp().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); + result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); + result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", userId=").append(userId); + sb.append(", userLoginName=").append(userLoginName); + sb.append(", ip=").append(ip); + sb.append(", country=").append(country); + sb.append(", regionId=").append(regionId); + sb.append(", regionName=").append(regionName); + sb.append(", cityId=").append(cityId); + sb.append(", cityName=").append(cityName); + sb.append(", isp=").append(isp); + sb.append(", status=").append(status); + sb.append(", remark=").append(remark); + sb.append(", createTime=").append(createTime); + sb.append(", ext1=").append(ext1); + sb.append(", ext2=").append(ext2); + sb.append(", ext3=").append(ext3); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/entity/SecUserLoginLogExample.java b/service/src/main/java/com/hfkj/entity/SecUserLoginLogExample.java new file mode 100644 index 0000000..9006f24 --- /dev/null +++ b/service/src/main/java/com/hfkj/entity/SecUserLoginLogExample.java @@ -0,0 +1,1303 @@ +package com.hfkj.entity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class SecUserLoginLogExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public SecUserLoginLogExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(Long value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(Long value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(Long value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(Long value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(Long value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(Long value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(Long value1, Long value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(Long value1, Long value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserLoginNameIsNull() { + addCriterion("user_login_name is null"); + return (Criteria) this; + } + + public Criteria andUserLoginNameIsNotNull() { + addCriterion("user_login_name is not null"); + return (Criteria) this; + } + + public Criteria andUserLoginNameEqualTo(String value) { + addCriterion("user_login_name =", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameNotEqualTo(String value) { + addCriterion("user_login_name <>", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameGreaterThan(String value) { + addCriterion("user_login_name >", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameGreaterThanOrEqualTo(String value) { + addCriterion("user_login_name >=", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameLessThan(String value) { + addCriterion("user_login_name <", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameLessThanOrEqualTo(String value) { + addCriterion("user_login_name <=", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameLike(String value) { + addCriterion("user_login_name like", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameNotLike(String value) { + addCriterion("user_login_name not like", value, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameIn(List values) { + addCriterion("user_login_name in", values, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameNotIn(List values) { + addCriterion("user_login_name not in", values, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameBetween(String value1, String value2) { + addCriterion("user_login_name between", value1, value2, "userLoginName"); + return (Criteria) this; + } + + public Criteria andUserLoginNameNotBetween(String value1, String value2) { + addCriterion("user_login_name not between", value1, value2, "userLoginName"); + return (Criteria) this; + } + + public Criteria andIpIsNull() { + addCriterion("ip is null"); + return (Criteria) this; + } + + public Criteria andIpIsNotNull() { + addCriterion("ip is not null"); + return (Criteria) this; + } + + public Criteria andIpEqualTo(String value) { + addCriterion("ip =", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotEqualTo(String value) { + addCriterion("ip <>", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpGreaterThan(String value) { + addCriterion("ip >", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpGreaterThanOrEqualTo(String value) { + addCriterion("ip >=", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpLessThan(String value) { + addCriterion("ip <", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpLessThanOrEqualTo(String value) { + addCriterion("ip <=", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpLike(String value) { + addCriterion("ip like", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotLike(String value) { + addCriterion("ip not like", value, "ip"); + return (Criteria) this; + } + + public Criteria andIpIn(List values) { + addCriterion("ip in", values, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotIn(List values) { + addCriterion("ip not in", values, "ip"); + return (Criteria) this; + } + + public Criteria andIpBetween(String value1, String value2) { + addCriterion("ip between", value1, value2, "ip"); + return (Criteria) this; + } + + public Criteria andIpNotBetween(String value1, String value2) { + addCriterion("ip not between", value1, value2, "ip"); + return (Criteria) this; + } + + public Criteria andCountryIsNull() { + addCriterion("country is null"); + return (Criteria) this; + } + + public Criteria andCountryIsNotNull() { + addCriterion("country is not null"); + return (Criteria) this; + } + + public Criteria andCountryEqualTo(String value) { + addCriterion("country =", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotEqualTo(String value) { + addCriterion("country <>", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryGreaterThan(String value) { + addCriterion("country >", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryGreaterThanOrEqualTo(String value) { + addCriterion("country >=", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryLessThan(String value) { + addCriterion("country <", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryLessThanOrEqualTo(String value) { + addCriterion("country <=", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryLike(String value) { + addCriterion("country like", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotLike(String value) { + addCriterion("country not like", value, "country"); + return (Criteria) this; + } + + public Criteria andCountryIn(List values) { + addCriterion("country in", values, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotIn(List values) { + addCriterion("country not in", values, "country"); + return (Criteria) this; + } + + public Criteria andCountryBetween(String value1, String value2) { + addCriterion("country between", value1, value2, "country"); + return (Criteria) this; + } + + public Criteria andCountryNotBetween(String value1, String value2) { + addCriterion("country not between", value1, value2, "country"); + return (Criteria) this; + } + + public Criteria andRegionIdIsNull() { + addCriterion("region_id is null"); + return (Criteria) this; + } + + public Criteria andRegionIdIsNotNull() { + addCriterion("region_id is not null"); + return (Criteria) this; + } + + public Criteria andRegionIdEqualTo(String value) { + addCriterion("region_id =", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdNotEqualTo(String value) { + addCriterion("region_id <>", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdGreaterThan(String value) { + addCriterion("region_id >", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdGreaterThanOrEqualTo(String value) { + addCriterion("region_id >=", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdLessThan(String value) { + addCriterion("region_id <", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdLessThanOrEqualTo(String value) { + addCriterion("region_id <=", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdLike(String value) { + addCriterion("region_id like", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdNotLike(String value) { + addCriterion("region_id not like", value, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdIn(List values) { + addCriterion("region_id in", values, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdNotIn(List values) { + addCriterion("region_id not in", values, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdBetween(String value1, String value2) { + addCriterion("region_id between", value1, value2, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionIdNotBetween(String value1, String value2) { + addCriterion("region_id not between", value1, value2, "regionId"); + return (Criteria) this; + } + + public Criteria andRegionNameIsNull() { + addCriterion("region_name is null"); + return (Criteria) this; + } + + public Criteria andRegionNameIsNotNull() { + addCriterion("region_name is not null"); + return (Criteria) this; + } + + public Criteria andRegionNameEqualTo(String value) { + addCriterion("region_name =", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameNotEqualTo(String value) { + addCriterion("region_name <>", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameGreaterThan(String value) { + addCriterion("region_name >", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameGreaterThanOrEqualTo(String value) { + addCriterion("region_name >=", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameLessThan(String value) { + addCriterion("region_name <", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameLessThanOrEqualTo(String value) { + addCriterion("region_name <=", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameLike(String value) { + addCriterion("region_name like", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameNotLike(String value) { + addCriterion("region_name not like", value, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameIn(List values) { + addCriterion("region_name in", values, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameNotIn(List values) { + addCriterion("region_name not in", values, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameBetween(String value1, String value2) { + addCriterion("region_name between", value1, value2, "regionName"); + return (Criteria) this; + } + + public Criteria andRegionNameNotBetween(String value1, String value2) { + addCriterion("region_name not between", value1, value2, "regionName"); + return (Criteria) this; + } + + public Criteria andCityIdIsNull() { + addCriterion("city_id is null"); + return (Criteria) this; + } + + public Criteria andCityIdIsNotNull() { + addCriterion("city_id is not null"); + return (Criteria) this; + } + + public Criteria andCityIdEqualTo(String value) { + addCriterion("city_id =", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdNotEqualTo(String value) { + addCriterion("city_id <>", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdGreaterThan(String value) { + addCriterion("city_id >", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdGreaterThanOrEqualTo(String value) { + addCriterion("city_id >=", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdLessThan(String value) { + addCriterion("city_id <", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdLessThanOrEqualTo(String value) { + addCriterion("city_id <=", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdLike(String value) { + addCriterion("city_id like", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdNotLike(String value) { + addCriterion("city_id not like", value, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdIn(List values) { + addCriterion("city_id in", values, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdNotIn(List values) { + addCriterion("city_id not in", values, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdBetween(String value1, String value2) { + addCriterion("city_id between", value1, value2, "cityId"); + return (Criteria) this; + } + + public Criteria andCityIdNotBetween(String value1, String value2) { + addCriterion("city_id not between", value1, value2, "cityId"); + return (Criteria) this; + } + + public Criteria andCityNameIsNull() { + addCriterion("city_name is null"); + return (Criteria) this; + } + + public Criteria andCityNameIsNotNull() { + addCriterion("city_name is not null"); + return (Criteria) this; + } + + public Criteria andCityNameEqualTo(String value) { + addCriterion("city_name =", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotEqualTo(String value) { + addCriterion("city_name <>", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameGreaterThan(String value) { + addCriterion("city_name >", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameGreaterThanOrEqualTo(String value) { + addCriterion("city_name >=", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameLessThan(String value) { + addCriterion("city_name <", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameLessThanOrEqualTo(String value) { + addCriterion("city_name <=", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameLike(String value) { + addCriterion("city_name like", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotLike(String value) { + addCriterion("city_name not like", value, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameIn(List values) { + addCriterion("city_name in", values, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotIn(List values) { + addCriterion("city_name not in", values, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameBetween(String value1, String value2) { + addCriterion("city_name between", value1, value2, "cityName"); + return (Criteria) this; + } + + public Criteria andCityNameNotBetween(String value1, String value2) { + addCriterion("city_name not between", value1, value2, "cityName"); + return (Criteria) this; + } + + public Criteria andIspIsNull() { + addCriterion("isp is null"); + return (Criteria) this; + } + + public Criteria andIspIsNotNull() { + addCriterion("isp is not null"); + return (Criteria) this; + } + + public Criteria andIspEqualTo(String value) { + addCriterion("isp =", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspNotEqualTo(String value) { + addCriterion("isp <>", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspGreaterThan(String value) { + addCriterion("isp >", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspGreaterThanOrEqualTo(String value) { + addCriterion("isp >=", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspLessThan(String value) { + addCriterion("isp <", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspLessThanOrEqualTo(String value) { + addCriterion("isp <=", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspLike(String value) { + addCriterion("isp like", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspNotLike(String value) { + addCriterion("isp not like", value, "isp"); + return (Criteria) this; + } + + public Criteria andIspIn(List values) { + addCriterion("isp in", values, "isp"); + return (Criteria) this; + } + + public Criteria andIspNotIn(List values) { + addCriterion("isp not in", values, "isp"); + return (Criteria) this; + } + + public Criteria andIspBetween(String value1, String value2) { + addCriterion("isp between", value1, value2, "isp"); + return (Criteria) this; + } + + public Criteria andIspNotBetween(String value1, String value2) { + addCriterion("isp not between", value1, value2, "isp"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andRemarkIsNull() { + addCriterion("remark is null"); + return (Criteria) this; + } + + public Criteria andRemarkIsNotNull() { + addCriterion("remark is not null"); + return (Criteria) this; + } + + public Criteria andRemarkEqualTo(String value) { + addCriterion("remark =", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkNotEqualTo(String value) { + addCriterion("remark <>", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkGreaterThan(String value) { + addCriterion("remark >", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkGreaterThanOrEqualTo(String value) { + addCriterion("remark >=", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkLessThan(String value) { + addCriterion("remark <", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkLessThanOrEqualTo(String value) { + addCriterion("remark <=", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkLike(String value) { + addCriterion("remark like", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkNotLike(String value) { + addCriterion("remark not like", value, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkIn(List values) { + addCriterion("remark in", values, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkNotIn(List values) { + addCriterion("remark not in", values, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkBetween(String value1, String value2) { + addCriterion("remark between", value1, value2, "remark"); + return (Criteria) this; + } + + public Criteria andRemarkNotBetween(String value1, String value2) { + addCriterion("remark not between", value1, value2, "remark"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andExt1IsNull() { + addCriterion("ext_1 is null"); + return (Criteria) this; + } + + public Criteria andExt1IsNotNull() { + addCriterion("ext_1 is not null"); + return (Criteria) this; + } + + public Criteria andExt1EqualTo(String value) { + addCriterion("ext_1 =", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotEqualTo(String value) { + addCriterion("ext_1 <>", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThan(String value) { + addCriterion("ext_1 >", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThanOrEqualTo(String value) { + addCriterion("ext_1 >=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThan(String value) { + addCriterion("ext_1 <", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThanOrEqualTo(String value) { + addCriterion("ext_1 <=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Like(String value) { + addCriterion("ext_1 like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotLike(String value) { + addCriterion("ext_1 not like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1In(List values) { + addCriterion("ext_1 in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotIn(List values) { + addCriterion("ext_1 not in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Between(String value1, String value2) { + addCriterion("ext_1 between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotBetween(String value1, String value2) { + addCriterion("ext_1 not between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt2IsNull() { + addCriterion("ext_2 is null"); + return (Criteria) this; + } + + public Criteria andExt2IsNotNull() { + addCriterion("ext_2 is not null"); + return (Criteria) this; + } + + public Criteria andExt2EqualTo(String value) { + addCriterion("ext_2 =", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotEqualTo(String value) { + addCriterion("ext_2 <>", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThan(String value) { + addCriterion("ext_2 >", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThanOrEqualTo(String value) { + addCriterion("ext_2 >=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThan(String value) { + addCriterion("ext_2 <", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThanOrEqualTo(String value) { + addCriterion("ext_2 <=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Like(String value) { + addCriterion("ext_2 like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotLike(String value) { + addCriterion("ext_2 not like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2In(List values) { + addCriterion("ext_2 in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotIn(List values) { + addCriterion("ext_2 not in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Between(String value1, String value2) { + addCriterion("ext_2 between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotBetween(String value1, String value2) { + addCriterion("ext_2 not between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt3IsNull() { + addCriterion("ext_3 is null"); + return (Criteria) this; + } + + public Criteria andExt3IsNotNull() { + addCriterion("ext_3 is not null"); + return (Criteria) this; + } + + public Criteria andExt3EqualTo(String value) { + addCriterion("ext_3 =", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotEqualTo(String value) { + addCriterion("ext_3 <>", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThan(String value) { + addCriterion("ext_3 >", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThanOrEqualTo(String value) { + addCriterion("ext_3 >=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThan(String value) { + addCriterion("ext_3 <", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThanOrEqualTo(String value) { + addCriterion("ext_3 <=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Like(String value) { + addCriterion("ext_3 like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotLike(String value) { + addCriterion("ext_3 not like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3In(List values) { + addCriterion("ext_3 in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotIn(List values) { + addCriterion("ext_3 not in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Between(String value1, String value2) { + addCriterion("ext_3 between", value1, value2, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotBetween(String value1, String value2) { + addCriterion("ext_3 not between", value1, value2, "ext3"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hfkj/service/SecUserLoginLogService.java b/service/src/main/java/com/hfkj/service/SecUserLoginLogService.java new file mode 100644 index 0000000..582b30e --- /dev/null +++ b/service/src/main/java/com/hfkj/service/SecUserLoginLogService.java @@ -0,0 +1,37 @@ +package com.hfkj.service; + +import com.hfkj.entity.SecUser; +import com.hfkj.entity.SecUserLoginLog; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; +import java.util.Map; + +/** + * 登录账户 + * @className: SecUserLoginLogService + * @author: HuRui + * @date: 2024/4/3 + **/ +public interface SecUserLoginLogService { + + /** + * 创建 + * @param userLoginLog + */ + void create(SecUserLoginLog userLoginLog); + + /** + * 异步创建登录日志 + * @param user + */ + void asyncCreateLog(SecUser user, HttpServletRequest request); + + /** + * 查询日志列表 + * @param param + * @return + */ + List getLogList(Map param); + +} diff --git a/service/src/main/java/com/hfkj/service/impl/SecUserLoginLogServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/SecUserLoginLogServiceImpl.java new file mode 100644 index 0000000..640ec42 --- /dev/null +++ b/service/src/main/java/com/hfkj/service/impl/SecUserLoginLogServiceImpl.java @@ -0,0 +1,98 @@ +package com.hfkj.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.AliyunService; +import com.hfkj.common.utils.RequestUtils; +import com.hfkj.dao.SecUserLoginLogMapper; +import com.hfkj.entity.SecUser; +import com.hfkj.entity.SecUserLoginLog; +import com.hfkj.entity.SecUserLoginLogExample; +import com.hfkj.service.SecUserLoginLogService; +import com.hfkj.sysenum.SecUserLoginLogStatusEnum; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * @className: SecUserLoginLogServiceImpl + * @author: HuRui + * @date: 2024/4/3 + **/ +@Service("secUserLoginLogService") +public class SecUserLoginLogServiceImpl implements SecUserLoginLogService { + + @Resource + private SecUserLoginLogMapper secUserLoginLogMapper; + + @Override + public void create(SecUserLoginLog userLoginLog) { + userLoginLog.setCreateTime(new Date()); + secUserLoginLogMapper.insert(userLoginLog); + } + + @Override + public void asyncCreateLog(SecUser user, HttpServletRequest request) { + // 创建一个单线程的线程池 + ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); + // 异步记录登录信息 + singleThreadExecutor.submit(new Runnable() { + @Override + public void run() { + SecUserLoginLog loginLog = new SecUserLoginLog(); + loginLog.setUserId(user.getId()); + loginLog.setUserLoginName(user.getLoginName()); + loginLog.setIp(RequestUtils.getIpAddress(request)); + // 查询ip归属地 + JSONObject ipAddress = AliyunService.queryAddress(loginLog.getIp()); + if (ipAddress != null) { + loginLog.setCountry(StringUtils.isNotBlank(ipAddress.getString("country"))?ipAddress.getString("country"):"未知"); + loginLog.setRegionId(StringUtils.isNotBlank(ipAddress.getString("region_id"))?ipAddress.getString("region_id"):null); + loginLog.setRegionName(StringUtils.isNotBlank(ipAddress.getString("region"))?ipAddress.getString("region"):"未知"); + loginLog.setCityId(StringUtils.isNotBlank(ipAddress.getString("city_id"))?ipAddress.getString("city_id"):null); + loginLog.setCityName(StringUtils.isNotBlank(ipAddress.getString("city"))?ipAddress.getString("city"):"未知"); + loginLog.setIsp(StringUtils.isNotBlank(ipAddress.getString("isp"))?ipAddress.getString("isp"):"未知"); + loginLog.setStatus(SecUserLoginLogStatusEnum.status1.getCode()); + } else { + loginLog.setCountry("未知"); + loginLog.setRegionName("未知"); + loginLog.setCityName("未知"); + loginLog.setIsp("未知"); + loginLog.setStatus(SecUserLoginLogStatusEnum.status2.getCode()); + } + create(loginLog); + } + }); + singleThreadExecutor.shutdown(); + } + + @Override + public List getLogList(Map param) { + SecUserLoginLogExample example = new SecUserLoginLogExample(); + SecUserLoginLogExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getLong(param, "userId") != null) { + criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId")); + } + + if (StringUtils.isNotBlank(MapUtils.getString(param, "userLoginName"))) { + criteria.andUserLoginNameEqualTo(MapUtils.getString(param, "userLoginName")); + } + + if (MapUtils.getInteger(param, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); + } + + example.setOrderByClause("create_time desc"); + return secUserLoginLogMapper.selectByExample(example); + } + + +} diff --git a/service/src/main/java/com/hfkj/service/impl/SecUserServiceImpl.java b/service/src/main/java/com/hfkj/service/impl/SecUserServiceImpl.java index bb8385c..e27a25f 100644 --- a/service/src/main/java/com/hfkj/service/impl/SecUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/impl/SecUserServiceImpl.java @@ -1,32 +1,39 @@ package com.hfkj.service.impl; +import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.security.AESEncodeUtil; import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.AliyunService; import com.hfkj.common.utils.MD5Util; +import com.hfkj.common.utils.RequestUtils; import com.hfkj.dao.SecUserMapper; -import com.hfkj.entity.SecMenu; -import com.hfkj.entity.SecRole; -import com.hfkj.entity.SecUser; -import com.hfkj.entity.SecUserExample; +import com.hfkj.entity.*; import com.hfkj.model.MenuTreeModel; import com.hfkj.model.SecUserSessionObject; import com.hfkj.service.SecMenuService; import com.hfkj.service.SecRoleService; +import com.hfkj.service.SecUserLoginLogService; import com.hfkj.service.SecUserService; import com.hfkj.sysenum.SecMenuTypeEnum; +import com.hfkj.sysenum.SecUserLoginLogStatusEnum; import com.hfkj.sysenum.SecUserStatusEnum; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.stream.Collectors; /** @@ -42,6 +49,8 @@ public class SecUserServiceImpl implements SecUserService { @Resource private UserCenter userCenter; @Resource + private SecUserLoginLogService secUserLoginLogService; + @Resource private SecRoleService secRoleService; @Resource private SecMenuService secMenuService; @@ -135,10 +144,14 @@ public class SecUserServiceImpl implements SecUserService { List button = secMenuService.queryRoleMenu(role.getId(), SecMenuTypeEnum.type2); // token 生成格式:账户id + 时间戳 - String token = AESEncodeUtil.aesEncrypt(user.getId()+"", "O8gTZ6wIovDPjhsaz0zAoqZmm3jtjIcO"); + String token = AESEncodeUtil.aesEncrypt(user.getId()+"_"+System.currentTimeMillis(), "O8gTZ6wIovDPjhsaz0zAoqZmm3jtjIcO"); SessionObject sessionObject = new SessionObject(token, new SecUserSessionObject(user, role, menuTree, button)); userCenter.save(sessionObject); + + // 异步记录登录信息 + secUserLoginLogService.asyncCreateLog(user, (HttpServletRequest) RequestContextHolder.getRequestAttributes().resolveReference(RequestAttributes.REFERENCE_REQUEST)); + return sessionObject; } diff --git a/service/src/main/java/com/hfkj/sysenum/SecUserLoginLogStatusEnum.java b/service/src/main/java/com/hfkj/sysenum/SecUserLoginLogStatusEnum.java new file mode 100644 index 0000000..a7174dd --- /dev/null +++ b/service/src/main/java/com/hfkj/sysenum/SecUserLoginLogStatusEnum.java @@ -0,0 +1,46 @@ +package com.hfkj.sysenum; + +/** + * 登录日志状态 + * @className: SecUserLoginLogStatusEnum + * @author: HuRui + * @date: 2024/4/3 + **/ +public enum SecUserLoginLogStatusEnum { + /** + * 正常 + */ + status1(1, "正常"), + + /** + * 风险 + */ + status2(2, "风险"), + ; + + private int code; + + private String name; + + + SecUserLoginLogStatusEnum(int code, String name) { + this.code = code; + this.name = name; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}