parent
08fe07e28e
commit
186eec8101
@ -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<String, String> headers = new HashMap<>(); |
||||
headers.put("Authorization", "APPCODE " + appcode); |
||||
headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); |
||||
|
||||
Map<String, String> 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(); |
||||
} |
||||
} |
||||
} |
@ -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<SecUserLoginLog> 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); |
||||
} |
@ -0,0 +1,7 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface SecUserLoginLogMapperExt { |
||||
} |
@ -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<String, Object> 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<String, Object> 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<Criteria> 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<Criterion> 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()); |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -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<SecUserLoginLog> getLogList(Map<String, Object> param); |
||||
|
||||
} |
@ -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<SecUserLoginLog> getLogList(Map<String, Object> 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); |
||||
} |
||||
|
||||
|
||||
} |
@ -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; |
||||
} |
||||
} |
Loading…
Reference in new issue