liujie
2023-08-04 1f9d05fd255fbd21356dad37527c7d33fda4fb8b
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
package com.dsh.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.Banner;
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.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.ArrayList;
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();
        }
    }
}