单位-分类导出

This commit is contained in:
gong
2026-01-30 18:24:32 +08:00
parent c974f9e092
commit f92a593ff8
9 changed files with 103 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup; import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -52,6 +53,12 @@ public class ShopProdCategoryController {
return CzgResult.success(data); return CzgResult.success(data);
} }
@GetMapping("/export")
@OperationLog("商品分类-导出")
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
shopProdCategoryService.exportShopProdCategory(param, response);
}
@GetMapping("{id}") @GetMapping("{id}")
@OperationLog("商品分类-详情") @OperationLog("商品分类-详情")
//@SaAdminCheckPermission("shopProdCategory:info") //@SaAdminCheckPermission("shopProdCategory:info")

View File

@@ -13,6 +13,7 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup; import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -53,6 +54,12 @@ public class ShopProdUnitController {
return CzgResult.success(data); return CzgResult.success(data);
} }
@GetMapping("/export")
@OperationLog("商品单位-导出")
public void exportProduct(ShopProdUnitDTO param, HttpServletResponse response) {
shopProdUnitService.exportShopProdUnit(param, response);
}
@GetMapping("{id}") @GetMapping("{id}")
@OperationLog("商品单位-详情") @OperationLog("商品单位-详情")
//@SaAdminCheckPermission("shopProdUnit:info") //@SaAdminCheckPermission("shopProdUnit:info")

View File

@@ -0,0 +1,20 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* @author yjjie
* @date 2026/1/30 18:15
*/
@Data
public class ProductCategoryExportDTO {
@ExcelProperty("分类名称")
private String name;
@ExcelProperty("简称")
private String shortName;
}

View File

@@ -0,0 +1,40 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 商品单位导出
* @author yjjie
* @date 2026/1/30 17:51
*/
@Data
public class ProductUnitExportDTO {
@ExcelProperty("单位名称")
private String name;
/**
* 单位类型 number-计数 weight-记重
*/
@ExcelIgnore
private String unitType;
@ExcelProperty("单位类型")
private String unitTypeRemark;
/**
* 单位来源 1-系统预设 0-商家创建
*/
@ExcelIgnore
private Integer isSystem;
@ExcelProperty("单位来源")
private String isSystemRemark;
public String getUnitTypeRemark() {
return "number".equals(unitType) ? "计数" : "记重";
}
public String getIsSystemRemark() {
return isSystem == 1 ? "系统预设" : "商家创建";
}
}

View File

@@ -4,6 +4,7 @@ import com.czg.product.dto.ShopProdCategoryDTO;
import com.czg.product.entity.ShopProdCategory; import com.czg.product.entity.ShopProdCategory;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -30,6 +31,8 @@ public interface ShopProdCategoryService extends IService<ShopProdCategory> {
*/ */
List<ShopProdCategoryDTO> getShopProdCategoryList(ShopProdCategoryDTO param); List<ShopProdCategoryDTO> getShopProdCategoryList(ShopProdCategoryDTO param);
void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response);
/** /**
* 获取店铺商品分类详情 * 获取店铺商品分类详情
* @param id id * @param id id

View File

@@ -4,6 +4,7 @@ import com.czg.product.dto.ShopProdUnitDTO;
import com.czg.product.entity.ShopProdUnit; import com.czg.product.entity.ShopProdUnit;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -31,6 +32,8 @@ public interface ShopProdUnitService extends IService<ShopProdUnit> {
*/ */
List<ShopProdUnitDTO> getShopProdUnitList(ShopProdUnitDTO param); List<ShopProdUnitDTO> getShopProdUnitList(ShopProdUnitDTO param);
void exportShopProdUnit(ShopProdUnitDTO param, HttpServletResponse response);
/** /**
* 获取商品单位详情 * 获取商品单位详情
* *

View File

@@ -277,7 +277,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
.setIsSale(getMainSkuIsSale(exportDTO)) .setIsSale(getMainSkuIsSale(exportDTO))
.setGroupTitleName(proGroupDTO.getTitle()) .setGroupTitleName(proGroupDTO.getTitle())
.setGroupProductNumber(Optional.ofNullable(proGroupDTO.getNumber()).map(String::valueOf).orElse("")) .setGroupProductNumber(Optional.ofNullable(proGroupDTO.getNumber()).map(String::valueOf).orElse(""))
.setGroupProductName(good.getProName() + " " + good.getSkuName()); .setGroupProductName(good.getProName() + "-" + good.getSkuName());
dataList.add(pkgDto); dataList.add(pkgDto);
} }

View File

@@ -3,7 +3,9 @@ package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.constants.SystemConstants; import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.product.dto.ProductCategoryExportDTO;
import com.czg.product.dto.ShopProdCategoryDTO; import com.czg.product.dto.ShopProdCategoryDTO;
import com.czg.product.entity.ShopProdCategory; import com.czg.product.entity.ShopProdCategory;
import com.czg.product.service.ProductService; import com.czg.product.service.ProductService;
@@ -16,6 +18,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain; import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -62,6 +65,14 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
return super.listAs(queryWrapper, ShopProdCategoryDTO.class); return super.listAs(queryWrapper, ShopProdCategoryDTO.class);
} }
@Override
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
queryWrapper.eq(ShopProdCategory::getStatus, SystemConstants.OneZero.ONE);
List<ProductCategoryExportDTO> exportList = listAs(queryWrapper, ProductCategoryExportDTO.class);
ExcelExportUtil.exportToResponse(exportList, ProductCategoryExportDTO.class, "商品分类列表", response);
}
@Override @Override
public ShopProdCategoryDTO getShopProdCategoryById(Long id) { public ShopProdCategoryDTO getShopProdCategoryById(Long id) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId(0L);

View File

@@ -3,7 +3,9 @@ package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.constants.SystemConstants; import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.product.dto.ProductUnitExportDTO;
import com.czg.product.dto.ShopProdUnitDTO; import com.czg.product.dto.ShopProdUnitDTO;
import com.czg.product.entity.ShopProdUnit; import com.czg.product.entity.ShopProdUnit;
import com.czg.product.enums.UnitTypeEnum; import com.czg.product.enums.UnitTypeEnum;
@@ -15,6 +17,7 @@ import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain; import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@@ -59,6 +62,14 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
return super.listAs(queryWrapper, ShopProdUnitDTO.class); return super.listAs(queryWrapper, ShopProdUnitDTO.class);
} }
@Override
public void exportShopProdUnit(ShopProdUnitDTO param, HttpServletResponse response) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
queryWrapper.eq(ShopProdUnit::getStatus,SystemConstants.OneZero.ONE);
List<ProductUnitExportDTO> unitExportDTOList = listAs(queryWrapper, ProductUnitExportDTO.class);
ExcelExportUtil.exportToResponse(unitExportDTOList, ProductUnitExportDTO.class, "单位列表", response);
}
@Override @Override
public ShopProdUnitDTO getShopProdUnitById(Long id) { public ShopProdUnitDTO getShopProdUnitById(Long id) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId(0L);