puzhibing
2023-05-22 c588d0fb5d7b61611b13911e4f0b65e760a7e862
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
package com.agentdriving.driver.modular.system.api;
 
import com.agentdriving.driver.core.util.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.agentdriving.driver.modular.system.model.Img;
import com.agentdriving.driver.modular.system.model.SystemConfig;
import com.agentdriving.driver.modular.system.service.IImgService;
import com.agentdriving.driver.modular.system.service.ISystemConfigService;
import com.agentdriving.driver.modular.system.util.ResultUtil;
import com.agentdriving.driver.modular.system.warpper.BaseWarpper;
import com.agentdriving.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.*;
 
import java.util.ArrayList;
import java.util.List;
 
@RestController
@RequestMapping("")
public class ImgController {
 
    @Autowired
    private IImgService imgService;
 
    @Autowired
    private ISystemConfigService systemConfigService;
 
 
 
    @ResponseBody
    @PostMapping("/base/img/querySysImg")
//    @ServiceLog(name = "获取系统图片", url = "/base/img/querySysImg")
    @ApiOperation(value = "获取系统图片", tags = {"司机端-公共接口"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "数据类型(1=启动页)", name = "type", required = true, dataType = "int"),
    })
    public ResponseWarpper<List<BaseWarpper>> querySysImg(@RequestParam("type") Integer type){
        if(ToolUtil.isEmpty(type)){
            return ResponseWarpper.success(ResultUtil.paranErr("type"));
        }
        try {
            List<BaseWarpper> list = new ArrayList<>();
            SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 8));
            if(null != systemConfig) {
                JSONObject jsonObject1 = JSON.parseObject(systemConfig.getContent());
                Integer num2 = jsonObject1.getInteger("num2");//启动页开关
                if(1 == num2){
                    List<Img> imgs = imgService.selectList(new EntityWrapper<Img>().eq("type", type));
                    for (Img img : imgs) {
                        BaseWarpper baseWarpper = new BaseWarpper();
                        baseWarpper.setId(img.getId().longValue());
                        baseWarpper.setPath(img.getImg());
                        list.add(baseWarpper);
                    }
                }
            }
            return ResponseWarpper.success(list);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
}