From f5e9062a5e1d201ebe2efa82d0be94fbd260987b Mon Sep 17 00:00:00 2001 From: twy <2301620162@qq.com> Date: Thu, 27 Jul 2023 18:20:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=97=E8=A1=A8=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5=E5=8F=8A=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=B5=81=E5=92=8C=E9=A2=84=E5=A4=84=E7=90=86md5?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserLiveController.java | 33 ++++++++++++++++++- .../com/iformall/domain/po/WxCVideoTable.java | 10 +++++- .../com/iformall/service/WxCVideoService.java | 2 +- .../service/impl/WxCVideoServiceImpl.java | 33 ++++++++++++++++++- .../main/resources/mapper/WxCVideoMapper.xml | 7 ++++ 5 files changed, 81 insertions(+), 4 deletions(-) diff --git a/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java b/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java index f2d5ce4..1487836 100644 --- a/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java +++ b/suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java @@ -200,7 +200,7 @@ public class UserLiveController extends BaseController { @AuthIgnore @PostMapping("/avatarList") @ApiOperation(value = "视频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") - public Map avatarList(@RequestBody Map params) { + public Map avatarList(@RequestBody Map params) throws Exception { Map avatarVos = new HashMap<>(); String ipaddress = getIpAddr(); logger.debug("[" + ipaddress + "] WxUserGrantController::getAvatarList"); @@ -209,6 +209,16 @@ public class UserLiveController extends BaseController { Long id = infoByPhone.getId(); System.out.println("id = " + id); + //鉴权 + WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); + if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { + HashMap status = new HashMap<>(); + status.put("code",ErrorCode.USER_ALREADY_LOGIN.getCode()); + status.put("message","用户已在其他设备登录"); + avatarVos.put("status",status); + return avatarVos; + } + Map status = new HashMap<>(); status.put("code",1000); status.put("msg","success"); @@ -229,6 +239,7 @@ public class UserLiveController extends BaseController { @PostMapping("/audioList") @ApiOperation(value = "音频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") public Map audioList(@RequestBody Map params) { + Map resultMap = new HashMap<>(); String ipaddress = getIpAddr(); logger.debug("[" + ipaddress + "] WxUserGrantController::getAudioList"); String phone = params.get("username"); @@ -237,6 +248,16 @@ public class UserLiveController extends BaseController { Long id = infoByPhone.getId(); System.out.println("id = " + id); + + WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); + if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { + HashMap status = new HashMap<>(); + status.put("code",ErrorCode.USER_ALREADY_LOGIN.getCode()); + status.put("message","用户已在其他设备登录"); + resultMap.put("status",status); + return resultMap; + } + // long id = getMemberId(); @@ -251,6 +272,7 @@ public class UserLiveController extends BaseController { @ApiOperation(value = "资源权限查询", notes = "{\"username\",\"string\",\"code\",\"string\",\"type\",\"int\",\"resource_id\",\"long\"}") @PostMapping("/author") public Map getAuthor(@RequestBody Map params) { + Map resultMap = new HashMap<>(); String ipaddress = getIpAddr(); logger.debug("[" + ipaddress + "] WxUserGrantController::getAuthor"); @@ -260,6 +282,15 @@ public class UserLiveController extends BaseController { Long id = infoByPhone.getId(); System.out.println("id = " + id); + WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); + if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { + HashMap status = new HashMap<>(); + status.put("code",ErrorCode.USER_ALREADY_LOGIN.getCode()); + status.put("message","用户已在其他设备登录"); + resultMap.put("status",status); + return resultMap; + } + //long id = getMemberId(); diff --git a/suimangService/src/main/java/com/iformall/domain/po/WxCVideoTable.java b/suimangService/src/main/java/com/iformall/domain/po/WxCVideoTable.java index 35749ba..710d3cb 100644 --- a/suimangService/src/main/java/com/iformall/domain/po/WxCVideoTable.java +++ b/suimangService/src/main/java/com/iformall/domain/po/WxCVideoTable.java @@ -28,6 +28,8 @@ public class WxCVideoTable extends TenantEntityWithoutFinalTenantId { @io.swagger.annotations.ApiModelProperty(value="数字人id",name="id") private int id; + @io.swagger.annotations.ApiModelProperty(value="套餐0共享 1定制",name="class") + private int classType; @io.swagger.annotations.ApiModelProperty(value="数字人名称",name="name") private String name; @@ -35,8 +37,14 @@ public class WxCVideoTable extends TenantEntityWithoutFinalTenantId { private String image; @io.swagger.annotations.ApiModelProperty(value="数字人样例视频链接",name="demo") private String demo; - @io.swagger.annotations.ApiModelProperty(value="数字人模板预处理信息文件链接",name="preInfo") + @io.swagger.annotations.ApiModelProperty(value="数字人样例视频链接",name="model") + private String model; + @io.swagger.annotations.ApiModelProperty(value="数字人模板预处理信息文件链接",name="preinfo") private String preInfo; + @io.swagger.annotations.ApiModelProperty(value="数字人模板预处理信息文件链接",name="model_path") + private String modelPath; + @io.swagger.annotations.ApiModelProperty(value="数字人模板预处理信息文件链接",name="preInfo_path") + private String preInfoPath; diff --git a/suimangService/src/main/java/com/iformall/service/WxCVideoService.java b/suimangService/src/main/java/com/iformall/service/WxCVideoService.java index 3e4a6d2..3fd48c1 100644 --- a/suimangService/src/main/java/com/iformall/service/WxCVideoService.java +++ b/suimangService/src/main/java/com/iformall/service/WxCVideoService.java @@ -8,7 +8,7 @@ import java.util.Map; public interface WxCVideoService { - Map getById(Long id); + Map getById(Long id) throws Exception; WxCVideoTable selectOne(Long id, long resource_id); } diff --git a/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java b/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java index e66ced3..8c5fd20 100644 --- a/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java +++ b/suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java @@ -7,6 +7,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.WxCUserBasicInfo; import com.iformall.domain.po.WxCVideoTable; import com.iformall.domain.vo.WxCUserBasicInfoVo; +import com.iformall.enums.EnumClassType; import com.iformall.mapper.WxCUserBasicInfoMapper; import com.iformall.mapper.WxCVideoMapper; import com.iformall.service.WxCUserTagsService; @@ -16,6 +17,11 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.math.BigInteger; +import java.security.MessageDigest; import java.util.*; import java.util.stream.Collectors; @@ -32,7 +38,7 @@ public class WxCVideoServiceImpl implements WxCVideoService,IExcelExportServer { @Autowired WxCVideoMapper wxCVideoMapper; @Override - public Map getById(Long id) { + public Map getById(Long id) throws Exception { System.out.println("id = " + id); List TemplateVideo = wxCVideoMapper.getById(id); @@ -52,8 +58,15 @@ public class WxCVideoServiceImpl implements WxCVideoService,IExcelExportServer { avatar.put("avatar_name",wxCVideoTable.getName()); avatar.put("avatar_image",wxCVideoTable.getImage()); avatar.put("avatar_demo",wxCVideoTable.getDemo()); + File modelFile = new File(wxCVideoTable.getModelPath()); + + avatar.put("avatar_demo_md5",getFileMD5(modelFile)); avatar.put("avatar_preinfo",wxCVideoTable.getPreInfo()); + + File preinfoFile = new File(wxCVideoTable.getPreInfoPath()); + avatar.put("avatar_preinfo_md5",getFileMD5(preinfoFile)); avatar.put("expire_time",wxCVideoTable.getExpireTime()); + avatar.put("class", wxCVideoTable.getClassType()); authorlist.add(avatar); data.put("authorlist",authorlist); } @@ -130,4 +143,22 @@ public class WxCVideoServiceImpl implements WxCVideoService,IExcelExportServer { } return null; } + + + + public static String getFileMD5(File file) throws Exception { + MessageDigest md = MessageDigest.getInstance("MD5"); + try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) { + byte[] buffer = new byte[1024]; + int read = 0; + while ((read = bis.read(buffer)) != -1) { + md.update(buffer, 0, read); + } + } + byte[] digest = md.digest(); + String md5 = String.format("%032x", new BigInteger(1, digest)); + return md5; + +} + } diff --git a/suimangService/src/main/resources/mapper/WxCVideoMapper.xml b/suimangService/src/main/resources/mapper/WxCVideoMapper.xml index bce9dd4..dd0e225 100644 --- a/suimangService/src/main/resources/mapper/WxCVideoMapper.xml +++ b/suimangService/src/main/resources/mapper/WxCVideoMapper.xml @@ -8,7 +8,11 @@ + + + + @@ -21,13 +25,16 @@ --> +