迁移 商品 分类
This commit is contained in:
parent
88df994553
commit
c544cf5d81
|
|
@ -30,9 +30,6 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class CurShopProdCategoryServiceImpl extends ServiceImpl<CurShopProdCategoryMapper, CurShopProdCategory> implements CurShopProdCategoryService {
|
public class CurShopProdCategoryServiceImpl extends ServiceImpl<CurShopProdCategoryMapper, CurShopProdCategory> implements CurShopProdCategoryService {
|
||||||
|
|
||||||
@Resource
|
|
||||||
private CurShopIdRelationService curShopIdRelationService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OldShopCategoryService oldShopCategoryService;
|
private OldShopCategoryService oldShopCategoryService;
|
||||||
|
|
||||||
|
|
@ -41,30 +38,28 @@ public class CurShopProdCategoryServiceImpl extends ServiceImpl<CurShopProdCateg
|
||||||
public CzgResult<String> mergeData() {
|
public CzgResult<String> mergeData() {
|
||||||
getMapper().truncateTable();
|
getMapper().truncateTable();
|
||||||
|
|
||||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
execMergeCategory();
|
||||||
|
|
||||||
execMergeCategory(oldAndCurShopIdMap);
|
|
||||||
return CzgResult.success("迁移成功");
|
return CzgResult.success("迁移成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execMergeCategory(Map<Long, Long> oldAndCurShopIdMap) {
|
private void execMergeCategory() {
|
||||||
Page<OldShopCategory> page = oldShopCategoryService.page(PageUtils.buildPage());
|
Page<OldShopCategory> page = oldShopCategoryService.page(PageUtils.buildPage());
|
||||||
|
|
||||||
while (!page.getRecords().isEmpty()) {
|
while (!page.getRecords().isEmpty()) {
|
||||||
saveCategory(page.getRecords(), oldAndCurShopIdMap);
|
saveCategory(page.getRecords());
|
||||||
|
|
||||||
page = oldShopCategoryService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
page = oldShopCategoryService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCategory(List<OldShopCategory> oldShopCategoryList, Map<Long, Long> oldShopIdMap) {
|
private void saveCategory(List<OldShopCategory> oldShopCategoryList) {
|
||||||
List<CurShopProdCategory> curShopProdCategories = new ArrayList<>();
|
List<CurShopProdCategory> curShopProdCategories = new ArrayList<>();
|
||||||
|
|
||||||
for (OldShopCategory oldShopCategory : oldShopCategoryList) {
|
for (OldShopCategory oldShopCategory : oldShopCategoryList) {
|
||||||
Long shopId = oldShopIdMap.get(Long.valueOf(oldShopCategory.getShopId()));
|
Long shopId = Long.valueOf(oldShopCategory.getShopId());
|
||||||
CurShopProdCategory curShopProdCategory = new CurShopProdCategory();
|
CurShopProdCategory curShopProdCategory = new CurShopProdCategory();
|
||||||
curShopProdCategory.setId(Long.valueOf(oldShopCategory.getId()));
|
curShopProdCategory.setId(Long.valueOf(oldShopCategory.getId()));
|
||||||
curShopProdCategory.setShopId(shopId == null ? 1L : shopId);
|
curShopProdCategory.setShopId(shopId);
|
||||||
curShopProdCategory.setName(oldShopCategory.getName());
|
curShopProdCategory.setName(oldShopCategory.getName());
|
||||||
curShopProdCategory.setShortName(oldShopCategory.getShortName());
|
curShopProdCategory.setShortName(oldShopCategory.getShortName());
|
||||||
curShopProdCategory.setPid(StrUtil.isBlank(oldShopCategory.getPid()) ? 1L : Long.parseLong(oldShopCategory.getPid()));
|
curShopProdCategory.setPid(StrUtil.isBlank(oldShopCategory.getPid()) ? 1L : Long.parseLong(oldShopCategory.getPid()));
|
||||||
|
|
|
||||||
|
|
@ -90,5 +90,12 @@
|
||||||
#### 执行表
|
#### 执行表
|
||||||
- tb_shop_prod_spec 表
|
- tb_shop_prod_spec 表
|
||||||
|
|
||||||
|
### 12. 商品分类
|
||||||
|
> /merge/product/mergeCategory
|
||||||
|
#### 执行表
|
||||||
|
- tb_shop_prod_category 表
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue