BUG
jiangqs
2023-04-24 aa2eae024f8f251c8e2b9eace5351dea7e315ed7
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package com.hrt.system.controller.miniapp;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hrt.common.core.domain.R;
import com.hrt.common.security.utils.SecurityUtils;
import com.hrt.system.domain.dto.*;
import com.hrt.system.domain.poji.member.Member;
import com.hrt.system.domain.vo.*;
import com.hrt.system.service.goods.GoodsService;
import com.hrt.system.service.member.MemberService;
import com.hrt.system.service.shop.ShopService;
import com.hrt.system.service.sys.AdvertService;
import com.hrt.system.service.sys.BannerService;
import com.hrt.system.service.sys.QuickEntryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * @author jqs34
 * @ClassName AppHomeController
 * @description: TODO
 * @date 2023年04月18日
 * @version: 1.0
 */
@Api(value = "小程序首页相关接口", tags = "小程序首页相关接口", description = "小程序首页相关接口")
@RestController
@RequestMapping("/app/home")
public class AppHomeController {
 
 
    @Autowired
    private MemberService memberService;
 
    @Autowired
    private BannerService bannerService;
 
    @Autowired
    private QuickEntryService quickEntryService;
 
    @Autowired
    private AdvertService advertService;
 
    @Autowired
    private GoodsService goodsService;
 
    @Autowired
    private ShopService shopService;
 
    @RequestMapping(value = "/getNearbyShop", method = RequestMethod.POST)
    @ApiOperation(value = "获取最近商户")
    public R<AppNearbyShopVo> getNearbyShop(@RequestBody AppNearbyShopDto appNearbyShopDto) {
        Long userId = SecurityUtils.getUserId();
        appNearbyShopDto.setUserId(userId);
        AppNearbyShopVo appNearbyShopVo = memberService.getNearbyShop(appNearbyShopDto);
        return R.ok(appNearbyShopVo);
    }
 
    @RequestMapping(value = "/getHomeBanner", method = RequestMethod.POST)
    @ApiOperation(value = "获取首页banner")
    public R<List<AppBannerVo>> getHomeBanner() {
        List<AppBannerVo> appBannerVoList = bannerService.listHomeBannerVo();
        return R.ok(appBannerVoList);
    }
 
    @RequestMapping(value = "/getQuickEntry", method = RequestMethod.POST)
    @ApiOperation(value = "获取首页快速入口")
    public R<List<AppQuickEntryVo>> getQuickEntry() {
        List<AppQuickEntryVo> appQuickEntryVoList = quickEntryService.listQuickEntryVo();
        return R.ok(appQuickEntryVoList);
    }
 
    @RequestMapping(value = "/getAdvert", method = RequestMethod.POST)
    @ApiOperation(value = "获取首页广告")
    public R<AppAdvertVo> getAdvert() {
        AppAdvertVo appAdvertVo = advertService.getAdvertVo();
        return R.ok(appAdvertVo);
    }
 
    @RequestMapping(value = "/pageRecommendGoods", method = RequestMethod.POST)
    @ApiOperation(value = "推荐商品")
    public R<Page<AppSimpleGoodsVo>> pageRecommendGoods(@RequestBody AppPageDto appPageDto) {
        Long userId = SecurityUtils.getUserId();
        Long shopId = null;
        if(userId!=null){
            Member member = memberService.getById(userId);
            if(member!=null&&member.getRealtionShopId()!=null){
                shopId = member.getRealtionShopId();
            }
        }
        Page<AppSimpleGoodsVo> page = new Page<>();
        page.setSize(appPageDto.getPageSize());
        page.setCurrent(appPageDto.getPageNum());
        List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsService.pageRecommendGoods(page,shopId);
        return R.ok(page.setRecords(appSimpleGoodsVoList));
    }
 
    @RequestMapping(value = "/pageShopGoods", method = RequestMethod.POST)
    @ApiOperation(value = "商城商品")
    public R<Page<AppSimpleGoodsVo>> pageShopGoods(@RequestBody AppShopGoodsPageDto appShopGoodsPageDto) {
        Long userId = SecurityUtils.getUserId();
        if(userId!=null){
            Member member = memberService.getById(userId);
            if(member!=null&&member.getRealtionShopId()!=null){
                appShopGoodsPageDto.setShopId(member.getRealtionShopId());
            }
        }
        Page<AppSimpleGoodsVo> page = new Page<>();
        page.setSize(appShopGoodsPageDto.getPageSize());
        page.setCurrent(appShopGoodsPageDto.getPageNum());
        List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsService.pageShopGoods(page,appShopGoodsPageDto);
        return R.ok(page.setRecords(appSimpleGoodsVoList));
    }
 
    @RequestMapping(value = "/pageSearchGoods", method = RequestMethod.POST)
    @ApiOperation(value = "搜索商品")
    public R<Page<AppSimpleGoodsVo>> pageSearchGoods(@RequestBody AppSearchGoodsPageDto appSearchGoodsPageDto) {
        Long userId = SecurityUtils.getUserId();
        if(userId!=null){
            Member member = memberService.getById(userId);
            if(member!=null&&member.getRealtionShopId()!=null){
                appSearchGoodsPageDto.setShopId(member.getRealtionShopId());
            }
        }
        Page<AppSimpleGoodsVo> page = new Page<>();
        page.setSize(appSearchGoodsPageDto.getPageSize());
        page.setCurrent(appSearchGoodsPageDto.getPageNum());
        List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsService.pageSearchGoods(page,appSearchGoodsPageDto);
        return R.ok(page.setRecords(appSimpleGoodsVoList));
    }
 
    @RequestMapping(value = "/pageSearchActivityGoods", method = RequestMethod.POST)
    @ApiOperation(value = "搜索活动商品")
    public R<Page<AppSimpleActivityGoodsVo>> pageSearchActivityGoods(@RequestBody AppSearchGoodsPageDto appSearchGoodsPageDto) {
        Long userId = SecurityUtils.getUserId();
        if(userId!=null){
            Member member = memberService.getById(userId);
            if(member!=null&&member.getRealtionShopId()!=null){
                appSearchGoodsPageDto.setShopId(member.getRealtionShopId());
            }
        }
        Page<AppSimpleActivityGoodsVo> page = new Page<>();
        page.setSize(appSearchGoodsPageDto.getPageSize());
        page.setCurrent(appSearchGoodsPageDto.getPageNum());
        List<AppSimpleActivityGoodsVo> appSimpleGoodsVoList = goodsService.pageSearchActivityGoods(page,appSearchGoodsPageDto);
        return R.ok(page.setRecords(appSimpleGoodsVoList));
    }
 
    @RequestMapping(value = "/getShopInfo", method = RequestMethod.POST)
    @ApiOperation(value = "获取商户详情")
    public R<AppShopInfoVo> getShopInfo(@RequestBody AppBaseGetDto appBaseGetDto) {
        AppShopInfoVo appShopInfoVo = shopService.getAppShopInfo(Long.valueOf(appBaseGetDto.getId()));
        return R.ok(appShopInfoVo);
    }
 
 
}