|
|
|
|
@@ -463,7 +463,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
}
|
|
|
|
|
taskId = generateService.flux(CreditsEventsEnum.TO_PRODUCT_IMAGE_FLUX, sb.toString(), tDesignPythonOutfit.getDesignUrl(), childFlag);
|
|
|
|
|
toProductImageResult.setModelName("flux");
|
|
|
|
|
toProductImageResult.setResultType("ToProductImage");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
// 走模型
|
|
|
|
|
if (childFlag){
|
|
|
|
|
@@ -485,12 +485,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
|
|
|
|
}
|
|
|
|
|
toProductImageResult.setImageStrength(toProductImageDTO.getImageStrength());
|
|
|
|
|
toProductImageResult.setResultType("ToProductImage");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
|
|
|
|
toProductImageResultMapper.insert(toProductImageResult);
|
|
|
|
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
|
|
|
|
result.add(toProductImageResult);
|
|
|
|
|
// 满足条件情况下默认添加到like
|
|
|
|
|
addToProductLike(toProductImageDTO, toProductImageResult.getId());
|
|
|
|
|
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
|
|
|
|
// 重新排序
|
|
|
|
|
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), toProductImageVO.getParentId());
|
|
|
|
|
}else {
|
|
|
|
|
if (StringUtils.isEmpty(prompt)) {
|
|
|
|
|
sb.append(",high quality clothing details,8K realistic,HDR");
|
|
|
|
|
@@ -505,7 +507,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
if (fluxTask){
|
|
|
|
|
taskId = generateService.flux(creditsEventsEnum, sb.toString(), toProductElement.getUrl(), childFlag);
|
|
|
|
|
toProductImageResult.setModelName("flux");
|
|
|
|
|
toProductImageResult.setResultType("ToProductImage");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
// 走模型
|
|
|
|
|
if (childFlag){
|
|
|
|
|
@@ -527,12 +529,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
toProductImageResult.setUserLikeGroupId(userLikeGroupId);
|
|
|
|
|
}
|
|
|
|
|
toProductImageResult.setImageStrength(toProductImageDTO.getImageStrength());
|
|
|
|
|
toProductImageResult.setResultType("ToProductImage");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.TO_PRODUCT_IMAGE.getValue());
|
|
|
|
|
toProductImageResultMapper.insert(toProductImageResult);
|
|
|
|
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
|
|
|
|
result.add(toProductImageResult);
|
|
|
|
|
// 满足条件情况下默认添加到like
|
|
|
|
|
addToProductLike(toProductImageDTO, toProductImageResult.getId());
|
|
|
|
|
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
|
|
|
|
// 重新排序
|
|
|
|
|
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue(), toProductImageVO.getParentId());
|
|
|
|
|
}
|
|
|
|
|
i ++;
|
|
|
|
|
sb = new StringBuilder("The best quality, masterpiece, real image.");
|
|
|
|
|
@@ -544,14 +548,59 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addToProductLike(ToProductImageDTO toProductImageDTO, Long toProductImageResultId){
|
|
|
|
|
if (Objects.nonNull(toProductImageDTO.getUserLikeSortId())
|
|
|
|
|
&& !toProductImageDTO.getUserLikeSortId().equals(0L)){
|
|
|
|
|
private void addToProductLike(Long parentId, Long toProductImageResultId, Long projectId){
|
|
|
|
|
if (Objects.nonNull(parentId)
|
|
|
|
|
&& !parentId.equals(0L)){
|
|
|
|
|
productImageLike(new ProductImageLikeDTO(Collections.singletonList(toProductImageResultId),
|
|
|
|
|
toProductImageDTO.getProjectId(), toProductImageDTO.getUserLikeSortId()));
|
|
|
|
|
projectId, parentId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void reArrangeSort(Long projectId, Long generateResultId, String relationType, Long parentId) {
|
|
|
|
|
// 1. 处理子集排序
|
|
|
|
|
rearrangeChildSort(generateResultId, parentId, relationType);
|
|
|
|
|
// 2. 处理父级排序
|
|
|
|
|
rearrangeParentSort(projectId, parentId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rearrangeChildSort(Long childId, Long parentId, String relationType) {
|
|
|
|
|
if (Objects.isNull(childId)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
CollectionSort child = collectionSortMapper.selectOne(new QueryWrapper<CollectionSort>().eq("relation_id", childId));
|
|
|
|
|
if (child == null || !child.getRelationType().equals(relationType)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (child.getSort() == 1) {
|
|
|
|
|
return; // 已经是第一位,无需处理
|
|
|
|
|
}
|
|
|
|
|
// 更新其他子集的排序
|
|
|
|
|
if (!"Design".equals(relationType)) {
|
|
|
|
|
collectionSortMapper.increaseGenerateSortBelow(parentId, relationType, child.getSort());
|
|
|
|
|
}
|
|
|
|
|
// 更新当前子集为第一位
|
|
|
|
|
child.setSort(1);
|
|
|
|
|
child.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
collectionSortMapper.updateById(child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rearrangeParentSort(Long projectId, Long parentId) {
|
|
|
|
|
CollectionSort parent = collectionSortMapper.selectById(parentId);
|
|
|
|
|
if (parent == null || !"Design".equals(parent.getRelationType())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (parent.getSort() == 1) {
|
|
|
|
|
return; // 已经是第一位,无需处理
|
|
|
|
|
}
|
|
|
|
|
// 更新其他父级的排序
|
|
|
|
|
collectionSortMapper.increaseDesignSortBelow(projectId, "Design", parent.getSort());
|
|
|
|
|
// 更新当前父级为第一位
|
|
|
|
|
parent.setSort(1);
|
|
|
|
|
parent.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
collectionSortMapper.updateById(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void toProduct(String taskId) {
|
|
|
|
|
@@ -940,7 +989,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
ToProductImageResult toProductImageResult = toProductImageResultMapper.selectById(toProductImageId);
|
|
|
|
|
toProductImageResult.setIsLike(0);
|
|
|
|
|
toProductImageResultMapper.updateById(toProductImageResult);
|
|
|
|
|
if (toProductImageResult.getResultType().equals("Relight")) {
|
|
|
|
|
if (toProductImageResult.getResultType().equals(CollectionType.RELIGHT.getValue())) {
|
|
|
|
|
if (null != productImageLikeDTO.getCollectionSortParentId()) {
|
|
|
|
|
designService.deleteCollectionSort(toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), productImageLikeDTO.getProjectId(), productImageLikeDTO.getCollectionSortParentId());
|
|
|
|
|
}
|
|
|
|
|
@@ -1063,7 +1112,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
if (fluxTask){
|
|
|
|
|
taskId = generateService.flux(creditsEventsEnum, s, toProductImageResult1.getUrl(), false);
|
|
|
|
|
toProductImageResult.setModelName("flux");
|
|
|
|
|
toProductImageResult.setResultType("Relight");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
// 走模型
|
|
|
|
|
pythonService.relight(toProductImageResult1.getUrl(), taskId, s, toProductImageDTO.getDirection(), relightType);
|
|
|
|
|
@@ -1083,19 +1132,21 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
|
|
|
|
}
|
|
|
|
|
toProductImageResult.setDirection(toProductImageDTO.getDirection());
|
|
|
|
|
toProductImageResult.setResultType("Relight");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
|
|
|
|
|
toProductImageResultMapper.insert(toProductImageResult);
|
|
|
|
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
|
|
|
|
result.add(toProductImageResult);
|
|
|
|
|
// 满足条件情况下默认添加到like
|
|
|
|
|
addToProductLike(toProductImageDTO, toProductImageResult.getId());
|
|
|
|
|
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
|
|
|
|
// 重新排序
|
|
|
|
|
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageVO.getParentId());
|
|
|
|
|
}else {
|
|
|
|
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
|
|
|
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
|
|
|
|
if (fluxTask){
|
|
|
|
|
taskId = generateService.flux(CreditsEventsEnum.RELIGHT_FLUX, s, toProductElement.getUrl(), false);
|
|
|
|
|
toProductImageResult.setModelName("flux");
|
|
|
|
|
toProductImageResult.setResultType("Relight");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
// 走模型
|
|
|
|
|
pythonService.relight(toProductElement.getUrl(), taskId, s, toProductImageDTO.getDirection(), "overall");
|
|
|
|
|
@@ -1115,12 +1166,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|
|
|
|
toProductImageResult.setBrightenValue(toProductImageDTO.getBrightenValue());
|
|
|
|
|
}
|
|
|
|
|
toProductImageResult.setDirection(toProductImageDTO.getDirection());
|
|
|
|
|
toProductImageResult.setResultType("Relight");
|
|
|
|
|
toProductImageResult.setResultType(CollectionType.RELIGHT.getValue());
|
|
|
|
|
toProductImageResultMapper.insert(toProductImageResult);
|
|
|
|
|
// toProductImageResult.setUrl(minioUtil.getPresignedUrl(toProductImageResult.getUrl(), 24 * 60));
|
|
|
|
|
result.add(toProductImageResult);
|
|
|
|
|
// 满足条件情况下默认添加到like
|
|
|
|
|
addToProductLike(toProductImageDTO, toProductImageResult.getId());
|
|
|
|
|
addToProductLike(toProductImageVO.getParentId(), toProductImageResult.getId(), toProductImageDTO.getProjectId());
|
|
|
|
|
// 重新排序
|
|
|
|
|
reArrangeSort(projectId, toProductImageResult.getId(), CollectionType.RELIGHT.getValue(), toProductImageVO.getParentId());
|
|
|
|
|
}
|
|
|
|
|
// 添加需要扣除的积分到预扣除区
|
|
|
|
|
creditsService.addRecordToCreditsDeduction(userHolder.getId(), taskId, creditsEventsEnum);
|
|
|
|
|
|