热榜增加时间字段配置

This commit is contained in:
sj
2022-11-01 14:22:57 +08:00
parent 44110bd059
commit e80ff782e7
6 changed files with 58 additions and 10 deletions
@@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@@ -40,6 +41,18 @@ public class AppStoreHotListController {
@GetMapping("/hotList")
@ApiOperation(value = "热门榜单列表",notes = "热门榜单")
public ApiResult<List<HotListDTO>> getYxStoreHotList(){
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));
}
}
@@ -18,6 +18,7 @@ import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
@@ -32,20 +33,22 @@ public class YxStoreHotList implements Serializable {
@TableId
private Integer id;
/** 榜单名称 */
@NotBlank
private String listName;
/** 榜单展示图片 */
private String listImage;
/** 所属月份 */
private String mouth;
/** 排序 */
private Integer sort;
/** 商品列表 */
private String productList;
/** 是否显示 */
private Integer isShow;
@@ -49,5 +49,11 @@ public interface YxStoreHotListService extends BaseService<YxStoreHotList> {
*/
void download(List<YxStoreHotListDto> all, HttpServletResponse response) throws IOException;
/**
* app根据月份获取列表
* @param mouth 想要查的月份
*/
List<HotListDTO> getList(String mouth);
List<HotListDTO> getList();
}
@@ -64,9 +64,10 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
public PageResult<YxStoreHotListVo> queryAll(YxStoreHotListQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxStoreHotList> page = new PageInfo<>(queryAll(criteria));
page.getList().forEach(hotList->{
List<Integer> productArr = JSONUtil.toList(hotList.getProductList(), Integer.class);
List<YxStoreProduct> list1 =new ArrayList<>();
PageResult<YxStoreHotListVo> result=generator.convertPageInfo(page, YxStoreHotListVo.class);
result.getContent().forEach(hotListVo->{
List<Integer> productArr = JSONUtil.toList(hotListVo.getProductList(), Integer.class);
ArrayList<YxStoreProduct> list1 =new ArrayList<>();
productArr.forEach(productId->{
LambdaQueryWrapper<YxStoreProduct> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
@@ -78,10 +79,9 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
list1.add(storeProduct);
}
});
hotList.setProductList(JSONUtil.toJsonStr(list1));
// hotList.setProductInfo(list1);
hotListVo.setProductInfoList(list1);
});
return generator.convertPageInfo(page, YxStoreHotListVo.class);
return result;
}
@@ -110,11 +110,25 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
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
public List<HotListDTO> getList() {
LambdaQueryWrapper<YxStoreHotList> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreHotList::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.orderByAsc(YxStoreHotList::getSort);
return getHotListDTOS(wrapper);
}
private List<HotListDTO> getHotListDTOS(LambdaQueryWrapper<YxStoreHotList> wrapper) {
List<HotListDTO> list = generator.convert(baseMapper.selectList(wrapper),HotListDTO.class);
list.forEach(hotListDto->{
List<Integer> productArr = JSONUtil.toList(hotListDto.getProductList(), Integer.class);
@@ -134,5 +148,4 @@ public class YxStoreHotListServiceImpl extends BaseServiceImpl<YxStoreHotListMap
return list;
}
}
@@ -1,9 +1,11 @@
package co.yixiang.modules.hotList.service.vo;
import co.yixiang.modules.product.domain.YxStoreProduct;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
@Data
@@ -20,6 +22,15 @@ public class YxStoreHotListVo implements Serializable {
/**商品列表*/
private String productList;
/**商品列表*/
private ArrayList<YxStoreProduct> productInfoList;
/** 榜单展示图片 */
private String listImage;
/** 所属月份 */
private String mouth;
/** 是否显示 */
private Integer isShow;
@@ -16,6 +16,8 @@ public class HotListDTO implements Serializable {
@TableId
/** 榜单列表ID */
private Integer id;
/** 榜单展示图片 */
private String listImage;
/** 榜单名称 */
private String listName;