cn.org.atool.fluent.mybatis.base.crud.BaseUpdate Maven / Gradle / Ivy
package cn.org.atool.fluent.mybatis.base.crud;
import cn.org.atool.fluent.mybatis.base.IEntity;
import cn.org.atool.fluent.mybatis.functions.StringSupplier;
import cn.org.atool.fluent.mybatis.segment.BaseWrapper;
import cn.org.atool.fluent.mybatis.segment.fragment.IFragment;
import cn.org.atool.fluent.mybatis.segment.model.PagedOffset;
import static cn.org.atool.fluent.mybatis.segment.fragment.Fragments.fragment;
import static cn.org.atool.fluent.mybatis.utility.StrConstant.EMPTY;
/**
* AbstractUpdateWrapper
*
* @param 对应的实体类
* @param 更新器
* @param 对应的查询器
* @author darui.wu 2020/6/17 4:24 下午
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public abstract class BaseUpdate<
E extends IEntity,
U extends IBaseUpdate,
NQ extends IBaseQuery>
extends BaseWrapper
implements IBaseUpdate {
protected BaseUpdate(String table, Class entityClass) {
super(fragment(table), () -> EMPTY, entityClass);
}
protected BaseUpdate(IFragment table, StringSupplier alias, Class entityClass) {
super(table, alias, entityClass);
}
@Override
public U limit(int limit) {
this.data.setPaged(new PagedOffset(0, limit));
return (U) this;
}
@Override
public U last(String lastSql) {
this.data.last(lastSql);
return (U) this;
}
/**
* 按条件更新时, 忽略乐观锁
*
* @return self
*/
public U ignoreLockVersion() {
this.data.setIgnoreLockVersion(true);
return (U) this;
}
}