| | |
| | | package com.supersavedriving.driver.modular.system.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.supersavedriving.driver.core.common.annotion.ServiceLog; |
| | | import com.supersavedriving.driver.core.util.ToolUtil; |
| | | import com.supersavedriving.driver.modular.system.model.Img; |
| | | import com.supersavedriving.driver.modular.system.model.SystemConfig; |
| | | import com.supersavedriving.driver.modular.system.service.IImgService; |
| | | import com.supersavedriving.driver.modular.system.service.ISystemConfigService; |
| | | 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.*; |
| | | |
| | |
| | | @RequestMapping("") |
| | | public class ImgController { |
| | | |
| | | Logger logger = LoggerFactory.getLogger("ServiceLog"); |
| | | |
| | | @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){ |
| | | ResponseWarpper responseWarpper = null; |
| | | if(ToolUtil.isEmpty(type)){ |
| | | responseWarpper = ResponseWarpper.success(ResultUtil.paranErr()); |
| | | return ResponseWarpper.success(ResultUtil.paranErr("type")); |
| | | } |
| | | |
| | | 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); |
| | | 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); |
| | | } |
| | | } |
| | | responseWarpper = ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | responseWarpper = new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | return ResponseWarpper.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ResponseWarpper(500, e.getMessage()); |
| | | } |
| | | logger.debug("" + |
| | | "\n接口地址:/base/img/querySysImg" + |
| | | "\n接口名称:获取系统图片" + |
| | | "\n请求参数:type:{}" + |
| | | "\n响应结果:{}" |
| | | , type, JSON.toJSONString(responseWarpper)); |
| | | return responseWarpper; |
| | | } |
| | | } |