package com.ruoyi.mall.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.mall.domain.MallBatchDetail; import com.ruoyi.mall.service.IMallBatchDetailService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 批次说明Controller * * @author lsm * @date 2023-10-19 */ @RestController @RequestMapping("/mall/mallBatchDetail") public class MallBatchDetailController extends BaseController { @Autowired private IMallBatchDetailService mallBatchDetailService; /** * 查询批次说明列表 */ @PreAuthorize("@ss.hasPermi('mall:mallBatchDetail:list')") @GetMapping("/list") public TableDataInfo list(MallBatchDetail mallBatchDetail) { startPage(); List list = mallBatchDetailService.selectMallBatchDetailList(mallBatchDetail); return getDataTable(list); } /** * 导出批次说明列表 */ @PreAuthorize("@ss.hasPermi('mall:mallBatchDetail:export')") @Log(title = "批次说明", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, MallBatchDetail mallBatchDetail) { List list = mallBatchDetailService.selectMallBatchDetailList(mallBatchDetail); ExcelUtil util = new ExcelUtil(MallBatchDetail.class); util.exportExcel(response, list, "批次说明数据"); } /** * 获取批次说明详细信息 */ @PreAuthorize("@ss.hasPermi('mall:mallBatchDetail:query')") @GetMapping(value = "/{batchDetailId}") public AjaxResult getInfo(@PathVariable("batchDetailId") Long batchDetailId) { return AjaxResult.success(mallBatchDetailService.selectMallBatchDetailByBatchDetailId(batchDetailId)); } /** * 新增批次说明 */ @PreAuthorize("@ss.hasPermi('mall:mallBatchDetail:add')") @Log(title = "批次说明", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody MallBatchDetail mallBatchDetail) { //新增设限 MallBatchDetail param = new MallBatchDetail(); param.setBatchId(mallBatchDetail.getBatchId()); param.setProvinceId(mallBatchDetail.getProvinceId()); param.setYear(mallBatchDetail.getYear()); List oldList = mallBatchDetailService.selectMallBatchDetailList(param); if(null != oldList && oldList.size()>0){ return AjaxResult.error(500,"不能重复添加"); } return toAjax(mallBatchDetailService.insertMallBatchDetail(mallBatchDetail)); } /** * 修改批次说明 */ @PreAuthorize("@ss.hasPermi('mall:mallBatchDetail:edit')") @Log(title = "批次说明", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody MallBatchDetail mallBatchDetail) { return toAjax(mallBatchDetailService.updateMallBatchDetail(mallBatchDetail)); } /** * 删除批次说明 */ @PreAuthorize("@ss.hasPermi('mall:mallBatchDetail:remove')") @Log(title = "批次说明", businessType = BusinessType.DELETE) @DeleteMapping("/{batchDetailIds}") public AjaxResult remove(@PathVariable Long[] batchDetailIds) { return toAjax(mallBatchDetailService.deleteMallBatchDetailByBatchDetailIds(batchDetailIds)); } }