Prechádzať zdrojové kódy

fix 清除活码缓存

zoujiajian 2 rokov pred
rodič
commit
4b95daf43d

+ 5 - 5
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpFollowServiceImpl.java

@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.constant.Constant;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;
-import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.mapper.corp.CorpFollowActiveCodeMapper;
 import com.cyksj.mapper.corp.CorpFollowDutyRelateMapper;
 import com.cyksj.mapper.corp.CorpFollowServiceRelateMapper;
@@ -16,9 +15,9 @@ import com.cyksj.mapper.corp.CorpTagMapper;
 import com.cyksj.model.dto.YhServiceDto;
 import com.cyksj.model.entity.*;
 import com.cyksj.model.request.corp.Attachments;
+import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
 import com.cyksj.service.corp.CorpFollowService;
-import com.cyksj.service.corp.CorpService;
 import com.cyksj.service.corp.WxCorpOps;
 import com.cyksj.service.mange.cms.CmsUserManager;
 import lombok.RequiredArgsConstructor;
@@ -28,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 
 /**
  * 项目名: yhlxj
@@ -52,9 +52,7 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 
 	private final CorpTagMapper corpTagMapper;
 
-	private final CorpService corpService;
-
-	private final YHLXWxCorpConfig yhlxWxCorpConfig;
+	private final RedisService redisService;
 
 	@Override
 	@Transactional(rollbackFor = Throwable.class)
@@ -150,6 +148,8 @@ public class CorpFollowServiceImpl implements CorpFollowService {
 		if (isReCreateAcCode) {
 			String code_str = corpFollowDynamicConfigService.createCorpFollowActiveCode(up_corpFollows, Constant.AC_CODE_KEY + activeCode.getId(), up_isDuty);
 			activeCode.setCodeStr(code_str);
+			Set<String> keys = redisService.keys(RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getNameFormat(activeCode.getId(), "*"));
+			redisService.del(keys.toArray(String[]::new));
 		} else if (isUpdateAcCode) {
 			corpFollowDynamicConfigService.updateCorpFollowActiveCode(dbActiveCode.getMarkTag(), activeCode.getMarkTag());
 		}

+ 6 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/CmsCorpFollowActiveCodeController.java

@@ -18,6 +18,7 @@ import com.cyksj.model.request.corp.CorpFollowContact;
 import com.cyksj.model.views.CorpActiveCodeGoodsOrderView;
 import com.cyksj.model.views.CorpActiveCodeOrderView;
 import com.cyksj.model.views.CorpFollowActiveCodeView;
+import com.cyksj.redis.RedisService;
 import com.cyksj.service.corp.CorpFollowDynamicConfigService;
 import com.cyksj.service.corp.CorpFollowService;
 import com.ejlchina.searcher.BeanSearcher;
@@ -35,6 +36,7 @@ import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.Set;
 
 /** admin/企业微信/客服活码
  *项目名: netflix
@@ -59,6 +61,8 @@ public class CmsCorpFollowActiveCodeController {
 
 	private final CorpUserMapper corpUserMapper;
 
+	private final RedisService redisService;
+
 	private final HttpServletRequest request;
 
 
@@ -105,6 +109,8 @@ public class CmsCorpFollowActiveCodeController {
 	@DeleteMapping("/del/active/code/{id}")
 	public Result<String> deleteByAcCodeById(@PathVariable Long id) throws Exception {
 		corpFollowService.deleteActiveCodeById(id);
+		Set<String> keys = redisService.keys(RedisService.key.CORP_FOLLOW_ACTIVE_CODE_KEY.getNameFormat(id, "*"));
+		redisService.del(keys.toArray(String[]::new));
 		return GatewayResponse.SUCCESS.newBuilder().toResult();
 	}