TASK:aida;

This commit is contained in:
shahaibo
2024-06-20 10:27:28 +08:00
parent 1f0439c7f9
commit ad1fa0e4c2
11 changed files with 215 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import com.ai.da.common.utils.MinioUtil;
import com.ai.da.common.utils.SendEmailUtil;
import com.ai.da.mapper.primary.*;
import com.ai.da.mapper.primary.entity.*;
import com.ai.da.mapper.secondary.AttributeRetrievalMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Row;
@@ -17,10 +18,13 @@ import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -205,4 +209,32 @@ public class MyTaskScheduler {
// }
// }
}
@Resource
private AttributeRetrievalMapper attributeRetrievalMapper;
public void addSystemFileStyle() {
String directoryPath = "C:\\Users\\10233\\Downloads\\blouse done\\blouse done\\废土风";
List<String> fileNames = getFileNames(directoryPath);
for (String fileName : fileNames) {
}
}
public static List<String> getFileNames(String directoryPath) {
List<String> fileNames = new ArrayList<>();
Path path = Paths.get(directoryPath);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
for (Path entry : stream) {
if (Files.isRegularFile(entry)) {
fileNames.add(entry.getFileName().toString());
}
}
} catch (IOException e) {
System.err.println("Error reading directory: " + e.getMessage());
}
return fileNames;
}
}

View File

@@ -49,7 +49,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
"/api/third/party/addNoLoginRequiredNew","/api/third/party/deleteNoLoginRequiredNew",
"/api/third/party/existNoLoginRequired","/api/third/party/getRedirectUrl",
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
"/api/portfolio/page", "/api/portfolio/detail",
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
"/api/account/designWorksRegister"
);

View File

@@ -200,4 +200,17 @@ public class RedisUtil {
Boolean isMember = redisTemplate.opsForSet().isMember(key, userId.toString());
return isMember != null && isMember;
}
public final static String PORTFOLIO_VIEW_KEY = "portfolio:view:";
public void increaseViewCount(Long portfolioId) {
String key = PORTFOLIO_VIEW_KEY + portfolioId;
redisTemplate.opsForValue().increment(key);
}
public Long getViewCount(Long portfolioId) {
String key = PORTFOLIO_VIEW_KEY + portfolioId;
return redisTemplate.opsForValue().increment(key, 0);
}
}

View File

@@ -93,4 +93,16 @@ public class PortfolioController {
public Response<PageBaseResponse<CommentVO>> commentPage(@Valid @RequestBody CommentPageDTO commentPageDTO) {
return Response.success(portfolioService.commentPage(commentPageDTO));
}
@ApiOperation(value = "增加浏览量")
@GetMapping("/viewsIncrease")
public Response<Boolean> viewsIncrease(@RequestParam("id") Long id) {
return Response.success(portfolioService.viewsIncrease(id));
}
@ApiOperation(value = "浏览量获取")
@GetMapping("/viewsGet")
public Response<Long> viewsGet(@RequestParam("id") Long id) {
return Response.success(portfolioService.viewsGet(id));
}
}

View File

