Browse Source

增加门户网站的游记列表页面的二维菜单接口

chenchen 5 months ago
parent
commit
ff03f71a7c

+ 56 - 1
application-webadmin/src/main/java/com/tourism/webadmin/app/website/controller/WebsiteTourismProjectTravelNotesController.java

@@ -1,12 +1,18 @@
 package com.tourism.webadmin.app.website.controller;
 
 import cn.dev33.satoken.annotation.SaIgnore;
+import com.tourism.common.core.object.MyOrderParam;
 import com.tourism.common.core.object.MyPageData;
 import com.tourism.common.core.object.ResponseResult;
 import com.tourism.common.log.annotation.OperationLog;
 import com.tourism.common.log.model.constant.SysOperationLogType;
 import com.tourism.webadmin.app.website.dto.TourismProjectTravelNotesToWebDto;
 import com.tourism.webadmin.app.website.service.BasicToWebService;
+import com.tourism.webadmin.app.website.vo.TourTravelNotesDirectoryCountryVo;
+import com.tourism.webadmin.app.website.vo.TourTravelNotesDirectoryVo;
+import com.tourism.webadmin.back.model.CompanyInfo;
+import com.tourism.webadmin.back.model.DirectoryInfo;
+import com.tourism.webadmin.back.service.DirectoryInfoService;
 import com.tourism.webadmin.back.service.TourTourismProjectTravelNotesService;
 import com.tourism.webadmin.back.service.TourUserLikeTravelNotesService;
 import com.tourism.webadmin.back.vo.TourTourismProjectTravelNotesVo;
@@ -19,6 +25,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Tag(name = "门户网站旅游游记接口")
 @Slf4j
 @RestController
@@ -30,7 +39,7 @@ public class WebsiteTourismProjectTravelNotesController {
     @Autowired
     private BasicToWebService basicToWebServicel;
     @Autowired
-    private TourTourismProjectTravelNotesService tourTourismProjectTravelNotesService;
+    private DirectoryInfoService directoryInfoService;
 
 
     /**
@@ -105,4 +114,50 @@ public class WebsiteTourismProjectTravelNotesController {
         basicToWebServicel.travelNotesViewCountAdd(travelNotesId);
         return ResponseResult.success();
     }
+
+
+    /**
+     * 游记菜单列表(二维数组)
+     * param
+     * @return 应答结果对象,包含查询结果集。
+     */
+    @OperationLog(type = SysOperationLogType.ADD)
+    @GetMapping("/travelNotesDirectoryList")
+    public ResponseResult<List<TourTravelNotesDirectoryVo>> travelNotesDirectoryList() {
+
+        //设置排序
+        MyOrderParam myOrderParam = new MyOrderParam();
+        MyOrderParam.OrderInfo orderInfo = new MyOrderParam.OrderInfo();
+        orderInfo.setAsc(true);
+        orderInfo.setFieldName("showOrder");
+        myOrderParam.add(orderInfo);
+        String orderBy = MyOrderParam.buildOrderBy(myOrderParam, DirectoryInfo.class);
+
+        //查询一级菜单
+        DirectoryInfo directoryInfo = new DirectoryInfo();
+        directoryInfo.setParentId(0L);
+        directoryInfo.setEnable(1);
+        List<DirectoryInfo> directoryInfoList = directoryInfoService.getDirectoryInfoList(directoryInfo, orderBy);
+        List<TourTravelNotesDirectoryVo> tourTravelNotesDirectoryVoList= new ArrayList<>();
+        TourTravelNotesDirectoryVo tourTravelNotesDirectoryVo = new TourTravelNotesDirectoryVo();
+        TourTravelNotesDirectoryCountryVo tourTravelNotesDirectoryCountryVo = new TourTravelNotesDirectoryCountryVo();
+        directoryInfoList.stream().forEach(item->{
+            tourTravelNotesDirectoryVo.setAreaId(item.getId().toString());
+            tourTravelNotesDirectoryVo.setAreaName(item.getMenuName());
+
+            DirectoryInfo directoryInfo1 = new DirectoryInfo();
+            directoryInfo1.setEnable(1);
+            directoryInfo1.setParentId(item.getId());
+            List<DirectoryInfo> countryList = directoryInfoService.getDirectoryInfoList(directoryInfo1,orderBy);
+            List<TourTravelNotesDirectoryCountryVo> tourTravelNotesDirectoryCountryVoList = new ArrayList<>();
+            for(DirectoryInfo country:countryList){
+                tourTravelNotesDirectoryCountryVo.setCountryId(country.getId().toString());
+                tourTravelNotesDirectoryCountryVo.setCountryName(country.getMenuName().toString());
+                tourTravelNotesDirectoryCountryVoList.add(tourTravelNotesDirectoryCountryVo);
+            }
+            tourTravelNotesDirectoryVo.setChildren(tourTravelNotesDirectoryCountryVoList);
+            tourTravelNotesDirectoryVoList.add(tourTravelNotesDirectoryVo);
+        });
+        return ResponseResult.success(tourTravelNotesDirectoryVoList);
+    }
 }

+ 28 - 0
application-webadmin/src/main/java/com/tourism/webadmin/app/website/vo/TourTravelNotesDirectoryCountryVo.java

@@ -0,0 +1,28 @@
+package com.tourism.webadmin.app.website.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * 门户网站中游记的二维菜单城市对象。
+ *
+ * @author 吃饭睡觉
+ * @date 2024-09-06
+ */
+@Schema(description = "TourTravelNotesDirectoryCountryVo视图对象")
+@Data
+public class TourTravelNotesDirectoryCountryVo {
+
+    /**
+     * 国家id。
+     */
+    @Schema(description = "国家id")
+    private String countryId;
+
+    /**
+     * 国家名称。
+     */
+    @Schema(description = "国家名称")
+    private String countryName;
+
+}

