puzhibing
2023-07-10 f95325fd2635a9af08c0acac70e70379978d128a
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
package com.dsh.course.controller;
 
import com.dsh.course.entity.TCoursePackage;
import com.dsh.course.model.vo.response.WeekLimitedResponse;
import com.dsh.course.service.TCoursePackageDiscountService;
import com.dsh.course.service.TCoursePackageService;
import com.dsh.course.util.ResultUtil;
import com.dsh.course.util.TokenUtil;
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.*;
 
/**
 * @author zhibing.pu
 * @date 2023/7/5 9:58
 */
@RestController
@RequestMapping("")
public class CoursePackageController {
 
    @Autowired
    private TCoursePackageService coursePackageService;
 
 
    @Autowired
    private TCoursePackageDiscountService tcpdService;
 
 
    @Autowired
    private TokenUtil tokenUtil;
 
    /**
     * 根据id获取课包
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/coursePackage/queryCoursePackageById")
    public TCoursePackage queryCoursePackageById(@RequestBody Integer id){
        try {
            TCoursePackage coursePackage = coursePackageService.getById(id);
            return coursePackage;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
 
    /**
     * 本周福利列表
     */
    @ResponseBody
    @PostMapping("/api/useBenefit/weekLimitedBenefit")
    @ApiOperation(value = "本周福利-限时折扣列表", tags = {"APP-使用福利"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(name = "discountType",value = "默认显示 限时折扣 (1限时折扣 2赠送课时)")
    })
    public ResultUtil<WeekLimitedResponse> thisWeeksBenefitList(Integer discountType,String lon,String lat){
        try {
            Integer appUserId = tokenUtil.getUserIdFormRedis();
            if(null == appUserId){
                return ResultUtil.tokenErr();
            }
            return ResultUtil.success(tcpdService.getWeeksBenefitCourse(appUserId,discountType,lon,lat));
        }catch (Exception e){
            return ResultUtil.runErr();
        }
    }
 
}