package com.agentdriving.user.modular.api; import com.agentdriving.user.core.util.ToolUtil; import com.agentdriving.user.modular.system.service.IAppUserService; import com.agentdriving.user.modular.system.service.ICommercialService; import com.agentdriving.user.modular.system.util.ResultUtil; import com.agentdriving.user.modular.system.warpper.CommercialWarpper; import com.agentdriving.user.modular.system.warpper.ResponseWarpper; 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 java.util.List; /** * 广告控制器 */ @RestController @RequestMapping() public class CommercialController { @Autowired private ICommercialService commercialService; @Autowired private IAppUserService appUserService; @ResponseBody @PostMapping("/api/commercial/queryCommercialList") // @ServiceLog(name = "获取广告列表", url = "/api/driver/queryCommercialList") @ApiOperation(value = "获取广告列表", tags = {"用户端-首页"}, notes = "") @ApiImplicitParams({ @ApiImplicitParam(value = "广告类型(1=弹窗广告,2=底部广告)", name = "type", required = true, dataType = "int"), @ApiImplicitParam(value = "设备类型(1=小程序,2=司机端)", name = "device", required = true, dataType = "int"), @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") }) public ResponseWarpper> queryCommercialList(Integer type, Integer device){ if(ToolUtil.isEmpty(type)){ return ResponseWarpper.success(ResultUtil.paranErr("type")); } if(ToolUtil.isEmpty(device)){ return ResponseWarpper.success(ResultUtil.paranErr("device")); } try { Integer uid = appUserService.getUserByRequest(); if(null == uid){ return ResponseWarpper.success(ResultUtil.tokenErr()); } List commercialWarppers = commercialService.queryCommercialList(uid, type, device); return ResponseWarpper.success(commercialWarppers); }catch (Exception e){ e.printStackTrace(); return new ResponseWarpper(500, e.getMessage()); } } }