📄 paymentlistaction.java
字号:
package com.longtime.wap.module.front.web.action;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.longtime.wap.common.WapConstant;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.common.web.PageConstant;
import com.longtime.wap.frame.common.UserSessionVO;
import com.longtime.wap.model.Payment;
import com.longtime.wap.model.UncommandWord;
import com.longtime.wap.module.front.common.FrontConstant;
import com.longtime.wap.module.front.service.FrontService;
/**
* 消费列表请求
*
* @author bulc
* @date Nov 19, 2007
*/
public class PaymentListAction extends FrontBaseAction {
private static final Log LOGGER = LogFactory
.getLog(PaymentListAction.class);
private FrontService frontService;
/**
* 注入服务对象
*
* @param frontService
* 设置服务对象
*/
public void setFrontService(FrontService frontService) {
this.frontService = frontService;
}
/**
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward listUserPayment(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
Page page = null;
String pageNumber = request.getParameter(PageConstant.PARA_PAGE);
if (GenericValidator.isBlankOrNull(pageNumber)) {
page = new Page(1);
} else {
page = new Page(Integer.parseInt(pageNumber));
}
UserSessionVO usVo = (UserSessionVO) request.getSession()
.getAttribute(WapConstant.USER_SESSION);
request.setAttribute(FrontConstant.USER_PAYMENTS_LIST, this
.filtPaymentContent(usVo.getUserId(), page));
request.setAttribute(PageConstant.ATTR_PAGE, page);
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
super.setHeader(request, frontService);
super.setLeft(request, frontService);
return mapping.findForward("userPaymentList");
}
/**
*
* @param userId
* 用户id对象
* @param page
* 分页对象
* @return 消费列表
*/
@SuppressWarnings("unchecked")
protected List filtPaymentContent(Long userId, Page page) {
List returnList = new ArrayList();
List payments = frontService.getPaymentsByUserId(userId, page);
try {
for (int i = 0; i < payments.size(); i++) {
Payment pay = (Payment) payments.get(i);
pay = this.filtPaymentContent(pay);
if ((pay.getInformationTitle().trim()).length() != 0) {
returnList.add(pay);
}
}
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return returnList;
}
/**
* @param pay 消费对象
* @return 消费对象
*/
protected Payment filtPaymentContent(Payment pay) {
try {
List ucw = this.frontService.getUncommandWords();
Iterator it = ucw.iterator();
while (it.hasNext()) {
UncommandWord ucWord = (UncommandWord) it.next();
if (!GenericValidator.isBlankOrNull(
pay.getInformationTitle())) {
if (pay.getInformationTitle().contains(ucWord.getWord())) {
StringBuilder replaceWord = new StringBuilder();
for (int i = 0; i < ucWord.getWord().length(); i++) {
replaceWord.append("*");
}
pay.setInformationTitle(pay.getInformationTitle()
.replaceAll(ucWord.getWord(),
replaceWord.toString()));
}
}
}
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return pay;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -