使用Servlet上传多张图片——实体层(ProductInfo.java)

package orz.treeSquirrels.entity;
/**
 * 商品信息表的实体类
 * @author Administrator
 *
 */
public class ProductInfo {
	
	private int productId;				//商品编号
	private String productName;			//商品名称
	private float price;				//商品价格
	private String details;				//商品详情
	private int stock;					//商品库存
	private String fileName;			//大图
	private String fileName_1;			//小图1
	private String fileName_2;			//小图2
	private String fileName_3;			//小图3
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public int getProductId() {
		return productId;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param productId   
	 */
	public void setProductId(int productId) {
		this.productId = productId;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public String getProductName() {
		return productName;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param productName   
	 */
	public void setProductName(String productName) {
		this.productName = productName;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public float getPrice() {
		return price;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param price   
	 */
	public void setPrice(float price) {
		this.price = price;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public String getDetails() {
		return details;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param details   
	 */
	public void setDetails(String details) {
		this.details = details;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public int getStock() {
		return stock;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param stock   
	 */
	public void setStock(int stock) {
		this.stock = stock;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public String getFileName() {
		return fileName;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param fileName   
	 */
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public String getFileName_1() {
		return fileName_1;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param fileName_1   
	 */
	public void setFileName_1(String fileName_1) {
		this.fileName_1 = fileName_1;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public String getFileName_2() {
		return fileName_2;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param fileName_2   
	 */
	public void setFileName_2(String fileName_2) {
		this.fileName_2 = fileName_2;
	}
	/**    
	 * @author Mu Xiongxiong       
	 * @created 2017-10-11 下午7:11:16 
	 * @return type 
	 */
	
	public String getFileName_3() {
		return fileName_3;
	}
	/**     
	 * @author Mu Xiongxiong      
	 * @created 2017-10-11 下午7:11:16         
	 * @param fileName_3   
	 */
	public void setFileName_3(String fileName_3) {
		this.fileName_3 = fileName_3;
	}
	

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
String productUrl = ""; if (null != resultList && resultList.size() > 0) { if ("2".equals(agentInfo.getIdentityType())) { for (int i = 0; i < resultList.size(); i++) { ProductInfo productInfo = new ProductInfo(); productInfo.setInternal_id(resultList.get(i).getInternal_id()); productInfo.setProduct_abbr(resultList.get(i).getProduct_abbr()); //整理中介产品信息 productUrl = productService.getProductUrl(resultList.get(i), agentInfo.getIdentityType(), agentStaffVo, request); productInfo.setProductUrl(productUrl); productInfo.setInsuranceNotice(Commonconst.INSURANCE_NOTICE_2); productInfo.setPrivacyPolicy(Commonconst.PRIVACY_POLICY); productInfo.setPrivacyPolicyUrl(productService.getPrivacyPolicyUrl(request)); productInfoList.add(productInfo); } } else { for (int i = 0; i < resultList.size(); i++) { ProductInfo productInfo = new ProductInfo(); productInfo.setInternal_id(resultList.get(i).getInternal_id()); productInfo.setProduct_abbr(resultList.get(i).getProduct_abbr()); //整理非中介渠道产品信息 productUrl = productService.getProductUrl(resultList.get(i), agentInfo.getIdentityType(), agentStaffVo, request); productInfo.setProductUrl(productUrl); if ("ANHMB".equals(resultList.get(i).getInternal_id())) { productInfo.setInsuranceNotice(Commonconst.INSURANCE_NOTICE_3); } else if ("RNMRB02".equals(resultList.get(i).getInternal_id())) { productInfo.setInsuranceNotice(Commonconst.INSURANCE_NOTICE_4); } else if ("ANMRB02".equals(resultList.get(i).getInternal_id()) || "ANMMB03".equals(resultList.get(i).getInternal_id()) || "ANMRB03".equals(resultList.get(i).getInternal_id()) || "ANMRB04".equals(resultList.get(i).getInternal_id()) || "ANEMRB".equals(resultList.get(i).getInternal_id()) || "BNFIB".equals(resultList.get(i).getInternal_id())) { productInfo.setInsuranceNotice(Commonconst.INSURANCE_NOTICE_1); } else { productInfo.setInsuranceNotice(Commonconst.INSURANCE_NOTICE_2); } productInfoList.add(productInfo); } } }缩短执行时间
05-31
这段代码的执行时间可以通过以下几个方面进行缩短: 1. 使用增强for循环:可以将for循环改成增强for循环,这样可以简化代码,同时也可以提高执行效率。例如: ``` for (ProductInfo result : resultList) { ProductInfo productInfo = new ProductInfo(); productInfo.setInternal_id(result.getInternal_id()); productInfo.setProduct_abbr(result.getProduct_abbr()); //省略中间代码 productInfoList.add(productInfo); } ``` 2. 减少重复计算:在for循环中,多次调用get方法获取相同的值,可以将这些值缓存起来,减少重复计算。例如: ``` for (ProductInfo result : resultList) { ProductInfo productInfo = new ProductInfo(); String internal_id = result.getInternal_id(); String product_abbr = result.getProduct_abbr(); productInfo.setInternal_id(internal_id); productInfo.setProduct_abbr(product_abbr); //省略中间代码 productInfoList.add(productInfo); } ``` 3. 简化判断逻辑:在第二个for循环中,对于不同的产品内部id,需要设置不同的保险提示语。可以使用Map来存储每个内部id对应的提示语,然后在for循环中查找对应的提示语即可。例如: ``` Map<String, String> insuranceNoticeMap = new HashMap<>(); insuranceNoticeMap.put("ANHMB", Commonconst.INSURANCE_NOTICE_3); insuranceNoticeMap.put("RNMRB02", Commonconst.INSURANCE_NOTICE_4); insuranceNoticeMap.put("ANMRB02", Commonconst.INSURANCE_NOTICE_1); insuranceNoticeMap.put("ANMMB03", Commonconst.INSURANCE_NOTICE_1); insuranceNoticeMap.put("ANMRB03", Commonconst.INSURANCE_NOTICE_1); insuranceNoticeMap.put("ANMRB04", Commonconst.INSURANCE_NOTICE_1); insuranceNoticeMap.put("ANEMRB", Commonconst.INSURANCE_NOTICE_1); insuranceNoticeMap.put("BNFIB", Commonconst.INSURANCE_NOTICE_1); for (ProductInfo result : resultList) { ProductInfo productInfo = new ProductInfo(); String internal_id = result.getInternal_id(); String product_abbr = result.getProduct_abbr(); productInfo.setInternal_id(internal_id); productInfo.setProduct_abbr(product_abbr); //省略中间代码 productInfo.setInsuranceNotice(insuranceNoticeMap.getOrDefault(internal_id, Commonconst.INSURANCE_NOTICE_2)); productInfoList.add(productInfo); } ``` 通过以上优化措施,可以缩短代码的执行时间,提高代码的效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

穆雄雄

哎,貌似还没开张来着呢~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值