zoujiajian 1 an în urmă
părinte
comite
75d5d8e16c

+ 35 - 0
netflix-dao/src/main/java/com/cyksj/model/views/UserMirrorShopAdvertiseFrontView.java

@@ -0,0 +1,35 @@
+package com.cyksj.model.views;
+
+import com.ejlchina.searcher.bean.DbField;
+import com.ejlchina.searcher.bean.SearchBean;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: UserMirrorShopAdvertiseFrontView
+ * 创建者: JavaZou
+ * 创建时间:2024/11/8 10:33
+ */
+@Getter
+@Setter
+@SearchBean(tables = "user_mirror_shop_manage_advertise uma inner join user_mirror_shop um on um.user_id = uma.user_id",
+		where = "uma.status is true",
+		orderBy = "uma.update_time desc")
+public class UserMirrorShopAdvertiseFrontView {
+	/**
+	 * 公告简介
+	 */
+	@DbField("uma.about")
+	private String about;
+
+	/**
+	 * 公告详情
+	 */
+	@DbField("uma.about")
+	private String detail;
+
+
+	@DbField("um.custom_id")
+	private String customId;
+}

+ 1 - 0
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -850,6 +850,7 @@ public class RedisService {
         GOODS_WHOLESALE_KEY("yh_home_paghe_cache:wholesale_key", "平台批发", 60 * 60 * 4L),
         USER_MIRROR_SHOP_BACK_LOGIN_KEY("user_mirror_shop_back_login:", "镜像店铺主后台key", 3 * 60),
         USER_MIRROR_SHOP_AUTH_SUCCESS_KEY("user_mirror_shop_auth_success_key:%s", "镜像店铺主后台微信授权", 60 * 10),
+        USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY("user_mirror_shop_advertise_cache_key:", "用户镜像店铺广告缓存key", 60 * 60 * 12),
         ;
 
         private String name;

+ 5 - 0
netflix-service/src/main/java/com/cyksj/service/mange/RefreshCacheService.java

@@ -34,4 +34,9 @@ public interface RefreshCacheService {
 	void goodsQuestionCache();
 
 	void refreshWholesaleGoods();
+
+	/**
+	 * 清除用户镜像店铺广告
+	 */
+	void refreshUserMirrorShopAdvertiseCache(Long userId);
 }

+ 16 - 0
netflix-service/src/main/java/com/cyksj/service/mange/impl/RefreshCacheServiceImpl.java

@@ -1,10 +1,14 @@
 package com.cyksj.service.mange.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.cyksj.mapper.mirrorshop.UserMirrorShopMapper;
+import com.cyksj.model.entity.UserMirrorShop;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.mange.RefreshCacheService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.Optional;
 import java.util.Set;
 
 /**
@@ -18,6 +22,8 @@ import java.util.Set;
 public class RefreshCacheServiceImpl implements RefreshCacheService {
 	private final RedisService redisService;
 
+	private final UserMirrorShopMapper userMirrorShopMapper;
+
 	@Override
 	public void refreshYhHomePageCache() {
 		Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
@@ -66,4 +72,14 @@ public class RefreshCacheServiceImpl implements RefreshCacheService {
 		Set<String> keys = redisService.keys(RedisService.key.GOODS_WHOLESALE_KEY.getName() + "*");
 		redisService.del(keys.toArray(String[]::new));
 	}
+
+	@Override
+	public void refreshUserMirrorShopAdvertiseCache(Long userId) {
+		Optional.ofNullable(userMirrorShopMapper.selectOne(Wrappers.lambdaQuery(UserMirrorShop.class).eq(UserMirrorShop::getUserId, userId).last("limit 1")))
+				.ifPresent(um -> {
+					String key = RedisService.key.USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY.getName() + um.getCustomId();
+					redisService.del(key);
+				});
+
+	}
 }

+ 6 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/mirrorshop/manage/CmsUserMirrorAdvertiseController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.entity.UserMirrorShopManageAdvertise;
+import com.cyksj.service.mange.RefreshCacheService;
 import com.cyksj.service.mirrorshop.UserMirrorShopAdvertiseService;
 import com.cyksj.web.util.StpUserMirrorShopManageUser;
 import com.ejlchina.searcher.BeanSearcher;
@@ -34,6 +35,8 @@ public class CmsUserMirrorAdvertiseController {
 
 	private final HttpServletRequest request;
 
+	private RefreshCacheService refreshCacheService;
+
 	/**
 	 * 店铺公告列表
 	 */
@@ -71,6 +74,7 @@ public class CmsUserMirrorAdvertiseController {
 			return GatewayResponse.SUCCESS.newBuilder().toResult();
 		}
 		userMirrorShopAdvertiseService.saveOrUpdate(advertise);
+		refreshCacheService.refreshUserMirrorShopAdvertiseCache(userId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 
@@ -88,6 +92,7 @@ public class CmsUserMirrorAdvertiseController {
 					}
 					en.setStatus(!en.getStatus());
 					userMirrorShopAdvertiseService.updateById(en);
+					refreshCacheService.refreshUserMirrorShopAdvertiseCache(userId);
 				});
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
@@ -101,6 +106,7 @@ public class CmsUserMirrorAdvertiseController {
 		userMirrorShopAdvertiseService.remove(Wrappers.lambdaQuery(UserMirrorShopManageAdvertise.class)
 				.eq(UserMirrorShopManageAdvertise::getId, id)
 				.eq(UserMirrorShopManageAdvertise::getUserId, userId));
+		refreshCacheService.refreshUserMirrorShopAdvertiseCache(userId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}
 }

+ 22 - 0
netflix-web/src/main/java/com/cyksj/web/controller/mirrorshop/UserMirrorShopFrontController.java

@@ -10,7 +10,9 @@ import com.cyksj.model.entity.UserMirrorShopFeeOrderDon;
 import com.cyksj.model.request.AlipayOrderDonReq;
 import com.cyksj.model.request.UserMirrorShopSubmitReq;
 import com.cyksj.model.response.AliPayTradeStatus;
+import com.cyksj.model.views.UserMirrorShopAdvertiseFrontView;
 import com.cyksj.model.views.UserMirrorShopInfoView;
+import com.cyksj.redis.RedisService;
 import com.cyksj.service.order.UserMirrorShopOrderService;
 import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
@@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -42,6 +45,8 @@ public class UserMirrorShopFrontController {
 
 	private final UserMirrorShopOrderService userMirrorShopOrderService;
 
+	private final RedisService redisService;
+
 	/**
 	 * 镜像店铺主 个人信息
 	 */
@@ -51,6 +56,23 @@ public class UserMirrorShopFrontController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult(userMirrorShopInfoView);
 	}
 
+	/**
+	 * 用户镜像店铺广告列表
+	 */
+	@GetMapping("/get/advertise/{customId}")
+	public Result<List<UserMirrorShopAdvertiseFrontView>> getAdvertise(@PathVariable String customId) {
+		String key = RedisService.key.USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY.getName() + customId;
+		Object value = redisService.get(key);
+		List<UserMirrorShopAdvertiseFrontView> userMirrorShopAdvertiseFrontViews;
+		if (value == null) {
+			userMirrorShopAdvertiseFrontViews = beanSearcher.searchList(UserMirrorShopAdvertiseFrontView.class, MapUtils.flatBuilder(request.getParameterMap()).field(UserMirrorShopAdvertiseFrontView::getCustomId, customId).build());
+			redisService.set(key, userMirrorShopAdvertiseFrontViews, RedisService.key.USER_MIRROR_SHOP_ADVERTISE_CACHE_KEY.getTimeout());
+		} else {
+			userMirrorShopAdvertiseFrontViews = (List<UserMirrorShopAdvertiseFrontView>) value;
+		}
+		return GatewayResponse.SUCCESS.newBuilder().toResult(userMirrorShopAdvertiseFrontViews);
+	}
+
 	/**
 	 * 立即开店
 	 */