mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-05 21:27:47 +08:00
🎨 #1571 对微信模版消息行业信息不一致的变态问题尽可能的进行优化
This commit is contained in:
parent
bcefec0f4b
commit
4eb1d1d71a
@ -41,9 +41,9 @@ public enum WxMpTemplateIndustryEnum {
|
||||
*/
|
||||
BANK("金融业", "银行", 7),
|
||||
/**
|
||||
* 金融业 - 基金|理财|信托
|
||||
* 金融业 - 证券|基金|理财|信托(实际是这个)
|
||||
*/
|
||||
FUND("金融业", "基金|理财|信托", 8),
|
||||
FUND("金融业", "证券基金理财信托", 8),
|
||||
/**
|
||||
* 金融业 - 保险
|
||||
*/
|
||||
@ -93,9 +93,9 @@ public enum WxMpTemplateIndustryEnum {
|
||||
*/
|
||||
MUSEUM("政府与公共事业", "博物馆", 20),
|
||||
/**
|
||||
* 政府与公共事业 - 公共事业|非盈利机构
|
||||
* 政府与公共事业 - 公共事业非盈利机构
|
||||
*/
|
||||
PUBLIC_WORKS_NONPROFIT("政府与公共事业", "公共事业|非盈利机构", 21),
|
||||
PUBLIC_WORKS_NONPROFIT("政府与公共事业", "公共事业非盈利机构", 21),
|
||||
/**
|
||||
* 医药护理 - 医药医疗
|
||||
*/
|
||||
@ -125,7 +125,7 @@ public enum WxMpTemplateIndustryEnum {
|
||||
*/
|
||||
THE_PLANE_RELATED("交通工具", "飞机相关", 28),
|
||||
/**
|
||||
* 房地产 - 建筑
|
||||
* 房地产 - 房地产|建筑(实际上是这个)
|
||||
*/
|
||||
ARCHITECTURE("房地产", "建筑", 29),
|
||||
/**
|
||||
@ -153,9 +153,9 @@ public enum WxMpTemplateIndustryEnum {
|
||||
*/
|
||||
AUTHENTICATION("商业服务", "认证", 35),
|
||||
/**
|
||||
* 商业服务 - 会计|审计
|
||||
* 商业服务 - 审计
|
||||
*/
|
||||
AUDIT("商业服务", "会计|审计", 36),
|
||||
AUDIT("商业服务", "审计", 36),
|
||||
/**
|
||||
* 文体娱乐 - 传媒
|
||||
*/
|
||||
|
@ -29,6 +29,11 @@ public class WxMpIndustryGsonAdapter implements JsonSerializer<WxMpTemplateIndus
|
||||
|
||||
private WxMpTemplateIndustryEnum convertFromJson(JsonObject json) {
|
||||
String secondClass = GsonHelper.getString(json, "second_class");
|
||||
final WxMpTemplateIndustryEnum industryEnum = WxMpTemplateIndustryEnum.findBySecondary(secondClass);
|
||||
if (industryEnum != null) {
|
||||
return industryEnum;
|
||||
}
|
||||
|
||||
if (secondClass.contains("|")) {
|
||||
secondClass = secondClass.split("\\|")[1];
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ public class WxMpTemplateMsgServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void testSetIndustry() throws Exception {
|
||||
WxMpTemplateIndustry industry = new WxMpTemplateIndustry(WxMpTemplateIndustryEnum.findByCode(1),
|
||||
WxMpTemplateIndustryEnum.findByCode(4));
|
||||
WxMpTemplateIndustry industry = new WxMpTemplateIndustry(WxMpTemplateIndustryEnum.findByCode(29),
|
||||
WxMpTemplateIndustryEnum.findByCode(8));
|
||||
boolean result = this.wxService.getTemplateMsgService().setIndustry(industry);
|
||||
Assert.assertTrue(result);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package me.chanjar.weixin.mp.bean.template;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* 测试类.
|
||||
@ -13,11 +12,21 @@ import static org.testng.Assert.*;
|
||||
*/
|
||||
public class WxMpTemplateIndustryTest {
|
||||
|
||||
@Test
|
||||
public void testFromJson() {
|
||||
String json="{\"primary_industry\":{\"first_class\":\"IT科技\",\"second_class\":\"互联网|电子商务\"},\"secondary_industry\":{\"first_class\":\"房地产\",\"second_class\":\"房地产|建筑\"}}";
|
||||
final WxMpTemplateIndustry industry = WxMpTemplateIndustry.fromJson(json);
|
||||
assertThat(industry).isNotNull();
|
||||
System.out.println(industry);
|
||||
}
|
||||
@Test
|
||||
public void testFromJson() {
|
||||
String json = "{\"primary_industry\":{\"first_class\":\"IT科技\",\"second_class\":\"互联网|电子商务\"}," +
|
||||
"\"secondary_industry\":{\"first_class\":\"房地产\",\"second_class\":\"房地产|建筑\"}}";
|
||||
final WxMpTemplateIndustry industry = WxMpTemplateIndustry.fromJson(json);
|
||||
assertThat(industry).isNotNull();
|
||||
System.out.println(industry);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromJson_another_example() {
|
||||
String json = "{\"primary_industry\":{\"first_class\":\"金融业\",\"second_class\":\"基金理财信托\"}," +
|
||||
"\"secondary_industry\":{\"first_class\":\"房地产\",\"second_class\":\"建筑\"}}";
|
||||
final WxMpTemplateIndustry industry = WxMpTemplateIndustry.fromJson(json);
|
||||
assertThat(industry).isNotNull();
|
||||
System.out.println(industry);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user