| | |
| | | |
| | | import cn.lili.common.aop.annotation.DemoSite; |
| | | import cn.lili.common.aop.annotation.PreventDuplicateSubmissions; |
| | | import cn.lili.common.context.ThreadContextHolder; |
| | | import cn.lili.common.enums.ResultCode; |
| | | import cn.lili.common.enums.ResultUtil; |
| | | import cn.lili.common.exception.ServiceException; |
| | |
| | | import cn.lili.modules.goods.entity.dos.Goods; |
| | | import cn.lili.modules.goods.entity.dos.GoodsSku; |
| | | import cn.lili.modules.goods.entity.dto.GoodsSearchParams; |
| | | import cn.lili.modules.goods.entity.dto.GoodsSortDTO; |
| | | import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; |
| | | import cn.lili.modules.goods.entity.enums.GoodsStatusEnum; |
| | | import cn.lili.modules.goods.entity.vos.GoodsSkuVO; |
| | | import cn.lili.modules.goods.entity.vos.GoodsVO; |
| | | import cn.lili.modules.goods.service.GoodsService; |
| | | import cn.lili.modules.goods.service.GoodsSkuService; |
| | | import cn.lili.modules.promotion.entity.dto.search.MemberCouponSearchParams; |
| | | import cn.lili.utils.COSUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * 管理端,商品管理接口 |
| | |
| | | @Autowired |
| | | private COSUtil cosUtil; |
| | | |
| | | @ApiOperation(value = "获得skuId") |
| | | @GetMapping("/getFirstSkuId/{id}") |
| | | public ResultMessage<String> getFirstSkuId(@PathVariable String id) { |
| | | List<GoodsSkuVO> goodsListByGoodsId = goodsSkuService.getGoodsListByGoodsId(id); |
| | | System.out.println(goodsListByGoodsId); |
| | | return ResultUtil.data(goodsListByGoodsId.get(0).getId()); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页获取") |
| | | @GetMapping(value = "/list") |
| | | public ResultMessage<IPage<Goods>> getByPage(GoodsSearchParams goodsSearchParams) { |
| | | return ResultUtil.data(goodsService.queryByParams(goodsSearchParams)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询商品清单导出导出列表") |
| | | @GetMapping("/queryExportGoods") |
| | | public void queryExportGoods(GoodsSearchParams searchParams) { |
| | | HttpServletResponse response = ThreadContextHolder.getHttpResponse(); |
| | | goodsService.queryExportGoods(response,searchParams);} |
| | | |
| | | @ApiOperation(value = "分页获取商品列表") |
| | | @GetMapping(value = "/sku/list") |
| | | public ResultMessage<IPage<GoodsSku>> getSkuByPage(GoodsSearchParams goodsSearchParams) { |
| | | return ResultUtil.data(goodsSkuService.getGoodsSkuByPage(goodsSearchParams)); |
| | | IPage<GoodsSku> goodsSkuByPage = goodsSkuService.getGoodsSkuByPage(goodsSearchParams); |
| | | goodsSkuByPage.getRecords().forEach(goodsSku -> { |
| | | String thumbnail = goodsSku.getThumbnail(); |
| | | if (StringUtils.isNotBlank(thumbnail)&&!thumbnail.contains("http")) { |
| | | goodsSku.setThumbnail(cosUtil.getPreviewUrl(goodsSku.getThumbnail())); |
| | | } |
| | | }); |
| | | return ResultUtil.data(goodsSkuByPage); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页获取待审核商品") |
| | |
| | | } |
| | | throw new ServiceException(ResultCode.GOODS_UNDER_ERROR); |
| | | } |
| | | @DemoSite |
| | | @PostMapping(value = "/goods/sort") |
| | | public ResultMessage<Object> goodsSort(@RequestBody @Valid GoodsSortDTO req) { |
| | | if (Boolean.TRUE.equals(goodsService.goodsSort(req))) { |
| | | return ResultUtil.success(); |
| | | } |
| | | throw new RuntimeException("修改排序失败"); |
| | | } |
| | | |
| | | @PreventDuplicateSubmissions |
| | | @ApiOperation(value = "管理员审核商品", notes = "管理员审核商品") |