出入库商品添加库存警告线
This commit is contained in:
@@ -1,21 +1,32 @@
|
||||
package cn.ysk.cashier.controller.product;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.dto.product.StockQueryDto;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.service.product.StockService;
|
||||
import cn.ysk.cashier.utils.BeanUtil;
|
||||
import cn.ysk.cashier.utils.SecurityUtils;
|
||||
import cn.ysk.cashier.vo.StockPageImpl;
|
||||
import cn.ysk.cashier.vo.StockUpdateValueVO;
|
||||
import cn.ysk.cashier.vo.StockUpdateWarnLineVO;
|
||||
import cn.ysk.cashier.vo.StockV2Vo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -89,7 +100,14 @@ public class StockController {
|
||||
public ResponseEntity<Object> queryTbProductV2(StockQueryDto criteria,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size){
|
||||
return new ResponseEntity<>(stockService.queryAllV2(criteria,page,size), HttpStatus.OK);
|
||||
Page<StockV2Vo> stockV2Vos = stockService.queryAllV2(criteria, page, size);
|
||||
Map<String, Object> dataMap = BeanUtil.transBean2Map(stockV2Vos);
|
||||
if (stockV2Vos.getContent().isEmpty()) {
|
||||
dataMap.put("warnLine", 0);
|
||||
}else {
|
||||
dataMap.put("warnLine", stockV2Vos.getContent().get(0).getWarnLine());
|
||||
}
|
||||
return new ResponseEntity<>(dataMap, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/sku")
|
||||
@@ -113,4 +131,14 @@ public class StockController {
|
||||
return new ResponseEntity<>("修改成功", HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("warnLine")
|
||||
@ApiOperation("修改商品警告线")
|
||||
public ResponseEntity<Object> updateProductWarnLine(@RequestBody StockUpdateWarnLineVO stockUpdateWarnLineVO) {
|
||||
if (StrUtil.isBlank(stockUpdateWarnLineVO.getShopId()) || stockUpdateWarnLineVO.getWarnLine() == null || stockUpdateWarnLineVO.getWarnLine() <= 0) {
|
||||
throw new BadRequestException("参数有误");
|
||||
}
|
||||
stockService.updateProductWarnLine(stockUpdateWarnLineVO);
|
||||
return new ResponseEntity<>("修改成功", HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user