Commit f4a1601e by 王祖波

内容分享企微素材使用老的前端合成还是新的后端合成 0老1新

parent 1b2b8aa5
package com.gic.haoban.manage.service.context.combined; package com.gic.haoban.manage.service.context.combined;
import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.ConfigService;
import com.ctrip.framework.apollo.model.ConfigChange; import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent; import com.ctrip.framework.apollo.model.ConfigChangeEvent;
...@@ -13,6 +14,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -13,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.imageio.ImageReader; import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageInputStream;
...@@ -23,6 +25,7 @@ import java.io.File; ...@@ -23,6 +25,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
...@@ -52,12 +55,7 @@ public class ImageCombined { ...@@ -52,12 +55,7 @@ public class ImageCombined {
new ThreadPoolExecutor.AbortPolicy() new ThreadPoolExecutor.AbortPolicy()
); );
private ImageCombined() { private static void refreshThreadPool(ConfigChangeEvent changeEvent) {
Config config = ConfigService.getAppConfig();
config.addChangeListener(this::refreshThreadPool);
}
private void refreshThreadPool(ConfigChangeEvent changeEvent) {
if (!StringUtils.equals(changeEvent.getNamespace(), APPLICATION)) { if (!StringUtils.equals(changeEvent.getNamespace(), APPLICATION)) {
return; return;
} }
...@@ -90,7 +88,10 @@ public class ImageCombined { ...@@ -90,7 +88,10 @@ public class ImageCombined {
static { static {
ImageIO.scanForPlugins(); // 初始化图像插件 ImageIO.scanForPlugins(); // 初始化图像插件
Config config = ConfigService.getAppConfig();
config.addChangeListener(ImageCombined::refreshThreadPool);
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL); BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL);
BufferedImage qrCodeImage = ImageIO.read(new URL(QR_CODE_URL)); BufferedImage qrCodeImage = ImageIO.read(new URL(QR_CODE_URL));
......
...@@ -5,6 +5,7 @@ import com.gic.commons.util.EntityUtil; ...@@ -5,6 +5,7 @@ import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.setting.ContentSettingDTO; import com.gic.content.api.dto.setting.ContentSettingDTO;
import com.gic.content.api.service.ContentSettingApiService; import com.gic.content.api.service.ContentSettingApiService;
import com.gic.haoban.manage.web.utils.ApolloUtils;
import com.gic.haoban.manage.web.vo.content.ContentSettingVO; import com.gic.haoban.manage.web.vo.content.ContentSettingVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -39,6 +40,7 @@ public class ContentSettingController { ...@@ -39,6 +40,7 @@ public class ContentSettingController {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
ContentSettingVO contentSettingVO = EntityUtil.changeEntityByJSON(ContentSettingVO.class, serviceResponse.getResult()); ContentSettingVO contentSettingVO = EntityUtil.changeEntityByJSON(ContentSettingVO.class, serviceResponse.getResult());
contentSettingVO.setCombinedType(ApolloUtils.combinedType(enterpriseId));
return RestResponse.successResult(contentSettingVO); return RestResponse.successResult(contentSettingVO);
} }
} }
package com.gic.haoban.manage.web.utils;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Constant;
import org.apache.commons.lang3.StringUtils;
public class ApolloUtils {
/**
* 内容分享企微素材使用老的前端合成还是新的后端合成 0老1新
* @return
*/
public static Integer combinedType(String eid) {
Config config = ConfigService.getAppConfig();
String combinedEid = config.getProperty("combinedEid", "");
if (StringUtils.isBlank(combinedEid)) {
return Constant.FLAG_TRUE;
}
return combinedEid.contains(eid) ? Constant.FLAG_TRUE : Constant.FLAG_FALSE;
}
}
...@@ -75,6 +75,11 @@ public class ContentSettingVO implements Serializable { ...@@ -75,6 +75,11 @@ public class ContentSettingVO implements Serializable {
*/ */
private Integer showStyle; private Integer showStyle;
/**
* 0老模式1新模式
*/
private Integer combinedType;
public Long getContentSettingId() { public Long getContentSettingId() {
return contentSettingId; return contentSettingId;
} }
...@@ -170,4 +175,12 @@ public class ContentSettingVO implements Serializable { ...@@ -170,4 +175,12 @@ public class ContentSettingVO implements Serializable {
public void setShowStyle(Integer showStyle) { public void setShowStyle(Integer showStyle) {
this.showStyle = showStyle; this.showStyle = showStyle;
} }
public Integer getCombinedType() {
return combinedType;
}
public void setCombinedType(Integer combinedType) {
this.combinedType = combinedType;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment