luoyisheng
2023-09-19 9c6740ce3038e1041979537ecbe7d801c21d0559
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
package com.dsh.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.Banner;
import com.dsh.other.entity.CreateHistoryDto;
import com.dsh.other.entity.GetHistoryDto;
import com.dsh.other.model.BannerVo;
import com.dsh.other.service.IBannerService;
import com.dsh.other.util.ResultUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * @author zhibing.pu
 * @date 2023/7/11 17:48
 */
@RestController
@RequestMapping("")
public class BannerController {
 
    @Autowired
    private IBannerService bannerService;
 
 
 
 
    @ResponseBody
    @PostMapping("/base/banner/queryBannerList")
    @ApiOperation(value = "获取banner数据", tags = {"APP-加入玩湃"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "位置(1=首页,2=首页底部,3=线上课得积分,4=看视频得奖励,5=常见问题)", name = "position", dataType = "int", required = true),
    })
    public ResultUtil<List<BannerVo>> queryBannerList(Integer position){
        try {
            List<Banner> list = bannerService.list(new QueryWrapper<Banner>().eq("position", position).eq("state", 1).orderByAsc("sort"));
            List<BannerVo> list1 = new ArrayList<>();
            for (Banner banner : list) {
                BannerVo bannerVo = new BannerVo();
                BeanUtils.copyProperties(banner, bannerVo);
                list1.add(bannerVo);
            }
            return ResultUtil.success(list1);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/class/hisotory")
    public  void createHistory(@RequestBody CreateHistoryDto createHistoryDto){
        createHistoryDto.setDate(new Date());
 
        bannerService.createHistory(createHistoryDto);
 
 
    }
 
    @ResponseBody
    @PostMapping("/class/gethisotory")
    public  List<GetHistoryDto> getHistory(@RequestBody Integer studentId){
 
      return   bannerService.gethistory(studentId);
 
 
    }
}