|
|
@@ -1,280 +1,54 @@
|
|
|
package com.yc.ship.module.miniapplet.controller.app.content;
|
|
|
|
|
|
import com.yc.ship.framework.common.pojo.CommonResult;
|
|
|
+import com.yc.ship.framework.common.pojo.PageResult;
|
|
|
import com.yc.ship.framework.common.util.object.BeanUtils;
|
|
|
-import com.yc.ship.module.miniapplet.controller.app.content.vo.AppCatalogueRespVO;
|
|
|
-import com.yc.ship.module.miniapplet.controller.app.content.vo.AppContentReqVO;
|
|
|
+import com.yc.ship.module.miniapplet.controller.app.content.vo.AppContentPageReqVO;
|
|
|
import com.yc.ship.module.miniapplet.controller.app.content.vo.AppContentRespVO;
|
|
|
-import com.yc.ship.module.miniapplet.dal.dataobject.catalogue.CatalogueDO;
|
|
|
import com.yc.ship.module.miniapplet.dal.dataobject.content.ContentDO;
|
|
|
-import com.yc.ship.module.miniapplet.service.catalogue.CatalogueService;
|
|
|
import com.yc.ship.module.miniapplet.service.content.ContentService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
-import java.util.*;
|
|
|
|
|
|
import static com.yc.ship.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
/**
|
|
|
- * @author :yaochao
|
|
|
+ *
|
|
|
* @description :TODO
|
|
|
* @date :2024/8/19 17:13
|
|
|
*/
|
|
|
-@Tag(name = "用户 APP - 目录/栏目/产品分组分类")
|
|
|
+@Tag(name = "用户 APP - 内容接口")
|
|
|
@RestController
|
|
|
@RequestMapping("/applet/content")
|
|
|
@Validated
|
|
|
@Slf4j
|
|
|
public class AppContentController {
|
|
|
|
|
|
-
|
|
|
- @Resource
|
|
|
- private CatalogueService catalogueService;
|
|
|
-
|
|
|
@Resource
|
|
|
private ContentService contentService;
|
|
|
|
|
|
|
|
|
- @PostMapping("/catalogueList")
|
|
|
-// @Operation(summary = "获取目录/栏目/产品分组分类列表")
|
|
|
- public CommonResult<List<AppCatalogueRespVO>> catalogueList(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
- List<CatalogueDO> catalogueDOS = catalogueService.getCatalogueList(reqVO);
|
|
|
- List<AppCatalogueRespVO> respVOS = BeanUtils.toBean(catalogueDOS, AppCatalogueRespVO.class);
|
|
|
- return success(respVOS);
|
|
|
+ @PostMapping("/page")
|
|
|
+ @Operation(summary = "获取内容分页列表")
|
|
|
+ public CommonResult<PageResult<AppContentRespVO>> content(@RequestBody @Valid AppContentPageReqVO reqVO) {
|
|
|
+ PageResult<ContentDO> page = contentService.getAppContentPage(reqVO);
|
|
|
+ return success(BeanUtils.toBean(page, AppContentRespVO.class));
|
|
|
}
|
|
|
|
|
|
-// @PostMapping("/catalogue")
|
|
|
-//// @Operation(summary = "获取目录/栏目/产品分组分类详情")
|
|
|
-// public CommonResult<AppCatalogueRespVO> catalogue(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
-//// CatalogueDO catalogueDO = catalogueService.getCatalogue(reqVO.getCatalogueId());
|
|
|
-//// AppCatalogueRespVO respVO = BeanUtils.toBean(catalogueDO, AppCatalogueRespVO.class);
|
|
|
-// CatalogueRespVO catalogueResp = catalogueService.getCatalogueResp(reqVO.getCatalogueId());
|
|
|
-// AppCatalogueRespVO respVO = BeanUtils.toBean(catalogueResp, AppCatalogueRespVO.class);
|
|
|
-// if (catalogueResp.getBusinessType() == 1) {
|
|
|
-// List<AppCategoryRespVO> categoryList = getCategoryRespList(reqVO);
|
|
|
-// if (StringUtils.isBlank(respVO.getImgUrl())) {
|
|
|
-// respVO.setImgUrl(categoryList.stream()
|
|
|
-// .filter(category -> StringUtils.isNotBlank(category.getExtraInfo().getImg()))
|
|
|
-// .map(category -> category.getExtraInfo().getImg())
|
|
|
-// .findFirst()
|
|
|
-// .orElse(null));
|
|
|
-// }
|
|
|
-// respVO.setCategoryList(categoryList);
|
|
|
-// reqVO.setCatalogueParentId(reqVO.getCatalogueId());
|
|
|
-// reqVO.setCatalogueId(null);
|
|
|
-// List<CatalogueDO> childCatalogueDOS = catalogueService.getCatalogueList(reqVO);
|
|
|
-// List<AppCatalogueRespVO> respVOS = BeanUtils.toBean(childCatalogueDOS, AppCatalogueRespVO.class);
|
|
|
-// for (AppCatalogueRespVO catalogueRespVO : respVOS) {
|
|
|
-// reqVO.setCatalogueId(catalogueRespVO.getId());
|
|
|
-// List<AppCategoryRespVO> childCategoryList = getCategoryRespList(reqVO);
|
|
|
-// catalogueRespVO.setCategoryList(childCategoryList);
|
|
|
-// if (StringUtils.isBlank(catalogueRespVO.getImgUrl())) {
|
|
|
-// respVO.setImgUrl(childCategoryList.stream()
|
|
|
-// .filter(category -> StringUtils.isNotBlank(category.getExtraInfo().getImg()))
|
|
|
-// .map(category -> category.getExtraInfo().getImg())
|
|
|
-// .findFirst()
|
|
|
-// .orElse(null));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// respVO.setCatalogueList(respVOS);
|
|
|
-// }
|
|
|
-// return success(respVO);
|
|
|
-// }
|
|
|
-
|
|
|
- @PostMapping("/contentList")
|
|
|
-// @Operation(summary = "获取内容列表")
|
|
|
- public CommonResult<List<AppContentRespVO>> contentList(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
- List<AppContentRespVO> respVOS = new ArrayList<>();
|
|
|
- if (reqVO.getCatalogueId() == null) {
|
|
|
- List<CatalogueDO> catalogueDOS = catalogueService.getCatalogueList(reqVO);
|
|
|
- if (!catalogueDOS.isEmpty()) {
|
|
|
- reqVO.setCatalogueId(catalogueDOS.get(0).getId());
|
|
|
- } else {
|
|
|
- return success(respVOS);
|
|
|
- }
|
|
|
- }
|
|
|
- List<ContentDO> contentDOS = contentService.getContentList(reqVO.getCatalogueId(), 1);
|
|
|
- respVOS = BeanUtils.toBean(contentDOS, AppContentRespVO.class);
|
|
|
- return success(respVOS);
|
|
|
+ // 内容详情
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @Operation(summary = "获取内容详情")
|
|
|
+ public CommonResult<AppContentRespVO> detail(@RequestParam("id") Long id) {
|
|
|
+ ContentDO content = contentService.getContent(id);
|
|
|
+ return success(BeanUtils.toBean(content, AppContentRespVO.class));
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/content")
|
|
|
-// @Operation(summary = "获取内容详情")
|
|
|
- public CommonResult<AppContentRespVO> content(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
- ContentDO contentDO = contentService.getContent(reqVO.getId());
|
|
|
- AppContentRespVO respVO = BeanUtils.toBean(contentDO, AppContentRespVO.class);
|
|
|
- return success(respVO);
|
|
|
- }
|
|
|
-
|
|
|
-// @PostMapping("/productList")
|
|
|
-//// @Operation(summary = "获取子产品列表")
|
|
|
-// public CommonResult<List<AppProductSpuRespVO>> productList(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
-// return success(getProductList(reqVO.getCategoryId(), reqVO.getProductName()));
|
|
|
-// }
|
|
|
-
|
|
|
-// @PostMapping("/product")
|
|
|
-//// @Operation(summary = "获取子产品详情")
|
|
|
-// public CommonResult<AppProductSpuRespVO> product(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
-// AppProductSpuRespVO respVO = getProduct(reqVO.getProductId());
|
|
|
-// return success(respVO);
|
|
|
-// }
|
|
|
-
|
|
|
-// @PostMapping("/search")
|
|
|
-//// @Operation(summary = "查询产品和子产品")
|
|
|
-// public CommonResult<?> search(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
-// String search = reqVO.getSearch() == null ? "" : reqVO.getSearch();
|
|
|
-// List<CategoryRespDTO> respVOS = productApi.getCategoryListByName(search).getCheckedData();
|
|
|
-// respVOS = respVOS.stream().filter(item -> item.getUseStatus()!=null && item.getUseStatus() == 1).collect(Collectors.toList());
|
|
|
-// List<AppCategoryRespVO> categoryList = BeanUtils.toBean(respVOS, AppCategoryRespVO.class);
|
|
|
-// Map<String, Object> respVO = new HashMap<>();
|
|
|
-// respVO.put("categoryList", categoryList);
|
|
|
-// List<ProductDO> productDOS = productService.getProductListByCategoryId(null, search, 1);
|
|
|
-// List<AppProductSpuRespVO> productList = BeanUtils.toBean(productDOS, AppProductSpuRespVO.class);
|
|
|
-// respVO.put("productList", productList);
|
|
|
-// return success(respVO);
|
|
|
-// }
|
|
|
-
|
|
|
-// @PostMapping("/searchRelationProduct")
|
|
|
-//// @Operation(summary = "根据产品ID或子产品ID查询产品关联的子产品")
|
|
|
-// public CommonResult<?> searchRelationProduct(@RequestBody @Valid AppContentReqVO reqVO) {
|
|
|
-// Long productId = reqVO.getProductId();
|
|
|
-// Long categoryId = reqVO.getCategoryId();
|
|
|
-// if (productId == null && categoryId == null) {
|
|
|
-// return error(130_003, "产品ID或子产品ID至少有一个必传");
|
|
|
-// }
|
|
|
-// if (categoryId == null) {
|
|
|
-// ProductDO product = productService.getProduct(productId);
|
|
|
-// if (product != null) {
|
|
|
-// categoryId = product.getCategoryId();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// CategoryRespDTO category = productApi.getCategory(categoryId).getCheckedData();
|
|
|
-// String relationProducts = category.getExtraInfo().getAppletProducts();
|
|
|
-// List<AppProductSpuRespVO> respVOS = new ArrayList<>(3);
|
|
|
-// if (StringUtils.isNotBlank(relationProducts)) {
|
|
|
-// JSONArray jsonArray = JSONUtil.parseArray(relationProducts);
|
|
|
-// for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
-// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
-// Long relationProductId = jsonObject.getLong("id");
|
|
|
-// AppProductSpuRespVO respVO = getProduct(relationProductId);
|
|
|
-// respVOS.add(respVO);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return success(respVOS);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// @PostMapping("/day/price/get")
|
|
|
-// @Operation(summary = "获得日历价")
|
|
|
-// public CommonResult<List<AppProductDayPriceRespVO>> getAppletDayPrice(@Valid @RequestBody AppletDayStockPriceReqVO reqVO) {
|
|
|
-// return success( productService.getProductDayPrice(reqVO));
|
|
|
-// }
|
|
|
-
|
|
|
-// private AppProductSpuRespVO getProduct(Long productId) {
|
|
|
-// ProductDO product = productService.getProduct(productId);
|
|
|
-// AppProductSpuRespVO respVO = BeanUtils.toBean(product, AppProductSpuRespVO.class);
|
|
|
-//
|
|
|
-// List<ProductGroupDO> groupDOList = productGroupService.getListByAppletProductId(productId);
|
|
|
-// if (groupDOList != null && !groupDOList.isEmpty()) {
|
|
|
-// respVO.setProductGroupList(BeanUtils.toBean(groupDOList, ProductGroupRespVO.class));
|
|
|
-// }
|
|
|
-// if (getLoginUserId() != null && product.getId() != null) {
|
|
|
-// respVO.setFavoriteId(productApi.getAppIsFavorite(getLoginUserId(), product.getId()).getCheckedData());
|
|
|
-// }
|
|
|
-// CategoryRespDTO categoryDTOS = productApi.getCategory(product.getCategoryId()).getCheckedData();
|
|
|
-// if (categoryDTOS != null) {
|
|
|
-// respVO.setSpuType(categoryDTOS.getExtraInfo().getSpuType());
|
|
|
-// respVO.setCatalogueType(categoryDTOS.getExtraInfo().getType());
|
|
|
-// }
|
|
|
-// if (respVO.getStatus() == 2) {
|
|
|
-// throw exception0(130_003, "该商品已下架");
|
|
|
-// }
|
|
|
-// return respVO;
|
|
|
-// }
|
|
|
-
|
|
|
-// private List<AppProductSpuRespVO> getProductList(Long categoryId, String productName) {
|
|
|
-// List<ProductDO> productList = productService.getProductAndGroup(categoryId, productName);
|
|
|
-// List<AppProductSpuRespVO> respVOS = BeanUtils.toBean(productList, AppProductSpuRespVO.class);
|
|
|
-// respVOS = respVOS.stream().filter(item -> {
|
|
|
-// if (item.getStatus() == 1) {
|
|
|
-// if (getLoginUserId() != null && item.getId() != null) {
|
|
|
-// item.setFavoriteId(productApi.getAppIsFavorite(getLoginUserId(), item.getId()).getCheckedData());
|
|
|
-// }
|
|
|
-// return true;
|
|
|
-// }
|
|
|
-// return false;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-// return respVOS;
|
|
|
-// }
|
|
|
|
|
|
- /**
|
|
|
- * @param reqVO
|
|
|
- * @return
|
|
|
- */
|
|
|
-// private List<AppCategoryRespVO> getCategoryRespList(AppContentReqVO reqVO) {
|
|
|
-// List<CategoryRespDTO> categoryDTOS = productApi.getCategoryListByCatalogueId(reqVO.getCatalogueId(), 1).getCheckedData();
|
|
|
-// List<AppCategoryRespVO> categoryList = BeanUtils.toBean(categoryDTOS, AppCategoryRespVO.class);
|
|
|
-// if (StringUtils.isNotBlank(reqVO.getLongitude()) && StringUtils.isNotBlank(reqVO.getLatitude()) && reqVO.getRice() != null) {
|
|
|
-// // 根据经纬度查询产品分组(小程序产品)
|
|
|
-// double[] bounds = GeoUtils.calculateBoundingCoordinates(Double.parseDouble(reqVO.getLatitude()), Double.parseDouble(reqVO.getLongitude()), reqVO.getRice());
|
|
|
-// // 开始纬度
|
|
|
-// double latitude1 = bounds[0];
|
|
|
-// // 结束纬度
|
|
|
-// double latitude2 = bounds[2];
|
|
|
-// // 开始经度
|
|
|
-// double longitude1 = bounds[1];
|
|
|
-// // 开始经度
|
|
|
-// double longitude2 = bounds[3];
|
|
|
-// categoryList = categoryList.stream().filter(e -> {
|
|
|
-// CategoryExtraRespDTO extraInfo = e.getExtraInfo();
|
|
|
-// if (extraInfo != null && StringUtils.isNotBlank(extraInfo.getCoordinate())) {
|
|
|
-// String[] split = extraInfo.getCoordinate().split(",");
|
|
|
-// double latitude = Double.parseDouble(split[1]);
|
|
|
-// double longitude = Double.parseDouble(split[0]);
|
|
|
-// return latitude >= latitude1 && latitude <= latitude2 && longitude >= longitude1 && longitude <= longitude2;
|
|
|
-// }
|
|
|
-// return false;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-// }
|
|
|
-// for (AppCategoryRespVO appCategoryRespVO : categoryList) {
|
|
|
-// List<AppProductSpuRespVO> spuList = getProductList(appCategoryRespVO.getId(), null);
|
|
|
-// // 使用 Stream API 找到最低售价
|
|
|
-// Optional<BigDecimal> minPrice = spuList.stream()
|
|
|
-// .map(AppProductSpuRespVO::getSalePrice)
|
|
|
-// .min(BigDecimal::compareTo);
|
|
|
-// // 使用 Stream API 计算售卖总数
|
|
|
-// int sellNum = 0;
|
|
|
-// if (!spuList.isEmpty()) {
|
|
|
-// sellNum = spuList.stream()
|
|
|
-// .mapToInt(AppProductSpuRespVO::getSellNum)
|
|
|
-// .sum();
|
|
|
-// }
|
|
|
-// spuList = spuList.stream().filter(e -> {
|
|
|
-// CategoryExtraRespDTO extraInfo = appCategoryRespVO.getExtraInfo();
|
|
|
-// e.setSpuType(extraInfo.getSpuType());
|
|
|
-// return true;
|
|
|
-// }).collect(Collectors.toList());
|
|
|
-// appCategoryRespVO.setSalePrice(minPrice.orElse(BigDecimal.ZERO));
|
|
|
-// appCategoryRespVO.setSellNum(sellNum);
|
|
|
-// appCategoryRespVO.setSpuList(spuList);
|
|
|
-// appCategoryRespVO.setResourceNum(spuList.size());
|
|
|
-// }
|
|
|
-// List<CatalogueDetailRespVO> respVOS = catalogueService.getCatalogueDetailList(reqVO.getCatalogueId());
|
|
|
-// Map<Long, Integer> sortNumMap = respVOS.stream()
|
|
|
-// .collect(Collectors.toMap(CatalogueDetailRespVO::getCategoryId, CatalogueDetailRespVO::getSortNum));
|
|
|
-// for (AppCategoryRespVO category : categoryList) {
|
|
|
-// category.setSortNum(sortNumMap.getOrDefault(category.getId(), 0));
|
|
|
-// }
|
|
|
-// categoryList.sort(Comparator.comparing(AppCategoryRespVO::getSortNum));
|
|
|
-// return categoryList;
|
|
|
-// }
|
|
|
|
|
|
}
|