@@ -0,0 +1,120 @@
package com.ai.da.model.enums;
import java.util.*;
public class StyleKeywordMapper {
private static final Map<StyleEnum, Map<String, List<String>>> styleCategoryKeywords = new HashMap<>();
static {
Map<String, List<String>> neoChineseKeywords = new HashMap<>();
neoChineseKeywords.put("Moodboard", Arrays.asList("New Chinese"));
neoChineseKeywords.put("Printboard", Arrays.asList("New Chinese", "traditional Chinese patterns", "dragons and phoenixes", "longevity peaches", "cloud patterns"));
neoChineseKeywords.put("Sketchboard", Arrays.asList("New Chinese", "blouse", "bow tie", "stand-up collars", "cross collars", "Chinese buttons"));
Map<String, List<String>> countryStyleKeywords = new HashMap<>();
countryStyleKeywords.put("Moodboard", Arrays.asList("Pastoral style"));
countryStyleKeywords.put("Printboard", Arrays.asList("fresh and natural feeling", "floral"));
countryStyleKeywords.put("Sketchboard", Arrays.asList("soft and comfortable", "chiffon", "cotton"));
Map<String, List<String>> futurismKeywords = new HashMap<>();
futurismKeywords.put("Moodboard", Arrays.asList("high-tech", "luminous"));
futurismKeywords.put("Printboard", Arrays.asList("geometric patterns", "lines and structured designs", "silver", "gold", "copper"));
futurismKeywords.put("Sketchboard", Arrays.asList("high tech", "exaggerated cutting", "three-dimensional design"));
Map<String, List<String>> minimalistKeywords = new HashMap<>();
minimalistKeywords.put("Moodboard", Arrays.asList("Minimalist style"));
minimalistKeywords.put("Printboard", Arrays.asList("Minimalist black and white"));
minimalistKeywords.put("Sketchboard", Arrays.asList("soft and breathable"));
Map<String, List<String>> lolitaKeywords = new HashMap<>();
lolitaKeywords.put("Moodboard", Arrays.asList("Lolita style"));
lolitaKeywords.put("Printboard", Arrays.asList("gentle", "cute", "elegant", "floral print"));
lolitaKeywords.put("Sketchboard", Arrays.asList("Layered skirts", "puff sleeves", "bows"));
Map<String, List<String>> y2kKeywords = new HashMap<>();
y2kKeywords.put("Moodboard", Arrays.asList("Y2K Style"));
y2kKeywords.put("Printboard", Arrays.asList("highly saturated colors", "glossy fabrics", "reflective fabrics"));
y2kKeywords.put("Sketchboard", Arrays.asList("low-waist miniskirts"));
Map<String, List<String>> businessKeywords = new HashMap<>();
businessKeywords.put("Moodboard", Arrays.asList("Business-style"));
businessKeywords.put("Printboard", Arrays.asList("colors are mostly black", "white", "gray", "dark blue", "brown", "neutral tones"));
businessKeywords.put("Sketchboard", Arrays.asList("simple and smooth lines"));
Map<String, List<String>> merladKeywords = new HashMap<>();
merladKeywords.put("Moodboard", Arrays.asList("Maillard Style"));
merladKeywords.put("Printboard", Arrays.asList("colors of Maillard-style clothing are mainly brown", "matched with tan", "reddish brown", "yellowish brown", "leopard print", "plaid"));
merladKeywords.put("Sketchboard", Arrays.asList("wide shoulder design", "extra-long cuts"));
Map<String, List<String>> outdoorFunctionalKeywords = new HashMap<>();
outdoorFunctionalKeywords.put("Moodboard", Arrays.asList("outdoor functional"));
outdoorFunctionalKeywords.put("Printboard", Arrays.asList("Simple"));
outdoorFunctionalKeywords.put("Sketchboard", Arrays.asList("multiple pocket designs"));
Map<String, List<String>> rockKeywords = new HashMap<>();
rockKeywords.put("Moodboard", Arrays.asList("rock-style"));
rockKeywords.put("Printboard", Arrays.asList("printed patterns include skulls", "flames", "music elements", "rock culture symbols"));
rockKeywords.put("Sketchboard", Arrays.asList("Leather"));
Map<String, List<String>> dopamineKeywords = new HashMap<>();
dopamineKeywords.put("Moodboard", Arrays.asList("dopamine-style"));
dopamineKeywords.put("Printboard", Arrays.asList("bright and highly saturated colors such as red", "orange", "yellow", "Cute and playful patterns such as flowers", "fruits", "animals"));
dopamineKeywords.put("Sketchboard", Arrays.asList("sequins", "beads", "metal decorations", "cheerful and lively atmosphere"));
Map<String, List<String>> gothicKeywords = new HashMap<>();
gothicKeywords.put("Moodboard", Arrays.asList("Gothic style"));
gothicKeywords.put("Printboard", Arrays.asList("deep and dark colors", "such as black", "dark purple", "dark red", "religious or mysterious patterns or prints such as crosses", "shackles", "bats", "skulls"));
gothicKeywords.put("Sketchboard", Arrays.asList("mysterious and gloomy atmosphere", "lines and layers"));
Map<String, List<String>> postApocalypticKeywords = new HashMap<>();
postApocalypticKeywords.put("Moodboard", Arrays.asList("wasteland style"));
postApocalypticKeywords.put("Printboard", Arrays.asList("damage", "graffiti", "smearing", "retro printing", "showing a shabby", "decadent", "cold appearance"));
postApocalypticKeywords.put("Sketchboard", Arrays.asList("a gloomy and heavy feeling"));
Map<String, List<String>> romanticKeywords = new HashMap<>();
romanticKeywords.put("Moodboard", Arrays.asList("Romantic style"));
romanticKeywords.put("Printboard", Arrays.asList("softness", "warmth and romance", "colors such as pink", "lavender", "light blue", "beige"));
romanticKeywords.put("Sketchboard", Arrays.asList("X-shaped and A-shaped silhouettes", "organza", "satin"));
Map<String, List<String>> wabiSabiKeywords = new HashMap<>();
wabiSabiKeywords.put("Moodboard", Arrays.asList("Wabi-Sabi style"));
wabiSabiKeywords.put("Printboard", Arrays.asList("natural materials such as wood", "stone", "hemp rope", "neutral tones and light colors"));
wabiSabiKeywords.put("Sketchboard", Arrays.asList("a quiet and peaceful atmosphere"));
styleCategoryKeywords.put(StyleEnum.NEO_CHINESE, neoChineseKeywords);
styleCategoryKeywords.put(StyleEnum.COUNTRY_STYLE, countryStyleKeywords);
styleCategoryKeywords.put(StyleEnum.FUTURISM, futurismKeywords);
styleCategoryKeywords.put(StyleEnum.MINIMALISM, minimalistKeywords);
styleCategoryKeywords.put(StyleEnum.LOLITA, lolitaKeywords);
styleCategoryKeywords.put(StyleEnum.Y2K, y2kKeywords);
styleCategoryKeywords.put(StyleEnum.BUSINESS, businessKeywords);
styleCategoryKeywords.put(StyleEnum.MERLAD, merladKeywords);
styleCategoryKeywords.put(StyleEnum.OUTDOOR_FUNCTIONAL, outdoorFunctionalKeywords);
styleCategoryKeywords.put(StyleEnum.ROCK, rockKeywords);
styleCategoryKeywords.put(StyleEnum.DOPAMINE, dopamineKeywords);
styleCategoryKeywords.put(StyleEnum.GOTHIC, gothicKeywords);
styleCategoryKeywords.put(StyleEnum.POST_APOCALYPTIC, postApocalypticKeywords);
styleCategoryKeywords.put(StyleEnum.ROMANTIC, romanticKeywords);
styleCategoryKeywords.put(StyleEnum.WABI_SABI, wabiSabiKeywords);
}
public static List<String> getKeywords(StyleEnum style, String category) {
Map<String, List<String>> categoryKeywords = styleCategoryKeywords.get(style);
if (categoryKeywords != null) {
List<String> keywords = categoryKeywords.get(category);
if (keywords != null) {
return keywords;
}
}
return Collections.emptyList();
}
public static Map<String, List<String>> getAllKeywordsByStyle(StyleEnum style) {
Map<String, List<String>> allKeywords = new HashMap<>();
allKeywords.put("Moodboard", getKeywords(style, "Moodboard"));
allKeywords.put("Printboard", getKeywords(style, "Printboard"));
allKeywords.put("Sketchboard", getKeywords(style, "Sketchboard"));
return allKeywords;
}
}

