package org.dromara.eims.controller; import java.util.List; import lombok.RequiredArgsConstructor; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.constraints.*; import cn.dev33.satoken.annotation.SaCheckPermission; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.log.annotation.Log; import org.dromara.common.web.core.BaseController; import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.core.domain.R; import org.dromara.common.core.validate.AddGroup; import org.dromara.common.core.validate.EditGroup; import org.dromara.common.log.enums.BusinessType; import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.eims.domain.vo.EimsInventoryVo; import org.dromara.eims.domain.bo.EimsInventoryBo; import org.dromara.eims.service.IEimsInventoryService; import org.dromara.common.mybatis.core.page.TableDataInfo; /** * 盘点 * * @author zhuguifei * @date 2025-01-16 */ @Validated @RequiredArgsConstructor @RestController @RequestMapping("/eims/inventory") public class EimsInventoryController extends BaseController { private final IEimsInventoryService eimsInventoryService; /** * 查询盘点列表 */ @SaCheckPermission("eims:inventory:list") @GetMapping("/list") public TableDataInfo list(EimsInventoryBo bo, PageQuery pageQuery) { return eimsInventoryService.queryPageList(bo, pageQuery); } /** * 导出盘点列表 */ @SaCheckPermission("eims:inventory:export") @Log(title = "盘点", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(EimsInventoryBo bo, HttpServletResponse response) { List list = eimsInventoryService.queryList(bo); ExcelUtil.exportExcel(list, "盘点", EimsInventoryVo.class, response); } /** * 获取盘点详细信息 * * @param inventoryId 主键 */ @SaCheckPermission("eims:inventory:query") @GetMapping("/{inventoryId}") public R getInfo(@NotNull(message = "主键不能为空") @PathVariable Long inventoryId) { return R.ok(eimsInventoryService.queryById(inventoryId)); } /** * 新增盘点 */ @SaCheckPermission("eims:inventory:add") @Log(title = "盘点", businessType = BusinessType.INSERT) @RepeatSubmit() @PostMapping() public R add(@Validated(AddGroup.class) @RequestBody EimsInventoryBo bo) { return toAjax(eimsInventoryService.insertByBo(bo)); } /** * 修改盘点 */ @SaCheckPermission("eims:inventory:edit") @Log(title = "盘点", businessType = BusinessType.UPDATE) @RepeatSubmit() @PutMapping() public R edit(@Validated(EditGroup.class) @RequestBody EimsInventoryBo bo) { return toAjax(eimsInventoryService.updateByBo(bo)); } /** * 删除盘点 * * @param inventoryIds 主键串 */ @SaCheckPermission("eims:inventory:remove") @Log(title = "盘点", businessType = BusinessType.DELETE) @DeleteMapping("/{inventoryIds}") public R remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] inventoryIds) { return toAjax(eimsInventoryService.deleteWithValidByIds(List.of(inventoryIds), true)); } }