|
@@ -2,14 +2,18 @@ package com.fs.course.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.fs.common.core.redis.RedisCache;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
|
|
+import com.fs.course.constant.CourseConstant;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.course.service.IFsCoursePlaySourceConfigService;
|
|
import com.fs.course.service.IFsCoursePlaySourceConfigService;
|
|
|
import com.fs.course.vo.FsCoursePlaySourceConfigVO;
|
|
import com.fs.course.vo.FsCoursePlaySourceConfigVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -18,6 +22,9 @@ import java.util.Map;
|
|
|
public class FsCoursePlaySourceConfigServiceImpl extends ServiceImpl<FsCoursePlaySourceConfigMapper, FsCoursePlaySourceConfig>
|
|
public class FsCoursePlaySourceConfigServiceImpl extends ServiceImpl<FsCoursePlaySourceConfigMapper, FsCoursePlaySourceConfig>
|
|
|
implements IFsCoursePlaySourceConfigService {
|
|
implements IFsCoursePlaySourceConfigService {
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询点播配置列表
|
|
* 查询点播配置列表
|
|
|
*/
|
|
*/
|
|
@@ -35,4 +42,56 @@ public class FsCoursePlaySourceConfigServiceImpl extends ServiceImpl<FsCoursePla
|
|
|
public FsCoursePlaySourceConfig selectCoursePlaySourceConfigByAppId(String appId) {
|
|
public FsCoursePlaySourceConfig selectCoursePlaySourceConfigByAppId(String appId) {
|
|
|
return baseMapper.selectCoursePlaySourceConfigByAppId(appId);
|
|
return baseMapper.selectCoursePlaySourceConfigByAppId(appId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void refreshBusinessDomainCache(String appId, String businessDomain) {
|
|
|
|
|
+ if (StringUtils.isBlank(appId)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, String> cache = new HashMap<>(2);
|
|
|
|
|
+ cache.put("appId", appId);
|
|
|
|
|
+ cache.put("businessDomain", businessDomain == null ? "" : businessDomain);
|
|
|
|
|
+ redisCache.setCacheObject(CourseConstant.getPlaySourceBusinessDomainKey(appId), cache);
|
|
|
|
|
+ log.info("刷新小程序业务域名缓存: appId={}, businessDomain={}", appId, businessDomain);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void removeBusinessDomainCache(String appId) {
|
|
|
|
|
+ if (StringUtils.isBlank(appId)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ redisCache.deleteObject(CourseConstant.getPlaySourceBusinessDomainKey(appId));
|
|
|
|
|
+ log.info("删除小程序业务域名缓存: appId={}", appId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
|
+ public Map<String, String> getBusinessDomainInfo(String appId) {
|
|
|
|
|
+ if (StringUtils.isBlank(appId)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ String key = CourseConstant.getPlaySourceBusinessDomainKey(appId);
|
|
|
|
|
+ Object cachedObj = redisCache.getCacheObject(key);
|
|
|
|
|
+ if (cachedObj instanceof Map) {
|
|
|
|
|
+ Map<?, ?> cached = (Map<?, ?>) cachedObj;
|
|
|
|
|
+ Object cachedAppId = cached.get("appId");
|
|
|
|
|
+ if (cachedAppId != null) {
|
|
|
|
|
+ Map<String, String> result = new HashMap<>(2);
|
|
|
|
|
+ result.put("appId", String.valueOf(cachedAppId));
|
|
|
|
|
+ Object domain = cached.get("businessDomain");
|
|
|
|
|
+ result.put("businessDomain", domain == null ? "" : String.valueOf(domain));
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FsCoursePlaySourceConfig config = baseMapper.selectCoursePlaySourceConfigByAppId(appId);
|
|
|
|
|
+ if (config == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ refreshBusinessDomainCache(config.getAppid(), config.getBusinessDomain());
|
|
|
|
|
+ Map<String, String> result = new HashMap<>(2);
|
|
|
|
|
+ result.put("appId", config.getAppid());
|
|
|
|
|
+ result.put("businessDomain", config.getBusinessDomain() == null ? "" : config.getBusinessDomain());
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|