Parcourir la source

视频列表返回添加字段及模板流和预处理md5验证

private_deployment
谈文友 il y a 1 an
Parent
révision
f5e9062a5e
5 fichiers modifiés avec 81 ajouts et 4 suppressions
  1. +32
    -1
      suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java
  2. +9
    -1
      suimangService/src/main/java/com/iformall/domain/po/WxCVideoTable.java
  3. +1
    -1
      suimangService/src/main/java/com/iformall/service/WxCVideoService.java
  4. +32
    -1
      suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java
  5. +7
    -0
      suimangService/src/main/resources/mapper/WxCVideoMapper.xml

+ 32
- 1
suimangCApi/src/main/java/com/iformall/controller/UserLiveController.java Voir le fichier

@@ -200,7 +200,7 @@ public class UserLiveController extends BaseController {
@AuthIgnore
@PostMapping("/avatarList")
@ApiOperation(value = "视频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}")
public Map<String,Object> avatarList(@RequestBody Map<String, String> params) {
public Map<String,Object> avatarList(@RequestBody Map<String, String> params) throws Exception {
Map<String,Object> 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<Object, Object> status = new HashMap<>();
status.put("code",ErrorCode.USER_ALREADY_LOGIN.getCode());
status.put("message","用户已在其他设备登录");
avatarVos.put("status",status);
return avatarVos;
}

Map<Object, Object> 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<String,Object> audioList(@RequestBody Map<String, String> params) {
Map<String,Object> 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<Object, Object> 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<String,Object> getAuthor(@RequestBody Map<String, String> params) {
Map<String,Object> 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<Object, Object> status = new HashMap<>();
status.put("code",ErrorCode.USER_ALREADY_LOGIN.getCode());
status.put("message","用户已在其他设备登录");
resultMap.put("status",status);
return resultMap;
}


//long id = getMemberId();



+ 9
- 1
suimangService/src/main/java/com/iformall/domain/po/WxCVideoTable.java Voir le fichier

@@ -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;





+ 1
- 1
suimangService/src/main/java/com/iformall/service/WxCVideoService.java Voir le fichier

@@ -8,7 +8,7 @@ import java.util.Map;
public interface WxCVideoService {


Map<String,Object> getById(Long id);
Map<String,Object> getById(Long id) throws Exception;

WxCVideoTable selectOne(Long id, long resource_id);
}

+ 32
- 1
suimangService/src/main/java/com/iformall/service/impl/WxCVideoServiceImpl.java Voir le fichier

@@ -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<String,Object> getById(Long id) {
public Map<String,Object> getById(Long id) throws Exception {
System.out.println("id = " + id);

List<WxCVideoTable> 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;

}

}

+ 7
- 0
suimangService/src/main/resources/mapper/WxCVideoMapper.xml Voir le fichier

@@ -8,7 +8,11 @@
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="image" jdbcType="VARCHAR" property="image"/>
<result column="demo" jdbcType="VARCHAR" property="demo"/>
<result column="model" jdbcType="VARCHAR" property="model"/>
<result column="model_path" jdbcType="VARCHAR" property="modelPath"/>
<result column="class" jdbcType="VARCHAR" property="classType"/>
<result column="preinfo" jdbcType="VARCHAR" property="preInfo"/>
<result column="preinfo_path" jdbcType="VARCHAR" property="preInfoPath"/>
<result column="expire_time" jdbcType="VARCHAR" property="expireTime"/>

</resultMap>
@@ -21,13 +25,16 @@
</resultMap>-->
<select id="getById" resultMap="BaseResultMap">
SELECT wca.user_name,expire_time,wcav.id,wcav.name,wcav.image,wcav.model,wcav.preinfo,wcav.demo
,wcav.class,wcav.model_path,wcav.preinfo_path
from wx_c_author wca
left join wx_c_avatar wcav on wcav.id =wca.resource_id
where wca.resource_id
in (select wca.resource_id from wx_c_author wca WHERE wca.user_id =#{id} AND wca.type = 0 )
</select>

<select id="selectOne" resultType="com.iformall.domain.po.WxCVideoTable">
SELECT wca.user_name,expire_time,wcav.id,wcav.name,wcav.image,wcav.model,wcav.preinfo,wcav.demo
,wcav.class,wcav.model_path,wcav.preinfo_path
from wx_c_author wca
left join wx_c_avatar wcav on wcav.id =wca.resource_id
where wca.resource_id =#{resource_id} and wca.user_id = #{id}


Chargement…
Annuler
Enregistrer