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> queryAdvertisement(Double lat, Double lnt, Integer type, HttpServletRequest request){ try { Integer uid = userInfoService.getUserIdFormRedis(request); List advertisementWarpper = advertisementService.queryAdvertisement(uid, lat, lnt, type); return ResultUtil.success(advertisementWarpper); }catch (Exception e){ e.printStackTrace(); return ResultUtil.runErr(); } } }