This commit is contained in:
ran.shang
2026-01-08 14:33:33 +08:00
parent 2b4458dc1b
commit 5405012faa
45 changed files with 1716 additions and 209 deletions

View File

@@ -311,7 +311,7 @@ public class RedissonUtils {
return null;
}
/**
* 校验上锁保存(有事务幂等)
* @param <T>
@@ -319,19 +319,19 @@ public class RedissonUtils {
* @param existSupplier
* @param saveSupplier
* @return
* @author sr on 2024-04-18
* @author sr on 2024-04-18
*/
public static <T extends IBaseDTO> Long lockAndSave(LockDTO lockDTO, Supplier<T> existSupplier,
Supplier<Long> saveSupplier) {
public static <T extends IBaseDTO> T lockAndSave(LockDTO lockDTO, Supplier<T> existSupplier,
Supplier<T> saveSupplier) {
return lockAndSave(lockDTO, existSupplier, saveSupplier, true, null);
}
public static <T extends IBaseDTO> Long lockAndSave(LockDTO lockDTO, Supplier<T> existSupplier,
Supplier<Long> saveSupplier, String existMsg) {
public static <T extends IBaseDTO> T lockAndSave(LockDTO lockDTO, Supplier<T> existSupplier,
Supplier<T> saveSupplier, String existMsg) {
return lockAndSave(lockDTO, existSupplier, saveSupplier, true, existMsg);
}
/**
* 校验上锁保存
* @param <T>
@@ -341,14 +341,14 @@ public class RedissonUtils {
* @param hasTransaction 当前是否有事务
* @param existMsg 存在抛的异常消息,空则不抛异常返回id
* @return
* @author sr on 2024-04-18
* @author sr on 2024-04-18
*/
public static <T extends IBaseDTO> Long lockAndSave(LockDTO lockDTO, Supplier<T> existSupplier,
Supplier<Long> saveSupplier, boolean hasTransaction, String existMsg) throws ExistException{
public static <T extends IBaseDTO> T lockAndSave(LockDTO lockDTO, Supplier<T> existSupplier,
Supplier<T> saveSupplier, boolean hasTransaction, String existMsg) throws ExistException {
IBaseDTO baseDTO = existSupplier.get();
if (baseDTO != null) {
if (StringUtils.isBlank(existMsg)) {
return baseDTO.getId();
return (T) baseDTO;
} else {
throw new ExistException(existMsg);
}
@@ -358,7 +358,7 @@ public class RedissonUtils {
baseDTO = existSupplier.get();
if (baseDTO != null) {
if (StringUtils.isBlank(existMsg)) {
return baseDTO.getId();
return (T) baseDTO;
} else {
throw new ExistException(existMsg);
}