Pu Zhibing
6 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
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
package com.stylefeng.guns.modular.api;
 
import com.stylefeng.guns.modular.system.service.IAdvertisementService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.AdvertisementWarpper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
 * 广告控制器
 */
@Api
@RestController
@RequestMapping("/base/advertisement")
public class AdvertisementController {
 
    @Autowired
    private IAdvertisementService advertisementService;
    
    @Autowired
    private IUserInfoService userInfoService;
 
 
 
    @ResponseBody
    @PostMapping("/queryByType")
    @ApiOperation(value = "获取广告列表【1.0】", tags = {"用户端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "数据类型(1:弹窗广告,2:底部广告)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "当前定位纬度", name = "lat", required = true, dataType = "double"),
            @ApiImplicitParam(value = "当前定位经度", name = "lnt", required = true, dataType = "double")
    })
    public ResultUtil<List<AdvertisementWarpper>> queryAdvertisement(Double lat, Double lnt, Integer type, HttpServletRequest request){
        try {
            Integer uid = userInfoService.getUserIdFormRedis(request);
            List<AdvertisementWarpper> advertisementWarpper = advertisementService.queryAdvertisement(uid, lat, lnt, type);
            return ResultUtil.success(advertisementWarpper);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
}