<resultMap id="spuAttrGroup" type="com.atguigu.gulimall.product.VO.SpuItemAttrGroupVo"> <result property="groupName" column="attr_group_name"></result> <collection property="attrs" ofType="com.atguigu.gulimall.product.VO.Attr"> <result property="attrId" column="attr_id"></result> <result property="attrName" column="attr_name"></result> <result property="attrValue" column="attr_value"></result> </collection> </resultMap> <select id="getAttrGroupWithAttrsBySpuId" resultMap="spuAttrGroup"> SELECT product.spu_id, pag.attr_group_id, pag.attr_group_name, product.attr_id, product.attr_name, product.attr_value FROM pms_product_attr_value product LEFT JOIN pms_attr_attrgroup_relation paar ON product.attr_id = paar.attr_id LEFT JOIN pms_attr_group pag ON paar.attr_group_id = pag.attr_group_id WHERE product.spu_id = #{spuId} AND pag.catelog_id = #{catalogId} </select>
异步
创建线程绑定数据
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
@ConfigurationProperties(prefix = "gulimall.thread")
@Component
@Data
public class ThreadPoolConfigProperties {
private Integer coreSize;
private Integer maxSize;
private Integer keepAliveTime;
}
#配置线程池
gulimall.thread.coreSize=20
gulimall.thread.maxSize=200
gulimall.thread.keepAliveTime=10
@Configuration
public class MyThreadConfig {
@Bean
public ThreadPoolExecutor threadPoolExecutor(ThreadPoolConfigProperties pool){
return new ThreadPoolExecutor(
pool.getCoreSize(),
pool.getMaxSize(),
pool.getKeepAliveTime(), TimeUnit.SECONDS,
new LinkedBlockingDeque<>(10000),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy());
}
}