|
|
|
|
@@ -749,6 +749,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
if (Objects.isNull(toProductImageResult)) {
|
|
|
|
|
throw new BusinessException("The source image does not exist.");
|
|
|
|
|
}
|
|
|
|
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
|
|
|
|
if (Objects.isNull(toProductImageRecord)) {
|
|
|
|
|
throw new BusinessException("This task does not exist.");
|
|
|
|
|
}
|
|
|
|
|
// 判断当任务从哪个模型获取结果
|
|
|
|
|
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName()) && toProductImageResult.getModelName().equals("flux")){
|
|
|
|
|
Project project = projectService.getById(toProductImageResult.getProjectId());
|
|
|
|
|
@@ -766,7 +770,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
toProductImageResultMapper.updateById(toProductImageResult);
|
|
|
|
|
results.add(new MagicToolResultVO(taskId, fluxResult));
|
|
|
|
|
} else {
|
|
|
|
|
results.add(processFluxResult(fluxResult, toProductImageResult, taskId));
|
|
|
|
|
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
|
|
|
|
|
// 扣积分
|
|
|
|
|
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
|
|
|
|
|
if (flag) creditsService.updateChangedCredits(String.valueOf(project.getAccountId()), taskId);
|
|
|
|
|
@@ -786,6 +790,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
|
|
|
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
|
|
|
|
magicToolResultVO.setDirection(toProductImageResult.getDirection());
|
|
|
|
|
magicToolResultVO.setBrightenValue(toProductImageResult.getBrightenValue());
|
|
|
|
|
magicToolResultVO.setImageStrength(toProductImageResult.getImageStrength());
|
|
|
|
|
magicToolResultVO.setPrompt(toProductImageRecord.getPrompt());
|
|
|
|
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
|
|
|
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
|
|
|
|
@@ -845,12 +853,12 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MagicToolResultVO processFluxResult(String fluxImgMinioPath, ToProductImageResult toProductImageResult, String taskId){
|
|
|
|
|
private MagicToolResultVO processFluxResult(String fluxImgMinioPath, ToProductImageResult toProductImageResult, String taskId, String prompt){
|
|
|
|
|
toProductImageResult.setTaskStatus("Success");
|
|
|
|
|
toProductImageResult.setUrl(fluxImgMinioPath);
|
|
|
|
|
toProductImageResultMapper.updateById(toProductImageResult);
|
|
|
|
|
|
|
|
|
|
MagicToolResultVO magicToolResultVO = new MagicToolResultVO();
|
|
|
|
|
MagicToolResultVO magicToolResultVO = CopyUtil.copyObject(toProductImageResult, MagicToolResultVO.class);
|
|
|
|
|
magicToolResultVO.setTaskId(taskId);
|
|
|
|
|
magicToolResultVO.setId(toProductImageResult.getId());
|
|
|
|
|
magicToolResultVO.setUrl(minioUtil.getPreSignedUrl(fluxImgMinioPath, CommonConstant.MINIO_IMAGE_EXPIRE_TIME));
|
|
|
|
|
@@ -858,6 +866,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
magicToolResultVO.setResultType(toProductImageResult.getResultType());
|
|
|
|
|
magicToolResultVO.setElementId(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setElementType(toProductImageResult.getElementType());
|
|
|
|
|
magicToolResultVO.setPrompt(prompt);
|
|
|
|
|
|
|
|
|
|
if (toProductImageResult.getElementType().equals("ProductElement")) {
|
|
|
|
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
|
|
|
|
|
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
|
|
|
|
|
@@ -1266,6 +1276,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
if (Objects.isNull(toProductImageResult)) {
|
|
|
|
|
throw new BusinessException("The source image does not exist.");
|
|
|
|
|
}
|
|
|
|
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(toProductImageResult.getToProductImageRecordId());
|
|
|
|
|
if (Objects.isNull(toProductImageRecord)) {
|
|
|
|
|
throw new BusinessException("This task does not exist.");
|
|
|
|
|
}
|
|
|
|
|
// 判断当任务从哪个模型获取结果
|
|
|
|
|
if (!StringUtil.isNullOrEmpty(toProductImageResult.getModelName())
|
|
|
|
|
&& toProductImageResult.getModelName().equals("flux")){
|
|
|
|
|
@@ -1285,7 +1299,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
toProductImageResultMapper.updateById(toProductImageResult);
|
|
|
|
|
results.add(new MagicToolResultVO(taskId, fluxResult));
|
|
|
|
|
} else {
|
|
|
|
|
results.add(processFluxResult(fluxResult, toProductImageResult, taskId));
|
|
|
|
|
results.add(processFluxResult(fluxResult, toProductImageResult, taskId, toProductImageRecord.getPrompt()));
|
|
|
|
|
// 扣积分
|
|
|
|
|
Boolean flag = creditsService.taskCreditsDeduction(project.getAccountId(), taskId);
|
|
|
|
|
if (flag) creditsService.updateChangedCredits(String.valueOf(project.getAccountId()), taskId);
|
|
|
|
|
@@ -1297,6 +1311,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
MagicToolResultVO magicToolResultVO = new Gson().fromJson(redisUtil.getFromString(key), MagicToolResultVO.class);
|
|
|
|
|
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(magicToolResultVO.getUrl())) {
|
|
|
|
|
String url = magicToolResultVO.getUrl();
|
|
|
|
|
magicToolResultVO.setDirection(toProductImageResult.getDirection());
|
|
|
|
|
magicToolResultVO.setBrightenValue(toProductImageResult.getBrightenValue());
|
|
|
|
|
magicToolResultVO.setImageStrength(toProductImageResult.getImageStrength());
|
|
|
|
|
magicToolResultVO.setPrompt(toProductImageRecord.getPrompt());
|
|
|
|
|
if (url.substring(url.lastIndexOf("/") + 1).equals("white_image.jpg")) {
|
|
|
|
|
magicToolResultVO.setStatus("Invalid");
|
|
|
|
|
} else {
|
|
|
|
|
@@ -2096,6 +2114,11 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
ToProductImageResultVO vo = CopyUtil.copyObject(result, ToProductImageResultVO.class);
|
|
|
|
|
// 设置sourceUrl
|
|
|
|
|
setSourceUrl(vo);
|
|
|
|
|
// 设置prompt
|
|
|
|
|
ToProductImageRecord toProductImageRecord = toProductImageRecordMapper.selectById(result.getToProductImageRecordId());
|
|
|
|
|
if (Objects.nonNull(toProductImageRecord)){
|
|
|
|
|
vo.setPrompt(toProductImageRecord.getPrompt());
|
|
|
|
|
}
|
|
|
|
|
// 按isLike分类
|
|
|
|
|
if (result.getIsLike() != null && result.getIsLike() == 1) {
|
|
|
|
|
likedList.add(vo);
|
|
|
|
|
|