📄 resourceaddaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package unicom.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import unicom.bean.Mobile;
import unicom.factory.ServiceFactory;
import unicom.service.IMobileService;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
/**
* @author xiaogang
* 日期:Apr 18, 2008
* 功能:低端控制器,增加电话号码,并设置为可用状态
* 优点:
* 缺点:
* 建议:
*/
public class ResourceAddAction extends IdentityFilter {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if(super.isAdminLogin(request))
{
DynaActionForm dyForm = (DynaActionForm)form;
long num1 = Long.parseLong((String)dyForm.get("numFrom"));
long num2 = Long.parseLong((String)dyForm.get("numTo"));
String type = (String)dyForm.get("type");
List telList = new ArrayList();
//将生成的Mobile添加到集合中
for (Long i = num1; i <= num2; i++) {
unicom.bean.Mobile mobile = new Mobile();
mobile.setNumber(i.toString());
mobile.setType(type);
mobile.setIsAvailable("Y");
telList.add(mobile);
}
//调用业务逻辑bean,完成添加电话号码操作
unicom.service.IMobileService mobileService = ServiceFactory.createMobileService();
boolean success = mobileService.addMobileList(telList);
if(success)
{
//成功添加后,跳转到成功提示页面
request.setAttribute("msg","恭喜,添加号码成功");
return mapping.findForward("msgpage");
}else{
//失败添加后,调转到失败提示页面
request.setAttribute("msg","抱歉,已经存在部分电话号码");
return mapping.findForward("msgpage");
}
}else{
request.setAttribute("msg","你还未登录");
return mapping.findForward("index");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -