📄 friendjsp.java
字号:
/*
* Created on 2007-5-5
* Last modified on 2007-5-5
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.view.jsp;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yeqiangwei.club.param.FriendParameter;
import com.yeqiangwei.club.service.ServiceLocator;
import com.yeqiangwei.club.service.ServiceWrapper;
import com.yeqiangwei.club.service.model.FriendLastPost;
import com.yeqiangwei.club.service.model.FriendModel;
import com.yeqiangwei.club.service.user.FriendService;
import com.yeqiangwei.club.service.user.UserLogin;
import com.yeqiangwei.club.util.BeanLocator;
import com.yeqiangwei.club.util.BeanUtils;
import com.yeqiangwei.club.view.model.FriendLastPostView;
import com.yeqiangwei.club.view.model.FriendView;
import com.yeqiangwei.util.ParamUtils;
import com.yeqiangwei.util.Validator;
public class FriendJsp extends BaseJsp{
public FriendJsp(HttpServletRequest request, HttpServletResponse response) {
super(request, response);
}
private String pagination = "";
public String getPagination() {
return pagination;
}
public void setPagination(String pagination) {
this.pagination = pagination;
}
public List<FriendLastPostView> findLastPost(int rows, boolean isTopic){
List<FriendLastPost> mlist = this.getFriendService().findLastPost(
UserLogin.getUserId(request),3,rows,isTopic);
List<FriendLastPostView> list = BeanUtils.copyList(mlist,BeanLocator.FRIENDLASTPOSTVIEW);
return list;
}
public List<FriendView> findByFriendUserId(int rows){
FriendParameter param = new FriendParameter();
param.setPage(1);
param.setRows(rows);
param.setOrderBy(null); //按关系值倒序排列
param.setFriendUserId(UserLogin.getUserId(request));
param.setMyUserId(null);
List<FriendModel> mlist = this.getFriendService().findByParameter(param);
if(!Validator.isEmpty(mlist)){
List<FriendView> list = BeanUtils.copyList(mlist,BeanLocator.FRIENDVIEW);
return list;
}else{
return null;
}
}
public List<FriendView> findBestFriendByMyUserId(int rows){
FriendParameter param = new FriendParameter();
param.setPage(1);
param.setRows(rows);
param.setOrderBy((byte)3); //按关系值倒序排列
param.setMyUserId(UserLogin.getUserId(request));
List<FriendModel> mlist = this.getFriendService().findByParameter(param);
List<FriendView> list = BeanUtils.copyList(mlist,BeanLocator.FRIENDVIEW);
return list;
}
public List<FriendView> findByMyUserId(int rows){
int userId = ParamUtils.getIntParameter(request,"userId",0);
if(userId==0){
userId = UserLogin.getUserId(request);
}
int page = ParamUtils.getIntParameter(request,"page",1);
FriendParameter param = new FriendParameter();
param.setPage(page);
param.setRows(rows);
param.setMyUserId(userId);
List<FriendModel> mlist = this.getFriendService().findByParameter(param);
List<FriendView> list = BeanUtils.copyList(mlist,BeanLocator.FRIENDVIEW);
return list;
/*
* 限制了上限为50位好友,因此分页暂不启用。
*/
//long total = this.getFriendService().countByParameter(param);
//StringBuffer url = new StringBuffer();
//url.append("friend.jsp?page=");
//this.setPagination(com.yeqiangwei.html.OutPrint.pagination(page, rows, total, url.toString(),5));
}
public FriendService getFriendService() {
return ServiceWrapper.<FriendService>getSingletonInstance(ServiceLocator.FRIEND);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -