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

📄 unitdao.java

📁 基于SPRING+DWR+EXT 技术的一个小项目(附源码和数据库脚本)
💻 JAVA
字号:
package com.hr.dao;

import java.util.ArrayList;
import java.util.List;

import com.hr.Unit;
import com.hr.User;
import com.philisense.arc.base.ProxyWebArcContext;
import com.philisense.arc.base.jdbc.query.Query;
import com.philisense.arc.base.jdbc.query.Runner;

public class UnitDAO {

	private Query query;

	private Runner getRunner() throws Exception {
		return (Runner) ProxyWebArcContext.getProxyArcContext().getQueryFactory().getRunnerObject();
	}

	private Query getQuery() throws Exception {
		if (query == null) {
			query = (Query) ProxyWebArcContext.getProxyArcContext().getQueryFactory().getObject();
		}
		return query;
	}

	public int removeRecords(ArrayList<String> ids) throws Exception {

		if (ids == null || ids.size() == 0) {
			return -1;
		}

		String sql = "delete from unit where id in (";
		for (int i = 0; i < ids.size(); i++) {
			sql += ids.get(i).toString() + ",";
		}
		sql = sql.substring(0, sql.length() - 1) + ")";
		
		Runner runner= getRunner();
		int count=runner.executeUpdate(sql);
		runner.close();
		
		return count;
	}

	public List<Unit> getRecords() throws Exception {

		Query query = getQuery();
		query.setNullWarp(true);
		query.setTrimWarp(true);
		query.setColumnWarp(false);
		query.setCodeWarp(false);
		
		return (List<Unit>)query.queryToBeanList("select * from unit order by id,parentid", Unit.class);
	}

	public int insertUnit(String name, String description, String parentId) throws Exception {
		String sql = "insert into unit(name,description,parentId) values('"+name+"','"+description+"',"+parentId+")";
		
		Runner runner= getRunner();
		int count=runner.executeUpdate(sql);
		runner.close();
		
		return count;
	}

	public int updateUnit(String id, String name, String description, String parentId) throws Exception { 
		String sql = "update unit set name='"+name+"',description='"+description+"',parentId="+parentId+" where id="+id;
		
		Runner runner= getRunner();
		int count=runner.executeUpdate(sql);
		runner.close();
		
		return count;
	}
}

⌨️ 快捷键说明

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