fix: resolve invalid multi-catch hierarchy
This commit is contained in:
@@ -23,7 +23,6 @@ import com.test.demo.vo.LoginVo;
|
|||||||
import com.test.demo.vo.UserVo;
|
import com.test.demo.vo.UserVo;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ public class AuthServiceImpl implements AuthService {
|
|||||||
user.setStatus(UserStatusEnum.NORMAL);
|
user.setStatus(UserStatusEnum.NORMAL);
|
||||||
try {
|
try {
|
||||||
userService.save(user);
|
userService.save(user);
|
||||||
} catch (DuplicateKeyException | DataIntegrityViolationException ex) {
|
} catch (DataIntegrityViolationException ex) {
|
||||||
throw new BizException(ResultCode.CONFLICT, "用户名已存在");
|
throw new BizException(ResultCode.CONFLICT, "用户名已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import com.test.demo.vo.UserVo;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -73,7 +72,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||||||
entity.setStatus(UserStatusEnum.NORMAL);
|
entity.setStatus(UserStatusEnum.NORMAL);
|
||||||
try {
|
try {
|
||||||
save(entity);
|
save(entity);
|
||||||
} catch (DuplicateKeyException | DataIntegrityViolationException ex) {
|
} catch (DataIntegrityViolationException ex) {
|
||||||
throw new BizException(ResultCode.CONFLICT, "用户名已存在");
|
throw new BizException(ResultCode.CONFLICT, "用户名已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +154,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||||||
entity.setStatus(UserStatusEnum.NORMAL);
|
entity.setStatus(UserStatusEnum.NORMAL);
|
||||||
try {
|
try {
|
||||||
save(entity);
|
save(entity);
|
||||||
} catch (DuplicateKeyException | DataIntegrityViolationException ex) {
|
} catch (DataIntegrityViolationException ex) {
|
||||||
throw new BizException(ResultCode.CONFLICT, "导入失败,用户名已存在: " + row.getUsername());
|
throw new BizException(ResultCode.CONFLICT, "导入失败,用户名已存在: " + row.getUsername());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user