📄 myfriend.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: MyFriend.java
package com.laoer.bbscs.web.action;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.business.IFriendService;
import com.laoer.bbscs.business.IUserInfoService;
import com.laoer.bbscs.sys.*;
import com.laoer.bbscs.web.form.FriendForm;
import com.laoer.bbscs.web.form.LoginForm;
import com.laoer.bbscs.web.servlet.UserCheck;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;
import org.apache.struts.util.MessageResources;
// Referenced classes of package com.laoer.bbscs.web.action:
// BaseAction
public class MyFriend extends BaseAction
{
public MyFriend()
{
}
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
{
ActionErrors errors = new ActionErrors();
FriendForm form = (FriendForm)actionForm;
UserCheck uc = getUserCheck(httpServletRequest, httpServletResponse, Constant.MESSAGE.getMessage(httpServletRequest.getLocale(), "place.friend"));
if(uc.isGuest())
{
errors.add("error.pleaselogin", new ActionError("error.pleaselogin"));
saveErrors(httpServletRequest, errors);
LoginForm loginForm = new LoginForm();
loginForm.setTourl(SysUtil.getToURL(httpServletRequest, "friend" + Constant.FILEPREFIX));
httpServletRequest.setAttribute("loginForm", loginForm);
return SysUtil.getPassLogin(actionMapping);
}
if(form.getAction().equals("list"))
{
java.util.List myFriend = getFriendService().findFriends(uc.getId(), (short)0);
java.util.List black = getFriendService().findFriends(uc.getId(), (short)1);
httpServletRequest.setAttribute("myFriend", myFriend);
httpServletRequest.setAttribute("black", black);
return actionMapping.findForward("friend");
}
if(form.getAction().equals("add"))
{
if(getFriendService().getMyFriendNum(uc.getId(), (short)0) >= SysInfo.getInstance().getFriendnum())
{
errors.add("error.friendtoolong", new ActionError("error.friendtoolong"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
UserInfo fui = getUserInfoService().findUserInfoByUserName(form.getFname());
if(fui == null)
{
errors.add("friendnameno", new ActionError("error.friendnameno"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
Friend f = getFriendService().findMyFriendByName(form.getFname(), uc.getId());
if(f != null)
{
errors.add("friendexist", new ActionError("error.friendexist"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
f = FriendFactory.getInstance(uc.getId());
f.setFid(fui.getId().longValue());
f.setFname(form.getFname());
f.setIsBlack((short)0);
f.setUserID(uc.getId());
f.setUserName(uc.getUsername());
f.setFcomment(form.getComment());
if(getFriendService().addFriend(f) == null)
{
errors.add("friendadderror", new ActionError("error.friendadderror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
} else
{
ActionForward forward = new ActionForward(SysUtil.getResultUrl("succeed.friendadd", "friend" + Constant.FILEPREFIX), true);
return forward;
}
}
if(form.getAction().equals("addb"))
{
if(getFriendService().getMyFriendNum(uc.getId(), (short)1) >= SysInfo.getInstance().getFriendnum())
{
errors.add("error.friendtoolong", new ActionError("error.friendtoolong"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
UserInfo fui = getUserInfoService().findUserInfoByUserName(form.getFname());
if(fui == null)
{
errors.add("friendnameno", new ActionError("error.friendnameno"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
Friend f = getFriendService().findMyFriendByName(form.getFname(), uc.getId());
if(f != null)
{
errors.add("friendexist", new ActionError("error.friendexist"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
}
f = FriendFactory.getInstance(uc.getId());
f.setFid(fui.getId().longValue());
f.setFname(form.getFname());
f.setIsBlack((short)1);
f.setUserID(uc.getId());
f.setUserName(uc.getUsername());
f.setFcomment(form.getComment());
if(getFriendService().saveFriend(f) == null)
{
errors.add("friendadderror", new ActionError("error.friendadderror"));
saveErrors(httpServletRequest, errors);
return actionMapping.findForward("error");
} else
{
ActionForward forward = new ActionForward(SysUtil.getResultUrl("succeed.blackadd", "friend" + Constant.FILEPREFIX), true);
return forward;
}
}
if(form.getAction().equals("del"))
{
getFriendService().delFriend(form.getId(), uc.getId());
ActionForward f = new ActionForward("/friend" + Constant.FILEPREFIX, true);
return f;
} else
{
return actionMapping.findForward("error");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -