|
@@ -76,12 +76,6 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private IGoodsSkuService goodsSkuService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IGoodsCategoryService goodsCategoryService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ISysUserService sysUserService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private MapperFacade mapperFacade;
|
|
|
|
|
@@ -96,11 +90,10 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
startPage();
|
|
|
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
|
|
|
queryWrapper.lambda().like(null != queryParam && StringUtils.isNotBlank(queryParam.getTitle()), Goods::getTitle, queryParam.getTitle());
|
|
|
- if (StringUtils.isNotBlank(queryParam.getGoodsId())) {
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(null != queryParam && StringUtils.isNotBlank(queryParam.getGoodsId()),
|
|
|
- Goods::getGoodsId, Long.valueOf(queryParam.getGoodsId()));
|
|
|
- }
|
|
|
+
|
|
|
+ queryWrapper.lambda()
|
|
|
+ .eq(null != queryParam && null != queryParam.getGoodsId() && 0 != queryParam.getGoodsId(),
|
|
|
+ Goods::getGoodsId, queryParam.getGoodsId());
|
|
|
// 成本
|
|
|
queryWrapper.lambda().ge(null != queryParam && null != queryParam.getMinCost(), Goods::getCost, queryParam.getMinCost());
|
|
|
queryWrapper.lambda().le(null != queryParam && null != queryParam.getMaxCost(), Goods::getCost, queryParam.getMaxCost());
|
|
@@ -126,11 +119,11 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
*/
|
|
|
@PostMapping(value = "/detail")
|
|
|
public AjaxResult getGoodsDetail(@RequestBody JSONObject jsonObject) {
|
|
|
- String goodsId = jsonObject.getString("goodsId");
|
|
|
- if (StringUtils.isBlank(goodsId)){
|
|
|
+ Long goodsId = jsonObject.getLong("goodsId");
|
|
|
+ if (null == goodsId || 0 == goodsId){
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
|
- Goods goods = goodsService.getById(Long.valueOf(goodsId));
|
|
|
+ Goods goods = goodsService.getById(goodsId);
|
|
|
if(null == goods) {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
@@ -157,9 +150,6 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
@ApiOperation(value = "新增商品信息", notes = "后台商品管理新增商品")
|
|
|
@PostMapping("/create")
|
|
|
public AjaxResult goodsCreate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
|
- if (StringUtils.isNotBlank(goodsParam.getGoodsId())) {
|
|
|
- return AjaxResult.error("该商品已存在");
|
|
|
- }
|
|
|
Goods goods = mapperFacade.map(goodsParam, Goods.class);
|
|
|
// 1、校验名称是否重复(商品表)
|
|
|
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
|
@@ -208,10 +198,10 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
@ApiOperation(value = "编辑商品信息", notes = "后台商品管理修改商品信息")
|
|
|
@PostMapping("/update")
|
|
|
public AjaxResult goodsUpdate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
|
- if (null == goodsParam || StringUtils.isBlank(goodsParam.getGoodsId())) {
|
|
|
+ if (null == goodsParam || null != goodsParam.getGoodsId() || 0 == goodsParam.getGoodsId()) {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
|
- Goods oldGoods = goodsService.getById(Long.valueOf(goodsParam.getGoodsId()));
|
|
|
+ Goods oldGoods = goodsService.getById(goodsParam.getGoodsId());
|
|
|
if(null == oldGoods || null == oldGoods.getGoodsId()) {
|
|
|
return AjaxResult.error("商品'" + oldGoods.getTitle() + "'编辑失败,商品ID异常");
|
|
|
}
|
|
@@ -274,7 +264,7 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
|
try {
|
|
|
- goodsService.lambdaUpdate().set(Goods::getStatus, status).eq(Goods::getGoodsId, Long.valueOf(goodsId)).update();
|
|
|
+ goodsService.lambdaUpdate().set(Goods::getStatus, status).eq(Goods::getGoodsId, goodsId).update();
|
|
|
// 查询代金券信息
|
|
|
} catch (Exception e) {
|
|
|
return AjaxResult.error("操作失败");
|
|
@@ -291,11 +281,11 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
*/
|
|
|
@PostMapping(value = "/remove")
|
|
|
public AjaxResult removeGoods(@RequestBody JSONObject jsonObject) {
|
|
|
- String goodsId = jsonObject.getString("goodsId");
|
|
|
- if (StringUtils.isBlank(goodsId)){
|
|
|
+ Long goodsId = jsonObject.getLong("goodsId");
|
|
|
+ if (null == goodsId || 0 == goodsId){
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
|
- Goods goods = goodsService.getById(Long.valueOf(goodsId));
|
|
|
+ Goods goods = goodsService.getById(goodsId);
|
|
|
if(null == goods || null == goods.getGoodsId() || 0 == goods.getGoodsId()) {
|
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|