| @@ -0,0 +1,47 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
| import com.iformall.dto.PageServiceVideoRecordDTO; | |||||
| import com.iformall.service.sm.ServiceInfoService; | |||||
| import com.iformall.service.sm.ServiceVideoRecordService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| /** | |||||
| * 数字人模板api | |||||
| * | |||||
| * @author xmzhao71 | |||||
| * @date 2023-10-17 | |||||
| */ | |||||
| @Api(tags = "接入方api") | |||||
| @RestController | |||||
| @RequestMapping("/api/serviceInfo") | |||||
| public class ApiServiceInfoController extends BaseController { | |||||
| @Autowired | |||||
| private ServiceInfoService serviceInfoService; | |||||
| @Autowired | |||||
| private ServiceVideoRecordService serviceVideoRecordService; | |||||
| @ApiOperation("当前接入方信息") | |||||
| @GetMapping("current") | |||||
| public ResultData pagePersonMould() { | |||||
| return new ResultData(serviceInfoService.getServiceInfo(getServiceId())); | |||||
| } | |||||
| @ApiOperation("当前接入方生成视频记录") | |||||
| @GetMapping("currentVideoRecords") | |||||
| public ResultData currentVideoRecords(PageServiceVideoRecordDTO dto) { | |||||
| ServiceVideoRecord svr = new ServiceVideoRecord(); | |||||
| svr.setServiceId(getServiceId()); | |||||
| return new ResultData(serviceVideoRecordService.listAsPage(svr, dto.getPageNum(), dto.getPageSize())); | |||||
| } | |||||
| } | |||||
| @@ -26,6 +26,8 @@ import com.iformall.service.MallUserInfoService; | |||||
| import com.iformall.service.sm.PersonMouldService; | import com.iformall.service.sm.PersonMouldService; | ||||
| import com.iformall.service.sm.ServiceInfoService; | import com.iformall.service.sm.ServiceInfoService; | ||||
| import com.iformall.service.sm.ServiceVideoRecordService; | import com.iformall.service.sm.ServiceVideoRecordService; | ||||
| import com.iformall.sm.AiVideoHelper; | |||||
| import com.iformall.smsdk.SmSdkUtils; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -164,7 +166,7 @@ public class ServiceInfoController extends MallUserInfoBaseController{ | |||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | @ApiVersion(group = SwaggerConstant.V_1_0_0) | ||||
| @ApiOperation("当前") | |||||
| @ApiOperation("当前视频生成记录") | |||||
| @GetMapping("/currentVideoRecords") | @GetMapping("/currentVideoRecords") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @@ -177,4 +179,31 @@ public class ServiceInfoController extends MallUserInfoBaseController{ | |||||
| PageInfo<ServiceVideoRecord> personMouldPage = serviceVideoRecordService.listAsPage(svr, pageNum, pageSize); | PageInfo<ServiceVideoRecord> personMouldPage = serviceVideoRecordService.listAsPage(svr, pageNum, pageSize); | ||||
| return new ResultData(personMouldPage); | return new ResultData(personMouldPage); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("私有化部署管理员当前") | |||||
| @GetMapping("/privateDeployAdminCurrent") | |||||
| public ResultData privateDeployAdminCurrent() { | |||||
| MallUserInfo user = this.getUser(); | |||||
| if (AiVideoHelper.localDeploy && user.checkAdmin()) { | |||||
| return new ResultData(SmSdkUtils.getCurrentServiceInfo()); | |||||
| }else { | |||||
| return new ResultData(Result.ERROR,"当前访问非法"); | |||||
| } | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||||
| @ApiOperation("私有化部署管理员当前视频生成记录") | |||||
| @GetMapping("/privateDeployAdminCurrentVideoRecords") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
| public ResultData privateDeployAdminCurrentVideoRecords(Integer pageNum, Integer pageSize) { | |||||
| MallUserInfo user = this.getUser(); | |||||
| if (AiVideoHelper.localDeploy && user.checkAdmin()) { | |||||
| return new ResultData(SmSdkUtils.currentVideoRecords(pageNum,pageSize)); | |||||
| }else { | |||||
| return new ResultData(Result.ERROR,"当前访问非法"); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -29,4 +29,14 @@ public interface SmSdkConstant { | |||||
| * 生成视频 | * 生成视频 | ||||
| */ | */ | ||||
| String GENERATE_VIDEO = "/api/video/generateVideo"; | String GENERATE_VIDEO = "/api/video/generateVideo"; | ||||
| /** | |||||
| * 当前接入方 | |||||
| */ | |||||
| String CURRENT_SERVICE_INFO = "/api/serviceInfo/current"; | |||||
| /** | |||||
| * 当前接入方生成视频记录 | |||||
| */ | |||||
| String CURRENT_SERVICE_VIDEO_RECORDS = "/api/serviceInfo/currentVideoRecords"; | |||||
| } | } | ||||
| @@ -2,6 +2,9 @@ package com.iformall.smsdk; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.sm.ServiceInfo; | |||||
| import com.iformall.domain.po.sm.ServiceVideoRecord; | |||||
| import com.iformall.sm.AiPreviewResult; | import com.iformall.sm.AiPreviewResult; | ||||
| import com.iformall.sm.AiVideoParam; | import com.iformall.sm.AiVideoParam; | ||||
| import com.iformall.sm.AiVideoResult; | import com.iformall.sm.AiVideoResult; | ||||
| @@ -55,4 +58,22 @@ public class SmSdkUtils { | |||||
| String data = resultObject.getString("data"); | String data = resultObject.getString("data"); | ||||
| return StringUtils.isNotBlank(data) ? JSON.parseObject(data, AiVideoResult.class) : new AiVideoResult(); | return StringUtils.isNotBlank(data) ? JSON.parseObject(data, AiVideoResult.class) : new AiVideoResult(); | ||||
| } | } | ||||
| public static ServiceInfo getCurrentServiceInfo() { | |||||
| String url = smSdkUtils.smSdkProperties.getBaseUrl() + SmSdkConstant.CURRENT_SERVICE_INFO; | |||||
| ResponseEntity<String> response = smSdkUtils.restTemplate.exchange(url, HttpMethod.GET, null, String.class); | |||||
| log.info("(遂芒api)【查询当前接入方】接口的响应数据:{}", JSON.toJSON(response.getBody())); | |||||
| JSONObject resultObject = JSON.parseObject(response.getBody()); | |||||
| String data = resultObject.getString("data"); | |||||
| return StringUtils.isNotBlank(data) ? JSON.parseObject(data, ServiceInfo.class) : new ServiceInfo(); | |||||
| } | |||||
| public static PageInfo<ServiceVideoRecord> currentVideoRecords(int pageNum,int pageSize) { | |||||
| String url = smSdkUtils.smSdkProperties.getBaseUrl() + SmSdkConstant.CURRENT_SERVICE_VIDEO_RECORDS+"?pageNum="+pageNum+"&pageSize="+pageSize; | |||||
| ResponseEntity<String> response = smSdkUtils.restTemplate.exchange(url, HttpMethod.GET, null, String.class); | |||||
| log.info("(遂芒api)【查询当前接入方】接口的响应数据:{}", JSON.toJSON(response.getBody())); | |||||
| JSONObject resultObject = JSON.parseObject(response.getBody()); | |||||
| String data = resultObject.getString("data"); | |||||
| return StringUtils.isNotBlank(data) ? JSON.parseObject(data, PageInfo.class) : new PageInfo<ServiceVideoRecord>(); | |||||
| } | |||||
| } | } | ||||