package com.supersavedriving.driver.modular.system.api;
|
|
import com.supersavedriving.driver.core.common.annotion.ServiceLog;
|
import com.supersavedriving.driver.core.util.ToolUtil;
|
import com.supersavedriving.driver.modular.system.service.ICommercialService;
|
import com.supersavedriving.driver.modular.system.service.IDriverService;
|
import com.supersavedriving.driver.modular.system.util.ResultUtil;
|
import com.supersavedriving.driver.modular.system.warpper.CommercialWarpper;
|
import com.supersavedriving.driver.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 javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
|
/**
|
* 广告控制器
|
*/
|
@RestController
|
@RequestMapping()
|
public class CommercialController {
|
|
@Autowired
|
private ICommercialService commercialService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
|
|
@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<List<CommercialWarpper>> queryCommercialList(Integer type, Integer device, HttpServletRequest request){
|
if(ToolUtil.isEmpty(type)){
|
return ResponseWarpper.success(ResultUtil.paranErr("type"));
|
}
|
if(ToolUtil.isEmpty(device)){
|
return ResponseWarpper.success(ResultUtil.paranErr("device"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequset(request);
|
if(null == uid){
|
return ResponseWarpper.success(ResultUtil.tokenErr());
|
}
|
List<CommercialWarpper> commercialWarppers = commercialService.queryCommercialList(uid, type, device);
|
return ResponseWarpper.success(commercialWarppers);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
}
|