|
|
@@ -1,8 +1,6 @@
|
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
import com.uas.platform.b2c.core.constant.IntegerConstant;
|
|
|
-import com.uas.platform.b2c.core.constant.SplitChar;
|
|
|
-import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
@@ -11,12 +9,10 @@ import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 商城私有字段的服务层
|
|
|
@@ -32,6 +28,9 @@ public class ProductPrivateServiceImpl implements ProductPrivateService {
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
|
|
+
|
|
|
@Autowired
|
|
|
public ProductPrivateServiceImpl(ProductPrivateDao productPrivateDao, GoodsService goodsService, JdbcTemplate jdbcTemplate) {
|
|
|
this.productPrivateDao = productPrivateDao;
|
|
|
@@ -62,9 +61,39 @@ public class ProductPrivateServiceImpl implements ProductPrivateService {
|
|
|
if (CollectionUtils.isEmpty(prIds)) {
|
|
|
return Collections.emptyList();
|
|
|
} else {
|
|
|
- String contact = StringUtilB2C.joinListUseContact(prIds, SplitChar.COMMA);
|
|
|
- String sql = "/*#mycat:db_type=master*/ select p.id, p.pr_id,p.pr_b2cenabled,p.pr_batchcount,p.pr_attach from product$private p where p.pr_id in ("+ contact +");";
|
|
|
+ String sql = "/*#mycat:db_type=master*/ select p.id, p.pr_id,p.pr_b2cenabled,p.pr_batchcount,p.pr_attach from product$private p where p.pr_id in (:ids);";
|
|
|
+ Map<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
+ paramMap.put("ids", prIds);
|
|
|
List<ProductPrivate> mapList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ProductPrivate.class));
|
|
|
+ List<Map<String, Object>> maps = namedParameterJdbcTemplate.queryForList(sql, paramMap);
|
|
|
+ List<ProductPrivate> list = new ArrayList<>();
|
|
|
+ ProductPrivate productPrivate;
|
|
|
+ for (Map<String, Object> stringObjectMap : maps) {
|
|
|
+ productPrivate = new ProductPrivate();
|
|
|
+ Object id = stringObjectMap.get("id");
|
|
|
+ if (id != null) {
|
|
|
+ productPrivate.setId((Long) id);
|
|
|
+ }
|
|
|
+ Object prId = stringObjectMap.get("pr_id");
|
|
|
+ if (prId != null) {
|
|
|
+ productPrivate.setPrId(Long.valueOf(prId.toString()));
|
|
|
+ }
|
|
|
+ Object b2cenabled = stringObjectMap.get("pr_b2cenabled");
|
|
|
+ if (b2cenabled != null) {
|
|
|
+ productPrivate.setB2cEnabled(Integer.valueOf(b2cenabled.toString()));
|
|
|
+ }
|
|
|
+ Object batchCount = stringObjectMap.get("pr_batchcount");
|
|
|
+ if (batchCount != null) {
|
|
|
+ productPrivate.setBatchCount(Integer.valueOf(batchCount.toString()));
|
|
|
+ }
|
|
|
+ Object attach = stringObjectMap.get("pr_attach");
|
|
|
+ if (attach != null) {
|
|
|
+ productPrivate.setAttach(attach.toString());
|
|
|
+ }
|
|
|
+ if ((id != null) && (prId != null)) {
|
|
|
+ list.add(productPrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
return mapList;
|
|
|
}
|
|
|
}
|