From f0ee0b2bc38f81602103f2e1922de09e5b4fca0b Mon Sep 17 00:00:00 2001 From: twy <2301620162@qq.com> Date: Fri, 28 Jul 2023 17:22:58 +0800 Subject: [PATCH] =?UTF-8?q?live=E6=89=80=E6=9C=89=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=80=9A=E8=BF=87token=E9=AA=8C=E8=AF=81id=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8D=B3=E7=99=BB=E5=BD=95=E6=89=8D=E6=9C=89?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserLiveController.java | 84 +--------------- .../impl/WxCLiveUserBasicInfoServiceImpl.java | 5 +- .../impl/WxCUserAuthorityServiceImpl.java | 79 ++++++++------- .../service/impl/WxCVideoServiceImpl.java | 40 +------- .../service/impl/WxCVoiceServiceImpl.java | 98 +++++-------------- 5 files changed, 77 insertions(+), 229 deletions(-) diff --git a/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java b/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java index c5542df..06a076d 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java @@ -88,7 +88,6 @@ public class UserLiveController extends BaseController { Map wxCLiveLoginVos = new HashMap<>(); String ipAddr = getIpAddr(); logger.debug("[" + ipAddr + "] WxUserGrantController::login"); - String phone = map.get("username"); String password = map.get("password"); if (StringUtils.isBlank(phone) || StringUtils.isBlank(password)) { @@ -97,7 +96,6 @@ public class UserLiveController extends BaseController { status.put("message", "手机号或密码为空"); wxCLiveLoginVos.put("status", status); return wxCLiveLoginVos; - // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "手机号或密码为空"); } WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); if (basicInfo == null) { @@ -106,22 +104,16 @@ public class UserLiveController extends BaseController { status.put("message", "用户不存在"); wxCLiveLoginVos.put("status", status); return wxCLiveLoginVos; - // return new ResultData(ErrorCode.USER_IS_EMPTY); } - String encryptPassword = new PasswordHelper().encryptPassword(password); - if (!encryptPassword.equals(basicInfo.getPassword())) { HashMap status = new HashMap<>(); status.put("code", ErrorCode.USER_PASSWD_ERR.getCode()); status.put("message", "手机号或密码错误"); wxCLiveLoginVos.put("status", status); return wxCLiveLoginVos; - // return new ResultData(ErrorCode.USER_PASSWD_ERR.getCode(), "手机号或密码错误"); } - int statu = Integer.parseInt(map.get("status")); - if (statu == 0) { WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); if (basicLiveInfo.getCode() != null && !map.get("code").equals(basicLiveInfo.getCode())) { @@ -130,7 +122,6 @@ public class UserLiveController extends BaseController { status.put("message", "用户已在其他设备登录"); wxCLiveLoginVos.put("status", status); return wxCLiveLoginVos; - // return new ResultData(ErrorCode.USER_ALREADY_LOGIN.getCode(), "用户已在其他设备登录"); } if (basicLiveInfo.getCode() == null) { wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), map.get("code")); @@ -144,34 +135,22 @@ public class UserLiveController extends BaseController { status.put("message", "设备已注销"); wxCLiveLoginVos.put("status", status); return wxCLiveLoginVos; - // return new ResultData(ErrorCode.USER_CANCEL_MCODE.getCode(), "设备已注销"); } - - wxCUserBasicInfoService.handleLoginUser(basicInfo); WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); - - WxCLiveLoginVo wxCLiveLoginVo = new WxCLiveLoginVo(); wxCLiveLoginVo.setCode(Integer.parseInt(map.get("code"))); - //wxCLiveLoginVo.setVersion(basicLiveInfo.getVersion()); wxCLiveLoginVo.setUsername(map.get("username")); - //wxCLiveLoginVo.setStatus(0); - //wxCLiveLoginVo.setCurrent_time(new Date(System.currentTimeMillis() / 1000)); - // wxCLiveLoginVo.setExpire_time(basicLiveInfo.getExpireTime().getTime() / 1000); - Map info = new HashMap(); Map data = new HashMap(); Map status = new HashMap<>(); status.put("code", 1000); status.put("message", "success"); - data.put("token", basicInfo.getToken()); data.put("status", 0); data.put("version", basicLiveInfo.getVersion()); data.put("current_time", new Date(System.currentTimeMillis() / 1000)); data.put("expire_time", basicLiveInfo.getExpireTime().getTime() / 1000); - info.put("log_id", basicInfo.getId()); info.put("server_type", "user login"); info.put("username", basicInfo.getPhone()); @@ -180,12 +159,8 @@ public class UserLiveController extends BaseController { wxCLiveLoginVo.setData(data); wxCLiveLoginVo.setInfo(info); wxCLiveLoginVos.put("status", status); - System.out.println("wxCLiveLoginVo.getToken() = " + wxCLiveLoginVo.getToken()); - - return wxCLiveLoginVos; - // return new ResultData(1000,"success",wxCLiveLoginVo); } /** @@ -198,11 +173,7 @@ public class UserLiveController extends BaseController { Map avatarVos = new HashMap<>(); String ipaddress = getIpAddr(); logger.debug("[" + ipaddress + "] WxUserGrantController::getAvatarList"); - String phone = params.get("username"); - WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); - Long id = infoByPhone.getId(); - System.out.println("id = " + id); - + Long id = getMemberId(); //鉴权 WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { @@ -212,17 +183,11 @@ public class UserLiveController extends BaseController { avatarVos.put("status", status); return avatarVos; } - Map status = new HashMap<>(); status.put("code", 1000); status.put("msg", "success"); - // long id = getMemberId(); - // System.out.println("id = " + id); - // WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.getById(infoByPhone.getId()); avatarVos.put("status", status); - - return wxCVideoService.getById(infoByPhone.getId()); - // return new ResultData(1000,"success",wxCVideoService.getById(infoByPhone.getId())); + return wxCVideoService.getById(id); } @@ -236,13 +201,7 @@ public class UserLiveController extends BaseController { Map resultMap = new HashMap<>(); String ipaddress = getIpAddr(); logger.debug("[" + ipaddress + "] WxUserGrantController::getAudioList"); - String phone = params.get("username"); - - WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); - Long id = infoByPhone.getId(); - System.out.println("id = " + id); - - + Long id = getMemberId(); WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { HashMap status = new HashMap<>(); @@ -251,10 +210,6 @@ public class UserLiveController extends BaseController { resultMap.put("status", status); return resultMap; } - - // long id = getMemberId(); - - return wxCVoiceService.getById(id); } @@ -269,13 +224,7 @@ public class UserLiveController extends BaseController { Map resultMap = new HashMap<>(); String ipaddress = getIpAddr(); logger.debug("[" + ipaddress + "] WxUserGrantController::getAuthor"); - - - String phone = params.get("username"); - WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); - Long id = infoByPhone.getId(); - System.out.println("id = " + id); - + Long id = getMemberId(); WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { HashMap status = new HashMap<>(); @@ -284,42 +233,29 @@ public class UserLiveController extends BaseController { resultMap.put("status", status); return resultMap; } - - - //long id = getMemberId(); - - String username = params.get("username"); String code = params.get("code"); Integer type = Integer.parseInt(params.get("type")); Long resourceId = Long.valueOf(params.get("resource_id")); - - return wxCUserAuthorityService.getAuthor(id, code, type, resourceId); } - @ApiOperation(value = "tts", notes = "{\"username\",\"string\",\"gen_txt\",\"string\",\"voice_id\",\"string\",\"voice_style\",\"string\",\"speed\",\"int\"}") @PostMapping("/audiotts") public Map voicePreview(@RequestBody Map params) { logger.debug("[" + getIpAddr() + "] UserLiveController::voicePreview"); - - String phone = params.get("username"); - WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); - Long id = infoByPhone.getId(); + Long id = getMemberId(); AiPreviewParam param = new AiPreviewParam(); if (params.get("voice_id") == null) { Map status = new HashMap<>(); status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); status.put("msg", "音色ID不能为空"); return status; - // return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "音色ID不能为空"); } if (StringUtils.isBlank(params.get("gen_txt"))) { Map status = new HashMap<>(); status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); status.put("msg", "需要生成的文字不能为空"); return status; - //return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "需要生成的文字不能为空"); } if (Integer.parseInt(params.get("speed")) == -1) { param.setSpeed(0); @@ -333,7 +269,6 @@ public class UserLiveController extends BaseController { info.put("log_id", id); info.put("server_type", "audio tts"); resultMap.put("info", info); - return resultMap; } @@ -344,9 +279,7 @@ public class UserLiveController extends BaseController { @GetMapping("exportVideo") public void exportVideo(@RequestBody Map params, HttpServletRequest request, HttpServletResponse response) { logger.debug("[" + getIpAddr() + "] UserLiveController::exportVideo"); - response.reset(); - File tmpFile = null; OutputStream outputStream = null; WxCUserBasicInfo infoByPhone = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), params.get("username")); @@ -356,18 +289,13 @@ public class UserLiveController extends BaseController { } catch (IOException e) { throw new MallinkException(ErrorCode.SYS_SERVER_ERROR); } - try { if (id == null) { throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL); } WxCVideoTable videoTable = wxCVideoService.selectOne(id, Long.parseLong(params.get("resource_id"))); - - //获取响应的输出流 InputStream inputStream = new URL(videoTable.getDemo()).openStream(); - - response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(videoTable.getId() + ".mp4", "UTF-8")); //解决编码问题 @@ -379,8 +307,6 @@ public class UserLiveController extends BaseController { while ((flag = inputStream.read(cache)) != -1) { outputStream.write(cache, 0, flag); } -// } - } catch (MallinkException e) { ResultData resultData = new ResultData(e.getErrorCode(), e.getMessage()); //解决编码问题 diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCLiveUserBasicInfoServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCLiveUserBasicInfoServiceImpl.java index 5a5e596..61c6b68 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCLiveUserBasicInfoServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCLiveUserBasicInfoServiceImpl.java @@ -17,11 +17,10 @@ public class WxCLiveUserBasicInfoServiceImpl implements WxCLiveUserBasicInfoServ @Override public WxCUserBasicInfo getById(Long id) { return wxCLiveUserBasicInfoMapper.selectById(id); - } + @Override public void updateCode(Long id, String code) { - - wxCLiveUserBasicInfoMapper.updateCode(id,code); + wxCLiveUserBasicInfoMapper.updateCode(id, code); } } diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java index 50b9d7e..868a141 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCUserAuthorityServiceImpl.java @@ -18,68 +18,71 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { @Override - public Map getAuthor(Long id, String code, Integer type, Long resourceId) { - List resultList = new ArrayList(); + public Map getAuthor(Long id, String code, Integer type, Long resourceId) { + List resultList = new ArrayList(); HashMap authorVos = new HashMap<>(); - if (type==0){ + if (type == 0) { //查询数字人相关权限 - resultList = wxCUserAuthorityMapper.getAuthorAvatar(id,0,resourceId); + resultList = wxCUserAuthorityMapper.getAuthorAvatar(id, 0, resourceId); } - if (type==1){ + if (type == 1) { //查询声纹相关权限 - resultList = wxCUserAuthorityMapper.getAuthorVoice(id,1,resourceId); - + resultList = wxCUserAuthorityMapper.getAuthorVoice(id, 1, resourceId); } - if (resourceId==null||resourceId==-1){ + if (resourceId == null || resourceId == -1) { //若资源id没有传入那就展示所有当前类型资源权限 - HashMap info = new HashMap<>(); HashMap status = new HashMap<>(); List authorList = new ArrayList(); for (WxCUserAuthority wxCUserAuthority : resultList) { HashMap data = new HashMap<>(); - data.put("username",wxCUserAuthority.getUserName()); - data.put("type",wxCUserAuthority.getType()); - data.put("resource_id",wxCUserAuthority.getResourceId()); - data.put("class",wxCUserAuthority.getClassType()); - data.put("current_time",new Date(System.currentTimeMillis()/1000)); - data.put("expire_time",wxCUserAuthority.getExpireTime().getTime()/1000); + data.put("username", wxCUserAuthority.getUserName()); + data.put("type", wxCUserAuthority.getType()); + data.put("resource_id", wxCUserAuthority.getResourceId()); + data.put("class", wxCUserAuthority.getClassType()); + data.put("current_time", new Date(System.currentTimeMillis() / 1000)); + data.put("expire_time", wxCUserAuthority.getExpireTime().getTime() / 1000); authorList.add(data); } - authorVos.put("authorList",authorList); - info.put("log_id",id); - info.put("server_type","author"); - authorVos.put("info",info); - status.put("code",1000); - status.put("msg","success"); - authorVos.put("status",status); + authorVos.put("authorList", authorList); + info.put("log_id", id); + info.put("server_type", "author"); + authorVos.put("info", info); + status.put("code", 1000); + status.put("msg", "success"); + authorVos.put("status", status); return authorVos; } HashMap data = new HashMap<>(); HashMap info = new HashMap<>(); HashMap status = new HashMap<>(); + if (resultList.size() == 0) { + status.put("code", 5001); + status.put("msg", "没有该资源的权限"); + authorVos.put("status", status); + return authorVos; + } for (WxCUserAuthority wxCUserAuthority : resultList) { - data.put("username",wxCUserAuthority.getUserName()); - data.put("type",wxCUserAuthority.getType()); - data.put("resource_id",wxCUserAuthority.getResourceId()); - if (String.valueOf(wxCUserAuthority.getClassType())!=null){ - data.put("class",wxCUserAuthority.getClassType()); + data.put("username", wxCUserAuthority.getUserName()); + data.put("type", wxCUserAuthority.getType()); + data.put("resource_id", wxCUserAuthority.getResourceId()); + + if (String.valueOf(wxCUserAuthority.getClassType()) != null) { + data.put("class", wxCUserAuthority.getClassType()); } data.put("class", EnumClassType.SHARE.getCode()); - data.put("current_time",new Date(System.currentTimeMillis()/1000)); - data.put("expire_time",wxCUserAuthority.getExpireTime().getTime()/1000); - + data.put("current_time", new Date(System.currentTimeMillis() / 1000)); + data.put("expire_time", wxCUserAuthority.getExpireTime().getTime() / 1000); } - authorVos.put("data",data); - info.put("log_id",id); - info.put("server_type","author"); - authorVos.put("info",info); - status.put("code",1000); - status.put("msg","success"); - authorVos.put("status",status); - + authorVos.put("data", data); + info.put("log_id", id); + info.put("server_type", "author"); + authorVos.put("info", info); + status.put("code", 1000); + status.put("msg", "success"); + authorVos.put("status", status); return authorVos; } } diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java index 7514180..f443645 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java @@ -39,16 +39,12 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer WxCVideoMapper wxCVideoMapper; @Override - public Map getById(Long id) throws Exception { + public Map getById(Long id) { System.out.println("id = " + id); - List TemplateVideo = wxCVideoMapper.getById(id); System.out.println("TemplateVideo = " + TemplateVideo); Map avatarVos = new HashMap(); Map data = new HashMap(); - - - //Map authorlist = new HashMap(); List authorlist = new ArrayList(); for (WxCVideoTable wxCVideoTable : TemplateVideo) { data.put("username", wxCVideoTable.getUserName()); @@ -77,14 +73,12 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer e.printStackTrace(); avatar.put("avatar_preinfo_md5", wxCVideoTable.getPreInfoMd5()); } - avatar.put("avatar_preinfo", wxCVideoTable.getPreInfo()); avatar.put("expire_time", wxCVideoTable.getExpireTime().getTime() / 1000); avatar.put("class", wxCVideoTable.getClassType()); authorlist.add(avatar); data.put("authorlist", authorlist); } - avatarVos.put("data", data); Map info = new HashMap(); Map status = new HashMap(); @@ -115,41 +109,13 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer if (null == list || list.size() <= 0) { return null; } - -// List userIds = list.stream().map(cc -> cc.getId()).collect(Collectors.toList()); -// if (null != userIds && userIds.size() > 0 ) { -// WxCreditHistory chaddq = new WxCreditHistory(); -// chaddq.setUserIdList(userIds); -// chaddq.setTenantId(tenantInfo.getFinalTenantId()); -// chaddq.setStartTime(basicInfo.getCreditStartTime()); -// chaddq.setEndTime(basicInfo.getCreditEndTime()); -// List chadds = creditHistoryMapper.findAddList(chaddq); -// Map chaddMap = new HashMap<>(); -// if(null != chadds){ -// chaddMap = chadds.stream().collect(Collectors.toMap(WxCreditHistory::getCUserId, WxCreditHistory::getCreditNum)); -// } -// -// WxCreditHistory chlesq = new WxCreditHistory(); -// chlesq.setUserIdList(userIds); -// chlesq.setTenantId(tenantInfo.getFinalTenantId()); -// chlesq.setStartTime(basicInfo.getCreditStartTime()); -// chlesq.setEndTime(basicInfo.getCreditEndTime()); -// List chless = creditHistoryMapper.findLesList(chlesq); -// Map chlesMap = new HashMap<>(); -// if(null != chless){ -// chlesMap = chless.stream().collect(Collectors.toMap(WxCreditHistory::getCUserId, WxCreditHistory::getCreditNum)); -// } - //处理会员标签 List tagIds = list.stream().map(cc -> cc.getTagId()).collect(Collectors.toList()); Map tagIdName = wxCUserTagsService.findIdTagNames(basicInfo.getFinalTenantId(), tagIds); list.stream().forEach(u -> { -// u.setAddCredit(finalChaddMap.get(u.getId())); -// u.setLesCredit(finalChlesMap.get(u.getId())); + u.setTagNames(tagIdName.get(u.getTagId())); }); -// -// } if (null != list && list.size() > 0) { List retList = new ArrayList(); retList.addAll(list); @@ -171,7 +137,5 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer byte[] digest = md.digest(); String md5 = String.format("%032x", new BigInteger(1, digest)); return md5; - } - } 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 727516c..2d744a8 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCVoiceServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCVoiceServiceImpl.java @@ -39,121 +39,78 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { @Override - public Map getById(Long id) { - + public Map getById(Long id) { List resultList = wxCVoiceMapper.getById(id); HashMap result = new HashMap<>(); HashMap data = new HashMap<>(); List audioList = new ArrayList(); - for (WxCVoiceTable wxCVoiceTable : resultList) { HashMap audio = new HashMap<>(); HashMap voice = new HashMap<>(); - data.put("username", wxCVoiceTable.getUserName()); - data.put("current_time", new Date(System.currentTimeMillis()/1000)); + 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()); - voice.put("expire_time", wxCVoiceTable.getExpireTime().getTime()/1000); + voice.put("expire_time", wxCVoiceTable.getExpireTime().getTime() / 1000); voice.put("voicename", wxCVoiceTable.getVoiceName()); voice.put("voicetype", EnumClassType.SHARE.getCode()); voice.put("displayname", wxCVoiceTable.getVoiceDisplayName()); voice.put("gender", wxCVoiceTable.getGender()); List styleList = new ArrayList(); - List strings = JSON.parseArray(wxCVoiceTable.getStyleList(), String.class); for (String y : strings) { - // List list = new ArrayList<>(); HashMap style = new HashMap<>(); style.put("stylename", y); style.put("displayname", EnumSpeakType.getEnum(y).getMessage()); style.put("styledemo", url + wxCVoiceTable.getMouldSmId() + "_" + y + end); - //list.add(style); styleList.add(style); } - - - -// for (String s : Arrays.asList(wxCVoiceTable.getStyleList())) { -//// VoiceInfoVo infoVo = new VoiceInfoVo(); -//// infoVo.setName(EnumSpeakType.getEnum(s).getMessage()); -//// infoVo.setEngName(s); -//// infoVo.setUrl(url + wxCVoiceTable.getMouldSmId() + "_" + s + end); -// style.put("stylename", s); -// style.put("displayname", EnumSpeakType.getEnum(s).getMessage()); -// style.put("styledemo", url + wxCVoiceTable.getMouldSmId() + "_" + s + end); -// styleList.add(style); -// } - // styleList.add(style); voice.put("styleList", styleList); - - -// style.put("stylename", wxCVoiceTable.getStyleName()); -// style.put("displayname", wxCVoiceTable.getStyleDisplayName()); -// style.put("styledemo", wxCVoiceTable.getStyleDemo()); - - } - - data.put("audioList", audioList); - result.put("data",data); + result.put("data", data); HashMap info = new HashMap<>(); HashMap status = new HashMap<>(); - info.put("log_id",id); - info.put("server_type","audio list"); - result.put("info",info); - status.put("code",1000); - status.put("msg","success"); - result.put("status",status); + info.put("log_id", id); + info.put("server_type", "audio list"); + result.put("info", info); + status.put("code", 1000); + status.put("msg", "success"); + result.put("status", status); return result; } - @Override - public Map voicePreview(AiPreviewParam aiPreviewParam) { + public Map voicePreview(AiPreviewParam aiPreviewParam) { VoiceInfo voiceInfo = voiceMapper.selectOne(new LambdaQueryWrapper().eq(VoiceInfo::getIsDel, 0).eq(VoiceInfo::getId, aiPreviewParam.getVoice_id())); - if (ObjectUtils.isEmpty(voiceInfo)){ - Map status = new HashMap<>(); - status.put("code",ErrorCode.SYS_SERVER_ERROR.getCode()); - status.put("msg","声音信息不存在"); + if (ObjectUtils.isEmpty(voiceInfo)) { + Map status = new HashMap<>(); + status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); + status.put("msg", "声音信息不存在"); return status; - // return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "声音信息不存在"); } AiPreviewParam param = new AiPreviewParam(); - param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(str,"[*]")); + param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(str, "[*]")); param.setVoice_id(voiceInfo.getMouldSmId()); param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? EnumSpeakType.default_0.getMessage() : aiPreviewParam.getVoice_style()); param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); AiPreviewResult result = AiVideoHelper.voicePreview(param); -// if (result.isSuccess()){ -// Map status = new HashMap<>(); -// status.put("data",new ResultData(result.getTime())); -// -// return status; -// //return new ResultData(result.getTime()); -// } - Map resultMap = new HashMap<>(); - Map data = new HashMap<>(); - data.put("ttsurl",result.getUrl()); - - Map status = new HashMap<>(); - status.put("code",1000); - status.put("msg","success"); - resultMap.put("data",data); - resultMap.put("status",status); + Map resultMap = new HashMap<>(); + Map data = new HashMap<>(); + data.put("ttsurl", result.getUrl()); + Map status = new HashMap<>(); + status.put("code", 1000); + status.put("msg", "success"); + resultMap.put("data", data); + resultMap.put("status", status); return resultMap; - //return new ResultData(result.getCode(), result.getMsgInfo(result.getCode(),result.getMsg())); } -//test + @Override public List chooseType(Long id) { List voiceInfos = voiceMapper.selectList( @@ -162,14 +119,13 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { if (StringUtils.isNotEmpty(x.getStyleList())) { List strings = JSON.parseArray(x.getStyleList(), String.class); List list = new ArrayList<>(); - strings.forEach(y->{ + strings.forEach(y -> { VoiceInfoVo infoVo = new VoiceInfoVo(); infoVo.setName(EnumSpeakType.getEnum(y).getMessage()); infoVo.setEngName(y); infoVo.setUrl(url + x.getMouldSmId() + "_" + y + end); list.add(infoVo); }); - VoiceInfoVo infoVo = new VoiceInfoVo(); infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); @@ -187,5 +143,5 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { } }); return voiceInfos; -} + } }