修改新增方法名称.

This commit is contained in:
nieqiurong 2024-06-08 23:01:11 +08:00
parent 95ae900334
commit c379b6470e
4 changed files with 5 additions and 5 deletions

View File

@ -440,7 +440,7 @@ public interface BaseMapper<T> extends Mapper<T> {
* @param entity 实体对象 (不能为空) * @param entity 实体对象 (不能为空)
* @since 3.5.7 * @since 3.5.7
*/ */
default boolean saveOrUpdate(T entity) { default boolean insertOrUpdate(T entity) {
Class<?> entityClass = GenericTypeUtils.resolveTypeArguments(getClass(), BaseMapper.class)[0]; Class<?> entityClass = GenericTypeUtils.resolveTypeArguments(getClass(), BaseMapper.class)[0];
TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass); TableInfo tableInfo = TableInfoHelper.getTableInfo(entityClass);
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!"); Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");

View File

@ -201,7 +201,7 @@ public abstract class ServiceImpl<M extends BaseMapper<T>, T> implements IServic
*/ */
@Override @Override
public boolean saveOrUpdate(T entity) { public boolean saveOrUpdate(T entity) {
return getBaseMapper().saveOrUpdate(entity); return getBaseMapper().insertOrUpdate(entity);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

View File

@ -227,7 +227,7 @@ public class Db {
if (Objects.isNull(entity)) { if (Objects.isNull(entity)) {
return false; return false;
} }
return SqlHelper.execute(getEntityClass(entity), baseMapper -> baseMapper.saveOrUpdate(entity)); return SqlHelper.execute(getEntityClass(entity), baseMapper -> baseMapper.insertOrUpdate(entity));
} }
/** /**

View File

@ -538,11 +538,11 @@ class H2UserMapperTest extends BaseTest {
@Test @Test
void testSaveOrUpdate() { void testSaveOrUpdate() {
var h2User = new H2User(); var h2User = new H2User();
userMapper.saveOrUpdate(h2User); userMapper.insertOrUpdate(h2User);
Assertions.assertNotNull(h2User.getTestId()); Assertions.assertNotNull(h2User.getTestId());
Assertions.assertNull(h2User.getLastUpdatedDt()); Assertions.assertNull(h2User.getLastUpdatedDt());
h2User.setName("test"); h2User.setName("test");
userMapper.saveOrUpdate(h2User); userMapper.insertOrUpdate(h2User);
Assertions.assertNotNull(h2User.getLastUpdatedDt()); Assertions.assertNotNull(h2User.getLastUpdatedDt());
} }