📄 mydetail.java
字号:
package com.laoer.bbscs.web.action;
import com.laoer.bbscs.web.form.*;
import org.apache.struts.action.*;
import com.laoer.bbscs.web.servlet.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.sys.*;
import javax.servlet.http.*;
/**
* <p>Title: TianYi BBS</p>
* <p>Description: TianYi BBS System</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: LAOER.COM/TIANYISOFT.NET</p>
* @author laoer
* @version 6.0
*/
public class MyDetail
extends BaseAction {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
ActionErrors errors = new ActionErrors();
MyDetailForm form = (MyDetailForm) actionForm;
UserCheck uc = this.getUserCheck(httpServletRequest, httpServletResponse,
Constant.MESSAGE.getMessage(
httpServletRequest.getLocale(),
"place.mydetail"));
if (uc.isGuest()) {
errors.add("error.pleaselogin", new ActionError("error.pleaselogin"));
saveErrors(httpServletRequest, errors);
LoginForm loginForm = new LoginForm();
loginForm.setTourl(SysUtil.getToURL(httpServletRequest,
"myDetail" + Constant.FILEPREFIX));
/*
loginForm.setTourl(SysUtil.encodeURL("myDetail" + Constant.FILEPREFIX,
Constant.CHARSET));*/
httpServletRequest.setAttribute("loginForm", loginForm);
//return actionMapping.findForward("login");
return SysUtil.getPassLogin(actionMapping);
}
if (form.getAction().equals("show")) {
UserDetail ud = getUserDetailService().findUserDetailByUserID(new Long(uc.
getId()));
if (ud == null) {
ud = new UserDetail();
ud.setUserID(uc.getId());
getUserDetailService().saveUserDetail(ud);
}
/*
UserInfo ui = this.getUserInfoService().findUserInfoById(new Long(uc.
getId()));*/
UserInfo ui = this.getUserCache().getUserInfoFromCache(uc.getId());
if (ui == null) {
errors.add("error.getusererror", new ActionError("error.getusererror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
form.setAction("edit");
form.setBrief(ud.getBrief());
form.setDreamjob(ud.getDreamJob());
form.setDreamlover(ud.getDreamLover());
form.setFavourart(ud.getFavourArt());
form.setFavourbook(ud.getFavourBook());
form.setFavourchat(ud.getFavourChat());
form.setFavourmovie(ud.getFavourMovie());
form.setFavourmusic(ud.getFavourMusic());
form.setFavourpeople(ud.getFavourPeople());
form.setFavourplace(ud.getFavourPlace());
form.setFavourteam(ud.getFavourTeam());
form.setGraduate(ud.getGraduate());
form.setHeight(ud.getHeight());
form.setHomepage(ud.getHomePage());
form.setIcqno(ud.getIcqNo());
form.setInterest(ud.getInterest());
form.setMsn(ud.getMsn());
form.setOicqno(ud.getOicqNo());
form.setSex(ud.getSex());
form.setWeight(ud.getWeight());
form.setYahoo(ud.getYahoo());
form.setUserFrom(ui.getUserFrom());
form.setForumPerNum(ui.getForumPerNum());
form.setPostPerNum(ui.getPostPerNum());
form.setTimeZone(ui.getTimeZone());
form.setEmail(ui.getEmail());
httpServletRequest.setAttribute("myDetailForm", form);
httpServletRequest.setAttribute("ui", ui);
return actionMapping.findForward("mydetail");
}
if (form.getAction().equals("edit")) {
UserDetail ud = getUserDetailService().findUserDetailByUserID(new Long(uc.
getId()));
/*
UserInfo ui = this.getUserInfoService().findUserInfoById(new Long(uc.
getId()));*/
UserInfo ui = this.getUserCache().getUserInfoFromCache(uc.getId());
if (ui == null) {
errors.add("error.getusererror", new ActionError("error.getusererror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
ud.setBrief(form.getBrief());
ud.setDreamJob(form.getDreamjob());
ud.setDreamLover(form.getDreamlover());
ud.setFavourArt(form.getFavourart());
ud.setFavourBook(form.getFavourbook());
ud.setFavourChat(form.getFavourchat());
ud.setFavourMovie(form.getFavourmovie());
ud.setFavourMusic(form.getFavourmusic());
ud.setFavourPeople(form.getFavourpeople());
ud.setFavourPlace(form.getFavourplace());
ud.setFavourTeam(form.getFavourteam());
ud.setGraduate(form.getGraduate());
ud.setHeight(form.getHeight());
ud.setHomePage(form.getHomepage());
ud.setIcqNo(form.getIcqno());
ud.setInterest(form.getInterest());
ud.setMsn(form.getMsn());
ud.setOicqNo(form.getOicqno());
ud.setSex(form.getSex());
ud.setWeight(form.getWeight());
ud.setYahoo(form.getYahoo());
ui.setUserFrom(form.getUserFrom());
ui.setPostPerNum(form.getPostPerNum());
ui.setForumPerNum(form.getForumPerNum());
ui.setTimeZone(form.getTimeZone());
ui.setEmail(form.getEmail());
if (getUserDetailService().saveUserDetail(ud) == null) {
errors.add("setmyinfo", new ActionError("error.setmyinfo"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
getUserInfoService().saveUserInfo(ui);
getUserInfoService().createUserFileInPost(ui);
this.getUserCache().removeFromCache(uc.getId());
//this.getUserCache().putUserInfoInCache(ui);
uc.addCookies(ui);
ActionForward f = new ActionForward(SysUtil.getResultUrl(
"succeed.setmyinfo", "myDetail" + Constant.FILEPREFIX), true);
return f;
}
if (form.getAction().equals("delpic")) {
UserInfo ui = this.getUserCache().getUserInfoFromCache(uc.getId());
if (ui == null) {
errors.add("error.getusererror", new ActionError("error.getusererror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
SysUtil.delFile(SysUtil.getUserFilePath(ui.getUsername(), uc.getId()) +
ui.getPicFileName());
ui.setHavePic( (short) 0);
ui.setPicFileName("");
getUserInfoService().saveUserInfo(ui);
getUserInfoService().createUserFileInPost(ui);
this.getUserCache().removeFromCache(uc.getId());
//this.getUserCache().putUserInfoInCache(ui);
uc.addCookies(ui);
ActionForward f = new ActionForward(SysUtil.getResultUrl(
"succeed.setmyinfo", "myDetail" + Constant.FILEPREFIX), true);
return f;
}
return actionMapping.findForward("error");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -