java


12
list集合参数传进来
逗号分割查询1,2,3,4,

String no = getParamStr( map, "no" );
if( StringUtil.empty( no ) ) {
logger.error( "no is null", this );
return getJsonResult( ExceptionCode.PARAM_NULL_ERROR );
}
// TODO:具体接口业务逻辑
List<String> noList = new ArrayList<String>();

// noList = Arrays.asList( no.toCharArray().toString() );
if( no.indexOf( "," ) < 0 ) {
noList.add( no.substring( 1, no.length() - 1 ) );
}
else {
for( String str : no.split( "," ) ) {
noList.add( str );
}
}
List<Commodity> commodityList = commodityService.selectByNoList( noList );

13
封装接口部分属性传输出去


Map<String, Object> retMap = new HashMap<String, Object>();
List<CommodityVO> list = new ArrayList<CommodityVO>();

retMap.put( "rencommendType", Integer.parseInt( rencommendType ) );
List<RecommendWidget> recommendWidgetList = widgetService.selectByRencommendType( retMap );
if( !recommendWidgetList.isEmpty() ) {
for( RecommendWidget recommendWidget : recommendWidgetList ) {
CommodityVO vo = new CommodityVO();
int id = recommendWidget.getTargetEntityId();
Commodity commodity = commodityService.selectByPrimaryKey( id );
vo.setId( commodity.getId() );
vo.setImgPath( recommendWidget.getImgPath() );
vo.setName( commodity.getName() );
vo.setPriceMeili( commodity.getPriceMeili() );
list.add( vo );
}
}
if( list != null ) {
return getSuccessJsonResult( list );

你可能感兴趣的:(java)