--修改函数失败没有回滚问题

This commit is contained in:
2025-11-06 17:16:47 +08:00
parent 57df202f6d
commit 12583611d9
3 changed files with 37 additions and 6 deletions

View File

@ -21,4 +21,15 @@ public interface ExceptionCommonCode {
* 执行数据库函数失败
*/
final BusinessCode DB_FUNCTION_EXEC_ERROR = BusinessCode.of(10511,"执行数据库函数失败:【{}】");
/**
* 执行数据库函数失败
*/
final BusinessCode DB_FUNCTION_SAVE_EXEC_ERROR = BusinessCode.of(10512,"保存函数失败:【{}】");
final BusinessCode DB_FUNCTION_DELETE_EXEC_ERROR = BusinessCode.of(10513,"删除函数失败:【{}】");
final BusinessCode DB_FUNCTION_ENABLE_EXEC_ERROR = BusinessCode.of(10514,"启用函数失败:【{}】");
final BusinessCode DB_FUNCTION_DISABLE_EXEC_ERROR = BusinessCode.of(10515,"作废函数失败:【{}】");
}

View File

@ -3,6 +3,10 @@ package com.xjrsoft.module.common.db.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.pictc.enums.BusinessCode;
import com.pictc.enums.ExceptionCommonCode;
import com.pictc.utils.StringUtils;
import com.xjrsoft.common.exception.BusinessException;
import com.xjrsoft.module.common.db.service.CommonCallService;
/**
@ -31,7 +35,11 @@ public class CommonCallUtils {
* @return String 返回类型 函数返回非空、或者数据库异常时rollback函数返回空时commit
*/
public static String saveAfter(String table,long id) {
return callService.saveAfter(table, id);
String error = callService.saveAfter(table, id);
if(StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_SAVE_EXEC_ERROR,error));
}
return error;
}
/**
@ -43,7 +51,11 @@ public class CommonCallUtils {
* @return String 返回类型
*/
public static String deleteBefore(String table,Long id) {
return callService.deleteBefore(table, id);
String error = callService.deleteBefore(table, id);
if(StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR,error));
}
return error;
}
@ -56,7 +68,11 @@ public class CommonCallUtils {
* @return String 返回类型
*/
public static String disableBefore(String table,Long id) {
return callService.disableBefore(table, id);
String error = callService.disableBefore(table, id);
if(StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DISABLE_EXEC_ERROR,error));
}
return error;
}
@ -68,7 +84,11 @@ public class CommonCallUtils {
* @return String 返回类型
*/
public static String enableBefore(String table,Long id) {
return callService.enableBefore(table, id);
String error = callService.enableBefore(table, id);
if(StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_ENABLE_EXEC_ERROR,error));
}
return error;
}

View File

@ -23,7 +23,7 @@
</modules>
<properties>
<revision>2.0.8</revision>
<revision>2.0.4</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>8</java.version>
@ -43,7 +43,7 @@
<dependency>
<groupId>com.geg</groupId>
<artifactId>itc-framework-ms</artifactId>
<version>2.0.8</version>
<version>${revision}</version>
<type>pom</type>
<scope>import</scope>
</dependency>