package com.ruoyi.stock.controller;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
import com.ruoyi.framework.web.domain.AjaxResult;
|
import com.ruoyi.stock.dto.ManufacturerDto;
|
import com.ruoyi.stock.execl.ManufacturerExcelDto;
|
import com.ruoyi.stock.pojo.Manufacturer;
|
import com.ruoyi.stock.service.ManufacturerService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.servlet.http.HttpServletResponse;
|
import lombok.AllArgsConstructor;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.util.List;
|
|
/**
|
* <p>
|
* 厂家前端控制器
|
* </p>
|
*
|
* @author 芯导软件(江苏)有限公司
|
* @since 2026-05-28 09:52:35
|
*/
|
@RestController
|
@RequestMapping("/stock/manufacturer")
|
@AllArgsConstructor
|
@Tag(name = "厂家管理")
|
public class ManufacturerController {
|
|
private ManufacturerService manufacturerService;
|
|
/**
|
* 厂家新增
|
* @param manufacturer
|
* @return
|
*/
|
@PostMapping("/add")
|
@Log(title = "厂家-新增", businessType = BusinessType.INSERT)
|
@Operation(summary = "新增厂家")
|
public AjaxResult add(@RequestBody Manufacturer manufacturer) {
|
manufacturerService.saveManufacturer(manufacturer);
|
return AjaxResult.success();
|
}
|
|
/**
|
* 厂家删除
|
* @param ids
|
* @return
|
*/
|
@DeleteMapping("/del")
|
@Log(title = "厂家-删除", businessType = BusinessType.DELETE)
|
@Operation(summary = "删除厂家")
|
public AjaxResult delManufacturer(@RequestBody List<Long> ids) {
|
if(CollectionUtils.isEmpty(ids)){
|
return AjaxResult.error("请选择至少一条数据");
|
}
|
manufacturerService.delManufacturer(ids);
|
return AjaxResult.success();
|
}
|
|
/**
|
* 厂家详情
|
* @param id
|
* @return
|
*/
|
@GetMapping("/{id}")
|
@Log(title = "厂家-详情", businessType = BusinessType.OTHER)
|
@Operation(summary = "厂家详情")
|
public AjaxResult manufacturerDetail(@PathVariable("id") Long id) {
|
return AjaxResult.success(manufacturerService.manufacturerDetail(id));
|
}
|
|
/**
|
* 厂家修改
|
* @param manufacturer
|
* @return
|
*/
|
@PostMapping("/update")
|
@Log(title = "厂家-修改", businessType = BusinessType.UPDATE)
|
@Operation(summary = "修改厂家")
|
public AjaxResult update(@RequestBody Manufacturer manufacturer) {
|
manufacturerService.manufacturerUpdate(manufacturer);
|
return AjaxResult.success();
|
}
|
|
/**
|
* 厂家管理分页查询
|
* @param page
|
* @param manufacturerDto
|
* @return
|
*/
|
@GetMapping("/listPage")
|
@Log(title = "厂家-分页查询", businessType = BusinessType.OTHER)
|
@Operation(summary = "厂家分页查询")
|
public AjaxResult manufacturerListPage(Page page, ManufacturerDto manufacturerDto) {
|
return AjaxResult.success(manufacturerService.manufacturerListPage(page, manufacturerDto));
|
}
|
|
/**
|
* 厂家导出
|
* @param response
|
* @param manufacturerDto
|
*/
|
@PostMapping("/export")
|
@Log(title = "厂家-导出", businessType = BusinessType.EXPORT)
|
@Operation(summary = "厂家导出")
|
public void manufacturerExport(HttpServletResponse response, ManufacturerDto manufacturerDto) {
|
manufacturerService.manufacturerExport(response, manufacturerDto);
|
}
|
|
/**
|
* 下载模板
|
* @param response
|
*/
|
@PostMapping("/downloadTemplate")
|
@Log(title = "厂家-下载模板", businessType = BusinessType.EXPORT)
|
@Operation(summary = "下载厂家模板")
|
public void downloadTemplate(HttpServletResponse response) {
|
ExcelUtil<ManufacturerExcelDto> util = new ExcelUtil<>(ManufacturerExcelDto.class);
|
util.importTemplateExcel(response, "厂家档案模板");
|
}
|
|
/**
|
* 厂家导入
|
*/
|
@PostMapping("/import")
|
@Log(title = "厂家-导入", businessType = BusinessType.IMPORT)
|
@Operation(summary = "导入厂家")
|
public AjaxResult importData(MultipartFile file) {
|
Boolean b = manufacturerService.importData(file);
|
if (b) {
|
return AjaxResult.success("导入成功");
|
}
|
return AjaxResult.error("导入失败");
|
}
|
|
/**
|
* 厂家选项接口
|
* @return
|
*/
|
@GetMapping("/getOptions")
|
@Log(title = "厂家-选项接口", businessType = BusinessType.OTHER)
|
@Operation(summary = "获取厂家选项")
|
public AjaxResult getOptions() {
|
return AjaxResult.success(manufacturerService.list());
|
}
|
}
|