|
@@ -50,12 +50,6 @@ public class GoodsMgrController extends BaseApiController {
|
|
@Autowired
|
|
@Autowired
|
|
private IGoodsSkuService goodsSkuService;
|
|
private IGoodsSkuService goodsSkuService;
|
|
|
|
|
|
-// @Autowired
|
|
|
|
-// private IGoodsCategoryService goodsCategoryService;
|
|
|
|
-
|
|
|
|
-// @Autowired
|
|
|
|
-// private ISysUserService sysUserService;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private MapperFacade mapperFacade;
|
|
private MapperFacade mapperFacade;
|
|
|
|
|
|
@@ -70,7 +64,9 @@ public class GoodsMgrController extends BaseApiController {
|
|
startPage();
|
|
startPage();
|
|
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
|
|
QueryWrapper<Goods> queryWrapper = new QueryWrapper<Goods>();
|
|
queryWrapper.lambda().like(null != queryParam && StringUtils.isNotBlank(queryParam.getTitle()), Goods::getTitle, queryParam.getTitle());
|
|
queryWrapper.lambda().like(null != queryParam && StringUtils.isNotBlank(queryParam.getTitle()), Goods::getTitle, queryParam.getTitle());
|
|
- queryWrapper.lambda().eq(null != queryParam && null != queryParam.getGoodsId(), Goods::getGoodsId, 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().ge(null != queryParam && null != queryParam.getMinCost(), Goods::getCost, queryParam.getMinCost());
|
|
queryWrapper.lambda().le(null != queryParam && null != queryParam.getMaxCost(), Goods::getCost, queryParam.getMaxCost());
|
|
queryWrapper.lambda().le(null != queryParam && null != queryParam.getMaxCost(), Goods::getCost, queryParam.getMaxCost());
|
|
@@ -96,12 +92,12 @@ public class GoodsMgrController extends BaseApiController {
|
|
*/
|
|
*/
|
|
@PostMapping(value = "/detail")
|
|
@PostMapping(value = "/detail")
|
|
public AjaxResult getGoodsDetail(@RequestBody JSONObject jsonObject) {
|
|
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);
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
}
|
|
}
|
|
Goods goods = goodsService.getById(goodsId);
|
|
Goods goods = goodsService.getById(goodsId);
|
|
- if(null == goods || null == goods.getGoodsId() || 0 == goods.getGoodsId()) {
|
|
|
|
|
|
+ if(null == goods) {
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
}
|
|
}
|
|
GoodsVO goodsVo = new GoodsVO();
|
|
GoodsVO goodsVo = new GoodsVO();
|
|
@@ -127,7 +123,7 @@ public class GoodsMgrController extends BaseApiController {
|
|
@ApiOperation(value = "新增商品信息", notes = "后台商品管理新增商品")
|
|
@ApiOperation(value = "新增商品信息", notes = "后台商品管理新增商品")
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
public AjaxResult goodsCreate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
public AjaxResult goodsCreate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
- if (null != goodsParam.getGoodsId()) {
|
|
|
|
|
|
+ if (null != goodsParam.getGoodsId() || 0 != goodsParam.getGoodsId()) {
|
|
return AjaxResult.error("该商品已存在");
|
|
return AjaxResult.error("该商品已存在");
|
|
}
|
|
}
|
|
Goods goods = mapperFacade.map(goodsParam, Goods.class);
|
|
Goods goods = mapperFacade.map(goodsParam, Goods.class);
|
|
@@ -178,7 +174,7 @@ public class GoodsMgrController extends BaseApiController {
|
|
@ApiOperation(value = "编辑商品信息", notes = "后台商品管理修改商品信息")
|
|
@ApiOperation(value = "编辑商品信息", notes = "后台商品管理修改商品信息")
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
public AjaxResult goodsUpdate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
public AjaxResult goodsUpdate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
- if (null == goodsParam || null == goodsParam.getGoodsId()) {
|
|
|
|
|
|
+ if (null == goodsParam || null != goodsParam.getGoodsId() || 0 == goodsParam.getGoodsId()) {
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
}
|
|
}
|
|
Goods oldGoods = goodsService.getById(goodsParam.getGoodsId());
|
|
Goods oldGoods = goodsService.getById(goodsParam.getGoodsId());
|
|
@@ -236,15 +232,15 @@ public class GoodsMgrController extends BaseApiController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "停用、启用商品", notes = "停用、启用商品")
|
|
@ApiOperation(value = "停用、启用商品", notes = "停用、启用商品")
|
|
@PostMapping("/status")
|
|
@PostMapping("/status")
|
|
- public AjaxResult goodsStatus(@RequestBody Goods goods) {
|
|
|
|
- Long goodsId = goods.getGoodsId();
|
|
|
|
- GoodsStatusEnum status = (null != goods && null != goods.getStatus())?goods.getStatus():null;
|
|
|
|
- if (null == goodsId || 0 == goodsId
|
|
|
|
- || null == status) {
|
|
|
|
|
|
+ public AjaxResult goodsStatus(@RequestBody JSONObject jsonObject) {
|
|
|
|
+ String goodsId = jsonObject.getString("goodsId");
|
|
|
|
+
|
|
|
|
+ GoodsStatusEnum status = GoodsStatusEnum.getStatusEnum(jsonObject.getString("status"));
|
|
|
|
+ if (StringUtils.isBlank(goodsId) || null == status) {
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- goodsService.lambdaUpdate().set(Goods::getStatus, goods.getStatus()).eq(Goods::getGoodsId, goodsId).update();
|
|
|
|
|
|
+ goodsService.lambdaUpdate().set(Goods::getStatus, status).eq(Goods::getGoodsId, goodsId).update();
|
|
// 查询代金券信息
|
|
// 查询代金券信息
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
return AjaxResult.error("操作失败");
|
|
return AjaxResult.error("操作失败");
|
|
@@ -261,8 +257,8 @@ public class GoodsMgrController extends BaseApiController {
|
|
*/
|
|
*/
|
|
@PostMapping(value = "/remove")
|
|
@PostMapping(value = "/remove")
|
|
public AjaxResult removeGoods(@RequestBody JSONObject jsonObject) {
|
|
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);
|
|
return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
}
|
|
}
|
|
Goods goods = goodsService.getById(goodsId);
|
|
Goods goods = goodsService.getById(goodsId);
|