mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
Merge pull request #56 from gadfly3173/get-by-sku
feat: 根据sku查找商品,用于购物车、订单跳转商品页面
This commit is contained in:
commit
0ca1040cc1
@ -55,7 +55,6 @@ public class GoodsController {
|
|||||||
return Result.success(list, pageResult.getTotal());
|
return Result.success(list, pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "商品详情")
|
@ApiOperation(value = "商品详情")
|
||||||
@ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path", dataType = "Long")
|
@ApiImplicitParam(name = "id", value = "商品ID", required = true, paramType = "path", dataType = "Long")
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
@ -63,4 +62,12 @@ public class GoodsController {
|
|||||||
GoodsDetailVO goodsDetailVO = goodsService.getGoodsById(id);
|
GoodsDetailVO goodsDetailVO = goodsService.getGoodsById(id);
|
||||||
return Result.success(goodsDetailVO);
|
return Result.success(goodsDetailVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "商品详情")
|
||||||
|
@ApiImplicitParam(name = "id", value = "商品SkuID", required = true, paramType = "path", dataType = "Long")
|
||||||
|
@GetMapping("/sku/{skuId}")
|
||||||
|
public Result<GoodsDetailVO> detailBySkuId(@PathVariable Long skuId) {
|
||||||
|
GoodsDetailVO goodsDetailVO = goodsService.getGoodsBySkuId(skuId);
|
||||||
|
return Result.success(goodsDetailVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,6 @@ import com.youlai.mall.pms.pojo.vo.app.GoodsDetailVO;
|
|||||||
*/
|
*/
|
||||||
public interface IGoodsService extends IService<PmsSpu> {
|
public interface IGoodsService extends IService<PmsSpu> {
|
||||||
GoodsDetailVO getGoodsById(Long id);
|
GoodsDetailVO getGoodsById(Long id);
|
||||||
|
|
||||||
|
GoodsDetailVO getGoodsBySkuId(Long skuId);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.youlai.common.web.exception.BizException;
|
||||||
import com.youlai.mall.pms.common.enums.AttributeTypeEnum;
|
import com.youlai.mall.pms.common.enums.AttributeTypeEnum;
|
||||||
import com.youlai.mall.pms.mapper.PmsSpuMapper;
|
import com.youlai.mall.pms.mapper.PmsSpuMapper;
|
||||||
import com.youlai.mall.pms.pojo.entity.PmsSku;
|
import com.youlai.mall.pms.pojo.entity.PmsSku;
|
||||||
@ -112,4 +113,14 @@ public class GoodsServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> implemen
|
|||||||
}
|
}
|
||||||
return goodsDetailVO;
|
return goodsDetailVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoodsDetailVO getGoodsBySkuId(Long skuId) {
|
||||||
|
PmsSku skuInfo = skuService.getById(skuId);
|
||||||
|
if (null == skuInfo) {
|
||||||
|
throw new BizException("商品不存在");
|
||||||
|
}
|
||||||
|
Long spuId = skuInfo.getSpuId();
|
||||||
|
return getGoodsById(spuId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user