puzhibing
2023-11-25 53e7558400dcacecdce70e39ebfe1727740f9296
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
package com.dsh.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.TImgConfig;
import com.dsh.other.feignclient.model.UserBenefitImage;
import com.dsh.other.service.TImgConfigService;
import com.dsh.other.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 图片配置控制器
 */
@Api
@CrossOrigin
@RestController
@RequestMapping("")
public class ImgConfigController {
 
    private Logger logger = LoggerFactory.getLogger("business-log");
 
 
    @Autowired
    private TImgConfigService imgConfigService;
 
 
    /**
     * 获取 没有学员信息的图片配置
     */
    @PostMapping("/base/imgConfig/getNoneStu")
    public List<TImgConfig> getDriver() {
        return imgConfigService.list(new QueryWrapper<TImgConfig>()
                .eq("position", 1));
    }
 
 
    /**
     * 获取系统图片
     *
     * @param position
     * @return
     */
    @ResponseBody
    @PostMapping("/base/systemImg/querySystemImg")
    @ApiOperation(value = "获取各种系统图片", tags = {"APP-公共接口"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "位置(1=无学员,2=成为会员,3=我的券包,4=线上商城,5=本周福利,6=今日免费,7启动页配置)", name = "position", dataType = "int", required = true),
    })
    public ResultUtil<String> querySystemImg(Integer position) {
        TImgConfig imgConfig = imgConfigService.getBaseMapper().selectOne(new QueryWrapper<TImgConfig>().eq("position", position));
        return ResultUtil.success(imgConfig.getContent());
    }
 
 
    @PostMapping("/base/imgConfig/getBenefitImage")
    public UserBenefitImage getImageConfig() {
        UserBenefitImage image = new UserBenefitImage();
        ArrayList<Integer> integers = new ArrayList<>();
        integers.add(1);
        integers.add(2);
        List<TImgConfig> tImgConfigs = imgConfigService.getBaseMapper().selectList(new QueryWrapper<TImgConfig>()
                .notIn("position", integers));
        if (tImgConfigs.size() > 0) {
            tImgConfigs.forEach(imgCg -> {
                switch (imgCg.getPosition()) {
                    case 3:
                        image.setMyConpons(imgCg.getContent());
                        break;
                    case 4:
                        image.setOnlineShop(imgCg.getContent());
                        break;
                    case 5:
                        image.setWeeksBenefit(imgCg.getContent());
                        break;
                    case 6:
                        image.setTodayFree(imgCg.getContent());
                        break;
                    default:
                        break;
                }
            });
        }
        return image;
    }
 
}