diff --git a/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java b/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java index 9468be2..c1abfaf 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java @@ -210,7 +210,7 @@ public class UserLiveController extends BaseController { resultMap.put("status", status); return resultMap; } - return wxCVoiceService.getById(id); + return wxCVoiceService.getById(id,basicLiveInfo.getPhone()); } /** diff --git a/suimangService/src/main/java/com/iformall/domain/po/WxCVoiceTable.java b/suimangService/src/main/java/com/iformall/domain/po/WxCVoiceTable.java index e926600..22d1a4e 100644 --- a/suimangService/src/main/java/com/iformall/domain/po/WxCVoiceTable.java +++ b/suimangService/src/main/java/com/iformall/domain/po/WxCVoiceTable.java @@ -28,7 +28,9 @@ public class WxCVoiceTable { private String localDisPlayName; @io.swagger.annotations.ApiModelProperty(value = "声纹ID", name = "id") - private int voiceId; + private Long voiceId; + @io.swagger.annotations.ApiModelProperty(value = "声纹ID", name = "languageId") + private Long languageId; @io.swagger.annotations.ApiModelProperty(value = "声纹名称(用于调微软接口)", name = "local_name") private String voiceName; @io.swagger.annotations.ApiModelProperty(value = "声纹展示名称", name = "display_name") @@ -39,7 +41,7 @@ public class WxCVoiceTable { private int voiceType; @io.swagger.annotations.ApiModelProperty(value = "声纹列表", name = "mould_sm_id") - private String MouldSmId; + private String mouldSmId; @io.swagger.annotations.ApiModelProperty(value = "声纹列表", name = "style_list") private String styleList ; diff --git a/suimangService/src/main/java/com/iformall/service/WxCVoiceService.java b/suimangService/src/main/java/com/iformall/service/WxCVoiceService.java index 042e303..f1b86ed 100644 --- a/suimangService/src/main/java/com/iformall/service/WxCVoiceService.java +++ b/suimangService/src/main/java/com/iformall/service/WxCVoiceService.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Map; public interface WxCVoiceService { - Map getById(Long id); + Map getById(Long id,String phone); List chooseType(Long id); diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCVoiceServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCVoiceServiceImpl.java index ecd7609..6696397 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCVoiceServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCVoiceServiceImpl.java @@ -43,20 +43,27 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { @Override - public Map getById(Long id) { + public Map getById(Long id,String phone) { List resultList = wxCVoiceMapper.getById(id); HashMap result = new HashMap<>(); HashMap data = new HashMap<>(); - List audioList = new ArrayList(); + data.put("username", phone); + data.put("current_time", new Date(System.currentTimeMillis() / 1000)); +// List audioList = new ArrayList(); + Map> audioList = new HashMap(); for (WxCVoiceTable wxCVoiceTable : resultList) { - HashMap audio = new HashMap<>(); + Map audio = audioList.get(wxCVoiceTable.getLanguageId()); + if(audio == null){ + audio = new HashMap<>(); + audio.put("LocaleName", wxCVoiceTable.getLocalelName()); + audio.put("displayname", wxCVoiceTable.getLocalDisPlayName()); + } + List> voiceList = (List>) audio.get("styleList"); + if(voiceList == null){ + voiceList = new ArrayList<>(); + } + HashMap voice = new HashMap<>(); - data.put("username", wxCVoiceTable.getUserName()); - data.put("current_time", new Date(System.currentTimeMillis() / 1000)); - audioList.add(audio); - audio.put("LocaleName", wxCVoiceTable.getLocalelName()); - audio.put("displayname", wxCVoiceTable.getLocalDisPlayName()); - List voiceList = new ArrayList(); voiceList.add(voice); audio.put("voiceList", voiceList); voice.put("voiceid", wxCVoiceTable.getVoiceId()); @@ -67,17 +74,34 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { voice.put("gender", wxCVoiceTable.getGender()); List styleList = new ArrayList(); - List strings = JSON.parseArray(wxCVoiceTable.getStyleList(), String.class); - for (String y : strings) { + if(StringUtils.isBlank(wxCVoiceTable.getStyleList())){ + HashMap style = new HashMap<>(); + style.put("stylename", "default"); + style.put("displayname", EnumSpeakType.getEnum("default").getMessage()); + style.put("styledemo", aliyunOSSConfig.getFiledomain() + demoDirectory + wxCVoiceTable.getMouldSmId() + "_" + "default" + demoSuffix); + styleList.add(style); + voice.put("styleList", styleList); + }else{ HashMap style = new HashMap<>(); - style.put("stylename", y); - style.put("displayname", EnumSpeakType.getEnum(y).getMessage()); - style.put("styledemo", aliyunOSSConfig.getFiledomain() + demoDirectory + wxCVoiceTable.getMouldSmId() + "_" + y + demoSuffix); + style.put("stylename", "default"); + style.put("displayname", EnumSpeakType.getEnum("default").getMessage()); + style.put("styledemo", aliyunOSSConfig.getFiledomain() + demoDirectory + wxCVoiceTable.getMouldSmId() + "_" + "default" + demoSuffix); styleList.add(style); + + List strings = JSON.parseArray(wxCVoiceTable.getStyleList(), String.class); + for (String y : strings) { + style = new HashMap<>(); + style.put("stylename", y); + style.put("displayname", EnumSpeakType.getEnum(y).getMessage()); + style.put("styledemo", aliyunOSSConfig.getFiledomain() + demoDirectory + wxCVoiceTable.getMouldSmId() + "_" + y + demoSuffix); + styleList.add(style); + } + voice.put("styleList", styleList); } - voice.put("styleList", styleList); } - data.put("audioList", audioList); + + data.put("audioList", new ArrayList<>(audioList.values())); + result.put("data", data); HashMap info = new HashMap<>(); HashMap status = new HashMap<>(); diff --git a/suimangService/src/main/resources/mapper/WxCVoiceMapper.xml b/suimangService/src/main/resources/mapper/WxCVoiceMapper.xml index 89e9e6e..872f45d 100644 --- a/suimangService/src/main/resources/mapper/WxCVoiceMapper.xml +++ b/suimangService/src/main/resources/mapper/WxCVoiceMapper.xml @@ -8,6 +8,7 @@ + @@ -15,7 +16,7 @@ - + @@ -33,7 +34,7 @@