优化saveOrUpdate逻辑

This commit is contained in:
smallchill 2024-07-10 18:21:17 +08:00
parent 87a6d93774
commit 29ba565bbf

View File

@ -67,6 +67,15 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
return super.updateBatchById(entityList, batchSize); return super.updateBatchById(entityList, batchSize);
} }
@Override
public boolean saveOrUpdate(T entity) {
if (entity.getId() == null) {
return this.save(entity);
} else {
return this.updateById(entity);
}
}
@Override @Override
public boolean deleteLogic(@NotEmpty List<Long> ids) { public boolean deleteLogic(@NotEmpty List<Long> ids) {
return super.removeByIds(ids); return super.removeByIds(ids);