package com.supersavedriving.driver.modular.system.api;
|
|
import com.alibaba.fastjson.JSON;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.supersavedriving.driver.core.util.ToolUtil;
|
import com.supersavedriving.driver.modular.system.model.Img;
|
import com.supersavedriving.driver.modular.system.service.IImgService;
|
import com.supersavedriving.driver.modular.system.util.ResultUtil;
|
import com.supersavedriving.driver.modular.system.warpper.BaseWarpper;
|
import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper;
|
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;
|
|
@RestController
|
@RequestMapping("")
|
public class ImgController {
|
|
Logger logger = LoggerFactory.getLogger("ServiceLog");
|
|
@Autowired
|
private IImgService imgService;
|
|
|
|
@ResponseBody
|
@PostMapping("/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){
|
ResponseWarpper responseWarpper = null;
|
if(ToolUtil.isEmpty(type)){
|
responseWarpper = ResponseWarpper.success(ResultUtil.paranErr());
|
}
|
|
if(ToolUtil.isNotEmpty(type)){
|
try {
|
List<Img> imgs = imgService.selectList(new EntityWrapper<Img>().eq("type", type));
|
List<BaseWarpper> list = new ArrayList<>();
|
for (Img img : imgs) {
|
BaseWarpper baseWarpper = new BaseWarpper();
|
baseWarpper.setId(img.getId());
|
baseWarpper.setPath(img.getImg());
|
list.add(baseWarpper);
|
}
|
responseWarpper = ResponseWarpper.success(list);
|
}catch (Exception e){
|
e.printStackTrace();
|
responseWarpper = new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
logger.debug("" +
|
"\n接口地址:/base/img/querySysImg" +
|
"\n接口名称:获取系统图片" +
|
"\n请求参数:type:{}" +
|
"\n响应结果:{}"
|
, type, JSON.toJSONString(responseWarpper));
|
return responseWarpper;
|
}
|
}
|