Authored by hugufei

添加测试数据库读并发的接口

... ... @@ -30,4 +30,6 @@ public interface ProductMapper {
List<Product> selectListByIds(List<Integer> ids);
List<BrandSortIdsBO> selectBrandSortIdsBOList();
List<Integer> selectBrandNewestSkns(List<String> brandIds,@Param(value = "offset") int offset,@Param(value = "pageSize") int limit);
}
\ No newline at end of file
... ...
... ... @@ -432,6 +432,16 @@
`p`.`brand_id`
]]>
</select>
<select id="selectBrandNewestSkns">
select erp_product_id from product where brand_id in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
order by first_shelve_time desc limit #{offset},#{pageSize}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.restapi;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.consumer.service.daoService.PressMySqlService;
@Controller
public class PressMySqlController {
@Autowired
private PressMySqlService pressMySqlService;
@RequestMapping(method = RequestMethod.GET, value = "/pressProductIndex")
@ResponseBody
public Map<String,Object> pressProductList(String brandIds,int size) {
return pressMySqlService.pressProductList(brandIds, size);
}
}
... ...
package com.yoho.search.consumer.service.daoService;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.search.dal.ProductMapper;
@Service
public class PressMySqlService {
@Autowired
private ProductMapper productMapper;
public Map<String, Object> pressProductList(String brandIds, int size) {
List<String> brandIdList = Arrays.asList(brandIds.split(","));
List<Integer> skns = productMapper.selectBrandNewestSkns(brandIdList, 1, size);
Map<String, Object> results = new HashMap<String, Object>();
results.put("skns", skns);
return results;
}
}
... ...