From 7abc35c9d7977820f6a1e704ec0c5ae565e439dc Mon Sep 17 00:00:00 2001 From: xxxllluuu Date: Tue, 9 Feb 2021 16:15:56 +0800 Subject: [PATCH] https://github.com/edp963/davinci/issues/2148 1. fix it --- .../java/edp/davinci/core/utils/SqlParseUtils.java | 6 ++++-- .../java/edp/davinci/service/impl/UserServiceImpl.java | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/edp/davinci/core/utils/SqlParseUtils.java b/server/src/main/java/edp/davinci/core/utils/SqlParseUtils.java index c6dd3a5e8..b6497ed0f 100644 --- a/server/src/main/java/edp/davinci/core/utils/SqlParseUtils.java +++ b/server/src/main/java/edp/davinci/core/utils/SqlParseUtils.java @@ -278,7 +278,6 @@ public List getSqls(String sqlStr, boolean isQuery) { String[] sqls = sqlStr.split(SEMICOLON); if (sqls.length > 0) { for (String sql : sqls) { - sql = sql.trim(); boolean select = isQuery(sql); if (isQuery) { if (select) { @@ -297,11 +296,14 @@ public List getSqls(String sqlStr, boolean isQuery) { } private boolean isQuery(String sql) { + + sql = sql.trim(); + if (sql.toLowerCase().startsWith(SELECT) || sql.toLowerCase().startsWith(WITH)) { return true; } - String temp = filterAnnotate(sql); + String temp = filterAnnotate(sql).trim(); return temp.toLowerCase().startsWith(SELECT) || temp.toLowerCase().startsWith(WITH); } diff --git a/server/src/main/java/edp/davinci/service/impl/UserServiceImpl.java b/server/src/main/java/edp/davinci/service/impl/UserServiceImpl.java index 11014359b..81e91a60a 100644 --- a/server/src/main/java/edp/davinci/service/impl/UserServiceImpl.java +++ b/server/src/main/java/edp/davinci/service/impl/UserServiceImpl.java @@ -470,7 +470,7 @@ public ResultMap uploadAvatar(User user, MultipartFile file, HttpServletRequest //校验文件是否图片 if (!fileUtils.isImage(file)) { - return resultMap.failAndRefreshToken(request).message("file format error"); + return resultMap.failAndRefreshToken(request).message("File format error"); } //上传文件 @@ -479,7 +479,7 @@ public ResultMap uploadAvatar(User user, MultipartFile file, HttpServletRequest try { avatar = fileUtils.upload(file, Constants.USER_AVATAR_PATH, fileName); if (StringUtils.isEmpty(avatar)) { - return resultMap.failAndRefreshToken(request).message("user avatar upload error"); + return resultMap.failAndRefreshToken(request).message("User avatar upload error"); } } catch (Exception e) { log.error("User avatar upload error, username:{}", user.getUsername(), e); @@ -500,7 +500,7 @@ public ResultMap uploadAvatar(User user, MultipartFile file, HttpServletRequest return resultMap.successAndRefreshToken(request).payload(map); } - return resultMap.failAndRefreshToken(request).message("server error, user avatar update fail"); + return resultMap.failAndRefreshToken(request).message("Server error, user avatar update fail"); } @@ -518,7 +518,7 @@ public ResultMap getUserProfile(Long id, User user, HttpServletRequest request) User tempUser = userMapper.getById(id); if (null == tempUser) { - return resultMap.failAndRefreshToken(request).message("user not found"); + return resultMap.failAndRefreshToken(request).message("User not found"); } UserProfile userProfile = new UserProfile(); @@ -578,7 +578,7 @@ public String forgetPassword(UserDistinctType userDistinctType, UserDistinctTick case USERNAME: String username = ticket.getTicket(); if (StringUtils.isEmpty(username)) { - throw new ServerException("username cannot be EMPTY!"); + throw new ServerException("Username cannot be EMPTY!"); } user = userMapper.selectByUsername(username); if (user == null) {