puzhibing
2023-03-18 c0f0b2825ed3dbef86b381c2490277164446dc10
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.supersavedriving.driver.modular.system.api;
 
import com.supersavedriving.driver.core.util.ToolUtil;
import com.supersavedriving.driver.modular.system.service.IDriverService;
import com.supersavedriving.driver.modular.system.service.IYouTuiDriverService;
import com.supersavedriving.driver.modular.system.util.ResultUtil;
import com.supersavedriving.driver.modular.system.warpper.DriverYouTuiWarpper;
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 java.util.List;
 
/**
 * @author zhibing.pu
 * @date 2023/3/15 17:50
 */
@RestController
@RequestMapping("")
public class YouTuiController {
 
    @Autowired
    private IYouTuiDriverService youTuiDriverService;
 
    @Autowired
    private IDriverService driverService;
 
 
 
 
 
 
 
    @ResponseBody
    @PostMapping("/api/youtui/queryDriverYouTui")
//    @ServiceLog(name = "获取司机优推数据", url = "/api/youtui/queryDriverYouTui")
    @ApiOperation(value = "获取司机优推数据", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<List<DriverYouTuiWarpper>> queryDriverYouTui(Integer pageNum, Integer pageSize){
        if(ToolUtil.isEmpty(pageNum)){
            return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
        }
        if(ToolUtil.isEmpty(pageSize)){
            return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
        }
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            List<DriverYouTuiWarpper> driverYouTuiWarppers = youTuiDriverService.queryDriverYouTui(uid, pageNum, pageSize);
            return ResponseWarpper.success(driverYouTuiWarppers);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/api/youtui/queryAllYouTui")
//    @ServiceLog(name = "获取兑换权益列表", url = "/api/youtui/queryAllYouTui")
    @ApiOperation(value = "获取兑换权益列表", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<List<DriverYouTuiWarpper>> queryAllYouTui(Integer pageNum, Integer pageSize){
        if(ToolUtil.isEmpty(pageNum)){
            return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
        }
        if(ToolUtil.isEmpty(pageSize)){
            return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
        }
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            List<DriverYouTuiWarpper> driverYouTuiWarppers = youTuiDriverService.queryAllYouTui(pageNum, pageSize);
            return ResponseWarpper.success(driverYouTuiWarppers);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/api/youtui/redeemBenefits")
//    @ServiceLog(name = "司机兑换优推", url = "/api/youtui/redeemBenefits")
    @ApiOperation(value = "司机兑换优推", tags = {"司机端-个人中心"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "优推数据id", name = "id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper redeemBenefits(Integer id){
        if(ToolUtil.isEmpty(id)){
            return ResponseWarpper.success(ResultUtil.paranErr("id"));
        }
        try {
            Integer uid = driverService.getUserByRequest();
            if(null == uid){
                return ResponseWarpper.tokenErr();
            }
            ResultUtil resultUtil = youTuiDriverService.redeemBenefits(uid, id);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
}