View File

@@ -14,4 +14,8 @@ public class PortfolioVO extends Portfolio {
private List<CollectionElement> collectionElementList;
private List<TDesignPythonOutfit> designPythonOutfitList;
private Integer isLike;
private Long viewNums;
private String userName;
}

View File

@@ -8,6 +8,9 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import java.util.List;
import java.util.Map;
/**
* 视图实体类
*
@@ -35,4 +38,6 @@ public class WorkspaceVO extends Workspace {
private String styleName;
private Map<String, List<String>> allKeywordsByStyle;
}

View File

@@ -31,4 +31,8 @@ public interface PortfolioService extends IService<Portfolio> {
Boolean unlike(Long id);
Long getLikeCount(Long id);
Boolean viewsIncrease(Long id);
Long viewsGet(Long id);
}

View File

@@ -396,6 +396,7 @@ 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()));
vo.setViewNums(redisUtil.getViewCount(vo.getId()));
return vo;
}
return null;
@@ -435,6 +436,9 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
}else {
vo.setIsLike(0);
}
redisUtil.increaseViewCount(portfolioDTO.getId());
vo.setViewNums(redisUtil.getViewCount(portfolioDTO.getId()));
vo.setUserName(accountMapper.selectById(vo.getAccountId()).getUserName());
return vo;
}
@@ -620,6 +624,17 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
return redisUtil.getLikeCount(id);
}
@Override
public Boolean viewsIncrease(Long id) {
redisUtil.increaseViewCount(id);
return Boolean.TRUE;
}
@Override
public Long viewsGet(Long id) {
return redisUtil.getViewCount(id);
}
private List<CommentVO> getChildCommentVOList(Long id) {
QueryWrapper<Comment> qw = new QueryWrapper<>();
qw.lambda().eq(Comment::getParentLevel1Id, id);

View File

@@ -238,13 +238,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
List<ToProductImageResult> result = new ArrayList<>();
int i = 0;
// 翻译
String prompt = toProductImageDTO.getPrompt();
String s = pythonService.promptTranslate(prompt);
for (ToProductImageVO toProductImageVO : toProductImageDTO.getToProductImageVOList()) {
if (toProductImageVO.getElementType().equals("DesignOutfit")) {
String taskId = UUID.randomUUID() + "-" + i + "-" + userHolder.getId();
i ++;
TDesignPythonOutfit tDesignPythonOutfit = designPythonOutfitMapper.selectById(toProductImageVO.getElementId());
// 走模型
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, toProductImageDTO.getPrompt());
pythonService.toProductImage(tDesignPythonOutfit.getDesignUrl(), taskId, s);
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(tDesignPythonOutfit.getId());
toProductImageResult.setElementType("DesignOutfit");
@@ -261,7 +264,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, toProductImageDTO.getPrompt());
pythonService.toProductImage(toProductElement.getUrl(), taskId, s);
ToProductImageResult toProductImageResult = new ToProductImageResult();
toProductImageResult.setElementId(toProductElement.getId());
toProductImageResult.setElementType("ProductElement");

View File

@@ -34,10 +34,7 @@ import javax.annotation.Resource;
import javax.naming.Context;
import java.io.*;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@@ -313,6 +310,9 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
Long styleId = workspaceRelStyles.get(0).getStyleId();
Style style = styleMapper.selectById(styleId);
StyleEnum styleEnum = StyleEnum.fromName(style.getName());
Map<String, List<String>> allKeywordsByStyle = StyleKeywordMapper.getAllKeywordsByStyle(styleEnum);
vo.setAllKeywordsByStyle(allKeywordsByStyle);
if (authPrincipalVo.getLanguage().equals(Language.ENGLISH.name())) {
vo.setStyleName(styleEnum.getEnglish());
}else {