@@ -201,7 +201,7 @@ public class VoiceMouldController extends BaseController { | |||||
PreviewVoiceVO pv = voiceInfoService.hyPreviewVoice(aiPreviewParam); | PreviewVoiceVO pv = voiceInfoService.hyPreviewVoice(aiPreviewParam); | ||||
Double time = pv.getTime();//秒 | Double time = pv.getTime();//秒 | ||||
if (time > 5*60 ) { | if (time > 5*60 ) { | ||||
return new ResultData(ErrorCode.MEMBER_NO_POINTS.getCode(),"视频最大时长为300秒,当前时长为"+time+"秒"); | |||||
return new ResultData(Result.ERROR,"视频最大时长为300秒,当前时长为"+time+"秒","video max times is 300 seconds. current is"+time+" seconds"); | |||||
} | } | ||||
//如果用户未支付,则只能1分钟以内,如果已支付,则可以5分钟以内 | //如果用户未支付,则只能1分钟以内,如果已支付,则可以5分钟以内 | ||||
ProductOrder po = new ProductOrder(); | ProductOrder po = new ProductOrder(); | ||||
@@ -209,7 +209,7 @@ public class VoiceMouldController extends BaseController { | |||||
Integer paidCount = productOrderService.findPaidCount(po); | Integer paidCount = productOrderService.findPaidCount(po); | ||||
if (null == paidCount || paidCount <= 0 ) { | if (null == paidCount || paidCount <= 0 ) { | ||||
if (time > 60) { | if (time > 60) { | ||||
return new ResultData(ErrorCode.MEMBER_NO_POINTS.getCode(),"视频最大时长为60秒,当前时长为"+time+"秒"); | |||||
return new ResultData(ErrorCode.MEMBER_NO_POINTS.getCode(),"视频最大时长为60秒,当前时长为"+time+"秒","video max times is 60 seconds. current is"+time+" seconds"); | |||||
} | } | ||||
} | } | ||||
return new ResultData(pv); | return new ResultData(pv); | ||||
@@ -1,6 +1,9 @@ | |||||
package com.iformall.common; | package com.iformall.common; | ||||
import java.util.HashMap; | |||||
import java.util.Map; | |||||
import com.iformall.enums.EnumLanguages; | |||||
/** | /** | ||||
* @author chenkx | * @author chenkx | ||||
@@ -10,6 +13,7 @@ public class Result { | |||||
public int code; | public int code; | ||||
public String message; | public String message; | ||||
public Map<String,String> languageMessage = new HashMap<String,String>(); | |||||
public static final int SUCCESS = 200; | public static final int SUCCESS = 200; | ||||
public static final int ERROR = 500; | public static final int ERROR = 500; | ||||
public static final int UNLOGIN = 701; | public static final int UNLOGIN = 701; | ||||
@@ -17,16 +21,30 @@ public class Result { | |||||
public Result() { | public Result() { | ||||
this.code = 200; | this.code = 200; | ||||
this.message = "success"; | this.message = "success"; | ||||
this.addLanguage(EnumLanguages.zh_CN, message); | |||||
} | } | ||||
public Result(int code, String message) { | public Result(int code, String message) { | ||||
this.code = code; | this.code = code; | ||||
this.message = message; | this.message = message; | ||||
this.addLanguage(EnumLanguages.zh_CN, message); | |||||
} | |||||
public Result(int code, String message,String enMessage) { | |||||
this.code = code; | |||||
this.message = message; | |||||
this.addLanguage(EnumLanguages.zh_CN, message).addLanguage(EnumLanguages.en_US, enMessage); | |||||
} | } | ||||
public Result(ErrorCode errorCode) { | public Result(ErrorCode errorCode) { | ||||
this.code = errorCode.getCode(); | this.code = errorCode.getCode(); | ||||
this.message = errorCode.getMessage(); | this.message = errorCode.getMessage(); | ||||
this.addLanguage(EnumLanguages.zh_CN, message); | |||||
} | |||||
public Result addLanguage(EnumLanguages language,String message) { | |||||
this.languageMessage.put(language.getLanguages(), message); | |||||
return this; | |||||
} | } | ||||
} | } |
@@ -8,6 +8,8 @@ import java.util.HashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
import com.iformall.enums.EnumLanguages; | |||||
/** | /** | ||||
* @author chenkx | * @author chenkx | ||||
* @date 2018-01-05. | * @date 2018-01-05. | ||||
@@ -69,29 +71,37 @@ public class ResultData extends Result { | |||||
public ResultData(int code, String message) { | public ResultData(int code, String message) { | ||||
super(code, message); | super(code, message); | ||||
} | } | ||||
public ResultData(int code, String message,String enMessage) { | |||||
super(code, message,enMessage); | |||||
} | |||||
public ResultData(int code, String message, Object data) { | public ResultData(int code, String message, Object data) { | ||||
this.code = code; | this.code = code; | ||||
this.message = message; | this.message = message; | ||||
this.data = data; | this.data = data; | ||||
super.addLanguage(EnumLanguages.zh_CN, message); | |||||
} | } | ||||
public ResultData(ErrorCode errorCode, Object data) { | public ResultData(ErrorCode errorCode, Object data) { | ||||
this.code = errorCode.getCode(); | this.code = errorCode.getCode(); | ||||
this.message = errorCode.getMessage(); | this.message = errorCode.getMessage(); | ||||
this.data = data; | this.data = data; | ||||
super.addLanguage(EnumLanguages.zh_CN, message); | |||||
} | } | ||||
public ResultData(ErrorCode errorCode) { | public ResultData(ErrorCode errorCode) { | ||||
this.code = errorCode.getCode(); | this.code = errorCode.getCode(); | ||||
this.message = errorCode.getMessage(); | this.message = errorCode.getMessage(); | ||||
super.addLanguage(EnumLanguages.zh_CN, message); | |||||
} | } | ||||
public HashMap<String, Object> toHashMap() { | public HashMap<String, Object> toHashMap() { | ||||
HashMap<String, Object> map = new HashMap<>(3); | |||||
HashMap<String, Object> map = new HashMap<>(4); | |||||
map.put("code", this.code); | map.put("code", this.code); | ||||
map.put("message", this.message); | map.put("message", this.message); | ||||
map.put("data", data); | map.put("data", data); | ||||
map.put("languageMessage", this.languageMessage); | |||||
return map; | return map; | ||||
} | } | ||||
@@ -108,7 +108,7 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
VoiceInfo voiceInfo = voiceMapper.selectOne(new LambdaQueryWrapper<VoiceInfo>() | VoiceInfo voiceInfo = voiceMapper.selectOne(new LambdaQueryWrapper<VoiceInfo>() | ||||
.eq(VoiceInfo::getIsDel, 0) | .eq(VoiceInfo::getIsDel, 0) | ||||
.eq(VoiceInfo::getId, aiPreviewParam.getVoice_id())); | .eq(VoiceInfo::getId, aiPreviewParam.getVoice_id())); | ||||
voiceInfo = Optional.ofNullable(voiceInfo).orElseThrow(() -> new BizException(ErrorCode.MEMBER_NO_POINTS.getCode(), "声音信息不存在")); | |||||
voiceInfo = Optional.ofNullable(voiceInfo).orElseThrow(() -> new BizException(ErrorCode.SYS_SERVER_ERROR.getCode(), "声音信息不存在")); | |||||
AiPreviewParam param = new AiPreviewParam(); | AiPreviewParam param = new AiPreviewParam(); | ||||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(Constant.text_pause,"[*]")); | param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(Constant.text_pause,"[*]")); | ||||