Merge branch 'dev/dev' into dev/dev_xp

# Conflicts:
#	src/main/java/com/ai/da/service/impl/DesignServiceImpl.java
#	src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java
This commit is contained in:
2024-07-04 14:42:51 +08:00
29 changed files with 588 additions and 96 deletions

View File

@@ -37,4 +37,6 @@ public interface PortfolioService extends IService<Portfolio> {
Long viewsGet(Long id);
Boolean commentDelete(CommentDTO commentDTO);
Boolean delete(Long id);
}

View File

@@ -53,7 +53,7 @@ public interface UserLikeGroupService extends IService<UserLikeGroup> {
CanvasElementUpload canvasElementUpload(MultipartFile file);
List<ToProductImageResult> productImageLikeList(ToProductImageDTO toProductImageDTO);
List<ToProductImageResultVO> productImageLikeList(ToProductImageDTO toProductImageDTO);
Boolean productImageUnLike(ProductImageLikeDTO productImageLikeDTO);

View File

@@ -13,6 +13,7 @@ import com.ai.da.mapper.primary.entity.*;
import com.ai.da.model.dto.*;
import com.ai.da.model.enums.ModelType;
import com.ai.da.model.enums.Sex;
import com.ai.da.model.enums.StyleEnum;
import com.ai.da.model.vo.*;
import com.ai.da.python.PythonService;
import com.ai.da.python.vo.DesignPythonItem;
@@ -578,6 +579,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, byId.getHigh(), byId.getWidth(), byId.getUrl()));
} else if (designDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
SysFileVO byId = sysFileService.getById(designDTO.getTemplateId());
if (!StringUtils.isEmpty(byId.getLevel3Type()) && byId.getLevel2Type().equals("Female")) {
elementVO.setStyle(byId.getLevel3Type());
}
LibraryModelPoint modelPoint = libraryModelPointService.getByRelationId(byId.getId(), designDTO.getModelType());
elementVO.setDesignLibraryModelPoint(calculateTemplatePointTemplate(modelPoint, 700, 320, byId.getUrl()));
}
@@ -664,6 +668,9 @@ public class CollectionElementServiceImpl extends ServiceImpl<CollectionElementM
Generate byId = generateService.getById(o.getGenerateId());
d.setAccountId(byId.getAccountId());
d.setLevel1Type(byId.getLevel1Type());
if (!StringUtils.isEmpty(byId.getLevel2Type())) {
d.setLevel2Type(byId.getLevel2Type());
}
d.setCreateDate(Date.from(o.getCreateDate().atZone(ZoneId.systemDefault()).toInstant()));
if (null != idToMap) {
DesignCollectionPrintElementDTO printDTO = idToMap.get(o.getId());

View File

@@ -997,7 +997,7 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
.collect(Collectors.toList());
response.setClothes(CopyUtil.copyList(filterDetail, DesignItemClothesDetailVO.class, (o, d) -> {
d.setId(o.getId());
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60));
d.setPath(minioUtil.getPreSignedUrl(o.getPath(), 24 * 60, true));
d.setMinIOPath(o.getPath());
d.setLevel1Type(converTypeToLevel1(o.getType()));
d.setGradient(JSONObject.parseObject(o.getGradientString(), Gradient.class));

View File

@@ -278,6 +278,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
path = "models/" + libraryUploadDTO.getModelSex().toLowerCase();
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
String newFilePath = processMannequins(filePath);
// String newFilePath = filePath;
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());

View File

@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import sun.security.krb5.internal.crypto.Des;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -94,10 +95,33 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
@Resource
private AccountMapper accountMapper;
@Resource
private WorkspaceMapper workspaceMapper;
@Resource
private SysFileMapper sysFileMapper;
@Resource
private LibraryMapper libraryMapper;
@Resource
private StyleMapper styleMapper;
@Resource
private WorkspaceRelStyleMapper workspaceRelStyleMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean publish(MultipartFile file, String data) {
PortfolioDTO portfolioDTO = JSONObject.parseObject(data, PortfolioDTO.class);
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
PortfolioDTO portfolioDTO = JSONObject.parseObject(data, PortfolioDTO.class);
QueryWrapper<Portfolio> existSameNameQw = new QueryWrapper<>();
existSameNameQw.lambda().eq(Portfolio::getPortfolioName, portfolioDTO.getPortfolioName());
existSameNameQw.lambda().eq(Portfolio::getAccountId, authPrincipalVo.getId());
List<Portfolio> portfoliosSameName = portfolioMapper.selectList(existSameNameQw);
if (!CollectionUtils.isEmpty(portfoliosSameName)) {
throw new BusinessException("The title of the published work has been used.");
}
if (file != null && file.getOriginalFilename() != null) {
String upload = minioUtil.upload("aida-canvas", String.valueOf(authPrincipalVo.getId()), file);
Canvas canvas = new Canvas();
@@ -108,14 +132,21 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (portfolioDTO.getOpenSource() == 1) {
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
userLikeGroupNew.setId(null);
userLikeGroupNew.setAccountId(-1L);
Long collectionIdOld = userLikeGroup.getCollectionId();
QueryWrapper<Design> designQueryWrapper = new QueryWrapper<>();
designQueryWrapper.lambda().eq(Design::getCollectionId, collectionIdOld);
Design designOld = designMapper.selectOne(designQueryWrapper);
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
List<CollectionElement> collectionElementListOld = collectionElementService.getByCollectionId(collectionIdOld);
collectionOld.setId(null);
collectionMapper.insert(collectionOld);
Long collectionIdNew = collectionOld.getId();
designOld.setCollectionId(collectionIdNew);
designOld.setId(null);
designMapper.insert(designOld);
userLikeGroupNew.setCollectionId(collectionIdNew);
userLikeGroupMapper.insert(userLikeGroupNew);
for (CollectionElement element : collectionElementListOld) {
@@ -135,6 +166,14 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (!CollectionUtils.isEmpty(portfolios)) {
portfolio = portfolios.get(0);
}
if (userLikeGroup.getOriginal() == 0) {
portfolio.setOriginal(0);
portfolio.setOriginalAccountId(userLikeGroup.getOriginalAccountId());
portfolio.setOriginalPortfolioId(userLikeGroup.getOriginalPortfolioId());
}else {
portfolio.setOriginal(1);
// portfolio.setOriginalAccountId(authPrincipalVo.getId());
}
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
portfolio.setPortfolioType("History");
portfolio.setCollectionId(collectionIdNew);
@@ -154,17 +193,12 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
}
List<UserLike> userLikeList = userLikeService.getUserLikeList(portfolioDTO.getUserLikeGroupId());
// Long coverIdNew = null;
// Boolean flag = false;
for (UserLike userLike : userLikeList) {
Long designOutfitIdOld = userLike.getDesignOutfitId();
TDesignPythonOutfit designPythonOutfit = designPythonOutfitMapper.selectById(designOutfitIdOld);
designPythonOutfit.setDesignId(-1L);
designPythonOutfit.setDesignItemId(-1L);
designPythonOutfit.setCollectionId(collectionIdNew);
// if (designPythonOutfit.getId().equals(coverIdOld)) {
// flag = true;
// }
designPythonOutfit.setId(null);
Long designItemIdOld = userLike.getDesignItemId();
DesignItem designItemOld = designItemMapper.selectById(designItemIdOld);
@@ -183,21 +217,12 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
qw.lambda().eq(TDesignPythonOutfitDetail::getDesignPythonOutfitId, designOutfitIdOld);
List<TDesignPythonOutfitDetail> tDesignPythonOutfitDetails = designPythonOutfitDetailMapper.selectList(qw);
for (TDesignPythonOutfitDetail tDesignPythonOutfitDetail : tDesignPythonOutfitDetails) {
// Long designPythonOutfitDetailIdOld = tDesignPythonOutfitDetail.getId();
tDesignPythonOutfitDetail.setId(null);
tDesignPythonOutfitDetail.setDesignId(-1L);
tDesignPythonOutfitDetail.setDesignPythonOutfitId(designOutfitIdNew);
designPythonOutfitDetailMapper.insert(tDesignPythonOutfitDetail);
}
// if (flag) {
// coverIdNew = designOutfitIdNew;
// portfolio.setCoverId(coverIdNew);
// portfolioMapper.updateById(portfolio);
// flag = false;
// }
// designPythonOutfitMapper.updateById(designPythonOutfit);
userLike.setDesignItemId(designItemIdNew);
userLike.setId(null);
userLike.setDesignId(-1L);
@@ -232,6 +257,15 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (!CollectionUtils.isEmpty(portfolios)) {
portfolio = portfolios.get(0);
}
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
if (userLikeGroup.getOriginal() == 0) {
portfolio.setOriginal(0);
portfolio.setOriginalAccountId(userLikeGroup.getOriginalAccountId());
portfolio.setOriginalPortfolioId(userLikeGroup.getOriginalPortfolioId());
}else {
portfolio.setOriginal(1);
// portfolio.setOriginalAccountId(authPrincipalVo.getId());
}
portfolio.setPortfolioName(portfolioDTO.getPortfolioName());
portfolio.setPortfolioType("Canvas");
portfolio.setAccountId(authPrincipalVo.getId());
@@ -256,9 +290,18 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
}
@Override
@Transactional(rollbackFor = Exception.class)
public PortfolioVO update(PortfolioDTO portfolioDTO) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
QueryWrapper<Portfolio> existSameNameQw = new QueryWrapper<>();
existSameNameQw.lambda().ne(Portfolio::getId, portfolioDTO.getId());
existSameNameQw.lambda().eq(Portfolio::getPortfolioName, portfolioDTO.getPortfolioName());
existSameNameQw.lambda().eq(Portfolio::getAccountId, authPrincipalVo.getId());
List<Portfolio> portfoliosSameName = portfolioMapper.selectList(existSameNameQw);
if (!CollectionUtils.isEmpty(portfoliosSameName)) {
throw new BusinessException("The title of the published work has been used.");
}
if (portfolioDTO.getPortfolioType().equals("History")) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById(portfolioDTO.getUserLikeGroupId());
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
userLikeGroupNew.setAccountId(-1L);
@@ -396,6 +439,11 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
vo.setViewNums(redisUtil.getViewCount(vo.getId()));
Long accountId = vo.getAccountId();
vo.setUserName(accountMapper.selectById(accountId).getUserName());
if (vo.getOriginal() == 0) {
vo.setOriginalUserName(accountMapper.selectById(vo.getOriginalAccountId()).getUserName());
}
return vo;
}
return null;
@@ -429,15 +477,23 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
Canvas canvas = canvasMapper.selectById(vo.getCanvasId());
vo.setCanvasUrl(minioUtil.getPreSignedUrl(canvas.getUrl(), 24 * 60));
vo.setLikeNum(redisUtil.getLikeCount(vo.getId()));
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), userHolder.getId());
if (postLikedByUser) {
vo.setIsLike(1);
}else {
if (userHolder == null) {
vo.setIsLike(0);
}else {
boolean postLikedByUser = redisUtil.isPostLikedByUser(portfolioDTO.getId(), userHolder.getId());
if (postLikedByUser) {
vo.setIsLike(1);
}else {
vo.setIsLike(0);
}
}
redisUtil.increaseViewCount(portfolioDTO.getId());
vo.setViewNums(redisUtil.getViewCount(portfolioDTO.getId()));
vo.setUserName(accountMapper.selectById(vo.getAccountId()).getUserName());
if (vo.getOriginal() == 0) {
vo.setOriginalUserName(accountMapper.selectById(vo.getOriginalAccountId()).getUserName());
vo.setOriginalPortfolioName(portfolioMapper.selectById(vo.getOriginalPortfolioId()).getPortfolioName());
}
return vo;
}
@@ -453,8 +509,22 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
if (Objects.isNull(userLikeGroup)) {
throw new BusinessException("");
}
// UserLikeGroup userLikeGroup = userLikeGroupMapper.selectById();
UserLikeGroup userLikeGroupNew = userLikeGroup.setId(null);
UserLikeGroup userLikeGroupNew = CopyUtil.copyObject(userLikeGroup, UserLikeGroup.class);
userLikeGroupNew.setId(null);
userLikeGroupNew.setCreateDate(new Date());
if (portfolio.getOriginal() == 1) {
if (Objects.equals(portfolio.getAccountId(), authPrincipalVo.getId())) {
userLikeGroupNew.setOriginal(1);
}else {
userLikeGroupNew.setOriginal(0);
userLikeGroupNew.setOriginalAccountId(portfolio.getAccountId());
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
}
}else {
userLikeGroupNew.setOriginal(0);
userLikeGroupNew.setOriginalAccountId(portfolio.getOriginalAccountId());
userLikeGroupNew.setOriginalPortfolioId(portfolio.getId());
}
userLikeGroupNew.setAccountId(authPrincipalVo.getId());
Long collectionIdOld = userLikeGroup.getCollectionId();
Collection collectionOld = collectionMapper.selectById(collectionIdOld);
@@ -486,6 +556,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
designMapper.insert(design);
userLikeGroupNew.setCollectionId(collectionIdNew);
userLikeGroupNew.setUpdateDate(new Date());
userLikeGroupMapper.insert(userLikeGroupNew);
// List<TCollectionElementRelation> collectionElementRelationListNew = new ArrayList<>();
for (CollectionElement element : collectionElementListOld) {
@@ -563,6 +634,117 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
}
}
Long collectionId = portfolio.getCollectionId();
QueryWrapper<Design> getWorkspaceQw = new QueryWrapper<>();
getWorkspaceQw.lambda().eq(Design::getCollectionId, collectionId);
List<Design> designs = designMapper.selectList(getWorkspaceQw);
if (!CollectionUtils.isEmpty(designs)) {
Design design1 = designs.get(0);
Long accountId = authPrincipalVo.getId();
QueryWrapper<Workspace> currentWorkspaceQw = new QueryWrapper<>();
currentWorkspaceQw.lambda().eq(Workspace::getAccountId, accountId);
currentWorkspaceQw.lambda().eq(Workspace::getIsLastIndex, 1);
List<Workspace> workspaces = workspaceMapper.selectList(currentWorkspaceQw);
if (!CollectionUtils.isEmpty(workspaces)) {
Workspace workspace1 = workspaces.get(0);
workspace1.setIsLastIndex(0);
workspaceMapper.updateById(workspace1);
Workspace workspaceNew = new Workspace();
workspaceNew.setWorkSpaceName("workspace of " + portfolio.getPortfolioName());
workspaceNew.setAccountId(accountId);
workspaceNew.setIsDeleted(0);
workspaceNew.setIsLastIndex(1);
workspaceNew.setCreateTime(LocalDateTime.now());
workspaceNew.setSystemDesignerPercentage((design1.getSystemScale().multiply(BigDecimal.valueOf(100)).intValue()));
if (design1.getSingleOverall().equals("overall")) {
workspaceNew.setPosition("Overall");
}else {
workspaceNew.setPosition(design1.getSwitchCategory());
}
workspaceMapper.insert(workspaceNew);
if (design1.getModelType().equals("System")) {
SysFile sysFile = sysFileMapper.selectById(design1.getTemplateId());
if (sysFile.getLevel2Type().equals("Female")) {
workspaceNew.setSex("Female");
workspaceNew.setMannequinFemaleId(design1.getTemplateId());
workspaceNew.setMannequinFemaleType("System");
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
Style style = styleMapper.selectOne(styleQueryWrapper);
WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
workspaceRelStyle.setStyleId(style.getId());
workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
workspaceRelStyleMapper.insert(workspaceRelStyle);
}
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
if (!CollectionUtils.isEmpty(anotherList)) {
SysFile anotherOne = anotherList.get(0);
workspaceNew.setMannequinMaleId(anotherOne.getId());
workspaceNew.setMannequinMaleType("System");
}
}else {
workspaceNew.setSex("Male");
workspaceNew.setMannequinMaleId(design1.getTemplateId());
workspaceNew.setMannequinMaleType("System");
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
if (!StringUtils.isEmpty(sysFile.getLevel3Type())) {
getAnotherOneQw.lambda().eq(SysFile::getLevel3Type, sysFile.getLevel3Type());
QueryWrapper<Style> styleQueryWrapper = new QueryWrapper<>();
styleQueryWrapper.lambda().eq(Style::getName, sysFile.getLevel3Type());
Style style = styleMapper.selectOne(styleQueryWrapper);
WorkspaceRelStyle workspaceRelStyle = new WorkspaceRelStyle();
workspaceRelStyle.setStyleId(style.getId());
workspaceRelStyle.setWorkspaceId(workspaceNew.getId());
workspaceRelStyleMapper.insert(workspaceRelStyle);
}
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
if (!CollectionUtils.isEmpty(anotherList)) {
SysFile anotherOne = anotherList.get(0);
workspaceNew.setMannequinFemaleId(anotherOne.getId());
workspaceNew.setMannequinFemaleType("System");
}
}
}else {
Library library = libraryMapper.selectById(design1.getTemplateId());
if (library.getLevel2Type().equals("Female")) {
workspaceNew.setSex("Female");
workspaceNew.setMannequinFemaleId(design1.getTemplateId());
workspaceNew.setMannequinFemaleType("Library");
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Male");
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
if (!CollectionUtils.isEmpty(anotherList)) {
SysFile anotherOne = anotherList.get(0);
workspaceNew.setMannequinMaleId(anotherOne.getId());
workspaceNew.setMannequinMaleType("System");
}
}else {
workspaceNew.setSex("Male");
workspaceNew.setMannequinMaleId(design1.getTemplateId());
workspaceNew.setMannequinMaleType("Library");
QueryWrapper<SysFile> getAnotherOneQw = new QueryWrapper<>();
getAnotherOneQw.lambda().eq(SysFile::getLevel1Type, "Models");
getAnotherOneQw.lambda().eq(SysFile::getLevel2Type, "Female");
List<SysFile> anotherList = sysFileMapper.selectList(getAnotherOneQw);
if (!CollectionUtils.isEmpty(anotherList)) {
SysFile anotherOne = anotherList.get(0);
workspaceNew.setMannequinFemaleId(anotherOne.getId());
workspaceNew.setMannequinFemaleType("System");
}
}
}
workspaceMapper.updateById(workspaceNew);
}
}
return userLikeGroupService.choose(userLikeGroupNew.getId());
}
@@ -641,8 +823,11 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
Long id = commentDTO.getId();
Portfolio portfolio = portfolioMapper.selectById(commentDTO.getPortfolioId());
Comment comment = commentMapper.selectById(id);
if (!Objects.equals(comment.getAccountId(), commentDTO.getAccountId()) || !Objects.equals(portfolio.getAccountId(), commentDTO.getAccountId())) {
throw new BusinessException("You do not have the permission to delete this comment");
AuthPrincipalVo userHolder = UserContext.getUserHolder();
if (!Objects.equals(portfolio.getAccountId(), userHolder.getId())) {
if (!Objects.equals(comment.getAccountId(), userHolder.getId())) {
throw new BusinessException("You do not have the permission to delete this comment");
}
}
// 删除主评论
commentMapper.deleteById(id);
@@ -657,6 +842,17 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
return Boolean.TRUE;
}
@Override
public Boolean delete(Long id) {
AuthPrincipalVo userHolder = UserContext.getUserHolder();
Portfolio portfolio = portfolioMapper.selectById(id);
if (!Objects.equals(portfolio.getAccountId(), userHolder.getId())) {
throw new BusinessException("You do not have the permission to delete portfolio.");
}
portfolioMapper.deleteById(id);
return Boolean.TRUE;
}
private List<CommentVO> getChildCommentVOList(Long id) {
QueryWrapper<Comment> qw = new QueryWrapper<>();
qw.lambda().eq(Comment::getParentLevel1Id, id);

View File

@@ -243,14 +243,18 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// 翻译
String prompt = toProductImageDTO.getPrompt();
String s = "";
if (!StringUtil.isNullOrEmpty(prompt)) s = pythonService.promptTranslate(prompt);
if (!StringUtil.isNullOrEmpty(prompt)) {
s = pythonService.promptTranslate(prompt);
}else {
s = "best quality, masterpiece. detailed, high-res, simple background, studio photography, extremely detailed, updo, detailed face, face, close-up, HDR, UHD, 8K realistic, Highly detailed, simple background, Studio lighting";
}
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
String taskId;
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, s);
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, s, toProductImageDTO.getImageStrength());
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
toProductImageResult.setElementType("DesignOutfit");
@@ -267,7 +271,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(toProductElement.getUrl(), taskId, s);
pythonService.toProductImage(toProductElement.getUrl(), taskId, s, toProductImageDTO.getImageStrength());
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductElement.getId());
toProductImageResult.setElementType("ProductElement");
@@ -348,12 +352,13 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (Objects.isNull(toProductImageResult)) {
throw new BusinessException("The source image does not exist.");
}
magicToolResultVO.setResultType(toProductImageResult.getResultType());
if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));
}else {
UserLike userLike = userLikeMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(userLike.getUrl(), 24 * 60));
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
}
}
} else if (Objects.isNull(magicToolResultVO)) {
@@ -407,7 +412,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
}
@Override
public List<ToProductImageResult> productImageLikeList(ToProductImageDTO toProductImageDTO) {
public List<ToProductImageResultVO> productImageLikeList(ToProductImageDTO toProductImageDTO) {
QueryWrapper<ToProductImageResult> qw = new QueryWrapper<>();
qw.lambda().eq(ToProductImageResult::getIsLike, 1);
qw.lambda().eq(ToProductImageResult::getUserLikeGroupId, toProductImageDTO.getUserLikeGroupId());
@@ -415,7 +420,20 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
for (ToProductImageResult toProductImageResult : toProductImageResults) {
toProductImageResult.setUrl(minioUtil.getPreSignedUrl(toProductImageResult.getUrl(), 24 * 60));
}
return toProductImageResults;
List<ToProductImageResultVO> toProductImageResultVOS = CopyUtil.copyList(toProductImageResults, ToProductImageResultVO.class);
for (ToProductImageResultVO toProductImageResultVO : toProductImageResultVOS) {
if (toProductImageResultVO.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductElement.getUrl(), 24 * 60));
}else if ((toProductImageResultVO.getElementType().equals("DesignOutfit"))) {
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(tDesignPythonOutfit.getDesignUrl(), 24 * 60));
}else {
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageResultVO.getElementId());
toProductImageResultVO.setSourceUrl(minioUtil.getPresignedUrl(toProductImageResult1.getUrl(), 24 * 60));
}
}
return toProductImageResultVOS;
}
@Override
@@ -447,17 +465,22 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
int i = 0;
// 翻译
String prompt = toProductImageDTO.getPrompt();
String s = pythonService.promptTranslate(prompt);
String s = "";
if (!StringUtil.isNullOrEmpty(prompt)) {
s = pythonService.promptTranslate(prompt);
}else {
s = "Snow moutain, snowy day, natural light";
}
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
if (toProductImageVO.getElementType().equals("ProductImage")) {
if (toProductImageVO.getElementType().equals("ToProductImage")) {
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
i ++;
ToProductImageResult toProductImageResult1 = toProductImageResultMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(toProductImageResult1.getUrl(), taskId, s);
pythonService.relight(toProductImageResult1.getUrl(), taskId, s, toProductImageDTO.getDirection());
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductImageResult1.getId());
toProductImageResult.setElementType("ProductImage");
toProductImageResult.setElementType("ToProductImage");
toProductImageResult.setCreateTime(LocalDateTime.now());
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
// toProductImageResult.setUrl(productImageUrl);
@@ -471,7 +494,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(toProductElement.getUrl(), taskId, s);
pythonService.relight(toProductElement.getUrl(), taskId, s, toProductImageDTO.getDirection());
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductElement.getId());
toProductImageResult.setElementType("ProductElement");
@@ -494,7 +517,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
List<MagicToolResultVO> results = new ArrayList<>();
Set<String> collect = new HashSet<>();
taskIdList.forEach(taskId -> {
String key = toProductImageResultKey + ":" + taskId;
String key = relightResultKey + ":" + taskId;
MagicToolResultVO magicToolResultVO = new Gson().fromJson(redisUtil.getFromString(key), MagicToolResultVO.class);
if (!Objects.isNull(magicToolResultVO) && !StringUtil.isNullOrEmpty(magicToolResultVO.getUrl())) {
String url = magicToolResultVO.getUrl();
@@ -508,6 +531,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
if (Objects.isNull(toProductImageResult)) {
throw new BusinessException("The source image does not exist.");
}
magicToolResultVO.setResultType(toProductImageResult.getResultType());
if (toProductImageResult.getElementType().equals("ProductElement")) {
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageResult.getElementId());
magicToolResultVO.setSourceUrl(minioUtil.getPreSignedUrl(toProductElement.getUrl(), 24 * 60));