Merge remote-tracking branch 'origin/dev/dev' into dev/dev
This commit is contained in:
@@ -37,10 +37,15 @@ public class Generate {
|
||||
*/
|
||||
private String level1Type;
|
||||
|
||||
/**
|
||||
* 图片来源 collection | library
|
||||
*/
|
||||
private String elementSource;
|
||||
|
||||
/**
|
||||
* 关联collection element id
|
||||
*/
|
||||
private Long collectionElementId;
|
||||
private Long elementId;
|
||||
|
||||
/**
|
||||
* caption的内容
|
||||
|
||||
@@ -134,6 +134,6 @@ public interface CollectionElementService extends IService<CollectionElement> {
|
||||
* @param level2Type
|
||||
* @return
|
||||
*/
|
||||
CollectionElement editLevel2Type(Long elementId, String level2Type);
|
||||
CollectionElement editLevel2Type(Long elementId, String level2Type, String designType);
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
|
||||
import io.minio.errors.MinioException;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -806,15 +807,32 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionElement editLevel2Type(Long elementId, String level2Type) {
|
||||
CollectionElement collectionElement = null;
|
||||
public CollectionElement editLevel2Type(Long elementId, String level2Type, String designType) {
|
||||
CollectionElement collectionElement = new CollectionElement();
|
||||
|
||||
if (!Objects.isNull(elementId)) {
|
||||
collectionElement = collectionElementMapper.selectById(elementId);
|
||||
if (!Objects.isNull(collectionElement)) {
|
||||
if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) {
|
||||
collectionElement.setLevel2Type(level2Type);
|
||||
updateById(collectionElement);
|
||||
if (!StringUtil.isNullOrEmpty(designType)){
|
||||
switch (designType){
|
||||
case "collection":
|
||||
collectionElement = collectionElementMapper.selectById(elementId);
|
||||
if (StringUtil.isNullOrEmpty(collectionElement.getLevel2Type()) || !(collectionElement.getLevel2Type()).equals(level2Type)) {
|
||||
collectionElement.setLevel2Type(level2Type);
|
||||
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;
|
||||
|
||||
@@ -111,13 +111,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
generateType);
|
||||
generate.setModelName(StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getVersion()) ? ModelNameEnum.MODEL_0.getCode() : generateThroughImageTextDTO.getVersion());
|
||||
generate.setCreateDate(DateUtil.getByTimeZone(generateThroughImageTextDTO.getTimeZone()));
|
||||
generate.setElementSource(StringUtil.isNullOrEmpty(generateThroughImageTextDTO.getDesignType()) ? null : generateThroughImageTextDTO.getDesignType());
|
||||
|
||||
String text = generateThroughImageTextDTO.getText();
|
||||
Long elementId = generateThroughImageTextDTO.getCollectionElementId();
|
||||
validateGeneraType(generate, text, elementId, generateType);
|
||||
|
||||
// 2.1 sketch或print在t_collection_element表中的信息是否需要更新 如 level2Type
|
||||
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type());
|
||||
// 2.1 sketch或print在t_collection_element表/t_library表中的信息是否需要更新 如 level2Type
|
||||
CollectionElement collectionElement = collectionElementService.editLevel2Type(elementId, generateThroughImageTextDTO.getLevel2Type(), generateThroughImageTextDTO.getDesignType());
|
||||
|
||||
// 3、向模型发起请求
|
||||
int mode = GenerateModeEnum.TEXT.getValue().equals(generateType) ?
|
||||
@@ -180,14 +181,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
if (Objects.isNull(elementId)) {
|
||||
throw new BusinessException("please.choose.an.image");
|
||||
}
|
||||
generate.setCollectionElementId(elementId);
|
||||
generate.setElementId(elementId);
|
||||
break;
|
||||
case "text-image":
|
||||
if (StringUtil.isNullOrEmpty(text) || Objects.isNull(elementId)) {
|
||||
throw new BusinessException("please.input.the.caption.and.choose.an.image");
|
||||
}
|
||||
generate.setText(text);
|
||||
generate.setCollectionElementId(elementId);
|
||||
generate.setElementId(elementId);
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user