Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
d76808d79c
|
|
@ -164,7 +164,7 @@ public class SysLogsVo {
|
|||
try{
|
||||
String uuid= UUID.randomUUID().toString().replace("-","").toUpperCase();
|
||||
vo.setLogId(uuid);
|
||||
String ip = IpUtils.getIpAddr();
|
||||
String ip = loginUser.getIpaddr();
|
||||
vo.setIp(ip);
|
||||
// 设置方法名称
|
||||
String className = joinPoint.getTarget().getClass().getName();
|
||||
|
|
|
|||
|
|
@ -238,7 +238,8 @@ public class PasswordValidatorService {
|
|||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST));
|
||||
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) {
|
||||
String ip = IpUtils.getIpAddr();
|
||||
if (IpUtils.isMatchedIp(blackStr,ip )) {
|
||||
logAndThrowError(username, "访问IP已被列入系统黑名单", "访问IP已被列入系统黑名单");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.common.core.utils.DateUtils;
|
|||
import com.bonus.common.core.utils.global.SystemGlobal;
|
||||
import com.bonus.common.log.enums.OperaResult;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.domain.SysLogsVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -15,6 +16,7 @@ import com.bonus.common.core.utils.StringUtils;
|
|||
import com.bonus.common.core.utils.ip.IpUtils;
|
||||
import com.bonus.system.api.RemoteLogService;
|
||||
import com.bonus.system.api.domain.SysLogininfor;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -119,6 +121,7 @@ public class SysRecordLogService
|
|||
if (StringUtils.isNotEmpty(userId)){
|
||||
sysLogsVo.setUserId(userId);
|
||||
}
|
||||
sysLogsVo.setIp(IpUtils.getIpAddr());
|
||||
sysLogsVo.setResultData("用户登录成功");
|
||||
sysLogsVo.setTitle("系统登录");
|
||||
sysLogsVo.setModel("系统认证模块");
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ import java.util.Map;
|
|||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.constant.TokenConstants;
|
||||
import com.bonus.common.core.text.Convert;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* Jwt工具类
|
||||
|
|
@ -25,8 +27,13 @@ public class JwtUtils
|
|||
*/
|
||||
public static String createToken(Map<String, Object> claims)
|
||||
{
|
||||
String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||
return token;
|
||||
String username = (String) claims.get(SecurityConstants.DETAILS_USERNAME);
|
||||
if (!StringUtils.isEmpty(username)){
|
||||
String encyrptUserName = Sm4Utils.encrypt(username);
|
||||
claims.put(SecurityConstants.DETAILS_USERNAME, encyrptUserName);
|
||||
System.out.print("****createToken里加密用户名是:" + encyrptUserName);
|
||||
}
|
||||
return Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +44,14 @@ public class JwtUtils
|
|||
*/
|
||||
public static Claims parseToken(String token)
|
||||
{
|
||||
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
|
||||
Claims claims = Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
|
||||
String username = getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||
if (!StringUtils.isEmpty(username)){
|
||||
String decryUsername = Sm4Utils.decrypt(username);
|
||||
System.out.print("****parseToken里解密用户名是:" + decryUsername);
|
||||
claims.put(SecurityConstants.DETAILS_USERNAME, decryUsername);
|
||||
}
|
||||
return claims;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -95,7 +109,7 @@ public class JwtUtils
|
|||
public static String getUserName(String token)
|
||||
{
|
||||
Claims claims = parseToken(token);
|
||||
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||
return getUserName(claims);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -106,7 +120,17 @@ public class JwtUtils
|
|||
*/
|
||||
public static String getUserName(Claims claims)
|
||||
{
|
||||
return getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||
String encryptUserName = getValue(claims, SecurityConstants.DETAILS_USERNAME);
|
||||
if (!StringUtils.isEmpty(encryptUserName)){
|
||||
String decryUsername = Sm4Utils.decrypt(encryptUserName);
|
||||
if (StringUtils.isEmpty(decryUsername)){
|
||||
return encryptUserName;
|
||||
}else {
|
||||
return decryUsername;
|
||||
}
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class Sm4Utils {
|
|||
// 返回带盐的加密结果(Hex编码)
|
||||
return HexUtil.encodeHexStr(encryptedData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
return null; // 发生异常时返回null
|
||||
}
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ public class Sm4Utils {
|
|||
byte[] decryptedData = sm4.decrypt(cipherText);
|
||||
return new String(decryptedData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
return null; // 发生异常时返回null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class SystemGlobal {
|
|||
*/
|
||||
public final static String LOG_ERR="2";
|
||||
|
||||
public final static int LOG_DEFEAT_SIZE=1024;
|
||||
public final static int LOG_DEFEAT_SIZE=1;
|
||||
|
||||
|
||||
public final static String ERR_NUM="NAN";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package com.bonus.common.core.utils.ip;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
|
|
|||
|
|
@ -3,13 +3,16 @@ package com.bonus.common.log.aspect;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.SpringUtils;
|
||||
import com.bonus.common.core.utils.global.SystemGlobal;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.domain.SysLogsVo;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
|
|
@ -23,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ import cn.hutool.json.JSONObject;
|
|||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.domain.R;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.ip.IpUtils;
|
||||
import com.bonus.common.security.utils.LogsUtils;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.api.RemoteLogService;
|
||||
import com.bonus.system.api.domain.SysLogsVo;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
|
@ -42,6 +44,8 @@ public class AuthLogic
|
|||
|
||||
|
||||
public RemoteLogService logService = SpringUtils.getBean(RemoteLogService.class);
|
||||
|
||||
public SystemConfig systemConfig = SpringUtils.getBean(SystemConfig.class);
|
||||
/**
|
||||
* 会话注销
|
||||
*/
|
||||
|
|
@ -180,6 +184,7 @@ public class AuthLogic
|
|||
public void addErrorLogs(ProceedingJoinPoint joinPoint,RequiresPermissions requiresPermissions){
|
||||
try{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
loginUser.setIpaddr(IpUtils.getIpAddr());
|
||||
SysLogsVo vo=SysLogsVo.getExceedAuthorithSysLogsVo(loginUser,joinPoint);
|
||||
LogsUtils.setRequestValue(joinPoint,vo,null);
|
||||
SysLogsVo sysLogsVo=new SysLogsVo();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ package com.bonus.common.security.feign;
|
|||
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.bonus.common.core.utils.SpringUtils;
|
||||
import com.bonus.config.SystemConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.bonus.common.core.constant.SecurityConstants;
|
||||
import com.bonus.common.core.utils.ServletUtils;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import com.bonus.common.core.constant.TokenConstants;
|
|||
import com.bonus.common.core.context.SecurityContextHolder;
|
||||
import com.bonus.common.core.utils.ServletUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
|
@ -99,8 +99,8 @@ public class SecurityUtils
|
|||
*/
|
||||
public static String encryptPassword(String password)
|
||||
{
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
return passwordEncoder.encode(password);
|
||||
return Sm4Utils.encrypt(password);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,17 +112,17 @@ public class SecurityUtils
|
|||
*/
|
||||
public static boolean matchesPassword(String rawPassword, String encodedPassword)
|
||||
{
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
return passwordEncoder.matches(rawPassword, encodedPassword);
|
||||
return encodedPassword.equals(Sm4Utils.encrypt(rawPassword));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2
|
||||
//$2a$10$zvlw3Mu8M.j.MhAChrYwluj88ziX6lVD3AoRrBQpwKMcdIZvKMoR2
|
||||
// String msg= encryptPassword("Admin@1234");
|
||||
String msg= encryptPassword("Bonus$2024");
|
||||
boolean rest = matchesPassword("Bonus$2024","$2a$10$8JaKSUAU.K.mceU1.YQbd.wP4EJzbrsIscjAwPlfDR7wAWV6s/BGa");
|
||||
String msg= encryptPassword("15888888888");
|
||||
// boolean rest = matchesPassword("Bonus$2024","$2a$10$8JaKSUAU.K.mceU1.YQbd.wP4EJzbrsIscjAwPlfDR7wAWV6s/BGa");
|
||||
// String msg = Sm4Utils.encrypt("Bonus$2026");
|
||||
System.err.println(msg);
|
||||
System.err.println(rest);
|
||||
// System.err.println(rest);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@ public class CaptchaConfig
|
|||
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "40");
|
||||
// KAPTCHA_SESSION_KEY
|
||||
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode");
|
||||
// 验证码文本字符长度 默认为5
|
||||
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "6");
|
||||
// // 验证码文本字符长度 默认为5,这个在自定义文本生成器里定义
|
||||
// properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
|
||||
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
|
||||
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
|
||||
|
||||
properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.bonus.gateway.config.MixedTextCreator");
|
||||
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
|
||||
// properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
|
||||
Config config = new Config(properties);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import java.util.Random;
|
|||
import com.google.code.kaptcha.text.impl.DefaultTextCreator;
|
||||
|
||||
/**
|
||||
* 验证码文本生成器
|
||||
* 数学计算验证码文本生成器
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.bonus.gateway.config;
|
||||
|
||||
|
||||
import com.google.code.kaptcha.text.TextProducer;
|
||||
import java.util.Random;
|
||||
|
||||
public class MixedTextCreator implements TextProducer {
|
||||
private static final String NUMBERS = "23456789";
|
||||
private static final String LETTERS = "abcdefghijkmnopqrstuvwxyz";
|
||||
private final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
// 确保至少包含2个数字和2个字母
|
||||
StringBuilder text = new StringBuilder(6);
|
||||
|
||||
// 添加2个随机数字
|
||||
for (int i = 0; i < 2; i++) {
|
||||
text.append(NUMBERS.charAt(random.nextInt(NUMBERS.length())));
|
||||
}
|
||||
|
||||
// 添加2个随机字母
|
||||
for (int i = 0; i < 2; i++) {
|
||||
text.append(LETTERS.charAt(random.nextInt(LETTERS.length())));
|
||||
}
|
||||
|
||||
// 添加剩余2个随机字符(可以是数字或字母)
|
||||
String allChars = NUMBERS + LETTERS;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
text.append(allChars.charAt(random.nextInt(allChars.length())));
|
||||
}
|
||||
|
||||
// 打乱字符顺序
|
||||
char[] chars = text.toString().toCharArray();
|
||||
for (int i = chars.length - 1; i > 0; i--) {
|
||||
int index = random.nextInt(i + 1);
|
||||
char temp = chars[index];
|
||||
chars[index] = chars[i];
|
||||
chars[i] = temp;
|
||||
}
|
||||
|
||||
return new String(chars);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
//package com.bonus.gateway.filter;
|
||||
//
|
||||
//import com.bonus.common.core.constant.CacheConstants;
|
||||
//import com.bonus.common.core.utils.DateUtils;
|
||||
//import com.bonus.common.core.utils.SpringUtils;
|
||||
//import com.bonus.common.core.utils.ip.IpUtils;
|
||||
//import com.bonus.common.redis.service.RedisService;
|
||||
//
|
||||
//import com.bonus.system.api.RemoteLogService;
|
||||
//import com.bonus.system.api.domain.SysLogsVo;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang3.ObjectUtils;
|
||||
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
//import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
//import org.springframework.core.Ordered;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.web.server.ServerWebExchange;
|
||||
//import reactor.core.publisher.Mono;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.net.InetAddress;
|
||||
//import java.net.UnknownHostException;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
///**
|
||||
// * @author bonus
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class IpFilter implements GlobalFilter, Ordered {
|
||||
// @Resource
|
||||
// private RedisService redisService;
|
||||
//
|
||||
//// @Resource
|
||||
//// private RemoteLogService remoteLogService;
|
||||
//// public RemoteLogService remoteLogService = SpringUtils.getBean(RemoteLogService.class);
|
||||
// /**
|
||||
// * Process the Web request and (optionally) delegate to the next {@code GatewayFilter}
|
||||
// * through the given {@link GatewayFilterChain}.
|
||||
// *
|
||||
// * @param exchange the current server exchange
|
||||
// * @param chain provides a way to delegate to the next filter
|
||||
// * @return {@code Mono<Void>} to indicate when request processing is complete
|
||||
// */
|
||||
// @Override
|
||||
// public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
// List<Map<String,Object>> cacheList = redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST);
|
||||
//
|
||||
// // 获取客户端的 IP 地址
|
||||
// String ip = exchange.getRequest().getHeaders().getFirst("X-Forwarded-For");
|
||||
// for (Map<String,Object> map : cacheList) {
|
||||
// String ipAddress = map.containsKey("ipAddress") ? map.get("ipAddress").toString() : null;
|
||||
// String ipRangeEnd = map.containsKey("ipRangeEnd") ?map.get("ipRangeEnd").toString(): null;
|
||||
// String ipRangeStart = map.containsKey("ipRangeStart")?map.get("ipRangeStart").toString():null;
|
||||
// String accessStartTime =map.containsKey("accessStartTime")? map.get("accessStartTime").toString():null;
|
||||
// String accessEndTime = map.containsKey("accessEndTime")?map.get("accessEndTime").toString():null;
|
||||
// if (ObjectUtils.isEmpty(ipAddress)){
|
||||
// if (isIpInRange(ip, ipRangeStart, ipRangeEnd)){
|
||||
// if (ObjectUtils.isNotEmpty(accessStartTime)){
|
||||
// boolean currentTimeInRange = isCurrentTimeInRange(accessStartTime, accessEndTime);
|
||||
// if (!currentTimeInRange){
|
||||
// // 完成响应
|
||||
// handleLog();
|
||||
// exchange.getResponse().setStatusCode(org.springframework.http.HttpStatus.FORBIDDEN);
|
||||
// return exchange.getResponse().setComplete();
|
||||
// }else {
|
||||
// return chain.filter(exchange);
|
||||
// }
|
||||
// }else {
|
||||
// return chain.filter(exchange);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }else {
|
||||
// if (ipAddress.equals(ip)){
|
||||
// if (ObjectUtils.isNotEmpty(accessStartTime)){
|
||||
// boolean currentTimeInRange = isCurrentTimeInRange(accessStartTime, accessEndTime);
|
||||
// if (!currentTimeInRange){
|
||||
// // 完成响应
|
||||
//// handleLog();
|
||||
// exchange.getResponse().setStatusCode(org.springframework.http.HttpStatus.FORBIDDEN);
|
||||
// return exchange.getResponse().setComplete();
|
||||
// }else {
|
||||
// return chain.filter(exchange);
|
||||
// }
|
||||
// }else {
|
||||
// return chain.filter(exchange);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// exchange.getResponse().setStatusCode(org.springframework.http.HttpStatus.FORBIDDEN);
|
||||
// return exchange.getResponse().setComplete();
|
||||
// }
|
||||
// private void handleLog()
|
||||
// {
|
||||
// SysLogsVo sysLogsVo = new SysLogsVo();
|
||||
// String uuid= UUID.randomUUID().toString().replace("-","").toUpperCase();
|
||||
// sysLogsVo.setLogId(uuid);
|
||||
// sysLogsVo.setOperaUserName("");
|
||||
// sysLogsVo.setIp(IpUtils.getIpAddr());
|
||||
// sysLogsVo.setOperTime(DateUtils.getTime());
|
||||
// sysLogsVo.setLogType(0);
|
||||
// sysLogsVo.setOperType("IP地址异常");
|
||||
// sysLogsVo.setWarningStatus("0");
|
||||
// try {
|
||||
//// remoteLogService.addLogs(sysLogsVo, "inner");
|
||||
// } catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * 检查给定的IP地址是否在指定的网段区间内
|
||||
// *
|
||||
// * @param ip 要检查的IP地址,例如 "192.168.1.10"
|
||||
// * @param startIp 区间开始的IP地址,例如 "192.168.1.0"
|
||||
// * @param endIp 区间结束的IP地址,例如 "192.168.1.255"
|
||||
// * @return true 如果IP在区间内;否则返回 false
|
||||
// */
|
||||
// public static boolean isIpInRange(String ip, String startIp, String endIp) {
|
||||
// try {
|
||||
// // 将 IP 地址、起始 IP 和结束 IP 转换为整数
|
||||
// long ipToCheck = ipToLong(InetAddress.getByName(ip));
|
||||
// long start = ipToLong(InetAddress.getByName(startIp));
|
||||
// long end = ipToLong(InetAddress.getByName(endIp));
|
||||
//
|
||||
// // 检查 IP 是否在区间内
|
||||
// return ipToCheck >= start && ipToCheck <= end;
|
||||
// } catch (UnknownHostException e) {
|
||||
// e.printStackTrace();
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 将IP地址转换为整数
|
||||
// *
|
||||
// * @param inetAddress IP地址对象
|
||||
// * @return 转换后的长整数
|
||||
// */
|
||||
// private static long ipToLong(InetAddress inetAddress) {
|
||||
// byte[] octets = inetAddress.getAddress();
|
||||
// long result = 0;
|
||||
// for (byte octet : octets) {
|
||||
// result = (result << 8) | (octet & 0xFF);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
// public static boolean isCurrentTimeInRange(String startDateTime, String endDateTime) {
|
||||
// // 定义日期时间格式
|
||||
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
//
|
||||
// // 将字符串转换为 LocalDateTime
|
||||
// LocalDateTime start = LocalDateTime.parse(startDateTime, formatter);
|
||||
// LocalDateTime end = LocalDateTime.parse(endDateTime, formatter);
|
||||
//
|
||||
// // 获取当前日期和时间
|
||||
// LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
//
|
||||
// // 检查当前日期和时间是否在指定的范围内
|
||||
// return !currentDateTime.isBefore(start) && !currentDateTime.isAfter(end);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get the order value of this object.
|
||||
// * <p>Higher values are interpreted as lower priority. As a consequence,
|
||||
// * the object with the lowest value has the highest priority (somewhat
|
||||
// * analogous to Servlet {@code load-on-startup} values).
|
||||
// * <p>Same order values will result in arbitrary sort positions for the
|
||||
// * affected objects.
|
||||
// *
|
||||
// * @return the order value
|
||||
// * @see #HIGHEST_PRECEDENCE
|
||||
// * @see #LOWEST_PRECEDENCE
|
||||
// */
|
||||
// @Override
|
||||
// public int getOrder() {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
|
|
@ -184,11 +184,12 @@ public class SysLogController extends BaseController {
|
|||
return service.getLogStatistics(dto);
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "查询日志告警")
|
||||
// @PostMapping("logWarn")
|
||||
// public R<Map<String,Object>> logWarn() {
|
||||
// return service.logWarn();
|
||||
// }
|
||||
@ApiOperation(value = "查询日志告警")
|
||||
@GetMapping("logWarn")
|
||||
public AjaxResult logWarn() {
|
||||
service.handleWarningLog();
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class SysUserController extends BaseController {
|
|||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
@GetMapping("/list")
|
||||
@PreventRepeatSubmit
|
||||
// @SysLog(title = "用户管理", businessType = OperaType.QUERY, logType = 0, module = "系统管理->用户管理", details = "查询用户列表")
|
||||
@SysLog(title = "用户管理", businessType = OperaType.QUERY, logType = 0, module = "系统管理->用户管理", details = "查询用户列表")
|
||||
public TableDataInfo list(SysUser user) {
|
||||
try {
|
||||
startPage();
|
||||
|
|
@ -229,10 +229,6 @@ public class SysUserController extends BaseController {
|
|||
ajax.put("user", user);
|
||||
ajax.put("roles", roles);
|
||||
ajax.put("permissions", permissions);
|
||||
//在系统管理员和审计管理员登录时处理警告日志
|
||||
if(roles.contains("admin") || roles.contains("audit") || roles.contains("systemAdmin")){
|
||||
sysLogService.handleWarningLog();
|
||||
}
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.system.service.impl;
|
||||
|
||||
import com.bonus.config.SystemConfig;
|
||||
import com.bonus.system.warning.SysWarning;
|
||||
import com.bonus.system.warning.WaringLogEvent;
|
||||
import com.google.common.collect.Maps;
|
||||
|
|
@ -25,6 +26,7 @@ import org.springframework.scheduling.annotation.Async;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -69,7 +71,7 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
}
|
||||
mapper.saveLogs(sysLog);
|
||||
if (sysLog.getLogType() == 2) {
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(sysLog.getLogId(),sysLog.getErrType() ,sysLog.getIp(),sysLog.getOperaUserName(),sysLog.getOperTime())));
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(sysLog.getLogId(),sysLog.getErrType() ,sysLog.getIp(),sysLog.getOperaUserName(),sysLog.getOperTime(),"0")));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("保存系统日志");
|
||||
|
|
@ -83,8 +85,8 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
try{
|
||||
String loginUuid = IdUtils.fastUUID();
|
||||
String ip = IpUtils.getIpAddr(request);
|
||||
sysLog.setLogId(loginUuid);
|
||||
sysLog.setIp(ip);
|
||||
sysLog.setLogId(loginUuid);
|
||||
sysLog.setGrade("高");
|
||||
sysLog.setErrType("越权访问");
|
||||
sysLog.setFailureReason("页面未授权");
|
||||
|
|
@ -110,7 +112,7 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
}
|
||||
mapper.saveLogs(sysLog);
|
||||
if (sysLog.getLogType() == 2) {
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(loginUuid, "越权访问", ip, user.getUsername(), DateUtils.getTime())));
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(loginUuid, "越权访问", ip, user.getUsername(), DateUtils.getTime(),"0")));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
@ -143,7 +145,7 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
try{
|
||||
String capacity=mapper.getLogsSet();
|
||||
if(StringUtils.isEmpty(capacity)){
|
||||
return R.ok("1024");
|
||||
return R.ok("1");
|
||||
}
|
||||
return R.ok(capacity);
|
||||
}catch (Exception e){
|
||||
|
|
@ -165,12 +167,12 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
return R.fail("请输入数字");
|
||||
}
|
||||
}else{
|
||||
return R.fail("日志容量最低是"+SystemGlobal.LOG_DEFEAT_SIZE+"Mb");
|
||||
return R.fail("日志容量最低是"+SystemGlobal.LOG_DEFEAT_SIZE+"GB");
|
||||
}
|
||||
|
||||
Double cap=Double.parseDouble(capacity);
|
||||
if(cap<SystemGlobal.LOG_DEFEAT_SIZE){
|
||||
return R.fail("日志容量最低是"+SystemGlobal.LOG_DEFEAT_SIZE+"Mb");
|
||||
return R.fail("日志容量最低是"+SystemGlobal.LOG_DEFEAT_SIZE+"GB");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
@ -187,7 +189,7 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
log.error(e.toString(),e);
|
||||
return R.fail("系统异常");
|
||||
}
|
||||
return R.ok("设置成功","'设置成功'");
|
||||
return R.ok("设置成功","设置成功");
|
||||
}
|
||||
public final static String SUCCESS="成功";
|
||||
/**
|
||||
|
|
@ -272,8 +274,8 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
Double d=Double.parseDouble(rl);
|
||||
Double max=Double.parseDouble(city)*bfb;
|
||||
if(d>=max){
|
||||
String warningEvent = "日志容量告警,当日日志内存为" +d+ "MB,日志内存超过总内存的90%,请及时处理!";
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning("0",warningEvent,"",null,null)));
|
||||
String warningEvent = "日志容量告警,当日日志内存为" +d+ "GB,日志内存超过总内存的90%,请及时处理!";
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning("0",warningEvent,"",null,null, "1")));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.toString(),e);
|
||||
|
|
@ -286,7 +288,7 @@ public class SysLogServiceImpl implements ISysLogService {
|
|||
List<SysLogsVo> list = mapper.getNotHandleWarningLog();
|
||||
// 使用for-each循环遍历List
|
||||
for (SysLogsVo item : list) {
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(item.getLogId(),item.getErrType(), item.getIp(),item.getOperaUserName(),item.getOperTime())));
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(item.getLogId(),item.getErrType(), item.getIp(),item.getOperaUserName(),item.getOperTime(),"0")));
|
||||
log.info("*****系统管理员和审计管理员处理异常日志*******");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
|
|||
public int addLogs(SysLogsVo sysLogsVo) {
|
||||
if (sysLogsVo.getLogType() == 2) {
|
||||
sysLogsVo.setWarningStatus("0");
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(sysLogsVo.getLogId(), sysLogsVo.getErrType(), sysLogsVo.getIp(), sysLogsVo.getOperaUserName(), sysLogsVo.getOperTime())));
|
||||
eventPublisher.publishEvent(new WaringLogEvent(new SysWarning(sysLogsVo.getLogId(), sysLogsVo.getErrType(), sysLogsVo.getIp(), sysLogsVo.getOperaUserName(), sysLogsVo.getOperTime(), "0")));
|
||||
}
|
||||
return operLogMapper.addLogs(sysLogsVo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ import java.util.Date;
|
|||
@Data
|
||||
public class SysWarning {
|
||||
|
||||
public SysWarning(String warningId,String warningEvent,String warningIp,String operaUserName,String operaTime ){
|
||||
public SysWarning(String warningId,String warningEvent,String warningIp,String operaUserName,String operaTime, String warningStatus){
|
||||
this.warningId = warningId;
|
||||
this.warningEvent = warningEvent;
|
||||
this.warningIp = warningIp;
|
||||
this.operaUserName = operaUserName;
|
||||
this.operaTime = operaTime;
|
||||
this.warningStatus = warningStatus;
|
||||
}
|
||||
private String warningId;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.system.warning;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bonus.common.core.utils.SpringUtils;
|
||||
import com.bonus.system.service.ISysLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
|
@ -24,9 +25,6 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
|||
private static final Logger logger = LoggerFactory.getLogger(WebSocketHandler.class);
|
||||
private static final CopyOnWriteArrayList<WebSocketSession> sessions = new CopyOnWriteArrayList<>();
|
||||
|
||||
@Resource(name = "ISysLogService")
|
||||
private ISysLogService logService;
|
||||
|
||||
public static void closeSession(WebSocketSession session) throws IOException {
|
||||
session.close();
|
||||
}
|
||||
|
|
@ -42,7 +40,7 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
|||
String jsonStr = JSON.toJSONString(warning);
|
||||
sendMessageToAll(jsonStr);
|
||||
} catch (Exception e) {
|
||||
System.out.print("处理日志告警失败");
|
||||
logger.error("处理日志告警失败" + event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +51,7 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
|||
@EventListener
|
||||
public void handleWebSocketConnectListener(SessionConnectedEvent event) {
|
||||
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
|
||||
System.out.println("WebSocket 连接建立,Session ID: " + headerAccessor.getSessionId());
|
||||
logger.debug("WebSocket 连接建立,Session ID: " + headerAccessor.getSessionId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,35 +61,36 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
|||
@EventListener
|
||||
public void handleWebSocketDisconnectListener(SessionDisconnectEvent event) {
|
||||
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
|
||||
System.out.println("WebSocket 连接断开,Session ID: " + headerAccessor.getSessionId());
|
||||
logger.debug("WebSocket 连接断开,Session ID: " + headerAccessor.getSessionId());
|
||||
}
|
||||
|
||||
// 处理用户确认消息
|
||||
@MessageMapping("/alert-handled")
|
||||
public void handleAlert(String alertId) {
|
||||
// 在这里处理告警确认逻辑
|
||||
System.out.println("Alert " + alertId + " has been handled");
|
||||
logger.debug("Alert " + alertId + " has been handled");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
sessions.add(session);
|
||||
logger.info("WebSocket 连接成功: " + session.getId());
|
||||
logger.debug("WebSocket 连接成功: " + session.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
|
||||
String payload = message.getPayload();
|
||||
logger.info("接收到消息: " + payload);
|
||||
logger.debug("接收到消息: " + payload);
|
||||
|
||||
ISysLogService logService = SpringUtils.getBean(ISysLogService.class);
|
||||
logService.updateLogsWithHandledStatus(payload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||
sessions.remove(session);
|
||||
logger.info("WebSocket 连接关闭: " + session.getId());
|
||||
logger.debug("WebSocket 连接关闭: " + session.getId());
|
||||
}
|
||||
|
||||
public void sendMessageToAll(String message) throws Exception {
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@
|
|||
</select>
|
||||
<select id="getLogsRl" resultType="java.lang.String">
|
||||
SELECT
|
||||
round(((data_length + index_length) / 1024 / 1024), 2) AS 'Size in MB'
|
||||
round(((data_length + index_length) / 1024 / 1024 / 1024), 2) AS 'Size in GB'
|
||||
FROM information_schema.TABLES
|
||||
WHERE table_schema = 'bns-cloud' AND table_name = 'sys_logs'
|
||||
</select>
|
||||
|
|
@ -270,7 +270,7 @@
|
|||
SELECT
|
||||
log_id logId, opera_user_name operaUserName,ip,
|
||||
user_id userId, oper_time operTime,
|
||||
oper_type operType
|
||||
oper_type operType, err_type errType
|
||||
FROM sys_logs
|
||||
where warning_status=0
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ create table sys_dept (
|
|||
-- ----------------------------
|
||||
-- 初始化-部门表数据
|
||||
-- ----------------------------
|
||||
insert into sys_dept values(100, 0, '0', '博诺思信息科技有限公司', 0, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(101, 100, '0,100', '合肥总公司', 1, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(102, 100, '0,100', '宿州分公司', 2, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(103, 101, '0,100,101', '研发部门', 1, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(104, 101, '0,100,101', '市场部门', 2, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(105, 101, '0,100,101', '测试部门', 3, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(106, 101, '0,100,101', '财务部门', 4, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(107, 101, '0,100,101', '运维部门', 5, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(108, 102, '0,100,102', '市场部门', 1, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(109, 102, '0,100,102', '财务部门', 2, '博诺思', '15888888888', 'xiaosi@ahbonus.com', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(100, 0, '0', '博诺思信息科技有限公司', 0, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(101, 100, '0,100', '合肥总公司', 1, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(102, 100, '0,100', '宿州分公司', 2, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(103, 101, '0,100,101', '研发部门', 1, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(104, 101, '0,100,101', '市场部门', 2, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(105, 101, '0,100,101', '测试部门', 3, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(106, 101, '0,100,101', '财务部门', 4, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(107, 101, '0,100,101', '运维部门', 5, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(108, 102, '0,100,102', '市场部门', 1, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
insert into sys_dept values(109, 102, '0,100,102', '财务部门', 2, '博诺思', '5b55c99f4df0945eed334f450b7f8aa5', '6808c5cacbe63dcd24944a4ee5d87956d26feac836c13cac1a478c1fc47f9531', '0', '0', 'admin', sysdate(), '', null);
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
|
@ -68,20 +68,11 @@ create table sys_user (
|
|||
primary key (user_id)
|
||||
) engine=innodb auto_increment=100 comment = '用户信息表';
|
||||
|
||||
ALTER TABLE `bns-cloud`.sys_user ADD is_permanent char(1) DEFAULT '1' NULL COMMENT '长期和临时用户标识0:临时用户,1:长期用户';
|
||||
ALTER TABLE `bns-cloud`.sys_user ADD is_built_in char(1) DEFAULT '1' NULL COMMENT '是否内置用户0:内置用户,1:非内置用户';
|
||||
|
||||
ALTER TABLE `bns-cloud`.sys_dept MODIFY COLUMN phone varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '联系电话';
|
||||
ALTER TABLE `bns-cloud`.sys_dept MODIFY COLUMN email varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '邮箱';
|
||||
|
||||
ALTER TABLE `bns-cloud`.sys_user MODIFY COLUMN email varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' NULL COMMENT '用户邮箱';
|
||||
ALTER TABLE `bns-cloud`.sys_user MODIFY COLUMN phonenumber varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' NULL COMMENT '手机号码';
|
||||
|
||||
-- ----------------------------
|
||||
-- 初始化-用户信息表数据
|
||||
-- ----------------------------
|
||||
insert into sys_user values(1, 103, 'bonus', '博诺思', '00', '38fb2b6be1e8b9024b0140fc673f0ed245b6b82ae6464387bbe806dc68e66fa8', '4eb762402e0ce5ef9d0028e2d622c53bc8ea1d7680ea4416975e4cc23b4ef7f0', '1', '', '$2a$10$5azz92OgGRyRUETz/ZJeZu1exkggPYUDRssvreywTjKk.0Pmn2Q16', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null,sysdate(), '系统管理员','0','0','1');
|
||||
insert into sys_user values(2, 103, 'audit', '博诺思', '00', '38fb2b6be1e8b9024b0140fc673f0ed245b6b82ae6464387bbe806dc68e66fa8', '4eb762402e0ce5ef9d0028e2d622c53bc8ea1d7680ea4416975e4cc23b4ef7f0', '1', '', '$2a$10$5azz92OgGRyRUETz/ZJeZu1exkggPYUDRssvreywTjKk.0Pmn2Q16', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null,sysdate(),'审计管理员','0','0','1');
|
||||
insert into sys_user values(1, 103, 'bonus', '博诺思', '00', '6668e3b17f15bf95c947d2e846aa39d2', '52d5f4cd548656484535afd493651f40', '1', '', 'a45acb66346098aa606768ee404e2c3c', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null,sysdate(), '系统管理员','0','0','1');
|
||||
insert into sys_user values(2, 103, 'audit', '博诺思', '00', '6668e3b17f15bf95c947d2e846aa39d2', '52d5f4cd548656484535afd493651f40', '1', '', 'a45acb66346098aa606768ee404e2c3c', '0', '0', '127.0.0.1', sysdate(), 'admin', sysdate(), '', null,sysdate(),'审计管理员','0','0','1');
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
|
|
@ -136,8 +127,6 @@ create table sys_role (
|
|||
primary key (role_id)
|
||||
) engine=innodb auto_increment=100 comment = '角色信息表';
|
||||
|
||||
ALTER TABLE `bns-cloud`.sys_role ADD is_built_in char(1) DEFAULT '1' NULL COMMENT '是否内置0:非内置角色,1:内置角色';
|
||||
|
||||
----------------------
|
||||
-- 初始化-角色信息表数据
|
||||
-- ----------------------------
|
||||
|
|
@ -295,6 +284,16 @@ INSERT INTO `sys_menu` VALUES (2012, '查询', 2011, 1, '', NULL, NULL, 1, 0, 'F
|
|||
INSERT INTO `sys_menu` VALUES (2013, '修改', 2011, 2, '', NULL, NULL, 1, 0, 'F', '0', '0', NULL, '#', 'admin', '2024-07-16 07:25:56', '', NULL, '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2014, '报警', 2011, 3, '', NULL, NULL, 1, 0, 'F', '0', '0', NULL, '#', 'admin', '2024-07-16 07:26:08', '', NULL, '', '0');
|
||||
|
||||
INSERT INTO `sys_menu` VALUES (2020, '白名单管理', 1, 1, 'ipWhitelist', 'system/ipWhitelist/index', NULL, 1, 0, 'C', '0', '0', 'system:whitelist:list', 'clipboard', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:28:51', '【请填写功能名称】菜单', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2021, '查询', 2020, 1, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:query', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:24:56', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2022, '新增', 2020, 2, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:add', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:05', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2023, '修改', 2020, 3, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:edit', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:13', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2024, '删除', 2020, 4, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:remove', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:20', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2025, '导出', 2020, 5, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:export', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:28', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2026, '用户锁定', 1, 7, 'lockUser', 'system/lockUser/index', NULL, 1, 0, 'C', '0', '0', NULL, 'radio', 'bonus_admin', '2024-11-07 03:10:44', '', NULL, '', '0');
|
||||
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- 6、用户和角色关联表 用户N-1角色
|
||||
-- ----------------------------
|
||||
|
|
@ -759,6 +758,7 @@ create table sys_logs (
|
|||
method_type varchar(30) NULL DEFAULT NULL COMMENT '方法类型 POST/个体',
|
||||
title varchar(255) NULL DEFAULT NULL,
|
||||
result_data varchar(3000) NULL DEFAULT NULL COMMENT '返回数据',
|
||||
warning_status char(1) NULL DEFAULT '1' NULL COMMENT'0未处理,1已处理'
|
||||
PRIMARY KEY (log_id) USING BTREE
|
||||
) engine = innodb comment = '系统日志表' ;
|
||||
|
||||
|
|
@ -770,36 +770,4 @@ create table sys_logs_set (
|
|||
capacity varchar(255) NULL DEFAULT NULL
|
||||
) engine = innodb comment = '数据库日志容量设置表';
|
||||
|
||||
insert into sys_logs_set values ('2048');
|
||||
|
||||
-- ------------------------------
|
||||
-- 22 waring table
|
||||
-- ------------------------------
|
||||
drop table if exists sys_warning;
|
||||
create table sys_warning (
|
||||
warning_id bigint(20) not null auto_increment comment '编号',
|
||||
warning_event varchar(50) default '' comment '告警事件',
|
||||
warning_content varchar(50) default '' comment '告警内容',
|
||||
warning_ip varchar(50) default '' comment '告警IP',
|
||||
warning_grade varchar(50) default '' comment '告警等级',
|
||||
opera_user_name varchar(50) default '' comment '操作人名称',
|
||||
warning_time datetime default sysdate comment '告警时间',
|
||||
warning_status char(1) default '0' comment '告警状态0未处理,1已处理',
|
||||
primary key (warning_id)
|
||||
) engine = innodb comment = '报警日志表';
|
||||
|
||||
|
||||
drop table if exists sys_ip_whitelist;
|
||||
CREATE TABLE `sys_ip_whitelist` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单个IP地址',
|
||||
`ip_range_start` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP网段起始地址',
|
||||
`ip_range_end` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP网段结束地址',
|
||||
`access_start_time` timestamp NULL DEFAULT NULL COMMENT '允许访问的开始时间',
|
||||
`access_end_time` timestamp NULL DEFAULT NULL COMMENT '允许访问的结束时间',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
|
||||
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '帐号状态(0正常 1停用)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = innodb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
insert into sys_logs_set values ('1');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE sys_user ADD is_permanent char(1) DEFAULT '1' NULL COMMENT '长期和临时用户标识0:临时用户,1:长期用户';
|
||||
ALTER TABLE sys_user ADD is_built_in char(1) DEFAULT '1' NULL COMMENT '是否内置用户0:内置用户,1:非内置用户';
|
||||
|
||||
ALTER TABLE sys_dept MODIFY COLUMN phone varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '联系电话';
|
||||
ALTER TABLE sys_dept MODIFY COLUMN email varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '邮箱';
|
||||
|
||||
ALTER TABLE sys_user MODIFY COLUMN email varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' NULL COMMENT '用户邮箱';
|
||||
ALTER TABLE sys_user MODIFY COLUMN phonenumber varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' NULL COMMENT '手机号码';
|
||||
|
||||
ALTER TABLE sys_role ADD is_built_in char(1) DEFAULT '1' NULL COMMENT '是否内置0:内置角色,1:非内置角色';
|
||||
|
||||
ALTER TABLE sys_logs
|
||||
ADD COLUMN warning_status CHAR(1) NULL DEFAULT '1' COMMENT '0未处理,1已处理';
|
||||
|
||||
ALTER TABLE sys_logs_set MODIFY COLUMN capacity varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '1' NULL COMMENT '单位是GB';
|
||||
|
||||
-- ------------------------------
|
||||
-- 22 waring table
|
||||
-- ------------------------------
|
||||
drop table if exists sys_warning;
|
||||
create table sys_warning (
|
||||
warning_id bigint(20) not null auto_increment comment '编号',
|
||||
warning_event varchar(50) default '' comment '告警事件',
|
||||
warning_content varchar(50) default '' comment '告警内容',
|
||||
warning_ip varchar(50) default '' comment '告警IP',
|
||||
warning_grade varchar(50) default '' comment '告警等级',
|
||||
opera_user_name varchar(50) default '' comment '操作人名称',
|
||||
warning_time datetime default NULL comment '告警时间',
|
||||
warning_status char(1) default '0' comment '告警状态0未处理,1已处理',
|
||||
primary key (warning_id)
|
||||
) engine = innodb comment = '报警日志表';
|
||||
|
||||
|
||||
drop table if exists sys_ip_whitelist;
|
||||
CREATE TABLE `sys_ip_whitelist` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '单个IP地址',
|
||||
`ip_range_start` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP网段起始地址',
|
||||
`ip_range_end` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'IP网段结束地址',
|
||||
`access_start_time` timestamp NULL DEFAULT NULL COMMENT '允许访问的开始时间',
|
||||
`access_end_time` timestamp NULL DEFAULT NULL COMMENT '允许访问的结束时间',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
|
||||
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '帐号状态(0正常 1停用)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = innodb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
|
||||
INSERT INTO `sys_menu` VALUES (2020, '白名单管理', 1, 1, 'ipWhitelist', 'system/ipWhitelist/index', NULL, 1, 0, 'C', '0', '0', 'system:whitelist:list', 'clipboard', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:28:51', '【请填写功能名称】菜单', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2021, '查询', 2020, 1, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:query', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:24:56', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2022, '新增', 2020, 2, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:add', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:05', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2023, '修改', 2020, 3, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:edit', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:13', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2024, '删除', 2020, 4, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:remove', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:20', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2025, '导出', 2020, 5, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:whitelist:export', '#', 'admin', '2024-11-06 06:23:22', 'bonus_admin', '2024-11-06 06:25:28', '', '0');
|
||||
INSERT INTO `sys_menu` VALUES (2026, '用户锁定', 1, 7, 'lockUser', 'system/lockUser/index', NULL, 1, 0, 'C', '0', '0', NULL, 'radio', 'bonus_admin', '2024-11-07 03:10:44', '', NULL, '', '0');
|
||||
Loading…
Reference in New Issue