扩展 crud 抽象类

v1.4.1
Parker 4 years ago
parent 0824ce86d3
commit cfe4f7d3d2

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.opsli.api.base.warpper.ApiWrapper;
import org.opsli.common.utils.WrapperUtil;
import org.opsli.core.base.entity.BaseEntity;
@ -146,6 +147,21 @@ public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseEnt
return null;
}
@Override
@Transactional(readOnly = false)
public E save(E model) {
if(model == null) return null;
// 修改
if(StringUtils.isNotBlank(model.getId())){
return this.update(model);
}
// 新增
model.setId(null);
return this.insert(model);
}
@Override
@Transactional(readOnly = false)
public boolean delete(String id) {

@ -99,6 +99,21 @@ public interface CrudServiceInterface<T extends BaseEntity,E extends ApiWrapper>
E update(E model);
/**
*
*
*
*
*
*
*
* ID ID
*
* @param model model
* @return E
*/
E save(E model);
/**
*
*

Loading…
Cancel
Save