+ 37 - 0
application-webadmin/src/main/java/com/tourism/webadmin/app/website/vo/TourTravelNotesDirectoryVo.java

@@ -0,0 +1,37 @@
+package com.tourism.webadmin.app.website.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 门户网站中游记的二维菜单地区对象。
+ *
+ * @author 吃饭睡觉
+ * @date 2024-10-12
+ */
+@Schema(description = "TourTravelNotesDirectoryVo视图对象")
+@Data
+public class TourTravelNotesDirectoryVo {
+
+    /**
+     * 地区id。
+     */
+    @Schema(description = "地区id")
+    private String areaId;
+
+    /**
+     * 地区名称。
+     */
+    @Schema(description = "地区名称")
+    private String areaName;
+
+    /**
+     * 城市。
+     */
+    @Schema(description = "城市")
+    private List<TourTravelNotesDirectoryCountryVo> children;
+
+}

+ 6 - 0
common/common-additional/pom.xml

@@ -58,5 +58,11 @@
             <version>5.8.23</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+            <version>3.34.1</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 161 - 0
common/common-additional/src/main/java/com/tourism/common/additional/utils/RedisUtils.java

@@ -0,0 +1,161 @@
+package com.tourism.common.additional.utils;
+import jakarta.annotation.Resource;
+import org.redisson.api.*;
+import org.redisson.client.codec.StringCodec;
+import org.springframework.stereotype.Component;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
+
+@Component
+public class RedisUtils {
+
+    private RedisUtils() {
+    }
+
+    /**
+     * 默认缓存时间
+     */
+    private static final Long DEFAULT_EXPIRED = 32000L;
+
+    /**
+     * 自动装配redisson client对象
+     */
+    @Resource
+    private RedissonClient redissonClient;
+
+    /**
+     * 用于操作key
+     * @return RKeys 对象
+     */
+    public RKeys getKeys() {
+        return redissonClient.getKeys();
+    }
+    /**
+     * 移除缓存
+     *
+     * @param key
+     */
+    public void delete(String key) {
+        redissonClient.getBucket(key).delete();
+    }
+
+    /**
+     * 获取getBuckets 对象
+     *
+     * @return RBuckets 对象
+     */
+    public RBuckets getBuckets() {
+        return redissonClient.getBuckets();
+    }
+
+    /**
+     * 读取缓存中的字符串,永久有效
+     *
+     * @param key 缓存key
+     * @return 字符串
+     */
+    public String getStr(String key) {
+        RBucket<String> bucket = redissonClient.getBucket(key);
+        return bucket.get();
+    }
+
+    /**
+     * 缓存字符串
+     *
+     * @param key
+     * @param value
+     */
+    public void setStr(String key, String value) {
+        RBucket<String> bucket = redissonClient.getBucket(key);
+        bucket.set(value);
+    }
+
+    /**
+     * 缓存带过期时间的字符串
+     *
+     * @param key     缓存key
+     * @param value   缓存值
+     * @param expired 缓存过期时间,long类型,必须传值
+     */
+    public void setStr(String key, String value, long expired) {
+        RBucket<String> bucket = redissonClient.getBucket(key, StringCodec.INSTANCE);
+        bucket.set(value, expired <= 0L ? DEFAULT_EXPIRED : expired, TimeUnit.SECONDS);
+    }
+
+    /**
+     * string 操作,如果不存在则写入缓存(string方式,不带有redisson的格式信息)
+     *
+     * @param key     缓存key
+     * @param value   缓存值
+     * @param expired 缓存过期时间
+     */
+    public Boolean setIfAbsent(String key, String value, long expired) {
+        RBucket<String> bucket = redissonClient.getBucket(key, StringCodec.INSTANCE);
+        return bucket.trySet(value, expired <= 0L ? DEFAULT_EXPIRED : expired, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 如果不存在则写入缓存(string方式,不带有redisson的格式信息),永久保存
+     *
+     * @param key   缓存key
+     * @param value 缓存值
+     */
+    public Boolean setIfAbsent(String key, String value) {
+        RBucket<String> bucket = redissonClient.getBucket(key, StringCodec.INSTANCE);
+        return bucket.trySet(value);
+    }
+
+    /**
+     * 判断缓存是否存在
+     *
+     * @param key
+     * @return true 存在
+     */
+    public Boolean isExists(String key) {
+        return redissonClient.getBucket(key).isExists();
+    }
+
+    /**
+     * 获取RList对象
+     *
+     * @param key RList的key
+     * @return RList对象
+     */
+    public <T> RList<T> getList(String key) {
+        return redissonClient.getList(key);
+    }
+
+    /**
+     * 获取RMapCache对象
+     *
+     * @param key
+     * @return RMapCache对象
+     */
+    public <K, V> RMapCache<K, V> getMap(String key) {
+        return redissonClient.getMapCache(key);
+    }
+
+    /**
+     * 获取RSET对象
+     *
+     * @param key
+     * @return RSET对象
+     */
+    public <T> RSet<T> getSet(String key) {
+        return redissonClient.getSet(key);
+    }
+
+    /**
+     * 获取RScoredSortedSet对象
+     *
+     * @param key
+     * @param <T>
+     * @return RScoredSortedSet对象
+     */
+    public <T> RScoredSortedSet<T> getScoredSortedSet(String key) {
+        return redissonClient.getScoredSortedSet(key);
+    }
+
+}
+