package com.newvideo.web.action; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.interceptor.ServletRequestAware; import org.springframework.stereotype.Controller; import com.newvideo.domain.DetailSystem; import com.newvideo.domain.SuperUserBanner; import com.newvideo.domain.SystemInfo; import com.newvideo.domain.UserBanner; import com.newvideo.domain.web.UserBannerAdmin; import com.newvideo.service.imp.SystemService; import com.newvideo.service.imp.UserBannerService; import com.newvideo.service.imp.UserService; import com.newvideo.util.Constant; import com.newvideo.util.LogUtil; import com.newvideo.util.StringUtil; import com.newvideo.web.tag.PageEntity; import com.opensymphony.xwork2.ActionSupport; @Controller public class UserBannerAction extends ActionSupport implements ServletRequestAware { @Resource private UserService userService; @Resource private SystemService systemService; @Resource private UserBannerService userBannerService; public UserBannerService getUserBannerService() { return userBannerService; } public void setUserBannerService(UserBannerService userBannerService) { this.userBannerService = userBannerService; } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } public SystemService getSystemService() { return systemService; } public void setSystemService(SystemService systemService) { this.systemService = systemService; } /** * */ private static final long serialVersionUID = 1L; HttpServletRequest request; /** * �ؼ��������б� * * @return */ public String userBannerList() { if (pageIndex == 0) pageIndex = 1; key = StringUtil.isNullOrEmpty(key) ? "" : StringUtil.getUTF8String(key, "iso-8859-1"); List list = userBannerService.getUserBannerAdmin(detailsystem, pageIndex); long count = userBannerService.getUserBannerAdminCount(detailsystem); PageEntity pe = new PageEntity(); pe.setPageIndex(pageIndex); pe.setPageSize(Constant.pageCount); Map map = new HashMap(); map.put("key", key); map.put("detailsystem", detailsystem + ""); pe.setParams(map); pe.setTotalCount((int) count); request.setAttribute("pageEntity", pe); request.setAttribute("userBannerAdminList", list); List detailSystemList = systemService.getDetailSystemList(); request.setAttribute("detailSystemList", detailSystemList); return SUCCESS; } public String addUserBanner() { UserBanner userBanner = new UserBanner(); userBanner.setCreatetime(System.currentTimeMillis() + ""); userBanner.setPicture(picture); userBanner.setBeizhu(StringUtil.getUTF8String(beizhu, "iso-8859-1")); userBanner.setSystem(new SystemInfo("1")); userBanner.setUrl(StringUtil.getUTF8String(url, "iso-8859-1")); userBannerService.addUserBanner(userBanner); String ids = request.getParameter("detailsystems"); if (!StringUtil.isNullOrEmpty(ids)) { String[] idst = ids.split(","); for (String st : idst) { SuperUserBanner sz = new SuperUserBanner(); sz.setCreatetime(System.currentTimeMillis() + ""); sz.setDetailSystem(new DetailSystem(st)); sz.setUserBanner(userBanner); userBannerService.addSuperUserBanner(sz); } } return SUCCESS; } public String updateUserBanner() { UserBanner userBanner = userBannerService.getUserBannerById(id); userBanner.setBeizhu(StringUtil.getUTF8String(beizhu, "iso-8859-1")); userBanner.setPicture(picture); userBanner.setUrl(url); userBannerService.updateUserBanner(userBanner); return SUCCESS; } public String getUserBanner() { id = StringUtil.isNullOrEmpty(id) ? request.getAttribute("id").toString() : id; UserBanner userBanner = userBannerService.getUserBannerById(id); request.setAttribute("userBanner", userBanner); return SUCCESS; } public String getUserBannerDetailSystem() { List list = systemService.getDetailSystemList(); request.setAttribute("detailSystemList", list); return SUCCESS; } public String deleteUserBanner() { userBannerService.deleteUserBanner(id); return SUCCESS; } public String deleteUserBannerList() { String urls = request.getParameter("urls"); String[] ids = urls.split(","); for (String st : ids) { userBannerService.deleteUserBanner(st); } return SUCCESS; } public void setServletRequest(HttpServletRequest arg0) { this.request = arg0; } // ������ @Override public void addActionError(String anErrorMessage) { super.addActionError(anErrorMessage); LogUtil.i(anErrorMessage); } @Override public void addFieldError(String fieldName, String errorMessage) { super.addFieldError(fieldName, errorMessage); LogUtil.i(errorMessage); } @Override public void addActionMessage(String aMessage) { super.addActionMessage(aMessage); LogUtil.i(aMessage); } private String key; private int pageIndex; private int detailsystem; public int getDetailsystem() { return detailsystem; } public void setDetailsystem(int detailsystem) { this.detailsystem = detailsystem; } public String getKey() { return key; } public void setKey(String key) { this.key = key; } public int getPageIndex() { return pageIndex; } public void setPageIndex(int pageIndex) { this.pageIndex = pageIndex; } private String id; private String picture; private String url; private String beizhu; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getBeizhu() { return beizhu; } public void setBeizhu(String beizhu) { this.beizhu = beizhu; } }