可令对口型
This commit is contained in:
50
yudao/module/tik/kling/KlingServiceImpl.java
Normal file
50
yudao/module/tik/kling/KlingServiceImpl.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.tik.kling;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.tik.kling.dto.KlingIdentifyFaceRequest;
|
||||
import cn.iocoder.yudao.module.tik.kling.dto.KlingIdentifyFaceResponse;
|
||||
import cn.iocoder.yudao.module.tik.kling.vo.KlingIdentifyFaceReqVO;
|
||||
import cn.iocoder.yudao.module.tik.kling.vo.KlingIdentifyFaceRespVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 可灵服务实现
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class KlingServiceImpl implements KlingService {
|
||||
|
||||
private final KlingClient klingClient;
|
||||
|
||||
@Override
|
||||
public KlingIdentifyFaceRespVO identifyFace(KlingIdentifyFaceReqVO reqVO) {
|
||||
// 转换请求对象
|
||||
KlingIdentifyFaceRequest request = BeanUtils.toBean(reqVO, KlingIdentifyFaceRequest.class);
|
||||
|
||||
// 调用302.ai API
|
||||
KlingIdentifyFaceResponse response = klingClient.identifyFace(request);
|
||||
|
||||
// 转换响应对象
|
||||
KlingIdentifyFaceRespVO respVO = new KlingIdentifyFaceRespVO();
|
||||
respVO.setSessionId(response.getData().getSessionId());
|
||||
|
||||
// 转换人脸数据列表
|
||||
if (response.getData().getFaceData() != null) {
|
||||
respVO.setFaceData(response.getData().getFaceData().stream()
|
||||
.map(face -> BeanUtils.toBean(face, KlingIdentifyFaceRespVO.FaceDataVO.class))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
log.info("[identify-face][识别完成][sessionId={}, faceCount={}]",
|
||||
respVO.getSessionId(),
|
||||
respVO.getFaceData() != null ? respVO.getFaceData().size() : 0);
|
||||
|
||||
return respVO;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user