init
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package io.v.nutz.base.dao;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.base.query.PageForm;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class CndPlus extends Cnd {
|
||||
private static final NutMap map = NutMap.NEW().addv("ascending", "asc").addv("descending", "desc");
|
||||
|
||||
public CndPlus() {
|
||||
}
|
||||
|
||||
public static String getOrder(String key) {
|
||||
return map.getString(key);
|
||||
}
|
||||
|
||||
public static CndPlus create() {
|
||||
return new CndPlus();
|
||||
}
|
||||
|
||||
public CndPlus and(PageForm pageForm) {
|
||||
if (StrUtil.isAllNotBlank(pageForm.getSearchName(), pageForm.getSearchKeyword())) {
|
||||
this.where().andLike(pageForm.getSearchName(), pageForm.getSearchKeyword());
|
||||
}
|
||||
if (StrUtil.isAllNotBlank(pageForm.getPageOrderName(), pageForm.getPageOrderBy())) {
|
||||
this.orderBy(pageForm.getPageOrderName(), getOrder(pageForm.getPageOrderBy()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public CndPlus andEx(String name, String op, Object value) {
|
||||
if (StrUtil.isNotBlank(name) && !Lang.isEmpty(value)) {
|
||||
this.and(name, op, value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user