From 3f50662d2e84ff72b4f3cd48026ac66af4700454 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 07 二月 2024 14:33:40 +0800 Subject: [PATCH] 新增加接口 --- cloud-server-other/src/main/java/com/dsh/other/controller/StoreConfigController.java | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 42 insertions(+), 9 deletions(-) diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreConfigController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreConfigController.java index 1392ca6..1568141 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreConfigController.java +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreConfigController.java @@ -1,8 +1,10 @@ package com.dsh.other.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.dsh.other.entity.HomeModule; import com.dsh.other.entity.StoreConfig; import com.dsh.other.model.StoreConfigVo; +import com.dsh.other.service.IHomeModuleService; import com.dsh.other.service.StoreConfigService; import com.dsh.other.util.ResultUtil; import io.swagger.annotations.ApiImplicitParam; @@ -10,10 +12,14 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; /** * @author zhibing.pu @@ -26,10 +32,17 @@ @Autowired private StoreConfigService storeConfigService; + @Autowired + private IHomeModuleService homeModuleService; + + + + + @ResponseBody @PostMapping("/base/store/queryStoreConfig") - @ApiOperation(value = "获取门店模块配置", tags = {"APP-加入玩湃"}) + @ApiOperation(value = "获取门店模块配置【2.0】", tags = {"APP-加入玩湃"}) @ApiImplicitParams({ @ApiImplicitParam(value = "门店id", name = "storeId", dataType = "int", required = true), }) @@ -38,12 +51,22 @@ return ResultUtil.paranErr("storeId"); } try { - List<StoreConfig> list = storeConfigService.list(new QueryWrapper<StoreConfig>().eq("storeId", storeId).orderByAsc("sort").eq("isOpen", 1)); + List<StoreConfig> list = storeConfigService.list(new QueryWrapper<StoreConfig>().eq("storeId", storeId) + .orderByAsc("sort").eq("isOpen", 1)); + HomeModule homeModule = homeModuleService.getOne(new QueryWrapper<HomeModule>().eq("isOpen", 1)); List<StoreConfigVo> listVo = new ArrayList<>(); + if(null != homeModule){ + StoreConfigVo vo = new StoreConfigVo(); + vo.setType(0); + vo.setIsOpen(homeModule.getIsOpen()); + vo.setSort(homeModule.getSort()); + vo.setBackgroundImage(homeModule.getBackgroundImage()); + listVo.add(vo); + } for (StoreConfig storeConfig : list) { StoreConfigVo storeConfigVo = new StoreConfigVo(); BeanUtils.copyProperties(storeConfig, storeConfigVo); - if (storeConfig.getBackgroundImage() == null || storeConfig.getBackgroundImage().equals("")) { + if (!StringUtils.hasLength(storeConfig.getBackgroundImage())) { switch (storeConfigVo.getType()) { case 1: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/8b7073a4d33d4eea9f0d173cb4db92a7.png"); @@ -56,32 +79,30 @@ case 3: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/08c5eca72fca4d479d21905d25870ef8.png"); break; - } case 4: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/8602be35e6cf4f76819b7b2d7b588efc.png"); break; - } case 5: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/694f84a1e2ba4d2c919f4f4ffaadece2.png"); break; - } case 6: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/81a83d229fea46a78be6a3ec1d5b7d6e.png"); break; - } case 7: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/312763e7565c48f2a16021c162c76018.png"); break; - } case 8: { storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/0771fb3bd4de43c08492d0912209e51f.png"); break; - + } + case 9: { + storeConfigVo.setBackgroundImage("https://we-park-life.oss-cn-beijing.aliyuncs.com/img/0771fb3bd4de43c08492d0912209e51f.png"); + break; } } @@ -89,6 +110,13 @@ listVo.add(storeConfigVo); } + //排序 + Collections.sort(listVo, new Comparator<StoreConfigVo>() { + @Override + public int compare(StoreConfigVo o1, StoreConfigVo o2) { + return o1.getSort().compareTo(o2.getSort()); + } + }); return ResultUtil.success(listVo); } catch (Exception e) { e.printStackTrace(); @@ -97,4 +125,9 @@ } + + + + + } -- Gitblit v1.7.1