功能:更新 YumiNail 用户端流程
This commit is contained in:
+45
-1
@@ -1,11 +1,19 @@
|
||||
package com.xiaowang.yuminailcore.controller;
|
||||
|
||||
import com.xiaowang.yuminailcore.annotation.OperationGuard;
|
||||
import com.xiaowang.yuminailcore.common.Result;
|
||||
import com.xiaowang.yuminailcore.dto.CommentDTO;
|
||||
import com.xiaowang.yuminailcore.vo.CommentVO;
|
||||
import com.xiaowang.yuminailcore.dto.ObjectStorageFileDTO;
|
||||
import com.xiaowang.yuminailcore.service.CommentService;
|
||||
import com.xiaowang.yuminailcore.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||
import com.xiaowang.yuminailcore.support.security.UploadSecurityValidator;
|
||||
import com.xiaowang.yuminailcore.vo.CommentVO;
|
||||
import com.xiaowang.yuminailcore.vo.ObjectStorageFileVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
@@ -25,6 +33,10 @@ public class CommentController {
|
||||
* Variable `commentService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final CommentService commentService;
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
private final MinioService minioService;
|
||||
private final TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
private final UploadSecurityValidator uploadSecurityValidator;
|
||||
|
||||
/**
|
||||
* 创建评论
|
||||
@@ -39,6 +51,38 @@ public class CommentController {
|
||||
return Result.success(id);
|
||||
}
|
||||
|
||||
@PostMapping("/upload-image")
|
||||
@OperationGuard(action = "comment-image-upload", ttlSeconds = 15, message = "图片正在上传中,请勿重复操作")
|
||||
public Result<ObjectStorageFileVO> uploadCommentImage(HttpServletRequest request, @RequestParam("file") MultipartFile file) {
|
||||
Long userId = (Long) request.getAttribute("userId");
|
||||
if (userId == null) {
|
||||
return Result.error("请先登录后再上传评价图片");
|
||||
}
|
||||
try {
|
||||
uploadSecurityValidator.validate(file);
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
if (originalFilename == null || originalFilename.isEmpty()) {
|
||||
originalFilename = "comment-image";
|
||||
}
|
||||
String fileExtension = originalFilename == null || !originalFilename.contains(".")
|
||||
? ""
|
||||
: originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
String objectName = snowflakeIdGenerator.nextIdString() + fileExtension;
|
||||
String fileUrl = minioService.uploadFile(file, objectName);
|
||||
|
||||
ObjectStorageFileDTO dto = new ObjectStorageFileDTO();
|
||||
dto.setFileName(originalFilename);
|
||||
dto.setFileUrl(fileUrl);
|
||||
dto.setStatus(1);
|
||||
|
||||
Long fileId = objectStorageFileService.createObjectStorageFile(dto);
|
||||
return Result.success(objectStorageFileService.getObjectStorageFileById(fileId));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("评价图片上传失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新评论
|
||||
*
|
||||
|
||||
+5
@@ -36,6 +36,11 @@ public class NailArtistController {
|
||||
List<NailArtistInfoDTO> nailArtistInfoDTOList = nailArtistInfoService.getAllAvailableNailArtists();
|
||||
return Result.success(nailArtistInfoDTOList);
|
||||
}
|
||||
|
||||
@GetMapping("/list/shop/{shopId}")
|
||||
public Result<List<NailArtistInfoDTO>> listByShopId(@PathVariable Long shopId) {
|
||||
return Result.success(nailArtistInfoService.getByShopId(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取美甲师信息(前台使用)
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.xiaowang.yuminailcore.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户评论信息表 DTO
|
||||
* 用于评论信息的传输
|
||||
@@ -36,4 +38,14 @@ public class CommentDTO {
|
||||
* 父级评论ID(0表示为根评论)
|
||||
*/
|
||||
private Long parentCommentId;
|
||||
|
||||
/**
|
||||
* 评论评分:1-5星,根评论使用
|
||||
*/
|
||||
private Integer ratingScore;
|
||||
|
||||
/**
|
||||
* 评论图片文件ID集合,根评论使用
|
||||
*/
|
||||
private List<Long> imageFileIds;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,18 @@ public class CommentDO extends BaseEntity {
|
||||
@TableField("parent_comment_id")
|
||||
private Long parentCommentId;
|
||||
|
||||
/**
|
||||
* 评论评分:1-5星
|
||||
*/
|
||||
@TableField("rating_score")
|
||||
private Integer ratingScore;
|
||||
|
||||
/**
|
||||
* 评论图片文件ID集合,多个ID以逗号分隔
|
||||
*/
|
||||
@TableField("image_file_ids")
|
||||
private String imageFileIds;
|
||||
|
||||
/**
|
||||
* 评论点赞数
|
||||
*/
|
||||
|
||||
+82
@@ -12,7 +12,11 @@ import com.xiaowang.yuminailcore.mapper.ProductMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.ShopMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserMapper;
|
||||
import com.xiaowang.yuminailcore.service.CommentService;
|
||||
import com.xiaowang.yuminailcore.service.MinioService;
|
||||
import com.xiaowang.yuminailcore.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.vo.CommentVO;
|
||||
import com.xiaowang.yuminailcore.vo.ObjectStorageFileVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -21,6 +25,7 @@ import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -51,6 +56,9 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
||||
* Variable `productMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final ProductMapper productMapper;
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
private final MinioService minioService;
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
|
||||
@Override
|
||||
/**
|
||||
@@ -137,11 +145,16 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
||||
}
|
||||
}
|
||||
CommentDO commentDO = new CommentDO();
|
||||
boolean rootComment = parentCommentId == null;
|
||||
commentDO.setUserId(currentUserId);
|
||||
commentDO.setShopId(shopId);
|
||||
commentDO.setProductId(productId);
|
||||
commentDO.setCommentContent(content);
|
||||
commentDO.setParentCommentId(parentCommentId);
|
||||
if (rootComment) {
|
||||
commentDO.setRatingScore(normalizeRatingScore(commentDTO.getRatingScore()));
|
||||
commentDO.setImageFileIds(joinImageFileIds(commentDTO.getImageFileIds()));
|
||||
}
|
||||
commentDO.setLikeCount(0);
|
||||
commentDO.setIsDelete(0);
|
||||
commentMapper.insert(commentDO);
|
||||
@@ -410,6 +423,10 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
||||
commentVO.setCommentContent(commentDO.getCommentContent());
|
||||
commentVO.setParentCommentId(commentDO.getParentCommentId());
|
||||
commentVO.setLikeCount(commentDO.getLikeCount());
|
||||
commentVO.setRatingScore(commentDO.getRatingScore());
|
||||
List<Long> imageFileIds = parseImageFileIds(commentDO.getImageFileIds());
|
||||
commentVO.setImageFileIds(imageFileIds);
|
||||
commentVO.setImageUrls(resolveImageUrls(imageFileIds));
|
||||
commentVO.setCreateTime(commentDO.getCreateTime());
|
||||
commentVO.setUpdateTime(commentDO.getUpdateTime());
|
||||
/**
|
||||
@@ -492,6 +509,71 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, CommentDO> im
|
||||
}
|
||||
}
|
||||
|
||||
private Integer normalizeRatingScore(Integer ratingScore) {
|
||||
if (ratingScore == null) {
|
||||
return 5;
|
||||
}
|
||||
return Math.max(1, Math.min(5, ratingScore));
|
||||
}
|
||||
|
||||
private String joinImageFileIds(List<Long> imageFileIds) {
|
||||
if (imageFileIds == null || imageFileIds.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return imageFileIds.stream()
|
||||
.filter(id -> id != null && id > 0)
|
||||
.distinct()
|
||||
.limit(6)
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
private List<Long> parseImageFileIds(String imageFileIds) {
|
||||
List<Long> result = new ArrayList<>();
|
||||
if (!StringUtils.hasText(imageFileIds)) {
|
||||
return result;
|
||||
}
|
||||
for (String token : imageFileIds.split(",")) {
|
||||
if (!StringUtils.hasText(token)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Long id = Long.valueOf(token.trim());
|
||||
if (id > 0) {
|
||||
result.add(id);
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
// Ignore malformed legacy tokens.
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(new LinkedHashSet<>(result));
|
||||
}
|
||||
|
||||
private List<String> resolveImageUrls(List<Long> imageFileIds) {
|
||||
if (imageFileIds == null || imageFileIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<Long, ObjectStorageFileVO> fileMap = objectStorageFileService.getObjectStorageFileMapByIds(new LinkedHashSet<>(imageFileIds));
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (Long imageFileId : imageFileIds) {
|
||||
ObjectStorageFileVO fileVO = fileMap.get(imageFileId);
|
||||
if (fileVO == null || !StringUtils.hasText(fileVO.getFileUrl())) {
|
||||
continue;
|
||||
}
|
||||
String objectName = objectStorageUrlSupport.extractObjectName(fileVO.getFileUrl());
|
||||
if (!StringUtils.hasText(objectName)) {
|
||||
urls.add(fileVO.getFileUrl());
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
urls.add(minioService.getPresignedUrl(objectName, 60));
|
||||
} catch (Exception ignored) {
|
||||
urls.add(fileVO.getFileUrl());
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `activeQuery`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
|
||||
+45
-8
@@ -156,17 +156,21 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
|
||||
List<UserDO> users = userMapper.selectList(new LambdaQueryWrapper<UserDO>()
|
||||
.in(UserDO::getId, serviceUserIds)
|
||||
.in(UserDO::getType, List.of(2, 3))
|
||||
.eq(UserDO::getIsDelete, 0));
|
||||
.eq(UserDO::getType, 3)
|
||||
.eq(UserDO::getStatus, 1)
|
||||
.eq(UserDO::getIsDelete, 0)
|
||||
.orderByAsc(UserDO::getCreateTime)
|
||||
.orderByAsc(UserDO::getId));
|
||||
List<NailArtistInfoDTO> result = new ArrayList<>();
|
||||
ShopDO shop = shopMapper.selectById(shopId);
|
||||
for (UserDO user : users) {
|
||||
NailArtistInfoDTO dto = getByUserId(user.getId());
|
||||
if (dto != null && isVisibleServiceUser(dto)) {
|
||||
dto.setShopId(shopId);
|
||||
dto.setShopName(shop == null ? null : shop.getShopName());
|
||||
result.add(dto);
|
||||
if (dto == null) {
|
||||
dto = buildFallbackArtistInfo(user);
|
||||
}
|
||||
dto.setShopId(shopId);
|
||||
dto.setShopName(shop == null ? null : shop.getShopName());
|
||||
result.add(dto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -418,6 +422,32 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return dto;
|
||||
}
|
||||
|
||||
private NailArtistInfoDTO buildFallbackArtistInfo(UserDO user) {
|
||||
NailArtistInfoDTO dto = new NailArtistInfoDTO();
|
||||
dto.setUserId(user.getId());
|
||||
dto.setNickname(user.getNickname());
|
||||
dto.setSignature(user.getSignature());
|
||||
dto.setUserType(user.getType());
|
||||
dto.setUserTypeName(resolveUserTypeName(user.getType()));
|
||||
dto.setIdentity("美甲师");
|
||||
dto.setStatus(1);
|
||||
dto.setParticipateProduction(1);
|
||||
dto.setShopId(user.getShopId());
|
||||
List<ShopSimpleVO> shopOptions = userShopBindingSupport.listShopOptionsByUserId(user.getId(), true, true);
|
||||
if (!shopOptions.isEmpty()) {
|
||||
ShopSimpleVO primaryShop = shopOptions.get(0);
|
||||
dto.setShopId(primaryShop.getId());
|
||||
dto.setShopName(primaryShop.getShopName());
|
||||
} else if (user.getShopId() != null && user.getShopId() > 0) {
|
||||
ShopDO shop = shopMapper.selectById(user.getShopId());
|
||||
if (shop != null) {
|
||||
dto.setShopId(shop.getId());
|
||||
dto.setShopName(shop.getShopName());
|
||||
}
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `isVisibleServiceUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
@@ -463,10 +493,17 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
throw new RuntimeException("美甲师信息不存在");
|
||||
}
|
||||
NailArtistInfoDTO artistInfo = getByUserId(artistId);
|
||||
if (artistInfo == null || !isVisibleServiceUser(artistInfo)) {
|
||||
if (artistInfo != null && isVisibleServiceUser(artistInfo)) {
|
||||
return artistInfo;
|
||||
}
|
||||
UserDO artist = userMapper.selectById(artistId);
|
||||
if (artist == null
|
||||
|| isDeleted(artist.getIsDelete())
|
||||
|| !Integer.valueOf(3).equals(artist.getType())
|
||||
|| !Integer.valueOf(1).equals(artist.getStatus())) {
|
||||
throw new RuntimeException("美甲师信息不存在");
|
||||
}
|
||||
return artistInfo;
|
||||
return buildFallbackArtistInfo(artist);
|
||||
}
|
||||
|
||||
private BigDecimal resolvePublicRating(Long artistId, NailArtistInfoDTO artistInfo) {
|
||||
|
||||
+19
@@ -39,6 +39,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -73,6 +75,8 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private static final int MAX_PUBLIC_PAGE_SIZE = 30;
|
||||
private static final Pattern DURATION_PATTERN = Pattern.compile("(\\d+)");
|
||||
private static final long DEFAULT_SERVICE_DURATION_MINUTES = 60L;
|
||||
/**
|
||||
* Variable `productMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -451,6 +455,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
productVO.setLikeCount(productDO.getLikeCount());
|
||||
productVO.setCollectCount(productDO.getCollectCount());
|
||||
productVO.setApproximateDuration(productDO.getApproximateDuration());
|
||||
productVO.setServiceDurationMinutes(resolveServiceDurationMinutes(productDO.getApproximateDuration()));
|
||||
String validBookableArtists = bookableArtistSupport.filterValidBookableArtists(productDO.getShopId(), productDO.getBookableArtists());
|
||||
productVO.setBookableArtists(productDO.getBookableArtists());
|
||||
productVO.setAvailableBookableArtistCount(countBookableArtists(validBookableArtists));
|
||||
@@ -489,6 +494,20 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
|
||||
return productVO;
|
||||
}
|
||||
|
||||
private long resolveServiceDurationMinutes(String approximateDuration) {
|
||||
if (!StringUtils.hasText(approximateDuration)) {
|
||||
return DEFAULT_SERVICE_DURATION_MINUTES;
|
||||
}
|
||||
Matcher matcher = DURATION_PATTERN.matcher(approximateDuration);
|
||||
if (matcher.find()) {
|
||||
try {
|
||||
return Math.max(1L, Long.parseLong(matcher.group(1)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
return DEFAULT_SERVICE_DURATION_MINUTES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `buildEnrichmentContext`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
|
||||
+60
-1
@@ -23,8 +23,10 @@ import com.xiaowang.yuminailcore.mapper.TagMapper;
|
||||
import com.xiaowang.yuminailcore.mapper.UserCouponMapper;
|
||||
import com.xiaowang.yuminailcore.service.CouponService;
|
||||
import com.xiaowang.yuminailcore.service.MapService;
|
||||
import com.xiaowang.yuminailcore.service.NailArtistInfoService;
|
||||
import com.xiaowang.yuminailcore.service.ObjectStorageFileService;
|
||||
import com.xiaowang.yuminailcore.service.ShopService;
|
||||
import com.xiaowang.yuminailcore.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.yuminailcore.support.ShopThemeSupport;
|
||||
import com.xiaowang.yuminailcore.support.UserShopBindingSupport;
|
||||
import com.xiaowang.yuminailcore.support.cache.MultiLevelCacheService;
|
||||
@@ -81,6 +83,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
private static final String DISABLED_SHOP_ARCHIVED_MESSAGE = "停用店铺已封存,仅允许重新启用";
|
||||
private static final Set<String> FEATURED_PRODUCT_TAG_NAMES = Set.of("特色作品", "热门");
|
||||
/**
|
||||
* Variable `shopMapper`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -117,10 +120,15 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
* Variable `objectStorageFileService`: Spring-injected collaborator used by this class to resolve public image URLs for trust cards.
|
||||
*/
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
/**
|
||||
* Variable `objectStorageUrlSupport`: converts stored object URLs into frontend-accessible signed URLs.
|
||||
*/
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
/**
|
||||
* Variable `userShopBindingSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
private final UserShopBindingSupport userShopBindingSupport;
|
||||
private final NailArtistInfoService nailArtistInfoService;
|
||||
/**
|
||||
* Variable `multiLevelCacheService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
|
||||
*/
|
||||
@@ -292,6 +300,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
}
|
||||
|
||||
long productCount = countActiveProducts(id);
|
||||
long artistCount = countShopArtists(id);
|
||||
List<ProductDO> featuredProducts = listFeaturedProducts(id);
|
||||
List<OrderArtistReviewDO> recentReviews = listSubmittedReviews(id, 3);
|
||||
BigDecimal averageRating = calculateAverageRating(id);
|
||||
@@ -317,6 +326,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
|
||||
ShopTrustProfileVO.Stats stats = new ShopTrustProfileVO.Stats();
|
||||
stats.setProductCount(productCount);
|
||||
stats.setArtistCount(artistCount);
|
||||
stats.setReviewCount(reviewCount);
|
||||
stats.setAverageRating(averageRating);
|
||||
stats.setRecentReviewCount(recentReviews.size());
|
||||
@@ -453,14 +463,23 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
return count == null ? 0L : count;
|
||||
}
|
||||
|
||||
private long countShopArtists(Long shopId) {
|
||||
return nailArtistInfoService.getByShopId(shopId).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: listFeaturedProducts returns representative active products for shop detail trust cards.
|
||||
* Usage: render at most three products and navigate to product detail when tapped.
|
||||
*/
|
||||
private List<ProductDO> listFeaturedProducts(Long shopId) {
|
||||
Set<String> featuredTagTokens = findFeaturedProductTagTokens(shopId);
|
||||
if (featuredTagTokens.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return productMapper.selectList(Wrappers.lambdaQuery(ProductDO.class)
|
||||
.eq(ProductDO::getShopId, shopId)
|
||||
.eq(ProductDO::getIsDelete, 0)
|
||||
.and(wrapper -> applyProductTagTokenConditions(wrapper, featuredTagTokens))
|
||||
.orderByDesc(ProductDO::getCollectCount)
|
||||
.orderByDesc(ProductDO::getLikeCount)
|
||||
.orderByDesc(ProductDO::getCreateTime)
|
||||
@@ -470,6 +489,45 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Set<String> findFeaturedProductTagTokens(Long shopId) {
|
||||
Set<String> tokens = new LinkedHashSet<>(FEATURED_PRODUCT_TAG_NAMES);
|
||||
List<TagDO> tags = tagMapper.selectList(Wrappers.lambdaQuery(TagDO.class)
|
||||
.eq(TagDO::getIsDelete, 0)
|
||||
.and(wrapper -> wrapper.eq(TagDO::getShopId, shopId)
|
||||
.or()
|
||||
.isNull(TagDO::getShopId)
|
||||
.or()
|
||||
.eq(TagDO::getShopId, 0L))
|
||||
.and(wrapper -> wrapper.in(TagDO::getTagName, FEATURED_PRODUCT_TAG_NAMES)
|
||||
.or()
|
||||
.in(TagDO::getDisplayName, FEATURED_PRODUCT_TAG_NAMES)));
|
||||
tags.stream()
|
||||
.map(TagDO::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.map(String::valueOf)
|
||||
.forEach(tokens::add);
|
||||
return tokens.stream()
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
private void applyProductTagTokenConditions(LambdaQueryWrapper<ProductDO> wrapper, Set<String> tagTokens) {
|
||||
boolean appended = false;
|
||||
for (String tagToken : tagTokens) {
|
||||
if (!StringUtils.hasText(tagToken)) {
|
||||
continue;
|
||||
}
|
||||
if (appended) {
|
||||
wrapper.or();
|
||||
}
|
||||
wrapper.apply("FIND_IN_SET({0}, REPLACE(tags, ';', ','))", tagToken);
|
||||
appended = true;
|
||||
}
|
||||
if (!appended) {
|
||||
wrapper.apply("1 = 0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: listSubmittedReviews loads privacy-safe submitted review rows for the shop.
|
||||
* Usage: only status=1 reviews should feed public trust display.
|
||||
@@ -538,6 +596,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
featured.setAvailableBookableArtistCount(artistCount);
|
||||
featured.setBookingHint(artistCount > 0 ? artistCount + " 位美甲师可预约" : "到店后由门店安排美甲师");
|
||||
featured.setImageUrl(resolveFirstImageUrl(product.getImageFileIds(), fileMap));
|
||||
featured.setImageFileIds(product.getImageFileIds());
|
||||
return featured;
|
||||
}
|
||||
|
||||
@@ -634,7 +693,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
for (Long fileId : fileIds) {
|
||||
ObjectStorageFileVO file = fileMap.get(fileId);
|
||||
if (file != null && StringUtils.hasText(file.getFileUrl())) {
|
||||
urls.add(file.getFileUrl());
|
||||
urls.add(objectStorageUrlSupport.toAccessibleUrl(file.getFileUrl()));
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
|
||||
@@ -70,6 +70,21 @@ public class CommentVO {
|
||||
*/
|
||||
private Integer likeCount;
|
||||
|
||||
/**
|
||||
* 评论评分:1-5星
|
||||
*/
|
||||
private Integer ratingScore;
|
||||
|
||||
/**
|
||||
* 评论图片文件ID集合
|
||||
*/
|
||||
private List<Long> imageFileIds;
|
||||
|
||||
/**
|
||||
* 评论图片展示链接
|
||||
*/
|
||||
private List<String> imageUrls;
|
||||
|
||||
/**
|
||||
* 评论创建时间
|
||||
*/
|
||||
|
||||
@@ -97,6 +97,11 @@ public class ProductVO {
|
||||
*/
|
||||
private String approximateDuration;
|
||||
|
||||
/**
|
||||
* 实际用于预约排期计算的服务时长(分钟)
|
||||
*/
|
||||
private Long serviceDurationMinutes;
|
||||
|
||||
/**
|
||||
* 可预约的美甲师ID集合,多个ID以逗号分隔
|
||||
*/
|
||||
|
||||
@@ -115,6 +115,12 @@ public class ShopTrustProfileVO {
|
||||
*/
|
||||
private Long productCount = 0L;
|
||||
|
||||
/**
|
||||
* Purpose: artistCount is the number of active nail artist users bound to this shop.
|
||||
* Usage: render as the staff confidence signal on shop detail pages.
|
||||
*/
|
||||
private Long artistCount = 0L;
|
||||
|
||||
/**
|
||||
* Purpose: recentReviewCount is the number of review cards included in this response.
|
||||
* Usage: clients use it for section labels and empty states.
|
||||
@@ -146,6 +152,12 @@ public class ShopTrustProfileVO {
|
||||
*/
|
||||
private String imageUrl;
|
||||
|
||||
/**
|
||||
* Purpose: imageFileIds provides product image file ids for clients that need signed image URLs.
|
||||
* Usage: clients may resolve the first id into a stable thumbnail URL.
|
||||
*/
|
||||
private String imageFileIds;
|
||||
|
||||
/**
|
||||
* Purpose: price carries the current product price.
|
||||
* Usage: show it as a current quote, not as historical order price.
|
||||
|
||||
@@ -85,6 +85,8 @@ create table t_comment
|
||||
product_id bigint unsigned default 0 null comment '关联商品表主键(0表示非商品评论)',
|
||||
comment_content text not null comment '评论内容',
|
||||
parent_comment_id bigint unsigned default 0 null comment '父级评论ID(0表示为根评论)',
|
||||
rating_score tinyint unsigned default 5 null comment '评论评分:1-5星',
|
||||
image_file_ids text null comment '评论图片文件ID集合,多个ID以逗号分隔',
|
||||
like_count int unsigned default 0 null comment '评论点赞数',
|
||||
create_time datetime default CURRENT_TIMESTAMP not null comment '评论创建时间',
|
||||
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '评论更新时间',
|
||||
|
||||
Reference in New Issue
Block a user