mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-26 07:28:58 +08:00
feat(warehouse): 添加仓库货品分类迁移功能
- 在 WarehouseGoodsRepository 中添加 migrateCategory 方法,用于更新货品分类 - 在 WarehouseGoodsCategoryController 中添加 migration 接口 - 新增 MigrationRequest 类用于封装迁移请求参数 - 在 WarehouseGoodsCategoryService 中实现 migration 方法,调用 Repository 中的迁移方法
This commit is contained in:
@@ -3,7 +3,14 @@ package cn.lihongjie.coal.warehouseGoods.repository;
|
||||
import cn.lihongjie.coal.base.dao.BaseRepository;
|
||||
import cn.lihongjie.coal.warehouseGoods.entity.WarehouseGoodsEntity;
|
||||
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface WarehouseGoodsRepository extends BaseRepository<WarehouseGoodsEntity> {}
|
||||
public interface WarehouseGoodsRepository extends BaseRepository<WarehouseGoodsEntity> {
|
||||
@Modifying
|
||||
@Query("update WarehouseGoodsEntity w set w.category.id = :toId where w.category.id = :fromId")
|
||||
void migrateCategory(@Param("fromId") String fromId, @Param("toId") String toId);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@ import cn.lihongjie.coal.annotation.OrgScope;
|
||||
import cn.lihongjie.coal.annotation.SysLog;
|
||||
import cn.lihongjie.coal.base.dto.CommonQuery;
|
||||
import cn.lihongjie.coal.base.dto.IdRequest;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.CreateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.UpdateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryTreeDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.*;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.service.WarehouseGoodsCategoryService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -64,4 +61,13 @@ public class WarehouseGoodsCategoryController {
|
||||
public List<WarehouseGoodsCategoryTreeDto> treeByIds(@RequestBody IdRequest request) {
|
||||
return this.service.getTreeByIds(request);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/migration")
|
||||
@SysLog(action = "迁移", message = "fromId + ' -> ' + toId")
|
||||
public Object migration(@RequestBody MigrationRequest request) {
|
||||
this.service.migration(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lihongjie.coal.warehouseGoodsCategory.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class MigrationRequest {
|
||||
|
||||
private String fromId;
|
||||
|
||||
private String toId;
|
||||
|
||||
}
|
||||
@@ -6,10 +6,8 @@ import cn.lihongjie.coal.base.service.BaseService;
|
||||
import cn.lihongjie.coal.common.TreeUtils;
|
||||
import cn.lihongjie.coal.dbFunctions.DbFunctionService;
|
||||
import cn.lihongjie.coal.exception.BizException;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.CreateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.UpdateWarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryDto;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryTreeDto;
|
||||
import cn.lihongjie.coal.warehouseGoods.repository.WarehouseGoodsRepository;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.dto.*;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.entity.WarehouseGoodsCategoryEntity;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.mapper.WarehouseGoodsCategoryMapper;
|
||||
import cn.lihongjie.coal.warehouseGoodsCategory.repository.WarehouseGoodsCategoryRepository;
|
||||
@@ -42,6 +40,8 @@ public class WarehouseGoodsCategoryService
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired private DbFunctionService dbFunctionService;
|
||||
@Autowired
|
||||
private WarehouseGoodsRepository warehouseGoodsRepository;
|
||||
|
||||
public WarehouseGoodsCategoryDto create(CreateWarehouseGoodsCategoryDto request) {
|
||||
WarehouseGoodsCategoryEntity entity = mapper.toEntity(request);
|
||||
@@ -142,4 +142,12 @@ public class WarehouseGoodsCategoryService
|
||||
(root, query, criteriaBuilder) -> root.get("id").in(request.getIds()));
|
||||
return roots.stream().map(de -> this.mapper.toTreeDto(de)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public void migration(MigrationRequest request) {
|
||||
|
||||
|
||||
warehouseGoodsRepository.migrateCategory(request.getFromId(), request.getToId());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user