use of com.goodskill.entity.Goods in project goodsKill by techa03.
the class GoodskillSeataApplication method testGlobalTransaction.
/**
* 测试seata分布式事务
*/
@GetMapping("/test")
@GlobalTransactional
public void testGlobalTransaction() {
Goods goods = new Goods();
goods.setName("test");
goodsService.addGoods(goods, null);
Seckill seckill = seckillService.getById(1001L);
seckill.setNumber(seckill.getNumber() - 1);
seckillService.saveOrUpdate(seckill);
// 测试异常情况
throw new RuntimeException();
}
use of com.goodskill.entity.Goods in project goodsKill by techa03.
the class MyJob method execute.
@Override
public void execute(ShardingContext context) {
switch(context.getShardingItem()) {
case 0:
try {
log.info("商品es索引开始更新。。。");
List list = goodsService.list().parallelStream().map(g -> {
Goods goods = new Goods();
BeanUtils.copyProperties(g, goods);
return goods;
}).collect(Collectors.toList());
goodsEsService.saveBatch(list);
log.info("商品es索引更新成功,条数:{}", list.size());
} catch (Exception e) {
log.warn("商品es索引定时任务更新失败!", e);
}
break;
// case n: ...
default:
break;
}
}
use of com.goodskill.entity.Goods in project goodsKill by techa03.
the class GoodsServiceImplTest method addGoods.
@Test
public void addGoods() {
Goods goods = new Goods();
goodsService.addGoods(goods, new byte[100]);
verify(goodsEsService, only()).save(any());
}
Aggregations