package com.oying.modules.pc.product.service.impl;
|
|
import com.oying.modules.pc.product.domain.ProductCategory;
|
import com.oying.utils.FileUtil;
|
import lombok.RequiredArgsConstructor;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.oying.modules.pc.product.service.ProductCategoryService;
|
import com.oying.modules.pc.product.domain.dto.ProductCategoryQueryCriteria;
|
import com.oying.modules.pc.product.mapper.ProductCategoryMapper;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import com.oying.utils.PageUtil;
|
import java.util.List;
|
import java.util.Map;
|
import java.io.IOException;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.LinkedHashMap;
|
import com.oying.utils.PageResult;
|
|
/**
|
* @description 服务实现
|
* @author lzp
|
* @date 2025-05-13
|
**/
|
@Service
|
@RequiredArgsConstructor
|
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements ProductCategoryService {
|
|
private final ProductCategoryMapper productCategoryMapper;
|
|
@Override
|
public PageResult<ProductCategory> queryAll(ProductCategoryQueryCriteria criteria, Page<Object> page){
|
return PageUtil.toPage(productCategoryMapper.findAll(criteria, page));
|
}
|
|
@Override
|
public List<ProductCategory> queryAll(ProductCategoryQueryCriteria criteria){
|
return productCategoryMapper.findAll(criteria);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void create(ProductCategory resources) {
|
productCategoryMapper.insert(resources);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void update(ProductCategory resources) {
|
ProductCategory productCategory = getById(resources.getId());
|
productCategory.copy(resources);
|
productCategoryMapper.updateById(productCategory);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void deleteAll(List<Long> ids) {
|
productCategoryMapper.deleteBatchIds(ids);
|
}
|
|
@Override
|
public void download(List<ProductCategory> all, HttpServletResponse response) throws IOException {
|
List<Map<String, Object>> list = new ArrayList<>();
|
for (ProductCategory productCategory : all) {
|
Map<String, Object> map = new LinkedHashMap<>();
|
map.put("商品ID", productCategory.getProductId());
|
map.put("所属一级店铺类目ID", productCategory.getStoreCategoryId());
|
map.put("所属二级店铺类目ID", productCategory.getStoreCategorySecondId());
|
map.put("创建者", productCategory.getCreateBy());
|
map.put("创建时间", productCategory.getCreateTime());
|
map.put("修改者", productCategory.getUpdateBy());
|
map.put("修改时间", productCategory.getUpdateTime());
|
list.add(map);
|
}
|
FileUtil.downloadExcel(list, response);
|
}
|
}
|