Merge remote-tracking branch 'origin/dev/dev' into dev/dev

This commit is contained in:
shahaibo
2024-04-09 13:58:37 +08:00
4 changed files with 37 additions and 13 deletions

View File

@@ -37,10 +37,15 @@ public class Generate {
*/ */
private String level1Type; private String level1Type;
/**
* 图片来源 collection | library
*/
private String elementSource;
/** /**
* 关联collection element id * 关联collection element id
*/ */
private Long collectionElementId; private Long elementId;
/** /**
* caption的内容 * caption的内容

View File

@@ -134,6 +134,6 @@ public interface CollectionElementService extends IService<CollectionElement> {
* @param level2Type * @param level2Type
* @return * @return
*/ */
CollectionElement editLevel2Type(Long elementId, String level2Type); CollectionElement editLevel2Type(Long elementId, String level2Type, String designType);
} }

View File

@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
import io.minio.errors.MinioException; import io.minio.errors.MinioException;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -806,15 +807,32 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
} }
@Override @Override
public CollectionElement editLevel2Type(Long elementId, String level2Type) { public CollectionElement editLevel2Type(Long elementId, String level2Type, String designType) {
CollectionElement collectionElement = null; CollectionElement collectionElement = new CollectionElement();
if (!Objects.isNull(elementId)) { if (!Objects.isNull(elementId)) {
if (!StringUtil.isNullOrEmpty(designType)){
switch (designType){
case "collection":
collectionElement = collectionElementMapper.selectById(elementId); collectionElement = collectionElementMapper.selectById(elementId);
if (!Objects.isNull(collectionElement)) {
if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) { if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) {
collectionElement.setLevel2Type(level2Type); collectionElement.setLevel2Type(level2Type);
updateById(collectionElement); updateById(collectionElement);
} }
break;
case "library":
Library libraryElement = libraryService.getById(elementId);
if (!Objects.isNull(libraryElement)) {
if (StringUtil.isNullOrEmpty(libraryElement.getLevel2Type()) || !(libraryElement.getLevel2Type()).equals(level2Type)){
libraryElement.setLevel2Type(level2Type);
libraryService.updateById(libraryElement);
}
BeanUtils.copyProperties(libraryElement,collectionElement);
}
break;
}
} else {
throw new BusinessException("element source type cannot be empty!");
} }
} }
return collectionElement; return collectionElement;

View File

@@ -111,13 +111,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
generateType); generateType);
generate.setModelName(StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) ? ModelNameEnum.MODEL_0.getCode() : generateThroughImageTextDTO.getVersion()); generate.setModelName(StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) ? ModelNameEnum.MODEL_0.getCode() : generateThroughImageTextDTO.getVersion());
generate.setCreateDate(DateUtil.getByTimeZone(generateThroughImageTextDTO.getTimeZone())); generate.setCreateDate(DateUtil.getByTimeZone(generateThroughImageTextDTO.getTimeZone()));
generate.setElementSource(StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getDesignType()) ? null : generateThroughImageTextDTO.getDesignType());
String text = generateThroughImageTextDTO.getText(); String text = generateThroughImageTextDTO.getText();
Long elementId = generateThroughImageTextDTO.getCollectionElementId(); Long elementId = generateThroughImageTextDTO.getCollectionElementId();
validateGeneraType(generate, text, elementId, generateType); validateGeneraType(generate, text, elementId, generateType);
// 2.1 sketch或print在t_collection_element表中的信息是否需要更新 如 level2Type // 2.1 sketch或print在t_collection_element表/t_library表中的信息是否需要更新 如 level2Type
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type()); CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType());
// 3、向模型发起请求 // 3、向模型发起请求
int mode = GenerateModeEnum.TEXT.getValue().equals(generateType) ? int mode = GenerateModeEnum.TEXT.getValue().equals(generateType) ?
@@ -180,14 +181,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
if (Objects.isNull(elementId)) { if (Objects.isNull(elementId)) {
throw new BusinessException("please.choose.an.image"); throw new BusinessException("please.choose.an.image");
} }
generate.setCollectionElementId(elementId); generate.setElementId(elementId);
break; break;
case "text-image": case "text-image":
if (StringUtil.isNullOrEmpty(text) || Objects.isNull(elementId)) { if (StringUtil.isNullOrEmpty(text) || Objects.isNull(elementId)) {
throw new BusinessException("please.input.the.caption.and.choose.an.image"); throw new BusinessException("please.input.the.caption.and.choose.an.image");
} }
generate.setText(text); generate.setText(text);
generate.setCollectionElementId(elementId); generate.setElementId(elementId);
default: default:
} }
} }