增加产品导入功能

This commit is contained in:
wuweihua
2026-09-04 18:08:08 +08:00
parent 5e15ab9c44
commit 7204497a65
16 changed files with 1644 additions and 22 deletions
@@ -0,0 +1,98 @@
package com.ruoyi.web.controller.price;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.price.domain.BmsProduct;
import com.ruoyi.price.domain.BmsProductCountry;
import com.ruoyi.price.service.IBmsProductService;
/**
* 产品列表(含 Excel 导入)
*
* @author ruoyi
*/
@RestController
@RequestMapping("/price/product")
public class ProductController extends BaseController
{
@Autowired
private IBmsProductService productService;
@PreAuthorize("@ss.hasPermi('price:product:list')")
@GetMapping("/list")
public TableDataInfo list(BmsProduct product)
{
startPage();
List<BmsProduct> list = productService.selectBmsProductList(product);
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('price:product:query')")
@GetMapping("/{productCode}/countries")
public AjaxResult countries(@PathVariable String productCode)
{
List<BmsProductCountry> list = productService.selectCountryListByProductCode(productCode);
return success(list);
}
@PreAuthorize("@ss.hasPermi('price:product:query')")
@GetMapping("/{productId}")
public AjaxResult getInfo(@PathVariable Long productId)
{
return success(productService.selectBmsProductById(productId));
}
@PreAuthorize("@ss.hasPermi('price:product:add')")
@Log(title = "产品列表", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody BmsProduct product)
{
product.setCreateBy(getUsername());
return toAjax(productService.insertBmsProduct(product));
}
@PreAuthorize("@ss.hasPermi('price:product:edit')")
@Log(title = "产品列表", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody BmsProduct product)
{
product.setUpdateBy(getUsername());
return toAjax(productService.updateBmsProduct(product));
}
@PreAuthorize("@ss.hasPermi('price:product:remove')")
@Log(title = "产品列表", businessType = BusinessType.DELETE)
@DeleteMapping("/{productIds}")
public AjaxResult remove(@PathVariable Long[] productIds)
{
return toAjax(productService.deleteBmsProductByIds(productIds));
}
/**
* 导入威狮B2C小包价表.xlsx(产品目录 + 国家服务明细)
*/
@Log(title = "产品列表", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:product:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
String message = productService.importProductExcel(file, updateSupport, getUsername());
return success(message);
}
}