puzhibing
2023-07-20 47a2f7da23d9a6b75c94be1557f845dc19330bd6
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
package com.supersavedriving.user.modular.api;
 
import com.supersavedriving.user.core.common.annotion.ServiceLog;
import com.supersavedriving.user.core.util.ToolUtil;
import com.supersavedriving.user.modular.system.service.IAppUserService;
import com.supersavedriving.user.modular.system.service.ICommercialService;
import com.supersavedriving.user.modular.system.util.ResultUtil;
import com.supersavedriving.user.modular.system.warpper.CommercialWarpper;
import com.supersavedriving.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 javax.servlet.http.HttpServletRequest;
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<List<CommercialWarpper>> 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<CommercialWarpper> commercialWarppers = commercialService.queryCommercialList(uid, type, device);
            return ResponseWarpper.success(commercialWarppers);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
}