| @@ -64,4 +64,9 @@ public class BaseController { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| return IPUtil.getIpAddr(request); | return IPUtil.getIpAddr(request); | ||||
| } | } | ||||
| public Long getServiceId() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| return (Long) request.getAttribute(Constant.SERVICE_ID); | |||||
| } | |||||
| } | } | ||||
| @@ -1,13 +1,11 @@ | |||||
| package com.iformall.controller.ai; | package com.iformall.controller.ai; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| import com.iformall.controller.BaseController; | |||||
| import com.iformall.dto.GenerateVideoDTO; | import com.iformall.dto.GenerateVideoDTO; | ||||
| import com.iformall.dto.PreviewVideoDTO; | import com.iformall.dto.PreviewVideoDTO; | ||||
| import com.iformall.service.AiVideoService; | import com.iformall.service.AiVideoService; | ||||
| import com.iformall.sm.AiPreviewParam; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | import org.springframework.web.bind.annotation.PostMapping; | ||||
| @@ -18,13 +16,13 @@ import org.springframework.web.bind.annotation.RestController; | |||||
| @Api(tags = "视频相关api") | @Api(tags = "视频相关api") | ||||
| @RestController | @RestController | ||||
| @RequestMapping("/ai/video") | @RequestMapping("/ai/video") | ||||
| public class AiVideoController { | |||||
| public class AiVideoController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private AiVideoService aiVideoService; | private AiVideoService aiVideoService; | ||||
| @ApiOperation("预览") | @ApiOperation("预览") | ||||
| @PostMapping("/preview") | |||||
| @PostMapping("/previewVideo") | |||||
| public ResultData previewVideo(@RequestBody PreviewVideoDTO dto) { | public ResultData previewVideo(@RequestBody PreviewVideoDTO dto) { | ||||
| return new ResultData(aiVideoService.previewVideo(PreviewVideoDTO.mappingParam(dto))); | return new ResultData(aiVideoService.previewVideo(PreviewVideoDTO.mappingParam(dto))); | ||||
| } | } | ||||
| @@ -32,6 +30,6 @@ public class AiVideoController { | |||||
| @ApiOperation("生成视频") | @ApiOperation("生成视频") | ||||
| @PostMapping("generateVideo") | @PostMapping("generateVideo") | ||||
| public ResultData generateVideo(@RequestBody GenerateVideoDTO dto) { | public ResultData generateVideo(@RequestBody GenerateVideoDTO dto) { | ||||
| return new ResultData(aiVideoService.generateVideo(dto.getAiVideoParam(), dto.getId())); | |||||
| return new ResultData(aiVideoService.generateVideo(dto.getAiVideoParam(), dto.getId(), getServiceId())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -50,6 +50,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(apiConfig == null){ | if(apiConfig == null){ | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非法请求"); | throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非法请求"); | ||||
| } | } | ||||
| request.setAttribute(Constant.SERVICE_ID, apiConfig.getServiceId()); | |||||
| request.setAttribute(Constant.APP_Id, apiConfig.getAppId()); | request.setAttribute(Constant.APP_Id, apiConfig.getAppId()); | ||||
| request.setAttribute(Constant.TENANT_ID, apiConfig.getTenantId()); | request.setAttribute(Constant.TENANT_ID, apiConfig.getTenantId()); | ||||
| request.setAttribute(Constant.PARENT_TENANT_ID, apiConfig.getParentTenantId()); | request.setAttribute(Constant.PARENT_TENANT_ID, apiConfig.getParentTenantId()); | ||||
| @@ -77,7 +78,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(StringUtils.isBlank(timeStamp)){ | if(StringUtils.isBlank(timeStamp)){ | ||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少timeStamp"); | throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"缺少timeStamp"); | ||||
| } | } | ||||
| long timestampDate = Long.valueOf(timeStamp) + 1000*60*5;//五分钟有效 | |||||
| long timestampDate = Long.parseLong(timeStamp) + 1000*60*5;//五分钟有效 | |||||
| long currDate = System.currentTimeMillis(); | long currDate = System.currentTimeMillis(); | ||||
| // 请求过期 | // 请求过期 | ||||
| if (timestampDate < currDate) { | if (timestampDate < currDate) { | ||||
| @@ -85,9 +86,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| } | } | ||||
| for (String key:notKeys) { | for (String key:notKeys) { | ||||
| if(parameterMap.containsKey(key)){ | |||||
| parameterMap.remove(key); | |||||
| } | |||||
| parameterMap.remove(key); | |||||
| } | } | ||||
| String newSignature = SignUtils.getSign(apiConfig.getSignKey(), parameterMap, "MD5"); | String newSignature = SignUtils.getSign(apiConfig.getSignKey(), parameterMap, "MD5"); | ||||
| @@ -23,5 +23,5 @@ public interface AiVideoService { | |||||
| * @param aiVideoParam | * @param aiVideoParam | ||||
| * @return {@link AiVideoResult} | * @return {@link AiVideoResult} | ||||
| */ | */ | ||||
| AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long taskId); | |||||
| AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long taskId, Long serviceId); | |||||
| } | } | ||||
| @@ -1,12 +1,14 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.dto.neuver.SaveServiceVideoRecordDTO; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | import com.iformall.domain.po.sm.UserMouldVideo; | ||||
| import com.iformall.dto.GenerateVideoDTO; | import com.iformall.dto.GenerateVideoDTO; | ||||
| import com.iformall.dto.PreviewVideoDTO; | import com.iformall.dto.PreviewVideoDTO; | ||||
| import com.iformall.enums.EnumVideoStatus; | import com.iformall.enums.EnumVideoStatus; | ||||
| import com.iformall.exception.BizException; | import com.iformall.exception.BizException; | ||||
| import com.iformall.service.AiVideoService; | import com.iformall.service.AiVideoService; | ||||
| import com.iformall.service.sm.ServiceVideoRecordService; | |||||
| 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.*; | import com.iformall.sm.*; | ||||
| @@ -26,10 +28,10 @@ import java.util.Optional; | |||||
| @Service | @Service | ||||
| public class AiVideoServiceImpl implements AiVideoService { | public class AiVideoServiceImpl implements AiVideoService { | ||||
| @Autowired | |||||
| private VoiceInfoService voiceInfoService; | |||||
| @Autowired | @Autowired | ||||
| private UserMouldVideoService userMouldVideoService; | private UserMouldVideoService userMouldVideoService; | ||||
| @Autowired | |||||
| private ServiceVideoRecordService serviceVideoRecordService; | |||||
| @Override | @Override | ||||
| public AiPreviewResult previewVideo(AiPreviewParam aiPreviewParam) { | public AiPreviewResult previewVideo(AiPreviewParam aiPreviewParam) { | ||||
| @@ -37,7 +39,7 @@ public class AiVideoServiceImpl implements AiVideoService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long taskId) { | |||||
| public AiVideoResult generateVideo(AiVideoParam aiVideoParam, Long taskId, Long serviceId) { | |||||
| // // 参数校验 | // // 参数校验 | ||||
| // UserMouldVideo userMouldVideo = Optional.ofNullable(userMouldVideoService.getById(dto.getId())).orElseThrow(() -> new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未找到用户数据")); | // UserMouldVideo userMouldVideo = Optional.ofNullable(userMouldVideoService.getById(dto.getId())).orElseThrow(() -> new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未找到用户数据")); | ||||
| // if (StringUtils.isBlank(userMouldVideo.getPaperwork())) { | // if (StringUtils.isBlank(userMouldVideo.getPaperwork())) { | ||||
| @@ -60,6 +62,11 @@ public class AiVideoServiceImpl implements AiVideoService { | |||||
| AiVideoResult video = AiVideoHelper.createVideo(aiVideoParam, taskId); | AiVideoResult video = AiVideoHelper.createVideo(aiVideoParam, taskId); | ||||
| if (video.isSuccess()) { | if (video.isSuccess()) { | ||||
| // 记录时长 | // 记录时长 | ||||
| SaveServiceVideoRecordDTO dto = SaveServiceVideoRecordDTO.builder() | |||||
| .serviceId(serviceId) | |||||
| .videoTime(String.valueOf(video.getDuration())) | |||||
| .build(); | |||||
| serviceVideoRecordService.saveServiceVideoRecord(dto); | |||||
| } | } | ||||
| return video; | return video; | ||||
| } | } | ||||
| @@ -9,7 +9,7 @@ import lombok.Data; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| @ApiModel(value = "获取语种") | |||||
| @ApiModel(value = "新增接入商") | |||||
| @Data | @Data | ||||
| public class SaveServiceInfoDTO { | public class SaveServiceInfoDTO { | ||||
| @ApiModelProperty("客户名称") | @ApiModelProperty("客户名称") | ||||
| @@ -0,0 +1,30 @@ | |||||
| package com.iformall.domain.dto.neuver; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Builder; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @ApiModel(value = "新增生成视频时长记录") | |||||
| @Data | |||||
| @Builder | |||||
| public class SaveServiceVideoRecordDTO { | |||||
| @ApiModelProperty("接入商标识") | |||||
| private Long serviceId; | |||||
| @ApiModelProperty("视频时长") | |||||
| private String videoTime; | |||||
| public static ServiceVideoRecord mapping(SaveServiceVideoRecordDTO dto) { | |||||
| ServiceVideoRecord serviceVideoRecord = new ServiceVideoRecord(); | |||||
| serviceVideoRecord.setId(IdWorker.get().nextId()); | |||||
| serviceVideoRecord.setCreateTime(new Date()); | |||||
| serviceVideoRecord.setUpdateTime(new Date()); | |||||
| serviceVideoRecord.setServiceId(dto.getServiceId()); | |||||
| serviceVideoRecord.setVideoTime(dto.getVideoTime()); | |||||
| return serviceVideoRecord; | |||||
| } | |||||
| } | |||||
| @@ -2,6 +2,7 @@ package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| @@ -52,5 +53,8 @@ public class WxThirdPartyApi extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="tpId") | @io.swagger.annotations.ApiModelProperty(value="",name="tpId") | ||||
| private String tpId; | private String tpId; | ||||
| @ApiModelProperty("接入商id") | |||||
| private Long serviceId; | |||||
| } | } | ||||
| @@ -1,4 +1,15 @@ | |||||
| package com.iformall.service.sm; | package com.iformall.service.sm; | ||||
| import com.iformall.domain.dto.neuver.SaveServiceVideoRecordDTO; | |||||
| /** | |||||
| * @author xmzhao71 | |||||
| * @date 2023-10-20 | |||||
| */ | |||||
| public interface ServiceVideoRecordService { | public interface ServiceVideoRecordService { | ||||
| /** | |||||
| * @param dto | |||||
| */ | |||||
| void saveServiceVideoRecord(SaveServiceVideoRecordDTO dto); | |||||
| } | } | ||||
| @@ -1,8 +1,20 @@ | |||||
| package com.iformall.service.sm.impl; | package com.iformall.service.sm.impl; | ||||
| import com.iformall.domain.dto.neuver.SaveServiceVideoRecordDTO; | |||||
| import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
| import com.iformall.mapper.ServiceVideoRecordMapper; | |||||
| import com.iformall.service.sm.ServiceVideoRecordService; | import com.iformall.service.sm.ServiceVideoRecordService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @Service | @Service | ||||
| public class ServiceVideoRecordServiceImpl implements ServiceVideoRecordService { | public class ServiceVideoRecordServiceImpl implements ServiceVideoRecordService { | ||||
| @Autowired | |||||
| private ServiceVideoRecordMapper serviceVideoRecordMapper; | |||||
| @Override | |||||
| public void saveServiceVideoRecord(SaveServiceVideoRecordDTO dto) { | |||||
| serviceVideoRecordMapper.insert(SaveServiceVideoRecordDTO.mapping(dto)); | |||||
| } | |||||
| } | } | ||||
| @@ -69,7 +69,8 @@ public class Constant { | |||||
| public static final String APP_Id = "APP_Id"; | public static final String APP_Id = "APP_Id"; | ||||
| public static final String APP_NAME = "APP_NAME"; | public static final String APP_NAME = "APP_NAME"; | ||||
| public static final String APP_INFO = "APPINFO"; | public static final String APP_INFO = "APPINFO"; | ||||
| public static final String SERVICE_ID = "SERVICE_ID"; | |||||
| public static final String LOGIN_B_USER_KEY = "LOGIN_B_USER_KEY"; | public static final String LOGIN_B_USER_KEY = "LOGIN_B_USER_KEY"; | ||||