@@ -0,0 +1,109 @@ | |||
package com.iformall.controller; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.iformall.common.ErrorCode; | |||
import com.iformall.common.ResultData; | |||
import com.iformall.domain.po.sm.PhotoSpeakVideo; | |||
import com.iformall.domain.po.sm.PreviewParam; | |||
import com.iformall.enums.EnumVideoStatus; | |||
import com.iformall.service.sm.PhotoSpeakVideoService; | |||
import com.iformall.service.sm.SDKService; | |||
import com.iformall.service.sm.PersonPhotoService; | |||
import com.iformall.service.sm.VoiceInfoService; | |||
import com.iformall.sm.AiPhotoSpeakParam; | |||
import com.iformall.sm.AiPreviewParam; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiImplicitParam; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import java.util.Date; | |||
/** | |||
* 对外开放的 API 接口 | |||
*/ | |||
@RestController | |||
@RequestMapping("/api/open") | |||
@Api(description = "对外开放的 API 接口") | |||
public class SDKController extends BaseController { | |||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
@Autowired | |||
private PersonPhotoService personPhotoService; | |||
@Autowired | |||
private VoiceInfoService voiceInfoService; | |||
@Autowired | |||
private PhotoSpeakVideoService photoSpeakVideoService; | |||
@ApiOperation("图片质量审核接口") | |||
@PostMapping("checkPhoto") | |||
@ApiImplicitParam(name = "material", value = "material", dataType = "String", paramType = "query", required = true) | |||
public ResultData checkPhoto(String material) { | |||
logger.debug("[" + getIpAddr() + "] SDKController::checkPhoto"); | |||
if (StringUtils.isBlank(material)) { | |||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | |||
} | |||
ResultData data = personPhotoService.checkPhoto(material); | |||
if (data.code == 2000) { | |||
return new ResultData(); | |||
} | |||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), data.message); | |||
} | |||
@ApiOperation("TTS音色预览") | |||
@PostMapping("/preview") | |||
public ResultData voicePreview(@RequestBody PreviewParam previewParam) { | |||
logger.debug("[" + getIpAddr() + "] SDKController::voicePreview"); | |||
if (previewParam.getVoiceId() == null) { | |||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "音色ID不能为空"); | |||
} | |||
if (StringUtils.isBlank(previewParam.getGenTxt())) { | |||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "需要生成的文字不能为空"); | |||
} | |||
AiPreviewParam param = new AiPreviewParam(); | |||
param.setVoice_id(previewParam.getVoiceId()); | |||
param.setVoice_style(previewParam.getVoiceStyle()); | |||
param.setGen_txt(previewParam.getGenTxt()); | |||
param.setGender(previewParam.getGender()); | |||
return new ResultData(voiceInfoService.voicePreview(param)); | |||
} | |||
@ApiOperation("生成视频") | |||
@PostMapping("/createVideo") | |||
public ResultData create(@RequestBody PhotoSpeakVideo record) { | |||
logger.debug("[" + getIpAddr() + "] MouldPatchController::saveOrUpdate"); | |||
if (record.getId() == null) { | |||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
} | |||
PhotoSpeakVideo mouldVideo = photoSpeakVideoService.getById(record.getId()); | |||
logger.info("TEST--" + JSONObject.toJSONString(mouldVideo)); | |||
if (mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())) { | |||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未找到用户数据"); | |||
} | |||
if (EnumVideoStatus.ing.getCode().equals(mouldVideo.getVideoStatus()) | |||
|| EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | |||
|| EnumVideoStatus.upload_ing.getCode().equals(mouldVideo.getVideoStatus()) | |||
|| EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoStatus())) { | |||
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "视频生成中"); | |||
} | |||
if (EnumVideoStatus.upload_success.getCode().equals(mouldVideo.getVideoStatus())) { | |||
//上传阿里云状态 生成成功 | |||
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "视频已生成完成"); | |||
} | |||
PhotoSpeakVideo mouldVideoUpd = new PhotoSpeakVideo(); | |||
mouldVideoUpd.setId(record.getId()); | |||
mouldVideoUpd.setVideoStatus(EnumVideoStatus.ing.getCode()); | |||
mouldVideoUpd.setVideoMsg(""); | |||
mouldVideoUpd.setCreateVideoDate(new Date()); | |||
photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | |||
photoSpeakVideoService.createVideo(mouldVideo, true); | |||
return new ResultData(); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.iformall.domain.po.sm; | |||
import lombok.Data; | |||
@Data | |||
public class PreviewParam { | |||
private String genTxt; | |||
private String voiceId; | |||
private String voiceStyle; | |||
private String gender; | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.iformall.domain.po.sm; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.util.Date; | |||
import java.io.Serializable; | |||
import io.swagger.models.auth.In; | |||
import lombok.Data; | |||
/** | |||
* @Description | |||
* @Author LRH | |||
* @Date 2023-06-13 | |||
*/ | |||
@Data | |||
@TableName("user_time_config" ) | |||
public class UserTimeConfig implements Serializable { | |||
private static final long serialVersionUID = 2953038588956565523L; | |||
@TableId | |||
private Integer id; | |||
/** | |||
* 用户类型(0-注册用户,1-邀请用户) | |||
*/ | |||
private Integer userType; | |||
/** | |||
* 默认时长(s) | |||
*/ | |||
private Long time; | |||
private String tenantId; | |||
private String parentTenantId; | |||
private Date createDate; | |||
private Date updateDate; | |||
private Integer isDel; | |||
} |
@@ -0,0 +1,34 @@ | |||
package com.iformall.enums.sm; | |||
public enum EnumSmUserType { | |||
REGISTER(0, "注册用户"), | |||
INVITE(1, "邀请的用户"), | |||
PAY(2, "充钱用户"), | |||
VIP(3, "VIP用户"), | |||
; | |||
public static EnumSmUserType getEnum(Integer code) { | |||
for (EnumSmUserType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumSmUserType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -4,11 +4,13 @@ import com.iformall.common.CommonMapper; | |||
import com.iformall.domain.po.AliBusinessCircleOrder; | |||
import com.iformall.domain.po.sm.InviteCode; | |||
import com.iformall.service.sm.InviteCodeService; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
public interface InviteCodeMapper extends CommonMapper<InviteCode, String> { | |||
public interface InviteCodeMapper extends CommonMapper<InviteCode, Long> { | |||
void addUseTotal(@Param("id") Long id, @Param("total") Integer total); | |||
} |
@@ -0,0 +1,7 @@ | |||
package com.iformall.mapper; | |||
import com.iformall.common.CommonMapper; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
public interface UserTimeConfigServiceMapper extends CommonMapper<UserTimeConfig, Long> { | |||
} |
@@ -0,0 +1,8 @@ | |||
package com.iformall.service.sm; | |||
import com.iformall.common.ResultData; | |||
import com.iformall.sm.AiPhotoSpeakParam; | |||
public interface SDKService { | |||
ResultData imgTalking(AiPhotoSpeakParam videoParam); | |||
} |
@@ -16,4 +16,6 @@ public interface UserCreateVideoNumService { | |||
UserCreateVideoNum queryInfoByUserId(Long userId); | |||
void uploadUserCreateVideoNum(Map<Long, Long> collect); | |||
void inviteUserAddCreatTime(Long id); | |||
} |
@@ -0,0 +1,8 @@ | |||
package com.iformall.service.sm; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
import io.swagger.models.auth.In; | |||
public interface UserTimeConfigService { | |||
UserTimeConfig getInfoByUerType(Integer i); | |||
} |
@@ -12,6 +12,9 @@ import com.iformall.mapper.InviteCodeInfoMapper; | |||
import com.iformall.service.WxCUserBasicInfoService; | |||
import com.iformall.service.sm.InviteCodeInfoService; | |||
import com.iformall.service.sm.InviteCodeService; | |||
import com.iformall.service.sm.UserCreateVideoNumService; | |||
import lombok.Data; | |||
import org.checkerframework.checker.units.qual.A; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.CollectionUtils; | |||
@@ -32,6 +35,9 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { | |||
@Autowired | |||
private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
@Autowired | |||
private UserCreateVideoNumService userCreateVideoNumService; | |||
/** | |||
* 使用邀请码 | |||
* | |||
@@ -64,7 +70,11 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { | |||
codeInfo.setPhone(codeInfo.getPhone()); | |||
inviteCodeInfoMapper.insert(codeInfo); | |||
inviteCodeService.addUseTotal(info.getId(), info.getTotal()); | |||
//邀请码最多使用10次 | |||
if (info.getTotal() < 10){ | |||
inviteCodeService.addUseTotal(info.getId(), info.getTotal()); | |||
userCreateVideoNumService.inviteUserAddCreatTime(cUser.getId()); | |||
} | |||
return new ResultData(); | |||
} else { | |||
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "邀请码不存在"); | |||
@@ -53,9 +53,6 @@ public class InviteCodeServiceImpl implements InviteCodeService { | |||
@Override | |||
public void addUseTotal(Long id, Integer total) { | |||
InviteCode code = new InviteCode(); | |||
code.setId(id); | |||
code.setTotal(total + 1); | |||
inviteCodeMapper.updateById(code); | |||
inviteCodeMapper.addUseTotal(id, total); | |||
} | |||
} |
@@ -66,6 +66,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
@Autowired | |||
private MusicInfoService musicInfoService; | |||
private final static String str = "\uD83D\uDD57"; | |||
@Override | |||
public PageInfo<PhotoSpeakVideo> listAsPage(PhotoSpeakVideo record, Integer pageIndex, Integer pageSize) { | |||
@@ -285,9 +286,6 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
} | |||
try { | |||
AiPreviewParam previewParam = new AiPreviewParam(); | |||
previewParam.setVoice_id(voiceMouldSmId); | |||
AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||
param.setImg(Base64Util.imageUrlToBase64(photoSpeakVideo.getPersonPhotoUrl())); | |||
param.setVoice_id(voiceMouldSmId); | |||
@@ -297,21 +295,15 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
Integer speakTypeStr = jsonObject.getInteger("speakType"); | |||
param.setVoice_style(StringUtils.isBlank(voiceType) ? "default" : EnumSpeakType.getEnum(speakTypeStr).getType()); | |||
previewParam.setVoice_style(StringUtils.isBlank(voiceType) ? "default" : EnumSpeakType.getEnum(speakTypeStr).getType()); | |||
Integer sex = jsonObject.getInteger("sex"); | |||
if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | |||
param.setGen_txt(paperwork); | |||
previewParam.setGen_txt(paperwork); | |||
param.setGen_txt(paperwork.replaceAll(str, "[*]")); | |||
if (sex == 1){ | |||
param.setGender("male"); | |||
previewParam.setGender("male"); | |||
}else if (sex == 2){ | |||
param.setGender("female"); | |||
previewParam.setGender("female"); | |||
}else { | |||
param.setGender("unknown"); | |||
previewParam.setGender("unknown"); | |||
} | |||
param.setUrl("None"); | |||
} else if (EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)) { | |||
@@ -320,21 +312,6 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
param.setUrl(voiceMaterialUrl); | |||
} | |||
//TTS音色预览 | |||
AiPreviewResult result = AiVideoHelper.voicePreview(previewParam); | |||
if (!result.isSuccess()) { | |||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
videoUpd.setVideoMsg(result.getMsgInfo(result.getCode(), result.getMsg())); | |||
videoUpd.setCreateVideoDate(new Date()); | |||
this.saveOrUpdate(videoUpd); | |||
if (flag) { | |||
//如果生成视频失败了,就把创建视频的次数加回去 | |||
userCreateVideoNumService.addOrSubtractNumberOfTimes(2, createVideoNum); | |||
} | |||
return new AsyncResult<>(0); | |||
} | |||
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||
if (video.isSuccess()) { | |||
videoUpd.setVideoPath(video.getUrl()); | |||
@@ -0,0 +1,54 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.iformall.common.ResultData; | |||
import com.iformall.enums.EnumSpeakType; | |||
import com.iformall.enums.EnumVideoStatus; | |||
import com.iformall.enums.EnumVoiceFrom; | |||
import com.iformall.service.sm.SDKService; | |||
import com.iformall.sm.AiPhotoSpeakParam; | |||
import com.iformall.sm.AiPhotoSpeakResult; | |||
import com.iformall.sm.AiVideoHelper; | |||
import com.iformall.utils.Base64Util; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.scheduling.annotation.AsyncResult; | |||
import org.springframework.stereotype.Service; | |||
import java.util.Date; | |||
@Service | |||
public class SDKServiceImpl implements SDKService { | |||
@Override | |||
public ResultData imgTalking(AiPhotoSpeakParam videoParam) { | |||
AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||
param.setImg(Base64Util.imageUrlToBase64(videoParam.getUrl())); | |||
param.setVoice_id(videoParam.getVoice_id()); | |||
param.setVoice_style(StringUtils.isBlank(voiceType) ? "default" : EnumSpeakType.getEnum(speakTypeStr).getType()); | |||
if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | |||
param.setGen_txt(paperwork.replaceAll(str, "[*]")); | |||
param.setGender("male"); | |||
param.setUrl("None"); | |||
} else if (EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)) { | |||
param.setGen_txt("None"); | |||
param.setGender("None"); | |||
param.setUrl(voiceMaterialUrl); | |||
} | |||
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||
if (video.isSuccess()) { | |||
videoUpd.setVideoPath(video.getUrl()); | |||
videoUpd.setVideoStatus(EnumVideoStatus.success.getCode()); | |||
videoUpd.setVideoMsg("success"); | |||
videoUpd.setCreateVideoDate(new Date()); | |||
this.saveOrUpdate(videoUpd); | |||
videoUpd.setTitle(photoSpeakVideo.getTitle()); | |||
this.uploadVideo(videoUpd); | |||
return new AsyncResult<>(1); | |||
} | |||
return null; | |||
} | |||
} |
@@ -2,17 +2,19 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.iformall.common.IdWorker; | |||
import com.iformall.domain.po.sm.UserCreateVideoNum; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
import com.iformall.enums.sm.EnumSmUserType; | |||
import com.iformall.mapper.UserCreateVideoNumMapper; | |||
import com.iformall.service.sm.UserCreateVideoNumService; | |||
import io.swagger.models.auth.In; | |||
import com.iformall.service.sm.UserTimeConfigService; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.ObjectUtils; | |||
import java.util.Date; | |||
import java.util.Map; | |||
@@ -24,11 +26,12 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
@Autowired | |||
private UserCreateVideoNumMapper userCreateVideoNumMapper; | |||
//总条数初始值 | |||
private static final Integer RESIDUE_TOTAL = 10; | |||
@Autowired | |||
private UserTimeConfigService userTimeConfigService; | |||
/** | |||
* 初始化注册用户创建视频的次数 | |||
* 初始化注册用户创建视频的时长 | |||
* | |||
* @param id 用户id | |||
* @Author LWH | |||
@@ -36,15 +39,19 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
* @date: 2023/6/8 10:23 | |||
*/ | |||
public Boolean initializationUserCreateVideoNum(Long id) { | |||
UserTimeConfig uerType = userTimeConfigService.getInfoByUerType(EnumSmUserType.REGISTER.getCode()); | |||
UserCreateVideoNum createVideoNum = new UserCreateVideoNum(); | |||
createVideoNum.setId(IdWorker.get().nextId()); | |||
createVideoNum.setUserId(id); | |||
createVideoNum.setResidueNum(RESIDUE_TOTAL); | |||
createVideoNum.setResidueTotal(RESIDUE_TOTAL); | |||
Date date = new Date(); | |||
createVideoNum.setCreateDate(date); | |||
createVideoNum.setUpdateDate(date); | |||
createVideoNum.setIsDel(0); | |||
if (!ObjectUtils.isEmpty(uerType)){ | |||
createVideoNum.setId(IdWorker.get().nextId()); | |||
createVideoNum.setUserId(id); | |||
createVideoNum.setTotalTime(uerType.getTime());//用户拥有总时长(单位:s) | |||
createVideoNum.setResidueTime(uerType.getTime());//用户剩余时长(单位:s) | |||
// createVideoNum.setEffectiveDate();//TODO 有效期 | |||
Date date = new Date(); | |||
createVideoNum.setCreateDate(date); | |||
createVideoNum.setUpdateDate(date); | |||
createVideoNum.setIsDel(0); | |||
} | |||
return userCreateVideoNumMapper.insert(createVideoNum) > 0; | |||
} | |||
@@ -55,7 +62,7 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
@Override | |||
public UserCreateVideoNum queryInfoByUserId(Long userId) { | |||
return userCreateVideoNumMapper.selectOne(new LambdaQueryWrapper<UserCreateVideoNum>().eq(UserCreateVideoNum::getUserId, userId)); | |||
return userCreateVideoNumMapper.selectOne(new LambdaQueryWrapper<UserCreateVideoNum>().eq(UserCreateVideoNum::getIsDel,0).eq(UserCreateVideoNum::getUserId, userId)); | |||
} | |||
@Override | |||
@@ -70,4 +77,18 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
.eq(UserCreateVideoNum::getUserId, entry.getKey())); | |||
} | |||
} | |||
/** | |||
* 使用邀请码用户增加时长 | |||
*/ | |||
@Override | |||
public void inviteUserAddCreatTime(Long id) { | |||
UserCreateVideoNum videoNum = queryInfoByUserId(id); | |||
UserTimeConfig uerType = userTimeConfigService.getInfoByUerType(EnumSmUserType.REGISTER.getCode()); | |||
if (!ObjectUtils.isEmpty(uerType)){ | |||
videoNum.setTotalTime(videoNum.getTotalTime() + uerType.getTime()); | |||
userCreateVideoNumMapper.updateById(videoNum); | |||
} | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
import com.iformall.mapper.UserTimeConfigServiceMapper; | |||
import com.iformall.service.sm.UserTimeConfigService; | |||
import io.swagger.models.auth.In; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Service | |||
public class UserTimeConfigServiceImpl implements UserTimeConfigService { | |||
@Autowired | |||
private UserTimeConfigServiceMapper userTimeConfigServiceMapper; | |||
@Override | |||
public UserTimeConfig getInfoByUerType(Integer i) { | |||
return userTimeConfigServiceMapper.selectOne(new LambdaQueryWrapper<UserTimeConfig>().eq(UserTimeConfig::getIsDel, 0).eq(UserTimeConfig::getUserType, i)); | |||
} | |||
} |
@@ -27,6 +27,8 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||
@Autowired | |||
private VoiceMapper voiceMapper; | |||
private final static String str = "\uD83D\uDD57"; | |||
@Override | |||
public List<VoiceInfo> chooseType(Long id) { | |||
List<VoiceInfo> voiceInfos = voiceMapper.selectList(new LambdaQueryWrapper<VoiceInfo>().eq(VoiceInfo::getLanguageId, id).orderByAsc(VoiceInfo::getDisplayName).select(VoiceInfo::getId, VoiceInfo::getDisplayName, VoiceInfo::getStyleList)); | |||
@@ -52,13 +54,12 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||
@Override | |||
public ResultData voicePreview(AiPreviewParam aiPreviewParam) { | |||
if (aiPreviewParam.getVoice_id() == null || StringUtils.isBlank(aiPreviewParam.getGen_txt())) { | |||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "参数不能为空"); | |||
} | |||
VoiceInfo voiceInfo = voiceMapper.selectOne(new LambdaQueryWrapper<VoiceInfo>().eq(VoiceInfo::getIsDel, 0).eq(VoiceInfo::getId, aiPreviewParam.getVoice_id())); | |||
if (ObjectUtils.isEmpty(voiceInfo)){ | |||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "声音信息不存在"); | |||
} | |||
AiPreviewParam param = new AiPreviewParam(); | |||
param.setGen_txt(aiPreviewParam.getGen_txt()); | |||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(str,"[*]")); | |||
param.setVoice_id(voiceInfo.getMouldSmId()); | |||
param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? "default" : aiPreviewParam.getVoice_style()); | |||
param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | |||
@@ -0,0 +1,10 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | |||
<mapper namespace="com.iformall.mapper.InviteCodeMapper"> | |||
<update id="addUseTotal"> | |||
UPDATE invite_code | |||
SET total = #{total} + 1 | |||
WHERE id = #{id} | |||
</update> | |||
</mapper> |