@@ -204,6 +204,7 @@ logging: | |||||
suimang: | suimang: | ||||
oral_broadcasting: xxx | oral_broadcasting: xxx | ||||
video_tts: | |||||
photo_speak: xxx | photo_speak: xxx | ||||
photo_speak_hy: xxx | photo_speak_hy: xxx | ||||
digital_avatar: xxx | digital_avatar: xxx | ||||
@@ -160,6 +160,7 @@ logging: | |||||
suimang: | suimang: | ||||
oral_broadcasting: xxx | oral_broadcasting: xxx | ||||
video_tts: | |||||
photo_speak: xxx | photo_speak: xxx | ||||
photo_speak_hy: xxx | photo_speak_hy: xxx | ||||
digital_avatar: xxx | digital_avatar: xxx | ||||
@@ -85,43 +85,44 @@ public class UserLiveController extends BaseController { | |||||
@PostMapping("/login") | @PostMapping("/login") | ||||
@ApiOperation(value = "用户登录", notes = "{\"username\":\"string\",\"password\":\"string\",\"code\":\"string\",\"status\":\"int\"}") | @ApiOperation(value = "用户登录", notes = "{\"username\":\"string\",\"password\":\"string\",\"code\":\"string\",\"status\":\"int\"}") | ||||
public Map<String, Object> login(@RequestBody Map<String, String> map, HttpServletResponse response) { | public Map<String, Object> login(@RequestBody Map<String, String> map, HttpServletResponse response) { | ||||
Map<String, Object> wxCLiveLoginVos = new HashMap<>(); | |||||
String ipAddr = getIpAddr(); | String ipAddr = getIpAddr(); | ||||
logger.debug("[" + ipAddr + "] WxUserGrantController::login"); | logger.debug("[" + ipAddr + "] WxUserGrantController::login"); | ||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
HashMap<String, Object> status = new HashMap<>(); | |||||
String code = map.get("code"); | |||||
String phone = map.get("username"); | String phone = map.get("username"); | ||||
String password = map.get("password"); | String password = map.get("password"); | ||||
if (StringUtils.isBlank(phone) || StringUtils.isBlank(password)) { | if (StringUtils.isBlank(phone) || StringUtils.isBlank(password)) { | ||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.SYS_PARAMETER_ERROR.getCode()); | status.put("code", ErrorCode.SYS_PARAMETER_ERROR.getCode()); | ||||
status.put("message", "手机号或密码为空"); | status.put("message", "手机号或密码为空"); | ||||
wxCLiveLoginVos.put("status", status); | |||||
return wxCLiveLoginVos; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); | WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); | ||||
if (basicInfo == null) { | if (basicInfo == null) { | ||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.USER_IS_EMPTY); | status.put("code", ErrorCode.USER_IS_EMPTY); | ||||
status.put("message", "用户不存在"); | status.put("message", "用户不存在"); | ||||
wxCLiveLoginVos.put("status", status); | |||||
return wxCLiveLoginVos; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
String encryptPassword = new PasswordHelper().encryptPassword(password); | String encryptPassword = new PasswordHelper().encryptPassword(password); | ||||
if (!encryptPassword.equals(basicInfo.getPassword())) { | if (!encryptPassword.equals(basicInfo.getPassword())) { | ||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.USER_PASSWD_ERR.getCode()); | status.put("code", ErrorCode.USER_PASSWD_ERR.getCode()); | ||||
status.put("message", "手机号或密码错误"); | status.put("message", "手机号或密码错误"); | ||||
wxCLiveLoginVos.put("status", status); | |||||
return wxCLiveLoginVos; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
int statu = Integer.parseInt(map.get("status")); | int statu = Integer.parseInt(map.get("status")); | ||||
if (statu == 0) { | if (statu == 0) { | ||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); | WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); | ||||
if (basicLiveInfo.getCode() != null && !map.get("code").equals(basicLiveInfo.getCode())) { | |||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||||
status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | ||||
status.put("message", "用户已在其他设备登录"); | status.put("message", "用户已在其他设备登录"); | ||||
wxCLiveLoginVos.put("status", status); | |||||
return wxCLiveLoginVos; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
if (basicLiveInfo.getCode() == null) { | if (basicLiveInfo.getCode() == null) { | ||||
wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), map.get("code")); | wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), map.get("code")); | ||||
@@ -130,37 +131,28 @@ public class UserLiveController extends BaseController { | |||||
if (statu == -1) { | if (statu == -1) { | ||||
wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), null); | wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), null); | ||||
basicInfo.setStatus(-2); | basicInfo.setStatus(-2); | ||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.USER_CANCEL_MCODE.getCode()); | status.put("code", ErrorCode.USER_CANCEL_MCODE.getCode()); | ||||
status.put("message", "设备已注销"); | status.put("message", "设备已注销"); | ||||
wxCLiveLoginVos.put("status", status); | |||||
return wxCLiveLoginVos; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
wxCUserBasicInfoService.handleLoginUser(basicInfo); | wxCUserBasicInfoService.handleLoginUser(basicInfo); | ||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); | WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); | ||||
WxCLiveLoginVo wxCLiveLoginVo = new WxCLiveLoginVo(); | |||||
wxCLiveLoginVo.setCode(map.get("code")); | |||||
wxCLiveLoginVo.setUsername(map.get("username")); | |||||
Map<String, Object> info = new HashMap(); | |||||
Map<String, Object> data = new HashMap(); | Map<String, Object> data = new HashMap(); | ||||
Map<Object, Object> status = new HashMap<>(); | |||||
status.put("code", 1000); | |||||
status.put("message", "success"); | |||||
data.put("token", basicInfo.getToken()); | |||||
data.put("username",basicInfo.getPhone()); | |||||
data.put("status", 0); | data.put("status", 0); | ||||
data.put("version", basicLiveInfo.getVersion()); | data.put("version", basicLiveInfo.getVersion()); | ||||
data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | ||||
data.put("expire_time", basicLiveInfo.getExpireTime().getTime() / 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()); | |||||
wxCLiveLoginVos.put("data", data); | |||||
wxCLiveLoginVos.put("info", info); | |||||
wxCLiveLoginVo.setData(data); | |||||
wxCLiveLoginVo.setInfo(info); | |||||
wxCLiveLoginVos.put("status", status); | |||||
System.out.println("wxCLiveLoginVo.getToken() = " + wxCLiveLoginVo.getToken()); | |||||
return wxCLiveLoginVos; | |||||
data.put("token", basicInfo.getToken()); | |||||
resultMap.put("data", data); | |||||
status.put("code", 1000); | |||||
status.put("message", "success"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
/** | /** | ||||
@@ -170,24 +162,30 @@ public class UserLiveController extends BaseController { | |||||
@PostMapping("/avatarList") | @PostMapping("/avatarList") | ||||
@ApiOperation(value = "视频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") | @ApiOperation(value = "视频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") | ||||
public Map<String, Object> avatarList(@RequestBody Map<String, String> params) throws Exception { | public Map<String, Object> avatarList(@RequestBody Map<String, String> params) throws Exception { | ||||
Map<String, Object> avatarVos = new HashMap<>(); | |||||
String ipaddress = getIpAddr(); | String ipaddress = getIpAddr(); | ||||
logger.debug("[" + ipaddress + "] WxUserGrantController::getAvatarList"); | logger.debug("[" + ipaddress + "] WxUserGrantController::getAvatarList"); | ||||
Long id = getMemberId(); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
HashMap<String, Object> status = new HashMap<>(); | |||||
String code = params.get("code"); | |||||
Long userId = getMemberId(); | |||||
//鉴权 | //鉴权 | ||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); | |||||
if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { | |||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(userId); | |||||
if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||||
status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | ||||
status.put("message", "用户已在其他设备登录"); | status.put("message", "用户已在其他设备登录"); | ||||
avatarVos.put("status", status); | |||||
return avatarVos; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
Map<Object, Object> status = new HashMap<>(); | |||||
Map<String, Object> data = wxCVideoService.getById(userId); | |||||
resultMap.put("data", data); | |||||
status.put("code", 1000); | status.put("code", 1000); | ||||
status.put("msg", "success"); | status.put("msg", "success"); | ||||
avatarVos.put("status", status); | |||||
return wxCVideoService.getById(id); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
@@ -198,77 +196,134 @@ public class UserLiveController extends BaseController { | |||||
@PostMapping("/audioList") | @PostMapping("/audioList") | ||||
@ApiOperation(value = "音频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") | @ApiOperation(value = "音频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") | ||||
public Map<String, Object> audioList(@RequestBody Map<String, String> params) { | public Map<String, Object> audioList(@RequestBody Map<String, String> params) { | ||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
String ipaddress = getIpAddr(); | String ipaddress = getIpAddr(); | ||||
logger.debug("[" + ipaddress + "] WxUserGrantController::getAudioList"); | logger.debug("[" + ipaddress + "] WxUserGrantController::getAudioList"); | ||||
Long id = getMemberId(); | |||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); | |||||
if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { | |||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
HashMap<String, Object> status = new HashMap<>(); | |||||
String code = params.get("code"); | |||||
Long userId = getMemberId(); | |||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(userId); | |||||
if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||||
status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | ||||
status.put("message", "用户已在其他设备登录"); | status.put("message", "用户已在其他设备登录"); | ||||
resultMap.put("status", status); | resultMap.put("status", status); | ||||
return resultMap; | return resultMap; | ||||
} | } | ||||
return wxCVoiceService.getById(id,null); | |||||
Map<String, Object> data = wxCVoiceService.getById(userId); | |||||
resultMap.put("data", data); | |||||
status.put("code", 1000); | |||||
status.put("msg", "success"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
/** | /** | ||||
* 资源权限查询 | * 资源权限查询 | ||||
*/ | */ | ||||
@ApiOperation(value = "资源权限查询", notes = "{\"username\",\"string\",\"code\",\"string\",\"type\",\"int\",\"resource_id\",\"long\"}") | @ApiOperation(value = "资源权限查询", notes = "{\"username\",\"string\",\"code\",\"string\",\"type\",\"int\",\"resource_id\",\"long\"}") | ||||
@PostMapping("/author") | @PostMapping("/author") | ||||
public Map<String, Object> getAuthor(@RequestBody Map<String, String> params) { | public Map<String, Object> getAuthor(@RequestBody Map<String, String> params) { | ||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
String ipaddress = getIpAddr(); | String ipaddress = getIpAddr(); | ||||
logger.debug("[" + ipaddress + "] WxUserGrantController::getAuthor"); | logger.debug("[" + ipaddress + "] WxUserGrantController::getAuthor"); | ||||
Long id = getMemberId(); | |||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); | |||||
if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { | |||||
HashMap<Object, Object> status = new HashMap<>(); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
HashMap<String, Object> status = new HashMap<>(); | |||||
String code = params.get("code"); | |||||
Integer type = Integer.parseInt(params.get("type")); | |||||
Long resourceId = Long.valueOf(params.get("resource_id")); | |||||
if(type == null){ | |||||
status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
status.put("message", "type 为空"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | |||||
if(resourceId == null){ | |||||
status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
status.put("message", "资源ID 为空"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | |||||
Long userId = getMemberId(); | |||||
WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(userId); | |||||
if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||||
status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | ||||
status.put("message", "用户已在其他设备登录"); | status.put("message", "用户已在其他设备登录"); | ||||
resultMap.put("status", status); | resultMap.put("status", status); | ||||
return resultMap; | return resultMap; | ||||
} | } | ||||
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); | |||||
Map<String, Object> data = wxCUserAuthorityService.getAuthor(userId, code, type, resourceId); | |||||
if(data != null){ | |||||
resultMap.put("data", data); | |||||
status.put("code", 1000); | |||||
status.put("msg", "success"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | |||||
status.put("code", ErrorCode.SYS_NULLPOINTER_ERROR.getCode()); | |||||
status.put("msg", "未查询到资源权限"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
@ApiOperation(value = "tts", notes = "{\"username\",\"string\",\"gen_txt\",\"string\",\"voice_id\",\"string\",\"voice_style\",\"string\",\"speed\",\"int\"}") | @ApiOperation(value = "tts", notes = "{\"username\",\"string\",\"gen_txt\",\"string\",\"voice_id\",\"string\",\"voice_style\",\"string\",\"speed\",\"int\"}") | ||||
@PostMapping("/audiotts") | @PostMapping("/audiotts") | ||||
public Map<String, Object> voicePreview(@RequestBody Map<String, String> params) { | public Map<String, Object> voicePreview(@RequestBody Map<String, String> params) { | ||||
logger.debug("[" + getIpAddr() + "] UserLiveController::voicePreview"); | logger.debug("[" + getIpAddr() + "] UserLiveController::voicePreview"); | ||||
Long id = getMemberId(); | |||||
AiPreviewParam param = new AiPreviewParam(); | |||||
if (params.get("voice_id") == null) { | |||||
Map<String, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
HashMap<String, Object> status = new HashMap<>(); | |||||
String voice_id = params.get("voice_id"); | |||||
String voiceStyle = params.get("voice_style"); | |||||
if (StringUtils.isBlank(voice_id)) { | |||||
status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
status.put("msg", "音色ID不能为空"); | status.put("msg", "音色ID不能为空"); | ||||
return status; | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
if (StringUtils.isBlank(params.get("gen_txt"))) { | |||||
Map<String, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); | |||||
status.put("msg", "需要生成的文字不能为空"); | |||||
return status; | |||||
Long voiceId = null; | |||||
try{ | |||||
voiceId = Long.parseLong(voice_id); | |||||
}catch(Exception e){ | |||||
status.put("code", ErrorCode.SYS_PARAMETER_ERROR.getCode()); | |||||
status.put("msg", "音色ID参数异常"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | |||||
String text = params.get("gen_txt"); | |||||
if (StringUtils.isBlank(text)) { | |||||
resultMap.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
resultMap.put("msg", "需要生成的文字不能为空"); | |||||
return resultMap; | |||||
} | } | ||||
if (Integer.parseInt(params.get("speed")) == -1) { | |||||
param.setSpeed(0); | |||||
String speedStr = params.get("speed"); | |||||
Integer speed = null; | |||||
try{ | |||||
speed = Integer.parseInt(speedStr); | |||||
}catch(Exception e){} | |||||
Map<String, Object> data = wxCVoiceService.voicePreview(voiceId,voiceStyle,text,speed); | |||||
if(data != null){ | |||||
resultMap.put("data", data); | |||||
status.put("code", 1000); | |||||
status.put("msg", "success"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
} | } | ||||
param.setSpeed(Integer.parseInt(params.get("speed"))); | |||||
param.setVoice_id(params.get("voice_id")); | |||||
param.setVoice_style(params.get("voice_style")); | |||||
param.setGen_txt(params.get("gen_txt")); | |||||
Map<String, Object> resultMap = wxCVoiceService.voicePreview(param); | |||||
Map<String, Object> info = new HashMap<>(); | |||||
info.put("log_id", id); | |||||
info.put("server_type", "audio tts"); | |||||
resultMap.put("info", info); | |||||
status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||||
status.put("msg", "获取tts 异常"); | |||||
resultMap.put("status", status); | |||||
return resultMap; | return resultMap; | ||||
} | } | ||||
@@ -330,7 +385,6 @@ public class UserLiveController extends BaseController { | |||||
public ResultData chooseType(Long id) { | public ResultData chooseType(Long id) { | ||||
logger.debug("[" + getIpAddr() + "] MouldPatchController::chooseType"); | logger.debug("[" + getIpAddr() + "] MouldPatchController::chooseType"); | ||||
List<VoiceInfo> voiceInfos = wxCVoiceService.chooseType(id); | List<VoiceInfo> voiceInfos = wxCVoiceService.chooseType(id); | ||||
System.out.println("voiceInfos = " + voiceInfos); | |||||
return new ResultData(wxCVoiceService.chooseType(id)); | |||||
return new ResultData(voiceInfos); | |||||
} | } | ||||
} | } |
@@ -190,6 +190,7 @@ logging: | |||||
suimang: | suimang: | ||||
oral_broadcasting: http://111.198.0.15:22266 | oral_broadcasting: http://111.198.0.15:22266 | ||||
video_tts: http://111.198.0.15:22222 | |||||
photo_speak: http://111.198.0.15:22299 | photo_speak: http://111.198.0.15:22299 | ||||
photo_speak_hy: http://111.198.0.15:22288 | photo_speak_hy: http://111.198.0.15:22288 | ||||
digital_avatar: http://nas.pucao.cn:2005 | digital_avatar: http://nas.pucao.cn:2005 | ||||
@@ -145,6 +145,7 @@ logging: | |||||
suimang: | suimang: | ||||
oral_broadcasting: http://111.198.0.15:22266 | oral_broadcasting: http://111.198.0.15:22266 | ||||
video_tts: http://111.198.0.15:22222 | |||||
photo_speak: http://111.198.0.15:22299 | photo_speak: http://111.198.0.15:22299 | ||||
photo_speak_hy: http://111.198.0.15:22288 | photo_speak_hy: http://111.198.0.15:22288 | ||||
digital_avatar: http://111.198.0.15:22200 | digital_avatar: http://111.198.0.15:22200 | ||||
@@ -193,6 +193,7 @@ logging: | |||||
suimang: | suimang: | ||||
oral_broadcasting: http://nas.pucao.cn:2001 | oral_broadcasting: http://nas.pucao.cn:2001 | ||||
video_tts: http://111.198.0.15:22222 | |||||
photo_speak: http://111.198.0.15:22299 | photo_speak: http://111.198.0.15:22299 | ||||
photo_speak_hy: http://111.198.0.15:22288 | photo_speak_hy: http://111.198.0.15:22288 | ||||
digital_avatar: http://nas.pucao.cn:2005 | digital_avatar: http://nas.pucao.cn:2005 | ||||
@@ -149,6 +149,7 @@ logging: | |||||
suimang: | suimang: | ||||
oral_broadcasting: http://111.198.0.15:22266 | oral_broadcasting: http://111.198.0.15:22266 | ||||
video_tts: http://111.198.0.15:22222 | |||||
photo_speak: http://111.198.0.15:22299 | photo_speak: http://111.198.0.15:22299 | ||||
photo_speak_hy: http://111.198.0.15:22288 | photo_speak_hy: http://111.198.0.15:22288 | ||||
digital_avatar: http://111.198.0.15:22200 | digital_avatar: http://111.198.0.15:22200 | ||||
@@ -5,5 +5,7 @@ import com.iformall.common.ResultData; | |||||
import java.util.Map; | import java.util.Map; | ||||
public interface WxCUserAuthorityService { | public interface WxCUserAuthorityService { | ||||
Map<String,Object> getAuthor(Long id, String code, Integer type, Long resourceId); | Map<String,Object> getAuthor(Long id, String code, Integer type, Long resourceId); | ||||
} | } |
@@ -8,7 +8,7 @@ import java.util.Map; | |||||
public interface WxCVideoService { | public interface WxCVideoService { | ||||
Map<String, Object> getById(Long id) throws Exception; | |||||
Map<String, Object> getById(Long userId) throws Exception; | |||||
WxCVideoTable selectOne(Long id, long resource_id); | WxCVideoTable selectOne(Long id, long resource_id); | ||||
} | } |
@@ -8,9 +8,11 @@ import java.util.List; | |||||
import java.util.Map; | import java.util.Map; | ||||
public interface WxCVoiceService { | public interface WxCVoiceService { | ||||
Map<String,Object> getById(Long id,String phone); | |||||
Map<String,Object> getById(Long userId); | |||||
List<VoiceInfo> chooseType(Long id); | List<VoiceInfo> chooseType(Long id); | ||||
Map<String,Object> voicePreview(AiPreviewParam aiPreviewParam); | |||||
Map<String, Object> voicePreview(Long voiceId, String voiceStyle, String text, Integer speed); | |||||
} | } |
@@ -19,8 +19,9 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { | |||||
@Override | @Override | ||||
public Map<String, Object> getAuthor(Long id, String code, Integer type, Long resourceId) { | public Map<String, Object> getAuthor(Long id, String code, Integer type, Long resourceId) { | ||||
List<WxCUserAuthority> resultList = new ArrayList<WxCUserAuthority>(); | |||||
HashMap<String, Object> authorVos = new HashMap<>(); | HashMap<String, Object> authorVos = new HashMap<>(); | ||||
List<WxCUserAuthority> resultList = new ArrayList<WxCUserAuthority>(); | |||||
if (type == 0) { | if (type == 0) { | ||||
//查询数字人相关权限 | //查询数字人相关权限 | ||||
@@ -31,41 +32,9 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { | |||||
resultList = wxCUserAuthorityMapper.getAuthorVoice(id, 1, resourceId); | resultList = wxCUserAuthorityMapper.getAuthorVoice(id, 1, resourceId); | ||||
} | } | ||||
if (resourceId == null || resourceId == -1) { | |||||
//若资源id没有传入那就展示所有当前类型资源权限 | |||||
HashMap<String, Object> info = new HashMap<>(); | |||||
HashMap<String, Object> status = new HashMap<>(); | |||||
List authorList = new ArrayList(); | |||||
for (WxCUserAuthority wxCUserAuthority : resultList) { | |||||
HashMap<String, Object> 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); | |||||
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); | |||||
return authorVos; | |||||
} | |||||
HashMap<String, Object> data = new HashMap<>(); | |||||
HashMap<String, Object> info = new HashMap<>(); | |||||
HashMap<String, Object> 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()); | |||||
if (resultList.size() == 1) { | |||||
HashMap<String, Object> data = new HashMap<>(); | |||||
WxCUserAuthority wxCUserAuthority = resultList.get(0); | |||||
data.put("type", wxCUserAuthority.getType()); | data.put("type", wxCUserAuthority.getType()); | ||||
data.put("resource_id", wxCUserAuthority.getResourceId()); | data.put("resource_id", wxCUserAuthority.getResourceId()); | ||||
@@ -75,14 +44,8 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { | |||||
data.put("class", EnumClassType.SHARE.getCode()); | data.put("class", EnumClassType.SHARE.getCode()); | ||||
data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | ||||
data.put("expire_time", wxCUserAuthority.getExpireTime().getTime() / 1000); | data.put("expire_time", wxCUserAuthority.getExpireTime().getTime() / 1000); | ||||
return data; | |||||
} | } | ||||
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; | |||||
return null; | |||||
} | } | ||||
} | } |
@@ -39,13 +39,12 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer | |||||
WxCVideoMapper wxCVideoMapper; | WxCVideoMapper wxCVideoMapper; | ||||
@Override | @Override | ||||
public Map<String, Object> getById(Long id) { | |||||
List<WxCVideoTable> TemplateVideo = wxCVideoMapper.getById(id); | |||||
Map<String, Object> avatarVos = new HashMap(); | |||||
public Map<String, Object> getById(Long userId) { | |||||
Map<String, Object> data = new HashMap(); | Map<String, Object> data = new HashMap(); | ||||
List<WxCVideoTable> TemplateVideo = wxCVideoMapper.getById(userId); | |||||
List authorlist = new ArrayList(); | List authorlist = new ArrayList(); | ||||
for (WxCVideoTable wxCVideoTable : TemplateVideo) { | for (WxCVideoTable wxCVideoTable : TemplateVideo) { | ||||
data.put("username", wxCVideoTable.getUserName()); | |||||
data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | ||||
Map<String, Object> avatar = new HashMap(); | Map<String, Object> avatar = new HashMap(); | ||||
@@ -63,7 +62,6 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer | |||||
avatar.put("avatar_model_md5", wxCVideoTable.getModelMd5()); | avatar.put("avatar_model_md5", wxCVideoTable.getModelMd5()); | ||||
} | } | ||||
try { | try { | ||||
File preinfoFile = new File(wxCVideoTable.getPreInfoPath()); | File preinfoFile = new File(wxCVideoTable.getPreInfoPath()); | ||||
avatar.put("avatar_preinfo_md5", getFileMD5(preinfoFile)); | avatar.put("avatar_preinfo_md5", getFileMD5(preinfoFile)); | ||||
@@ -75,19 +73,10 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer | |||||
avatar.put("expire_time", wxCVideoTable.getExpireTime().getTime() / 1000); | avatar.put("expire_time", wxCVideoTable.getExpireTime().getTime() / 1000); | ||||
avatar.put("class", wxCVideoTable.getClassType()); | avatar.put("class", wxCVideoTable.getClassType()); | ||||
authorlist.add(avatar); | authorlist.add(avatar); | ||||
data.put("authorlist", authorlist); | |||||
} | } | ||||
avatarVos.put("data", data); | |||||
Map<String, Object> info = new HashMap(); | |||||
Map<String, Object> status = new HashMap(); | |||||
info.put("log_id", id); | |||||
info.put("server_type", "avatar list"); | |||||
status.put("code", 1000); | |||||
status.put("msg", "success"); | |||||
avatarVos.put("info", info); | |||||
avatarVos.put("status", status); | |||||
return avatarVos; | |||||
data.put("authorlist", authorlist); | |||||
return data; | |||||
} | } | ||||
@Override | @Override | ||||
@@ -17,9 +17,12 @@ import com.iformall.mapper.WxCVoiceMapper; | |||||
import com.iformall.service.WxCVoiceService; | import com.iformall.service.WxCVoiceService; | ||||
import com.iformall.sm.AiPreviewParam; | import com.iformall.sm.AiPreviewParam; | ||||
import com.iformall.sm.AiPreviewResult; | import com.iformall.sm.AiPreviewResult; | ||||
import com.iformall.sm.AiTtsHelper; | |||||
import com.iformall.sm.AiVideoHelper; | import com.iformall.sm.AiVideoHelper; | ||||
import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.util.ObjectUtils; | import org.springframework.util.ObjectUtils; | ||||
@@ -28,6 +31,7 @@ import java.util.*; | |||||
@Service | @Service | ||||
public class WxCVoiceServiceImpl implements WxCVoiceService { | public class WxCVoiceServiceImpl implements WxCVoiceService { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
@Autowired | @Autowired | ||||
WxCVoiceMapper wxCVoiceMapper; | WxCVoiceMapper wxCVoiceMapper; | ||||
@@ -43,11 +47,10 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
@Override | @Override | ||||
public Map<String, Object> getById(Long id,String phone) { | |||||
List<WxCVoiceTable> resultList = wxCVoiceMapper.getById(id); | |||||
HashMap<String, Object> result = new HashMap<>(); | |||||
public Map<String, Object> getById(Long userId) { | |||||
HashMap<String, Object> data = new HashMap<>(); | HashMap<String, Object> data = new HashMap<>(); | ||||
data.put("username", phone); | |||||
List<WxCVoiceTable> resultList = wxCVoiceMapper.getById(userId); | |||||
data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | ||||
// List audioList = new ArrayList(); | // List audioList = new ArrayList(); | ||||
Map<Long,Map<String, Object>> audioList = new HashMap(); | Map<Long,Map<String, Object>> audioList = new HashMap(); | ||||
@@ -102,44 +105,10 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
} | } | ||||
data.put("audioList", new ArrayList<>(audioList.values())); | data.put("audioList", new ArrayList<>(audioList.values())); | ||||
result.put("data", data); | |||||
HashMap<String, Object> info = new HashMap<>(); | |||||
HashMap<String, Object> 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); | |||||
return result; | |||||
} | |||||
@Override | |||||
public Map<String, Object> voicePreview(AiPreviewParam aiPreviewParam) { | |||||
VoiceInfo voiceInfo = voiceMapper.selectOne(new LambdaQueryWrapper<VoiceInfo>().eq(VoiceInfo::getIsDel, 0).eq(VoiceInfo::getId, aiPreviewParam.getVoice_id())); | |||||
if (ObjectUtils.isEmpty(voiceInfo)) { | |||||
Map<String, Object> status = new HashMap<>(); | |||||
status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); | |||||
status.put("msg", "声音信息不存在"); | |||||
return status; | |||||
} | |||||
AiPreviewParam param = new AiPreviewParam(); | |||||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(Constant.text_pause, "[*]")); | |||||
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); | |||||
Map<String, Object> resultMap = new HashMap<>(); | |||||
Map<String, Object> data = new HashMap<>(); | |||||
data.put("ttsurl", result.getUrl()); | |||||
Map<String, Object> status = new HashMap<>(); | |||||
status.put("code", 1000); | |||||
status.put("msg", "success"); | |||||
resultMap.put("data", data); | |||||
resultMap.put("status", status); | |||||
return resultMap; | |||||
return data; | |||||
} | } | ||||
@Override | @Override | ||||
public List<VoiceInfo> chooseType(Long id) { | public List<VoiceInfo> chooseType(Long id) { | ||||
List<VoiceInfo> voiceInfos = voiceMapper.selectList( | List<VoiceInfo> voiceInfos = voiceMapper.selectList( | ||||
@@ -173,4 +142,27 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
}); | }); | ||||
return voiceInfos; | return voiceInfos; | ||||
} | } | ||||
@Override | |||||
public Map<String, Object> voicePreview(Long voiceId, String voiceStyle, String text, Integer speed) { | |||||
VoiceInfo voiceInfo = voiceMapper.selectById(voiceId); | |||||
if(voiceInfo == null){ | |||||
logger.error("未查询到声音{}"+voiceId); | |||||
return null; | |||||
} | |||||
AiPreviewParam param = new AiPreviewParam(); | |||||
param.setVoice_id(voiceInfo.getMouldSmId()); | |||||
param.setVoice_style(StringUtils.isBlank(voiceStyle) ? EnumSpeakType.default_0.getMessage() : voiceStyle); | |||||
param.setGen_txt(text.replaceAll(Constant.text_pause, "[*]")); | |||||
param.setSpeed(speed==null?100:speed); | |||||
AiPreviewResult aiTtsResult = AiTtsHelper.voicePreview(param); | |||||
if(!aiTtsResult.isSuccess()){ | |||||
logger.error("tts 预览失败{}"+aiTtsResult.getMsg()); | |||||
return null; | |||||
} | |||||
Map<String, Object> data = new HashMap<>(); | |||||
data.put("ttsurl", aiTtsResult.getUrl()); | |||||
return data; | |||||
} | |||||
} | } |
@@ -0,0 +1,75 @@ | |||||
package com.iformall.sm; | |||||
import com.alibaba.fastjson.JSON; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.iformall.utils.Base64Util; | |||||
import com.iformall.utils.HttpUtil; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.stereotype.Component; | |||||
@Slf4j | |||||
@Component | |||||
public class AiTtsHelper { | |||||
public static String video_tts; | |||||
@Value("${suimang.video_tts}") | |||||
public void setVideoTts(String video_tts){ | |||||
this.video_tts = video_tts; | |||||
} | |||||
public static String doPost(String url, String params) { | |||||
return HttpUtil.doAiVideoPost(url,params); | |||||
} | |||||
public static AiPreviewResult voicePreview(AiPreviewParam param) { | |||||
String response = doPost(video_tts + "/tts_wav", JSONObject.toJSONString(param)); | |||||
log.info("TTS音色预览 end response:" + response); | |||||
AiPreviewResult result = new AiPreviewResult(); | |||||
if (StringUtils.isBlank(response)) { | |||||
result.setSuccess(false); | |||||
result.setMsg("(MetaService)TTS音色预览失败,请稍后重试"); | |||||
return result; | |||||
} | |||||
JSONObject jsonObject = JSON.parseObject(response); | |||||
JSONObject status = jsonObject.getJSONObject("status"); | |||||
Integer code = status.getInteger("code"); | |||||
String msg = status.getString("msg"); | |||||
if (code == null) { | |||||
result.setSuccess(false); | |||||
result.setMsg("(MetaService)TTS音色预览异常,请稍后重试"); | |||||
return result; | |||||
} | |||||
if (code.intValue() == 3000) { | |||||
JSONObject data = jsonObject.getJSONObject("data"); | |||||
String strURL = data.getString("url"); | |||||
String time = data.getString("time"); | |||||
result.setCode(200); | |||||
result.setSuccess(true); | |||||
result.setUrl(video_tts + strURL); | |||||
result.setTime(Double.valueOf(time)); | |||||
String resultMsg = result.getMsgInfo(code, msg); | |||||
result.setMsg(resultMsg); | |||||
} else { | |||||
result.setCode(code); | |||||
result.setSuccess(false); | |||||
String resultMsg = result.getMsgInfo(code, msg); | |||||
result.setMsg(resultMsg); | |||||
} | |||||
return result; | |||||
} | |||||
public static void main(String[] args) { | |||||
} | |||||
} |