| @@ -32,7 +32,6 @@ public class AiVideoController { | |||||
| @ApiOperation("生成视频") | @ApiOperation("生成视频") | ||||
| @PostMapping("generateVideo") | @PostMapping("generateVideo") | ||||
| public ResultData generateVideo(@RequestBody GenerateVideoDTO dto) { | public ResultData generateVideo(@RequestBody GenerateVideoDTO dto) { | ||||
| aiVideoService.generateVideo(dto); | |||||
| return new ResultData(); | |||||
| return new ResultData(aiVideoService.generateVideo(dto.getAiVideoParam(), dto.getId())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.dto; | package com.iformall.dto; | ||||
| import com.iformall.sm.AiVideoParam; | |||||
| import io.swagger.annotations.ApiModel; | import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| @@ -9,4 +10,14 @@ import lombok.Data; | |||||
| public class GenerateVideoDTO { | public class GenerateVideoDTO { | ||||
| @ApiModelProperty(value = "视频唯一标识") | @ApiModelProperty(value = "视频唯一标识") | ||||
| private Long id; | private Long id; | ||||
| @ApiModelProperty(value = "生成视频参数") | |||||
| private AiVideoParam aiVideoParam; | |||||
| public static GenerateVideoDTO build(AiVideoParam aiVideoParam, Long id) { | |||||
| GenerateVideoDTO dto = new GenerateVideoDTO(); | |||||
| dto.setId(id); | |||||
| dto.setAiVideoParam(aiVideoParam); | |||||
| return dto; | |||||
| } | |||||
| } | } | ||||
| @@ -3,6 +3,8 @@ package com.iformall.service; | |||||
| import com.iformall.dto.GenerateVideoDTO; | import com.iformall.dto.GenerateVideoDTO; | ||||
| import com.iformall.dto.PreviewVideoDTO; | import com.iformall.dto.PreviewVideoDTO; | ||||
| import com.iformall.sm.AiPreviewParam; | import com.iformall.sm.AiPreviewParam; | ||||
| import com.iformall.sm.AiVideoParam; | |||||
| import com.iformall.sm.AiVideoResult; | |||||
| /** | /** | ||||
| * ai视频服务 | * ai视频服务 | ||||
| @@ -13,10 +15,12 @@ import com.iformall.sm.AiPreviewParam; | |||||
| public interface AiVideoService { | public interface AiVideoService { | ||||
| Double previewVideo(PreviewVideoDTO dto); | Double previewVideo(PreviewVideoDTO dto); | ||||
| /** | /** | ||||
| * 生成视频 | * 生成视频 | ||||
| * | * | ||||
| * @param dto | |||||
| * @param aiVideoParam | |||||
| * @return {@link AiVideoResult} | |||||
| */ | */ | ||||
| void generateVideo(GenerateVideoDTO dto); | |||||
| AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long taskId); | |||||
| } | } | ||||
| @@ -9,6 +9,9 @@ import com.iformall.exception.BizException; | |||||
| import com.iformall.service.AiVideoService; | import com.iformall.service.AiVideoService; | ||||
| import com.iformall.service.sm.UserMouldVideoService; | import com.iformall.service.sm.UserMouldVideoService; | ||||
| import com.iformall.service.sm.VoiceInfoService; | import com.iformall.service.sm.VoiceInfoService; | ||||
| import com.iformall.sm.AiVideoHelper; | |||||
| import com.iformall.sm.AiVideoParam; | |||||
| import com.iformall.sm.AiVideoResult; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -36,25 +39,31 @@ public class AiVideoServiceImpl implements AiVideoService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void generateVideo(GenerateVideoDTO dto) { | |||||
| // 参数校验 | |||||
| UserMouldVideo userMouldVideo = Optional.ofNullable(userMouldVideoService.getById(dto.getId())).orElseThrow(() -> new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未找到用户数据")); | |||||
| if (StringUtils.isBlank(userMouldVideo.getPaperwork())) { | |||||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未填写视频文案"); | |||||
| } | |||||
| if (EnumVideoStatus.ing.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
| || EnumVideoStatus.success.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
| || EnumVideoStatus.upload_ing.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
| || EnumVideoStatus.upload_fail.getCode().equals(userMouldVideo.getVideoStatus())) { | |||||
| throw new BizException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "视频生成中"); | |||||
| } | |||||
| if (EnumVideoStatus.upload_success.getCode().equals(userMouldVideo.getVideoStatus())) { | |||||
| throw new BizException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "视频已生成完成"); | |||||
| } | |||||
| public AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long taskId) { | |||||
| // // 参数校验 | |||||
| // UserMouldVideo userMouldVideo = Optional.ofNullable(userMouldVideoService.getById(dto.getId())).orElseThrow(() -> new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未找到用户数据")); | |||||
| // if (StringUtils.isBlank(userMouldVideo.getPaperwork())) { | |||||
| // throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未填写视频文案"); | |||||
| // } | |||||
| // if (EnumVideoStatus.ing.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
| // || EnumVideoStatus.success.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
| // || EnumVideoStatus.upload_ing.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
| // || EnumVideoStatus.upload_fail.getCode().equals(userMouldVideo.getVideoStatus())) { | |||||
| // throw new BizException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "视频生成中"); | |||||
| // } | |||||
| // if (EnumVideoStatus.upload_success.getCode().equals(userMouldVideo.getVideoStatus())) { | |||||
| // throw new BizException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "视频已生成完成"); | |||||
| // } | |||||
| // | |||||
| // // 更新视频信息 | |||||
| // updateUserMouldVideo(userMouldVideo); | |||||
| // userMouldVideoService.createVideo(userMouldVideo); | |||||
| // 更新视频信息 | |||||
| updateUserMouldVideo(userMouldVideo); | |||||
| userMouldVideoService.createVideo(userMouldVideo); | |||||
| AiVideoResult video = AiVideoHelper.createVideo(aiVideoParam, taskId); | |||||
| if (video.isSuccess()) { | |||||
| // 记录时长 | |||||
| } | |||||
| return video; | |||||
| } | } | ||||
| private void updateUserMouldVideo(UserMouldVideo userMouldVideo) { | private void updateUserMouldVideo(UserMouldVideo userMouldVideo) { | ||||
| @@ -0,0 +1,15 @@ | |||||
| package com.iformall.common; | |||||
| public interface CommonConstant { | |||||
| /** | |||||
| * 状态(0:锁定,1:正常) | |||||
| */ | |||||
| Integer STATUS_NORMAL = 1; | |||||
| Integer STATUS_ABNORMAL = 0; | |||||
| /** | |||||
| * 删除状态(0:未删除,1:已删除) | |||||
| */ | |||||
| Integer DEL_FLAG_DELETED = 1; | |||||
| Integer DEL_FLAG_NORMAL = 0; | |||||
| } | |||||
| @@ -0,0 +1,36 @@ | |||||
| package com.iformall.domain.dto.neuver; | |||||
| import com.iformall.common.CommonConstant; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.sm.ServiceInfo; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @ApiModel(value = "获取语种") | |||||
| @Data | |||||
| public class SaveServiceInfoDTO { | |||||
| @ApiModelProperty("客户名称") | |||||
| private String name; | |||||
| @ApiModelProperty("所在地址") | |||||
| private String address; | |||||
| @ApiModelProperty("客户唯一凭证,api接入需提供") | |||||
| private String code; | |||||
| @ApiModelProperty("接入方式(1:api接入,2:私有化接入)") | |||||
| private Integer type; | |||||
| public static ServiceInfo mapping(SaveServiceInfoDTO dto) { | |||||
| ServiceInfo serviceInfo = new ServiceInfo(); | |||||
| serviceInfo.setId(IdWorker.get().nextId()); | |||||
| serviceInfo.setCreateTime(new Date()); | |||||
| serviceInfo.setUpdateTime(new Date()); | |||||
| serviceInfo.setName(dto.getName()); | |||||
| serviceInfo.setAddress(dto.getAddress()); | |||||
| serviceInfo.setCode(dto.getCode()); | |||||
| serviceInfo.setType(dto.getType()); | |||||
| serviceInfo.setStatus(CommonConstant.STATUS_NORMAL); | |||||
| return serviceInfo; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,66 @@ | |||||
| package com.iformall.domain.po.sm; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.util.Date; | |||||
| /** | |||||
| * 接入商实体 | |||||
| * | |||||
| * @author xmzhao71 | |||||
| * @date 2023-10-19 | |||||
| */ | |||||
| @TableName(value = "service_info") | |||||
| @Data | |||||
| public class ServiceInfo { | |||||
| /** | |||||
| * 接入商id,唯一标识 | |||||
| */ | |||||
| @TableField("id") | |||||
| private Long id; | |||||
| /** | |||||
| * 创建时间 | |||||
| */ | |||||
| @TableField("create_time") | |||||
| private Date createTime; | |||||
| /** | |||||
| * 更新时间 | |||||
| */ | |||||
| @TableField("update_time") | |||||
| private Date updateTime; | |||||
| /** | |||||
| * 客户名称 | |||||
| */ | |||||
| @TableField("name") | |||||
| private String name; | |||||
| /** | |||||
| * 所在地址 | |||||
| */ | |||||
| @TableField("address") | |||||
| private String address; | |||||
| /** | |||||
| * 客户唯一凭证,api接入需提供 | |||||
| */ | |||||
| @TableField("code") | |||||
| private String code; | |||||
| /** | |||||
| * 接入方式(1:api接入,2:私有化接入) | |||||
| */ | |||||
| @TableField("type") | |||||
| private Integer type; | |||||
| /** | |||||
| * 状态(0:锁定,1:正常) | |||||
| */ | |||||
| @TableField("status") | |||||
| private Integer status; | |||||
| /** | |||||
| * 删除状态(0:未删除,1:已删除) | |||||
| */ | |||||
| @TableField("del_flag") | |||||
| private Integer delFlag; | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.domain.po.sm; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| /** | |||||
| * @author xmzhao71 | |||||
| * @date 2023-10-19 | |||||
| */ | |||||
| @TableName(value = "service_video_record") | |||||
| @Data | |||||
| public class ServiceVideoRecord { | |||||
| /** | |||||
| * 主键id | |||||
| */ | |||||
| @TableField("id") | |||||
| private Long id; | |||||
| /** | |||||
| * 创建时间 | |||||
| */ | |||||
| @TableField("create_time") | |||||
| private Date createTime; | |||||
| /** | |||||
| * 更新时间 | |||||
| */ | |||||
| @TableField("update_time") | |||||
| private Date updateTime; | |||||
| /** | |||||
| * 接入商标识 | |||||
| */ | |||||
| @TableField("service_id") | |||||
| private Long serviceId; | |||||
| /** | |||||
| * 视频时长 | |||||
| */ | |||||
| @TableField("video_time") | |||||
| private String videoTime; | |||||
| } | |||||
| @@ -0,0 +1,7 @@ | |||||
| package com.iformall.domain.vo.neuver; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class PageServiceInfoVO { | |||||
| } | |||||
| @@ -0,0 +1,7 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.sm.ServiceInfo; | |||||
| public interface ServiceInfoMapper extends CommonMapper<ServiceInfo, Long> { | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.sm.ServiceInfo; | |||||
| import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
| public interface ServiceVideoRecordMapper extends CommonMapper<ServiceVideoRecord, Long> { | |||||
| } | |||||
| @@ -0,0 +1,30 @@ | |||||
| package com.iformall.service.sm; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.dto.neuver.SaveServiceInfoDTO; | |||||
| import com.iformall.domain.vo.neuver.PageServiceInfoVO; | |||||
| /** | |||||
| * 接入商service | |||||
| * | |||||
| * @author xmzhao71 | |||||
| * @date 2023-10-19 | |||||
| */ | |||||
| public interface ServiceInfoService { | |||||
| /** | |||||
| * 创建接入商 | |||||
| * | |||||
| * @param dto | |||||
| */ | |||||
| void saveServiceInfo(SaveServiceInfoDTO dto); | |||||
| /** | |||||
| * 接入商分页查询 | |||||
| * | |||||
| * @param pageNum | |||||
| * @param pageSize | |||||
| * @return {@link PageInfo}<{@link PageServiceInfoVO}> | |||||
| */ | |||||
| PageInfo<PageServiceInfoVO> pageServiceInfo(Integer pageNum, Integer pageSize); | |||||
| } | |||||
| @@ -0,0 +1,4 @@ | |||||
| package com.iformall.service.sm; | |||||
| public interface ServiceVideoRecordService { | |||||
| } | |||||
| @@ -0,0 +1,40 @@ | |||||
| package com.iformall.service.sm.impl; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.CommonConstant; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.dto.neuver.SaveServiceInfoDTO; | |||||
| import com.iformall.domain.po.sm.ServiceInfo; | |||||
| import com.iformall.domain.vo.neuver.PageServiceInfoVO; | |||||
| import com.iformall.exception.BizException; | |||||
| import com.iformall.mapper.ServiceInfoMapper; | |||||
| import com.iformall.service.sm.ServiceInfoService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Optional; | |||||
| @Service | |||||
| public class ServiceInfoServiceImpl implements ServiceInfoService { | |||||
| @Autowired | |||||
| private ServiceInfoMapper serviceInfoMapper; | |||||
| @Override | |||||
| public void saveServiceInfo(SaveServiceInfoDTO dto) { | |||||
| // 校验 | |||||
| ServiceInfo serviceInfo = serviceInfoMapper.selectOne(new LambdaQueryWrapper<ServiceInfo>() | |||||
| .eq(ServiceInfo::getDelFlag, CommonConstant.DEL_FLAG_NORMAL) | |||||
| .eq(ServiceInfo::getCode, dto.getCode())); | |||||
| Optional.ofNullable(serviceInfo).orElseThrow(() -> new BizException(ErrorCode.CODE_ALREADY_EXISTS)); | |||||
| serviceInfoMapper.insert(SaveServiceInfoDTO.mapping(dto)); | |||||
| } | |||||
| @Override | |||||
| public PageInfo<PageServiceInfoVO> pageServiceInfo(Integer pageNum, Integer pageSize) { | |||||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> serviceInfoMapper.selectList(null)); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| package com.iformall.service.sm.impl; | |||||
| import com.iformall.service.sm.ServiceVideoRecordService; | |||||
| import org.springframework.stereotype.Service; | |||||
| @Service | |||||
| public class ServiceVideoRecordServiceImpl implements ServiceVideoRecordService { | |||||
| } | |||||