Browse Source

字典参数查询首页数据列表接口

wwl 3 years ago
parent
commit
9c3b2d433d

+ 12 - 0
zzjs-admin/src/main/java/com/miaxis/app/controller/carousel/AppletHomePageDataInfoController.java

@@ -6,8 +6,10 @@ import com.miaxis.common.core.controller.BaseController;
 import com.miaxis.common.core.domain.Response;
 import com.miaxis.common.core.domain.Response;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -36,5 +38,15 @@ public class AppletHomePageDataInfoController extends BaseController {
     }
     }
 
 
 
 
+    /**
+     * 查询首页数据列表--字典参数
+     */
+    @GetMapping("/dictValueHomePageDataList/{dictValues}")
+    @ApiOperation("查询首页数据列表--字典参数")
+    public Response dictValueHomePageDataList(@ApiParam(name = "dictValues",value = "字典参数",required = true)
+                                    @PathVariable("dictValues") String[] dictValues){
+        return homePageDataInfoService.dictValueHomePageDataList(dictValues);
+    }
+
 
 
 }
 }

+ 7 - 1
zzjs-service/src/main/java/com/miaxis/carousel/service/IHomePageDataInfoService.java

@@ -60,6 +60,13 @@ public interface IHomePageDataInfoService extends IService<HomePageDataInfo>{
      */
      */
     Response getHomePageDataList();
     Response getHomePageDataList();
 
 
+    /**
+     * 查询首页数据列表--字典参数
+     * @param dictValues
+     * @return
+     */
+    Response dictValueHomePageDataList(String[] dictValues);
+
 
 
     int updateHomePageDataByPictureName(HomePageDataInfoVo homePageDataInfoVo);
     int updateHomePageDataByPictureName(HomePageDataInfoVo homePageDataInfoVo);
 
 
@@ -69,5 +76,4 @@ public interface IHomePageDataInfoService extends IService<HomePageDataInfo>{
      */
      */
     Response synchroData();
     Response synchroData();
 
 
-
 }
 }

+ 38 - 0
zzjs-service/src/main/java/com/miaxis/carousel/service/impl/HomePageDataInfoServiceImpl.java

@@ -179,6 +179,44 @@ public class HomePageDataInfoServiceImpl extends ServiceImpl<HomePageDataInfoMap
         return Response.success(map);
         return Response.success(map);
     }
     }
 
 
+
+    /**
+     * 查询首页数据列表--字典参数
+     * @param dictValues
+     * @return
+     */
+    @Override
+    public Response dictValueHomePageDataList(String[] dictValues) {
+        Map<String, List<HomePageDataInfoVo>> map = new HashMap<>();
+
+        for (String dictData : dictValues) {
+            List<HomePageDataInfoVo> newInfos = new ArrayList<>();
+            Set carouselChartkeys = redisTemplate.keys(Constants.HOME_PAGE_DATA_KEY + dictData+":*");
+            if (!carouselChartkeys.isEmpty()){
+                for (Object key : carouselChartkeys) {
+                    String jsonStr = (String) redisTemplate.opsForValue().get(key);
+                    HomePageDataInfoVo homePageDataInfoVo = JSONObject.parseObject(jsonStr).toJavaObject(HomePageDataInfoVo.class);
+                    newInfos.add(homePageDataInfoVo);
+                }
+            }else {
+                //数据库获取(此处可不做查询!)
+                HomePageDataInfo homePageDataInfo = new HomePageDataInfo();
+                homePageDataInfo.setDataType(dictData);
+                homePageDataInfo.setStatus("0");//启用状态
+                newInfos = homePageDataInfoMapper.selectHomePageDataInfoList(homePageDataInfo);
+            }
+            //排序
+            List<HomePageDataInfoVo> infoVos = newInfos.stream()
+                    .sorted(Comparator.comparing(HomePageDataInfoVo::getWeight).reversed())
+                    .collect(Collectors.toList());
+
+            map.put(dictData,infoVos);
+        }
+
+        return Response.success(map);
+    }
+
+
     /**
     /**
      * 同步数据
      * 同步数据
      * @return
      * @return