📄 crudaction.java
字号:
package com.easyjweb.action;
import java.util.ArrayList;
import java.util.Collection;
import com.easyjf.util.CommUtil;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.CrudAction;
import com.easyjf.web.tools.DbPageList;
import com.easyjf.web.tools.IPageList;
import com.easyjweb.business.$tableName;
/**
* 使用添删改查action
* @author easyjwebtools
*
*/
public class ${tableName}Action extends CrudAction {
/**
* 查询及分页,通过实现AbstractCrudAction中的抽象方法实现
*/
public IPageList doQuery(WebForm form, int currentPage, int pageSize) {
String scope = "1=1";
Collection paras = new ArrayList();
String orderType = CommUtil.null2String(form.get("orderType"));
String orderField = CommUtil.null2String(form.get("orderField"));
if (!"".equals(orderField)) {
scope += " order by " + orderField;
if (!"".equals(orderType))
scope += " " + orderType;
}
DbPageList pList = new DbPageList(${tableName}.class, scope, paras);
pList.doList(currentPage, pageSize);
return pList;
}
/**
* 这个方法负责根据Form中的数据转换成java对象。
*
*/
public Object form2Obj(WebForm form) {
String cid = (String) form.get("cid");
$!tableName obj = null;
if (cid != null && (!cid.equals("")))
obj =($tableName)this.getDao().get(${tableName}.class,cid);
if (obj == null)
obj = new ${tableName}();
return form.toPo(obj);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -