修复bug
This commit is contained in:
parent
ca5066e21e
commit
00a719d9ba
|
|
@ -11,6 +11,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
import javax.validation.constraints.Email;
|
import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -194,7 +195,7 @@ public class SysUser extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Xss(message = "用户昵称不能包含脚本字符")
|
@Xss(message = "用户昵称不能包含脚本字符")
|
||||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
@Size(min = 0, max = 20, message = "用户昵称长度不能超过20个字符")
|
||||||
public String getNickName() {
|
public String getNickName() {
|
||||||
return nickName;
|
return nickName;
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +206,7 @@ public class SysUser extends BaseEntity {
|
||||||
|
|
||||||
@Xss(message = "用户账号不能包含脚本字符")
|
@Xss(message = "用户账号不能包含脚本字符")
|
||||||
@NotBlank(message = "用户账号不能为空")
|
@NotBlank(message = "用户账号不能为空")
|
||||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
@Size(min = 0, max = 20, message = "用户账号长度不能超过20个字符")
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
@ -215,7 +216,7 @@ public class SysUser extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Email(message = "邮箱格式不正确")
|
@Email(message = "邮箱格式不正确")
|
||||||
// @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +225,7 @@ public class SysUser extends BaseEntity {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
@Pattern(regexp = "^\\d{11}$", message = "手机号码只能包含11位数字")
|
||||||
public String getPhonenumber() {
|
public String getPhonenumber() {
|
||||||
return phonenumber;
|
return phonenumber;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class Sm4Utils {
|
||||||
* 加密数据,使用固定盐
|
* 加密数据,使用固定盐
|
||||||
*
|
*
|
||||||
* @param plainText 明文,待加密的字符串
|
* @param plainText 明文,待加密的字符串
|
||||||
* @return 加密后的密文(包含盐),Hex 编码格式
|
* @return 加密后的密文(包含盐),Hex 编码格式,如果加密异常就返回传入的字符串
|
||||||
*/
|
*/
|
||||||
public static String encrypt(String plainText) {
|
public static String encrypt(String plainText) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -29,8 +29,7 @@ public class Sm4Utils {
|
||||||
// 返回带盐的加密结果(Hex编码)
|
// 返回带盐的加密结果(Hex编码)
|
||||||
return HexUtil.encodeHexStr(encryptedData);
|
return HexUtil.encodeHexStr(encryptedData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
return plainText; // 发生异常时返回null
|
||||||
return null; // 发生异常时返回null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,7 +37,7 @@ public class Sm4Utils {
|
||||||
* 解密数据,使用固定盐
|
* 解密数据,使用固定盐
|
||||||
*
|
*
|
||||||
* @param cipherText 密文(包含盐),Hex 编码格式的字符串
|
* @param cipherText 密文(包含盐),Hex 编码格式的字符串
|
||||||
* @return 解密后的明文字符串
|
* @return 解密后的明文字符串,如果解密异常就返回传入的字符串
|
||||||
*/
|
*/
|
||||||
public static String decrypt(String cipherText) {
|
public static String decrypt(String cipherText) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -48,8 +47,7 @@ public class Sm4Utils {
|
||||||
byte[] decryptedData = sm4.decrypt(cipherText);
|
byte[] decryptedData = sm4.decrypt(cipherText);
|
||||||
return new String(decryptedData);
|
return new String(decryptedData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
return cipherText; // 发生异常时返回null
|
||||||
return null; // 发生异常时返回null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +61,7 @@ public class Sm4Utils {
|
||||||
System.out.println("加密后: " + encryptedText);
|
System.out.println("加密后: " + encryptedText);
|
||||||
|
|
||||||
// 解密密文
|
// 解密密文
|
||||||
String decryptedText = Sm4Utils.decrypt(encryptedText);
|
String decryptedText = Sm4Utils.decrypt(plainText);
|
||||||
System.out.println("解密后: " + decryptedText);
|
System.out.println("解密后: " + decryptedText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.bonus.common.core.utils.ServletUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||||
import com.bonus.system.api.model.LoginUser;
|
import com.bonus.system.api.model.LoginUser;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
|
@ -116,14 +117,25 @@ public class SecurityUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
//老的加密方式要保留,偶尔调试要用
|
||||||
|
// BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
// String encodePass = passwordEncoder.encode("Bonus$2026");
|
||||||
|
// System.out.println(encodePass);
|
||||||
|
// boolean result = passwordEncoder.matches("Bonus$2026", "$2a$10$0TaYZgPNd7eqpvsKx4KZnu0nPiSQlVn5SZZaJa2q6tLPuI9bWD0lW");
|
||||||
|
// System.out.println("result: " + result);
|
||||||
|
|
||||||
//$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2
|
//$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2
|
||||||
//$2a$10$zvlw3Mu8M.j.MhAChrYwluj88ziX6lVD3AoRrBQpwKMcdIZvKMoR2
|
//$2a$10$zvlw3Mu8M.j.MhAChrYwluj88ziX6lVD3AoRrBQpwKMcdIZvKMoR2
|
||||||
// String msg= encryptPassword("Admin@1234");
|
// String msg= encryptPassword("Admin@1234");
|
||||||
// String msg= encryptPassword("15888888888");
|
// String msg= encryptPassword("15888888888");
|
||||||
// boolean rest = matchesPassword("Bonus$2024","$2a$10$8JaKSUAU.K.mceU1.YQbd.wP4EJzbrsIscjAwPlfDR7wAWV6s/BGa");
|
// boolean rest = matchesPassword("Bonus$2024","$2a$10$8JaKSUAU.K.mceU1.YQbd.wP4EJzbrsIscjAwPlfDR7wAWV6s/BGa");
|
||||||
String msg = Sm4Utils.encrypt("Bonus$2026");
|
String msg = Sm4Utils.encrypt("18956025265");
|
||||||
// String msg = Sm4Utils.decrypt("4eb762402e0ce5ef9d0028e2d622c53bc8ea1d7680ea4416975e4cc23b4ef7f0");
|
|
||||||
System.err.println(msg);
|
System.err.println(msg);
|
||||||
|
|
||||||
|
String msg1 = Sm4Utils.encrypt("1895");
|
||||||
|
System.err.println(msg1);
|
||||||
|
// String msg = Sm4Utils.decrypt("4eb762402e0ce5ef9d0028e2d622c53bc8ea1d7680ea4416975e4cc23b4ef7f0");
|
||||||
|
|
||||||
// System.err.println(rest);
|
// System.err.println(rest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,13 +78,11 @@ public class SysUserController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("system:user:list"))
|
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||||
@GetMapping("/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) {
|
public TableDataInfo list(SysUser user) {
|
||||||
try {
|
try {
|
||||||
startPage();
|
startPage();
|
||||||
List<SysUser> list = userService.selectUserList(user);
|
List<SysUser> list = userService.selectUserList(user);
|
||||||
webSocketHandler.sendMessageToAll("213123");
|
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.toString(), e);
|
logger.error(e.toString(), e);
|
||||||
|
|
|
||||||
|
|
@ -562,7 +562,14 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
failureNum++;
|
failureNum++;
|
||||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||||
|
//修复禅道bug 4076,wangweiwei 2024/12/16
|
||||||
|
String message = e.getMessage();
|
||||||
|
if (message != null && message.contains(":")) {
|
||||||
|
// 去掉冒号及其前面的字段名部分
|
||||||
|
failureMsg.append(msg + message.substring(message.indexOf(":") + 2).trim());
|
||||||
|
}else {
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
|
}
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue