spring+struts2+dwr


package org.swj.site.dao;

import java.io.File;
import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientCallback;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.swj.site.domain.Staff;
import org.swj.site.util.ExcelUtil;

import com.ibatis.sqlmap.client.SqlMapExecutor;

public class StaffDao extends SqlMapClientDaoSupport
{
private ExcelUtil excelUtil;
private Staff staff;

public void setStaff(Staff staff)
{
this.staff = staff;
}
public void setExcelUtil(ExcelUtil excelUtil)
{
this.excelUtil = excelUtil;
}

@SuppressWarnings("unchecked")
public void insertStaff(File file,int sheetNum,int rowNum,int cellNum){

final List<String> result = excelUtil.readExcel(file,sheetNum,rowNum,cellNum);
getSqlMapClientTemplate().execute(new SqlMapClientCallback(){
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException
{
executor.startBatch();
for(int i=0;i<result.size();i++){
String[] strs = result.get(i).split(",");
staff.setStaffNo(strs[0]);
staff.setStaffName(strs[1]);
staff.setStaffDepartment(strs[2]);
staff.setStatus(strs[3]);
executor.insert("insertStaff",staff);
}
executor.executeBatch();
return null;
}
});
}

public void updateStaff(Staff staff){
getSqlMapClientTemplate().update("updateStaff",staff);
}

@SuppressWarnings("unchecked")
public List<Staff> selectAllStaff(Staff staff){
return getSqlMapClientTemplate().queryForList("selectStaff",staff);
}

public Staff selectStaffByNo(Staff staff){
return (Staff)getSqlMapClientTemplate().queryForObject("selectStaff",staff);
}
}

package org.swj.site.service;

import java.io.File;
import java.util.List;

import org.swj.site.dao.StaffDao;
import org.swj.site.domain.Staff;

public class StaffService
{
private StaffDao staffDao;

public void setStaffDao(StaffDao staffDao)
{
this.staffDao = staffDao;
}
public void insertStaff(File file,int sheetNum,int rowNum,int cellNum){
staffDao.insertStaff(file,sheetNum,rowNum,cellNum);
}

public void updateStaff(Staff staff){
staffDao.updateStaff(staff);
}

public List<Staff> selectAllStaff(Staff staff){

List<Staff> staffList = staffDao.selectAllStaff(staff);

return staffList;
}

public Staff selectStaffByNo(Staff staff){
return staffDao.selectStaffByNo(staff);
}

}

package org.swj.site.util;

import org.displaytag.decorator.TableDecorator;
import org.swj.site.domain.Staff;

public class Wrapper extends TableDecorator
{

public String getLink(){
StringBuffer htmlStr = new StringBuffer();
Staff staff = (Staff)getCurrentRowObject();

htmlStr.append("<a href=\"list.action?staffNo=");
htmlStr.append(staff.getStaffNo());
htmlStr.append("&action=renounce\">Renounce</a>");
return htmlStr.toString();

}

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值