package com.kingdee.eas.hr.emp.web.handler;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kingdee.bos.BOSException;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.shr.affair.web.handler.util.EmployeeUtil;
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;

/**
 * 员工信息维护
 * @author issuser
 *
 */
public class EmployeeEditHandlerEx extends EmployeeEditHandler {
	
	
	@Override
	protected void verifyModel(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model)
			throws SHRWebException {
		PersonInfo personInfo = (PersonInfo) model;
		EmployeeUtil employeeUtil = new EmployeeUtil();
		//用户名唯一校验
		Boolean isUniqueCheck;
		try {
			isUniqueCheck = employeeUtil.checkUserName(
					personInfo.get("userName").toString(),personInfo.getId().toString(),personInfo.getNumber());
			if( !isUniqueCheck){
				throw new ShrWebBizException("This user name："+ personInfo.get("userName") + "already exists"); 
			}
		} catch (BOSException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		super.verifyModel(request, response, model);
	}

}
