Browse Source

热榜增加时间字段配置

zyj
sj 2 years ago
parent
commit
e80ff782e7
  1. 13
      zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java
  2. 9
      zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java
  3. 6
      zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java
  4. 27
      zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java
  5. 11
      zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/vo/YxStoreHotListVo.java
  6. 2
      zsw-bxg/src/main/java/co/yixiang/utils/HotListDTO.java

13
zsw-bxg/src/main/java/co/yixiang/app/modules/hotList/rest/AppStoreHotListController.java

@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -40,6 +41,18 @@ public class AppStoreHotListController {
@GetMapping("/hotList") @GetMapping("/hotList")
@ApiOperation(value = "热门榜单列表",notes = "热门榜单") @ApiOperation(value = "热门榜单列表",notes = "热门榜单")
public ApiResult<List<HotListDTO>> getYxStoreHotList(){ public ApiResult<List<HotListDTO>> getYxStoreHotList(){
return ApiResult.ok(yxStoreHotListService.getList()); return ApiResult.ok(yxStoreHotListService.getList());
} }
/**
* 热门榜单列表
*/
@AnonymousAccess
@GetMapping("/hotList/{mouth}")
@ApiOperation(value = "根据年月查询热门榜单列表",notes = "热门榜单")
public ApiResult<List<HotListDTO>> getYxStoreHotList(@PathVariable String mouth){
return ApiResult.ok(yxStoreHotListService.getList(mouth));
}
} }

9
zsw-bxg/src/main/java/co/yixiang/modules/hotList/domain/YxStoreHotList.java

@ -18,6 +18,7 @@ import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -32,20 +33,22 @@ public class YxStoreHotList implements Serializable {
@TableId @TableId
private Integer id; private Integer id;
/** 榜单名称 */ /** 榜单名称 */
@NotBlank @NotBlank
private String listName; private String listName;
/** 榜单展示图片 */
private String listImage;
/** 所属月份 */
private String mouth;
/** 排序 */ /** 排序 */
private Integer sort; private Integer sort;
/** 商品列表 */ /** 商品列表 */
private String productList; private String productList;
/** 是否显示 */ /** 是否显示 */
private Integer isShow; private Integer isShow;

6
zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/YxStoreHotListService.java

@ -49,5 +49,11 @@ public interface YxStoreHotListService extends BaseService<YxStoreHotList> {
*/ */
void download(List<YxStoreHotListDto> all, HttpServletResponse response) throws IOException; void download(List<YxStoreHotListDto> all, HttpServletResponse response) throws IOException;
/**
* app根据月份获取列表
* @param mouth 想要查的月份
*/
List<HotListDTO> getList(String mouth);
List<HotListDTO> getList(); List<HotListDTO> getList();
} }

27
zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/impl/YxStoreHotListServiceImpl.java

@ -64,9 +64,10 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) { public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) {
getPage(pageable); getPage(pageable);
PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria)); PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria));
page.getList().forEach(hotList->{ PageResult<YxStoreHotListVo> result=generator.convertPageInfo(page, YxStoreHotListVo.class);
List<Integer> productArr = JSONUtil.toList(hotList.getProductList(), Integer.class); result.getContent().forEach(hotListVo->{
List<YxStoreProduct> list1 =new ArrayList<>(); List<Integer> productArr = JSONUtil.toList(hotListVo.getProductList(), Integer.class);
ArrayList<YxStoreProduct> list1 =new ArrayList<>();
productArr.forEach(productId->{ productArr.forEach(productId->{
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue()) wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
@ -78,10 +79,9 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
list1.add(storeProduct); list1.add(storeProduct);
} }
}); });
hotList.setProductList(JSONUtil.toJsonStr(list1)); hotListVo.setProductInfoList(list1);
// hotList.setProductInfo(list1);
}); });
return generator.convertPageInfo(page, YxStoreHotListVo.class); return result;
} }
@ -110,11 +110,25 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override
public List<HotListDTO> getList(String mouth) {
LambdaQueryWrapper<YxStoreHotList> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.orderByAsc(YxStoreHotList::getSort)
.eq(YxStoreHotList::getMouth,mouth);
return getHotListDTOS(wrapper);
}
;
@Override @Override
public List<HotListDTO> getList() { public List<HotListDTO> getList() {
LambdaQueryWrapper<YxStoreHotList> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<YxStoreHotList> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue()) wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.orderByAsc(YxStoreHotList::getSort); .orderByAsc(YxStoreHotList::getSort);
return getHotListDTOS(wrapper);
}
private List<HotListDTO> getHotListDTOS(LambdaQueryWrapper<YxStoreHotList> wrapper) {
List<HotListDTO> list = generator.convert(baseMapper.selectList(wrapper),HotListDTO.class); List<HotListDTO> list = generator.convert(baseMapper.selectList(wrapper),HotListDTO.class);
list.forEach(hotListDto->{ list.forEach(hotListDto->{
List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class); List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class);
@ -134,5 +148,4 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
return list; return list;
} }
} }

11
zsw-bxg/src/main/java/co/yixiang/modules/hotList/service/vo/YxStoreHotListVo.java

@ -1,9 +1,11 @@
package co.yixiang.modules.hotList.service.vo; package co.yixiang.modules.hotList.service.vo;
import co.yixiang.modules.product.domain.YxStoreProduct;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
@Data @Data
@ -20,6 +22,15 @@ public class YxStoreHotListVo implements Serializable {
/**商品列表*/ /**商品列表*/
private String productList; private String productList;
/**商品列表*/
private ArrayList<YxStoreProduct> productInfoList;
/** 榜单展示图片 */
private String listImage;
/** 所属月份 */
private String mouth;
/** 是否显示 */ /** 是否显示 */
private Integer isShow; private Integer isShow;

2
zsw-bxg/src/main/java/co/yixiang/utils/HotListDTO.java

@ -16,6 +16,8 @@ public class HotListDTO implements Serializable {
@TableId @TableId
/** 榜单列表ID */ /** 榜单列表ID */
private Integer id; private Integer id;
/** 榜单展示图片 */
private String listImage;
/** 榜单名称 */ /** 榜单名称 */
private String listName; private String listName;

Loading…
Cancel
Save