package com.yuanchu.mom.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.mom.pojo.ImportRepertory; import com.yuanchu.mom.pojo.dto.ImportRepertoryDto; import com.yuanchu.mom.utils.JackSonUtil; import com.yuanchu.mom.utils.Jwt; import com.yuanchu.mom.vo.Result; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import com.yuanchu.mom.service.ImportRepertoryService; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 成品入库表(ImportRepertory)表控制层 * * @author zss * @since 2023-08-10 10:27:01 */ @Api(tags = "WMS管理-->成品入库") @RestController @RequestMapping("/importRepertory") public class ImportRepertoryController { @Autowired private ImportRepertoryService importRepertoryService; @Resource Jwt jwt; @ApiOperation(value = "新增成品入库") @PostMapping("/addImpRep") public Result addSale(@RequestHeader("token") String token,@Validated @RequestBody ImportRepertoryDto importRepertoryDto) throws Exception { Map data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); importRepertoryService.addImpRep(data.get("name").replaceAll("\"", ""), importRepertoryDto); return Result.success("新增成功!"); } @ApiOperation("查询所有入库列表") @ApiImplicitParams(value = { @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), @ApiImplicitParam(name = "orderCode", value = "订单编号", dataTypeClass = String.class), @ApiImplicitParam(name = "name", value = "材料名称", dataTypeClass = String.class), @ApiImplicitParam(name = "time", value = "入库日期", dataTypeClass = String.class) }) @GetMapping("/selectAllImpRep") public Result selectAllImpRep(int pageSize, int countSize, String orderCode, String name, String time) { IPage> importRepertoryPage = importRepertoryService.selectAllImpRep(new Page(pageSize, countSize), orderCode, name, time); Map map = new HashMap<>(); map.put("total", importRepertoryPage.getTotal()); map.put("row", importRepertoryPage.getRecords()); return Result.success(map); } @ApiOperation("根据id查看入库详情") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "入库id", dataTypeClass = Integer.class, required = true) }) @GetMapping("/selectImpRepById") public Result selectImpRepById(Integer id) { return Result.success(importRepertoryService.getById(id)); } @ApiOperation(value = "根据入库id删除") @ApiImplicitParams(value = { @ApiImplicitParam(name = "id", value = "入库id", dataTypeClass = Integer.class, required = true) }) @PostMapping("/delImpRep") public Result delImpRep(Integer id) { importRepertoryService.delImpRep(id); return Result.success(); } @ApiOperation(value = "批量删除") @ApiImplicitParams(value = { @ApiImplicitParam(name = "ids", value = "ids", dataTypeClass = Integer.class, dataType = "List", required = true) }) @PostMapping("/delAllImpRep") public Result delAllImpRep(@RequestParam("ids") List ids) { importRepertoryService.delAllImpRep(ids); return Result.success(); } }