你好BANQ,你覺的execute方法中的迴圈程式碼和組裝respMsg物件的程式碼有沒有必要在這個類中再加兩個方法封裝
package com.moloon.sonny.action;
import java.util.Iterator;
import java.util.List;
import com.moloon.aslan.core.Item;
import com.moloon.aslan.core.Request;
import com.moloon.aslan.core.Response;
import com.moloon.aslan.core.support.ActionSupport;
import com.moloon.framework.exception.ServiceException;
import com.moloon.framework.page.Page;
import com.moloon.sonny.message.request.CircleAlbumInfoMessage;
import com.moloon.sonny.message.response.CircleAlbumInfoRespMessage;
import com.moloon.sonny.message.response.ErrorRespMessage;
import com.moloon.sonny.message.response.item.AlbumUserInfoRespItem;
import com.moloon.sonny.message.response.item.SimpleCircleItem;
import com.moloon.sonny.pojo.Troop;
import com.moloon.sonny.service.CircleService;
import com.moloon.sonny.service.UserBaseInfoService;
import com.moloon.sonny.util.PageCalculator;
import com.moloon.sonny.vo.PhotoListVO;
import com.moloon.sonny.vo.SmsUserBaseInfoVO;
/**
* 請求圈相簿資訊
*
* @author lvyg
* @version 1.1, 2006-12-7
* @since JDK1.5
*/
public class LoadCircleAlbumAction extends ActionSupport {
private CircleService circleService;
private UserBaseInfoService baseInfoService;
private int pageStep = 10;
public UserBaseInfoService getBaseInfoService() {
return baseInfoService;
}
public void setBaseInfoService(UserBaseInfoService baseInfoService) {
this.baseInfoService = baseInfoService;
}
/**
* @return Returns the pageStep.
*/
public int getPageStep() {
return pageStep;
}
/**
* @param pageStep
* The pageStep to set.
*/
public void setPageStep(int pageStep) {
this.pageStep = pageStep;
}
/**
* @return Returns the circleService.
*/
public CircleService getCircleService() {
return circleService;
}
/**
* @param circleService
* The circleService to set.
*/
public void setCircleService(CircleService circleService) {
this.circleService = circleService;
}
@Override
public String execute(Request request, Response response) {
CircleAlbumInfoMessage reqMsg = (CircleAlbumInfoMessage) request
.getMessage();
Page page = new Page();
page.setCurrPageNo(reqMsg.getPageId());
page.setPageSize(pageStep);
PageCalculator pageBar = new PageCalculator(page);
List list = null;
try {
list = circleService.getPhotoUserInfo(String.valueOf(reqMsg
.getCricleId()), page);
Item[] albumUserInfoItem = null;
if (list != null&&list.size()>0) {
albumUserInfoItem=new AlbumUserInfoRespItem[list.size()];
Iterator it = list.iterator();
int i=0;
while(it.hasNext()) {
PhotoListVO photoVo = (PhotoListVO) it.next();
AlbumUserInfoRespItem respItem = new AlbumUserInfoRespItem();
respItem.setName(photoVo.getUserName());
respItem.setUserId(photoVo.getUserId());
respItem.setAge(photoVo.getAge().byteValue());
respItem.setSex(photoVo.getSex().byteValue());
respItem.setProvName(photoVo.getProvinceName());
try {
SmsUserBaseInfoVO vo=baseInfoService.getUserBaseInfoVO(photoVo.getUserId());
respItem.setCircleOwner(vo.isIsTroopCreater());
} catch (Exception e) {
respItem.setCircleOwner(false);
}
albumUserInfoItem[i++] = respItem;
}
}
CircleAlbumInfoRespMessage respMsg = new CircleAlbumInfoRespMessage();
if(null == albumUserInfoItem || 0 == albumUserInfoItem.length) {
respMsg.setUserNum(0);
} else {
respMsg.setUserNum(albumUserInfoItem.length);
respMsg.setAlbumUserInfoItem(albumUserInfoItem);
}
respMsg.setBackPage(pageBar.getFront());// 上一頁
respMsg.setNextPage(pageBar.getBack());// 下一頁
respMsg.setSessionId(reqMsg.getSessionId());
respMsg.setSequence(reqMsg.getSequence());
response.write(respMsg);
} catch (ServiceException e) {
ErrorRespMessage errMsg = new ErrorRespMessage();
errMsg.setSequence(reqMsg.getSequence());
errMsg.setSessionId(reqMsg.getSessionId());
response.write(errMsg);
}
return null;
}
}
import java.util.Iterator;
import java.util.List;
import com.moloon.aslan.core.Item;
import com.moloon.aslan.core.Request;
import com.moloon.aslan.core.Response;
import com.moloon.aslan.core.support.ActionSupport;
import com.moloon.framework.exception.ServiceException;
import com.moloon.framework.page.Page;
import com.moloon.sonny.message.request.CircleAlbumInfoMessage;
import com.moloon.sonny.message.response.CircleAlbumInfoRespMessage;
import com.moloon.sonny.message.response.ErrorRespMessage;
import com.moloon.sonny.message.response.item.AlbumUserInfoRespItem;
import com.moloon.sonny.message.response.item.SimpleCircleItem;
import com.moloon.sonny.pojo.Troop;
import com.moloon.sonny.service.CircleService;
import com.moloon.sonny.service.UserBaseInfoService;
import com.moloon.sonny.util.PageCalculator;
import com.moloon.sonny.vo.PhotoListVO;
import com.moloon.sonny.vo.SmsUserBaseInfoVO;
/**
* 請求圈相簿資訊
*
* @author lvyg
* @version 1.1, 2006-12-7
* @since JDK1.5
*/
public class LoadCircleAlbumAction extends ActionSupport {
private CircleService circleService;
private UserBaseInfoService baseInfoService;
private int pageStep = 10;
public UserBaseInfoService getBaseInfoService() {
return baseInfoService;
}
public void setBaseInfoService(UserBaseInfoService baseInfoService) {
this.baseInfoService = baseInfoService;
}
/**
* @return Returns the pageStep.
*/
public int getPageStep() {
return pageStep;
}
/**
* @param pageStep
* The pageStep to set.
*/
public void setPageStep(int pageStep) {
this.pageStep = pageStep;
}
/**
* @return Returns the circleService.
*/
public CircleService getCircleService() {
return circleService;
}
/**
* @param circleService
* The circleService to set.
*/
public void setCircleService(CircleService circleService) {
this.circleService = circleService;
}
@Override
public String execute(Request request, Response response) {
CircleAlbumInfoMessage reqMsg = (CircleAlbumInfoMessage) request
.getMessage();
Page page = new Page();
page.setCurrPageNo(reqMsg.getPageId());
page.setPageSize(pageStep);
PageCalculator pageBar = new PageCalculator(page);
List list = null;
try {
list = circleService.getPhotoUserInfo(String.valueOf(reqMsg
.getCricleId()), page);
Item[] albumUserInfoItem = null;
if (list != null&&list.size()>0) {
albumUserInfoItem=new AlbumUserInfoRespItem[list.size()];
Iterator it = list.iterator();
int i=0;
while(it.hasNext()) {
PhotoListVO photoVo = (PhotoListVO) it.next();
AlbumUserInfoRespItem respItem = new AlbumUserInfoRespItem();
respItem.setName(photoVo.getUserName());
respItem.setUserId(photoVo.getUserId());
respItem.setAge(photoVo.getAge().byteValue());
respItem.setSex(photoVo.getSex().byteValue());
respItem.setProvName(photoVo.getProvinceName());
try {
SmsUserBaseInfoVO vo=baseInfoService.getUserBaseInfoVO(photoVo.getUserId());
respItem.setCircleOwner(vo.isIsTroopCreater());
} catch (Exception e) {
respItem.setCircleOwner(false);
}
albumUserInfoItem[i++] = respItem;
}
}
CircleAlbumInfoRespMessage respMsg = new CircleAlbumInfoRespMessage();
if(null == albumUserInfoItem || 0 == albumUserInfoItem.length) {
respMsg.setUserNum(0);
} else {
respMsg.setUserNum(albumUserInfoItem.length);
respMsg.setAlbumUserInfoItem(albumUserInfoItem);
}
respMsg.setBackPage(pageBar.getFront());// 上一頁
respMsg.setNextPage(pageBar.getBack());// 下一頁
respMsg.setSessionId(reqMsg.getSessionId());
respMsg.setSequence(reqMsg.getSequence());
response.write(respMsg);
} catch (ServiceException e) {
ErrorRespMessage errMsg = new ErrorRespMessage();
errMsg.setSequence(reqMsg.getSequence());
errMsg.setSessionId(reqMsg.getSessionId());
response.write(errMsg);
}
return null;
}
}
相關文章
- 一個C#封裝的加密解密類程式碼C#封裝加密解密
- 那些坑你沒商量的程式碼死迴圈
- laravel框架的程式碼加密有沒有什麼好的方法啊?Laravel框架加密
- Redis::set()沒有這個方法Redis
- android 在程式碼中安裝apk的方法AndroidAPK
- 有沒有一段程式碼,讓你覺得人類的智慧也可以璀璨無比?
- 陣列方法的封裝/程式碼的複用加強陣列封裝
- banq,你好,我有一個急需解決的問題??
- 你能從這兩個程式原始碼中發現什麼原始碼
- Python中合併兩個列表常用的方法有哪些?Python
- 程式碼模板 | 我的程式碼沒有else
- 這裡有你在程式設計面試中取得成功所需的技巧和方法...程式設計面試
- 在同一個類中呼叫另一個方法沒有觸發 Spring AOP 的問題Spring
- lcobucci/jwt的安裝和使用(讓天下沒有難寫和難讀的程式碼)JWT
- ScaleHeight 的封裝程式碼封裝
- 他說遇到了迴圈匯入,但是我怎麼看我的程式碼都沒有迴圈匯入
- 觸發器儘量考慮內部程式碼過程的封裝(在11g中沒有差別)觸發器封裝
- react 有沒有類似vue中watch這樣的api?ReactVueAPI
- spring明明沒有迴圈引用的,為什麼總報這個錯?Spring
- java輔助開發的兩個封裝類Java封裝
- 將PL/SQL程式碼封裝在靈巧的包中SQL封裝
- 10 個有關程式碼審查和程式碼質量的事實
- 用java.util.Collections中的sort方法對兩個類的物件進行排序Java物件排序
- 板橋你好,請Petstore的程式碼哪裡有下載???
- 你覺得我的這段Java程式碼還有優化的空間嗎?Java優化
- 封裝我們的VBA程式碼封裝
- 程式碼改變世界 | 如何封裝一個簡單的 Koa封裝
- HashMap的get方法有可能導致死迴圈HashMap
- C庫中沒有itoa以及C++中string沒有split方法的原因C++
- 將建立程式的API-posix_spawn封裝成一個程式類API封裝
- python 根據物件和方法名,返回提供這個方法的定義的類Python物件
- 判斷裝置驅動有沒有被載入的方法
- 一行程式碼完成 JAVA 的 EXCEL 讀寫——EasyExcel 的方法封裝行程JavaExcel封裝
- laravel 定義模型的區域性查詢作用域方法沒有PhpStorm沒有程式碼提示Laravel模型PHPORM
- 程式碼整潔之道的 7 個方法
- 提高jQuery程式碼效能的幾個方法jQuery
- Java 方法中迴圈呼叫具有事務的方法Java
- 掌握這些程式碼安全檢視方法,提升你的程式碼質量