puzhibing
2023-10-08 22199bbdda579861736420fe26c2873ab0f5d21c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.sinata.rest.modular.mall.controller;
 
import com.sinata.common.enums.mall.EnumMallOrderState;
import com.sinata.rest.common.ApiUtils;
import com.sinata.rest.modular.mall.controller.body.BodyMallIndexSelGoods;
import com.sinata.rest.modular.mall.controller.vo.VoClassify;
import com.sinata.rest.modular.mall.controller.vo.VoGoods;
import com.sinata.rest.modular.mall.service.IMallClassifyOneService;
import com.sinata.rest.modular.mall.service.IMallGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.List;
 
/**
 * <p>
 * 商城首页相关接口
 * </p>
 *
 * @ClassName com.sinata.rest.modular.mall.controller.MallIndexController
 * @Description 商城首页相关接口
 * @Author BaiHua
 * @Date 2023/3/18 16:38
 */
@Slf4j
@RestController
@RequestMapping("/mall/index")
@Api(tags = "商城-首页相关接口", description = "获取首页数据")
public class MallIndexController {
    @Autowired
    private IMallGoodsService goodsService;
    @Autowired
    private IMallClassifyOneService mallClassifyOneService;
 
    @ApiOperation(value = "商品分类")
    @GetMapping(value = "/firstClassify")
    public ApiUtils<List<VoClassify>> firstClassify() {
        List<VoClassify> firstClassifyList = mallClassifyOneService.getFirstClassifyAll();
        return ApiUtils.returnOK(firstClassifyList);
    }
    
    @ApiOperation(value = "推荐商品")
    @PostMapping(value = "/hotGoods")
    public ApiUtils<List<VoGoods>> hotGoods(@Validated @RequestBody BodyMallIndexSelGoods body) {
        List<VoGoods> hotGoodsList = goodsService.getHotGoodsByBody(body, Arrays.asList(EnumMallOrderState.WAIT_CHECK.index, EnumMallOrderState.SUCCESS.index));
        return ApiUtils.returnOK(hotGoodsList);
    }
 
//    @GetMapping(value = "/classifyTwoInIndex")
//    @ApiOperation(value = "首页二级分类", notes = "单独获取首页的二级分类数据", response = VoClassifyTwo.class)
//    @ApiImplicitParams({
//        @ApiImplicitParam(name = "firstClassifyId", value = "一级分类ID", dataType = "Int", paramType = "query"),
//    })
//    public Object classifyTwoInIndex(Integer firstClassifyId) {
//        List<VoClassifyTwo> firstClassifyList = mallClassifyTwoService.getFirstClassifyByIndex(firstClassifyId);
//        return ApiUtils.returnOK(firstClassifyList);
//    }
//
//    @GetMapping(value = "/classifyTwo")
//    @ApiOperation(value = "二级分类", notes = "单独获取一级下的所有二级分类数据", response = VoClassifyTwo.class)
//    @ApiImplicitParams({
//        @ApiImplicitParam(name = "firstClassifyId", value = "一级分类ID", dataType = "Int", paramType = "query"),
//    })
//    public Object classifyTwo(Integer firstClassifyId) {
//        List<VoClassifyTwo> firstClassifyList = mallClassifyTwoService.getFirstClassifyByParentId(firstClassifyId);
//        return ApiUtils.returnOK(firstClassifyList);
//    }
//
//    @GetMapping(value = "/classifyAll")
//    @ApiOperation(value = "所有二级分类", notes = "获取所有二级分类数据", response = VoClassifyTwo.class)
//    public Object classifyAll() {
//        List<VoClassifyTwo> firstClassifyList = mallClassifyTwoService.getFirstClassifyAll();
//        return ApiUtils.returnOK(firstClassifyList);
//    }
}