⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crudaction.java

📁 EasyJF开源Blog系统是一个由EasyJF开源团队组织开发的基于Java平台的开源博客系统。当前Blog已经实现了基本的基本的博客的书写、流量统计、排名、个人像册、RSS、支持自定义模板、静态h
💻 JAVA
字号:
package $package;

import java.util.ArrayList;
import java.util.Collection;

import com.easyjf.blog.domain.PhotoDir;
import com.easyjf.util.CommUtil;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
import com.easyjf.web.tools.CrudAction;
import com.easyjf.web.tools.DbPageList;

import com.easyjf.web.tools.IPageList;
import ${beanPackage}.$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);
	}
	public Page doDelBatch(WebForm form, Module module) {
		String MulitCid = CommUtil.null2String(form.get("mulitCid"));
			int num = 0;		
			String[] s = MulitCid.split(",");
			if(s!=null){
			for (int i = 0; i < s.length; i++) {
				$!tableName obj=($!tableName)this.getDao().get(${tableName}.class,s[i]);				
				if(this.getDao().del(obj))num++;
			}
			form.addResult("msg", "成功删除了" + num + "条信息的状态!");
			}		
		return super.doQuery(form,module,this.getCurrentUser(form));		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -