diff --git a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java index 06294584..514797f8 100644 --- a/src/main/java/com/ai/da/common/config/MyTaskScheduler.java +++ b/src/main/java/com/ai/da/common/config/MyTaskScheduler.java @@ -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 fileNames = getFileNames(directoryPath); + for (String fileName : fileNames) { + + } + } + + public static List getFileNames(String directoryPath) { + List fileNames = new ArrayList<>(); + Path path = Paths.get(directoryPath); + + try (DirectoryStream 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; + } } diff --git a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java index 32b98fb4..0d1bed1a 100644 --- a/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java +++ b/src/main/java/com/ai/da/common/security/filter/AuthenticationFilter.java @@ -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","/api/account/questionnaire" ); diff --git a/src/main/java/com/ai/da/common/utils/RedisUtil.java b/src/main/java/com/ai/da/common/utils/RedisUtil.java index 82cf1fd8..e15bc5d0 100644 --- a/src/main/java/com/ai/da/common/utils/RedisUtil.java +++ b/src/main/java/com/ai/da/common/utils/RedisUtil.java @@ -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); + } + } diff --git a/src/main/java/com/ai/da/controller/PortfolioController.java b/src/main/java/com/ai/da/controller/PortfolioController.java index 4f8041b5..725c178a 100644 --- a/src/main/java/com/ai/da/controller/PortfolioController.java +++ b/src/main/java/com/ai/da/controller/PortfolioController.java @@ -93,4 +93,16 @@ public class PortfolioController { public Response> commentPage(@Valid @RequestBody CommentPageDTO commentPageDTO) { return Response.success(portfolioService.commentPage(commentPageDTO)); } + + @ApiOperation(value = "增加浏览量") + @GetMapping("/viewsIncrease") + public Response viewsIncrease(@RequestParam("id") Long id) { + return Response.success(portfolioService.viewsIncrease(id)); + } + + @ApiOperation(value = "浏览量获取") + @GetMapping("/viewsGet") + public Response viewsGet(@RequestParam("id") Long id) { + return Response.success(portfolioService.viewsGet(id)); + } } diff --git a/src/main/java/com/ai/da/model/enums/StyleKeywordMapper.java b/src/main/java/com/ai/da/model/enums/StyleKeywordMapper.java new file mode 100644 index 00000000..29debd77 --- /dev/null +++ b/src/main/java/com/ai/da/model/enums/StyleKeywordMapper.java @@ -0,0 +1,120 @@ +package com.ai.da.model.enums; + +import java.util.*; + +public class StyleKeywordMapper { + + private static final Map>> styleCategoryKeywords = new HashMap<>(); + + static { + Map> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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 getKeywords(StyleEnum style, String category) { + Map> categoryKeywords = styleCategoryKeywords.get(style); + if (categoryKeywords != null) { + List keywords = categoryKeywords.get(category); + if (keywords != null) { + return keywords; + } + } + return Collections.emptyList(); + } + + public static Map> getAllKeywordsByStyle(StyleEnum style) { + Map> allKeywords = new HashMap<>(); + allKeywords.put("Moodboard", getKeywords(style, "Moodboard")); + allKeywords.put("Printboard", getKeywords(style, "Printboard")); + allKeywords.put("Sketchboard", getKeywords(style, "Sketchboard")); + return allKeywords; + } +} diff --git a/src/main/java/com/ai/da/model/vo/PortfolioVO.java b/src/main/java/com/ai/da/model/vo/PortfolioVO.java index 030e6d16..12e9199b 100644 --- a/src/main/java/com/ai/da/model/vo/PortfolioVO.java +++ b/src/main/java/com/ai/da/model/vo/PortfolioVO.java @@ -14,4 +14,8 @@ public class PortfolioVO extends Portfolio { private List collectionElementList; private List designPythonOutfitList; private Integer isLike; + + private Long viewNums; + + private String userName; } diff --git a/src/main/java/com/ai/da/model/vo/WorkspaceVO.java b/src/main/java/com/ai/da/model/vo/WorkspaceVO.java index 45800ae5..71710978 100644 --- a/src/main/java/com/ai/da/model/vo/WorkspaceVO.java +++ b/src/main/java/com/ai/da/model/vo/WorkspaceVO.java @@ -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> allKeywordsByStyle; + } diff --git a/src/main/java/com/ai/da/service/PortfolioService.java b/src/main/java/com/ai/da/service/PortfolioService.java index 0714ae69..aa6ca14b 100644 --- a/src/main/java/com/ai/da/service/PortfolioService.java +++ b/src/main/java/com/ai/da/service/PortfolioService.java @@ -31,4 +31,8 @@ public interface PortfolioService extends IService { Boolean unlike(Long id); Long getLikeCount(Long id); + + Boolean viewsIncrease(Long id); + + Long viewsGet(Long id); } diff --git a/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java b/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java index 2d2a93d9..3d347b4f 100644 --- a/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/PortfolioServiceImpl.java @@ -396,6 +396,7 @@ public class PortfolioServiceImpl extends ServiceImpl getChildCommentVOList(Long id) { QueryWrapper qw = new QueryWrapper<>(); qw.lambda().eq(Comment::getParentLevel1Id, id); diff --git a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java index b7bd7505..22024e16 100644 --- a/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/UserLikeGroupServiceImpl.java @@ -238,13 +238,16 @@ public class UserLikeGroupServiceImpl extends ServiceImpl 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> allKeywordsByStyle = StyleKeywordMapper.getAllKeywordsByStyle(styleEnum); + vo.setAllKeywordsByStyle(allKeywordsByStyle); if (authPrincipalVo.getLanguage().equals(Language.ENGLISH.name())) { vo.setStyleName(styleEnum.getEnglish()); }else {