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

📄 userpicaction.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
字号:
package com.laoer.bbscs.bbs.action;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.laoer.bbscs.bbs.actionform.*;
import com.laoer.bbscs.bbs.business.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import com.laoer.bbscs.servlet.*;
import com.laoer.bbscs.db.*;
import org.apache.struts.util.*;
import java.util.*;

public class UserPicAction
    extends Action {
  public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {

    ActionErrors errors = new ActionErrors();
    UserPicActionForm form = (UserPicActionForm) actionForm;
    UserSessionCheck myUserSessionCheck = new UserSessionCheck(form.getSid(),
        httpServletRequest);
    if (!myUserSessionCheck.checkSession()) {
      errors.add("error.timeout", new ActionError("error.timeout"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }
    if (myUserSessionCheck.isGuest()) {
      errors.add("noguest", new ActionError("error.user.noguest"));
      saveErrors(httpServletRequest, errors);
      return actionMapping.findForward("error");
    }
    if (form.getAction().equals("list")) {
      MessageResources messages = getResources(httpServletRequest);
      Locale locale = getLocale(httpServletRequest);
      httpServletRequest.setAttribute("myUserSessionCheck", myUserSessionCheck);
      httpServletRequest.setAttribute("sid", form.getSid());
      Pages myPages = PagesFactory.getInstance();
      String[] pagessign = {
          messages.getMessage(locale, "bbscs.pages.first"),
          messages.getMessage(locale, "bbscs.pages.previous"),
          messages.getMessage(locale, "bbscs.pages.next"),
          messages.getMessage(locale, "bbscs.pages.end")};
      myPages.setPagesign(pagessign);
      myPages.setPerPageNum(9);
      //myPages.setPerPageNum(2);
      myPages.setPages(Integer.parseInt(form.getPages()));
      myPages.setFileName(Sys.getURL() + "userPicAction.do?sid=" + form.getSid() +
                          "&action=list&");
      UserPic aUserPic = UserPicFactory.getInstance();
      aUserPic.setPages(myPages);
      List piclist = (List) aUserPic.getUserPicList(null, "list");
      String pagebreakstr = aUserPic.getListPageBreak();
      httpServletRequest.setAttribute("plistlist", piclist);
      httpServletRequest.setAttribute("myPages", myPages);
      httpServletRequest.setAttribute("pages", form.getPages());
      httpServletRequest.setAttribute("pagebreakstr", pagebreakstr);
      return actionMapping.findForward("photolist");
    }
    if (form.getAction().equals("setstar")) {
      UserPicInfo aUserPicInfo = new UserPicInfo();
      aUserPicInfo.setUserID(Long.parseLong(form.getSetstar()));
      UserPic aUserPic = UserPicFactory.getInstance();
      aUserPic.setUserPicInfo(aUserPicInfo);
      if (aUserPic.setStar() != Sys.RESULT_RIGHT) {
        errors.add("error.handlerror", new ActionError("error.handlerror"));
        saveErrors(httpServletRequest, errors);
        return actionMapping.findForward("error");
      }
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("",
          Sys.getURL() + "userPicAction.do?sid=" + form.getSid() +
          "&action=list&pages=" + form.getPages()));
             return actionMapping.findForward("forwards");*/

      ActionForward f = new ActionForward("/userPicAction.do?sid=" +
                                          form.getSid() +
                                          "&action=list&pages=" + form.getPages(), true);
      return f;

    }
    if (form.getAction().equals("del")) {
      UserPicInfo aUserPicInfo = new UserPicInfo();
      aUserPicInfo.setID(form.getPicID());
      UserPic aUserPic = UserPicFactory.getInstance();
      aUserPic.setUserPicInfo(aUserPicInfo);
      if (aUserPic.getUserPic(null, "PID", true) == Sys.RESULT_RIGHT) {
        aUserPicInfo = aUserPic.getUserPicInfo();
        java.io.File myPicFile = new java.io.File(Util.getUserImgPath(
            aUserPicInfo.getUserName(), aUserPicInfo.getUserID()) +
                                                  aUserPicInfo.getPicFileName());
        if (myPicFile.exists()) {
          myPicFile.delete();
        }
      }
      int result = aUserPic.delUserPic(null, "delID");
      System.out.println(result);
      aUserPicInfo = null;
      aUserPic = null;
      UserInfo aui = new UserInfo();
      aui.setID(Long.parseLong(form.getUserID()));
      aui.setHavePic(0);
      aui.setPicFileName("");
      User au = UserFactory.getInstance();
      au.setUserInfo(aui);
      au.updateUser(null, "userPic");
      /*
             httpServletRequest.setAttribute("aForwardInfo",
                                      new ForwardInfo("",
          Sys.getURL() + "userPicAction.do?sid=" + form.getSid() +
          "&action=list&pages=" + form.getPages()));
             return actionMapping.findForward("forwards");*/

      ActionForward f = new ActionForward("/userPicAction.do?sid=" +
                                          form.getSid() +
                                          "&action=list&pages=" + form.getPages(), true);
      return f;

    }
    return actionMapping.findForward("error");
  }
}

⌨️ 快捷键说明

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