# Conflicts:
#	itc-pcitc-dependencies/itc-pcitc-dependencies-service/src/main/java/com/xjrsoft/module/common/db/utils/CommonCallUtils.java
This commit is contained in:
2025-11-06 17:20:29 +08:00
26 changed files with 801 additions and 824 deletions

View File

@ -16,80 +16,77 @@ import com.xjrsoft.module.common.db.service.CommonCallService;
*/
@Component
public class CommonCallUtils {
private static CommonCallService callService;
@Autowired
public void setCallService(CommonCallService callService) {
CommonCallUtils.callService = callService;
}
/**
* @Description:
一、新增、修改记录时,在同一个事务里执行如下过程:
1、更新表
2、调用数据库函数pc_表名.f_save(表主键)
3、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @Description:
* 一、新增、修改记录时,在同一个事务里执行如下过程:
* 1、更新表
* 2、调用数据库函数pc_表名.f_save(表主键)
* 3、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @param table 表名
* @param id 表主键
* @return String 返回类型 函数返回非空、或者数据库异常时rollback函数返回空时commit
* @param id 表主键
* @return String 返回类型 函数返回非空、或者数据库异常时rollback函数返回空时commit
*/
public static String saveAfter(String table,long 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;
}
/**
* @Description:
二、删除记录时,在同一个事务里执行如下过程:
1、调用数据库函数pc_表名.f_delete(表主键)
2、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @return
* @return String 返回类型
*/
public static String deleteBefore(String table,Long 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;
}
/**
* @Description:
二、停用时,在同一个事务里执行如下过程:
1、调用数据库函数pc_表名.f_off(表主键)
2、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @return
* @return String 返回类型
*/
public static String disableBefore(String table,Long 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;
}
/**
* @Description:
1、调用数据库函数pc_表名.f_on(表主键)
2、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @return
* @return String 返回类型
*/
public static String enableBefore(String table,Long id) {
String error = callService.enableBefore(table, id);
if(StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_ENABLE_EXEC_ERROR,error));
public static String saveAfter(String table, long 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;
}
/**
* @Description:
* 二、删除记录时,在同一个事务里执行如下过程:
* 1、调用数据库函数pc_表名.f_delete(表主键)
* 2、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @return
* @return String 返回类型
*/
public static String deleteBefore(String table, Long 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;
}
/**
* @Description:
* 二、停用时,在同一个事务里执行如下过程:
* 1、调用数据库函数pc_表名.f_off(表主键)
* 2、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @return
* @return String 返回类型
*/
public static String disableBefore(String table, Long 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;
}
/**
* @Description:
* 1、调用数据库函数pc_表名.f_on(表主键)
* 2、函数返回非空、或者数据库异常时rollback函数返回空时commit
* @return
* @return String 返回类型
*/
public static String enableBefore(String table, Long 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;
}
}