| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.ProductModelDto; |
| | | import com.ruoyi.basic.mapper.ProductMapper; |
| | | import com.ruoyi.basic.mapper.ProductModelMapper; |
| | | import com.ruoyi.basic.pojo.Product; |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.production.dto.ProductStructureDto; |
| | | import com.ruoyi.production.mapper.ProductStructureMapper; |
| | | import com.ruoyi.production.pojo.ProductStructure; |
| | | import com.ruoyi.production.service.ProductStructureService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private ProductStructureMapper productStructureMapper; |
| | | @Autowired |
| | | private ProductModelMapper productModelMapper; |
| | | @Autowired |
| | | private ProductMapper productMapper; |
| | | |
| | | @Override |
| | | public List<ProductStructureDto> listByproductModelId(Long productModelId) { |
| | | return productStructureMapper.listByproductModelId( productModelId); |
| | | public ProductModelDto listByproductModelId(Long productModelId) { |
| | | ProductModel productModel = productModelMapper.selectById(productModelId); |
| | | Product product = productMapper.selectById(productModel.getProductId()); |
| | | ProductModelDto productModelDto = new ProductModelDto(); |
| | | BeanUtils.copyProperties(productModel,productModelDto); |
| | | productModelDto.setProductName(product.getProductName()); |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listByproductModelId(productModelId); |
| | | productModelDto.setProductStructureList(productStructureDtos); |
| | | return productModelDto; |
| | | } |
| | | |
| | | @Override |
| | | public Boolean addProductStructureDto(ProductStructureDto productStructureDto) { |
| | | this.remove(new QueryWrapper<ProductStructure>().lambda().eq(ProductStructure::getProductModelId, productStructureDto.getProductModelId())); |
| | | this.remove(new QueryWrapper<ProductStructure>().lambda().eq(ProductStructure::getParentId, productStructureDto.getParentId())); |
| | | productStructureDto.getProductStructureList().forEach(productStructure -> { |
| | | productStructure.setParentId(productStructureDto.getParentId()); |
| | | }); |
| | | return this.saveBatch(productStructureDto.getProductStructureList()); |
| | | } |
| | | } |