fix: resolve invalid multi-catch hierarchy

This commit is contained in:
root
2026-03-17 04:06:10 +08:00
parent 60f4fce90b
commit d65f21dae2
2 changed files with 3 additions and 5 deletions

View File

@@ -23,7 +23,6 @@ import com.test.demo.vo.LoginVo;
import com.test.demo.vo.UserVo;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
@@ -109,7 +108,7 @@ public class AuthServiceImpl implements AuthService {
user.setStatus(UserStatusEnum.NORMAL);
try {
userService.save(user);
} catch (DuplicateKeyException | DataIntegrityViolationException ex) {
} catch (DataIntegrityViolationException ex) {
throw new BizException(ResultCode.CONFLICT, "用户名已存在");
}
}

View File

@@ -22,7 +22,6 @@ import com.test.demo.vo.UserVo;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@@ -73,7 +72,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
entity.setStatus(UserStatusEnum.NORMAL);
try {
save(entity);
} catch (DuplicateKeyException | DataIntegrityViolationException ex) {
} catch (DataIntegrityViolationException ex) {
throw new BizException(ResultCode.CONFLICT, "用户名已存在");
}
}
@@ -155,7 +154,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
entity.setStatus(UserStatusEnum.NORMAL);
try {
save(entity);
} catch (DuplicateKeyException | DataIntegrityViolationException ex) {
} catch (DataIntegrityViolationException ex) {
throw new BizException(ResultCode.CONFLICT, "导入失败,用户名已存在: " + row.getUsername());
}
}