修复店铺主图保存后不回显
This commit is contained in:
+12
-1
@@ -289,7 +289,18 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopDO> implements
|
||||
* @param shopDO parameter `shopDO` supplied by the caller
|
||||
* @return return result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
return convertToVO(shopDO);
|
||||
ShopVO shopVO = convertToVO(shopDO);
|
||||
List<Long> coverImageFileIds = parseLongIds(shopDO.getCoverImageFileId(), ",");
|
||||
List<Long> imageFileIds = parseLongIds(shopDO.getImageFileIds(), ",");
|
||||
Set<Long> fileIds = new LinkedHashSet<>();
|
||||
fileIds.addAll(coverImageFileIds);
|
||||
fileIds.addAll(imageFileIds);
|
||||
Map<Long, ObjectStorageFileVO> fileMap = fileIds.isEmpty()
|
||||
? Collections.emptyMap()
|
||||
: objectStorageFileService.getObjectStorageFileMapByIds(fileIds);
|
||||
shopVO.setCoverImageUrls(resolveImageUrls(coverImageFileIds, fileMap));
|
||||
shopVO.setImageUrls(resolveImageUrls(imageFileIds, fileMap));
|
||||
return shopVO;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
+31
@@ -21,6 +21,7 @@ import com.xiaowang.jayucloud.core.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.support.UserShopBindingSupport;
|
||||
import com.xiaowang.jayucloud.core.support.cache.MultiLevelCacheService;
|
||||
import com.xiaowang.jayucloud.core.modules.file.vo.ObjectStorageFileVO;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.vo.ShopVO;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.vo.ShopTrustProfileVO;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -28,6 +29,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -136,6 +138,35 @@ class ShopServiceImplTest {
|
||||
verify(shopMapper, never()).updateById(disabledShop);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getShopByIdShouldResolveCoverImageUrls() {
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setId(9L);
|
||||
shop.setShopName("Yumi Test Shop");
|
||||
shop.setCoverImageFileId("100");
|
||||
shop.setIsDelete(0);
|
||||
when(shopMapper.selectById(9L)).thenReturn(shop);
|
||||
when(appCacheProperties.getShop()).thenReturn(new AppCacheProperties.CacheSpec(60, 120));
|
||||
when(multiLevelCacheService.getOrLoad(
|
||||
anyString(),
|
||||
any(Duration.class),
|
||||
any(Duration.class),
|
||||
any(),
|
||||
any()
|
||||
)).thenAnswer(invocation -> ((java.util.function.Supplier<?>) invocation.getArgument(4)).get());
|
||||
|
||||
ObjectStorageFileVO cover = new ObjectStorageFileVO();
|
||||
cover.setId(100L);
|
||||
cover.setFileUrl("https://img.test/cover.jpg");
|
||||
when(objectStorageFileService.getObjectStorageFileMapByIds(any()))
|
||||
.thenReturn(Map.of(100L, cover));
|
||||
|
||||
ShopVO shopVO = service.getShopById(9L);
|
||||
|
||||
assertThat(shopVO.getCoverImageUrls()).containsExactly("https://img.test/cover.jpg");
|
||||
verify(objectStorageFileService).getObjectStorageFileMapByIds(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getShopTrustProfileAggregatesPublicTrustDataWithoutContactPhone() {
|
||||
ShopDO shop = new ShopDO();
|
||||
|
||||
@@ -475,3 +475,12 @@
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
|
||||
- 影响范围:仅影响店铺档案编辑页底部操作区;不改变保存接口、表单字段、封面上传和其它页面按钮样式。
|
||||
- 验证方式:执行店铺档案编辑页 JS 语法检查、WXSS BOM 检查、`git diff --check`、微信开发者工具 CLI `preview` 和 GitNexus staged 变更检测。
|
||||
|
||||
## 2026-07-24 店务小程序店铺主图保存后不回显修复
|
||||
|
||||
- 变更原因:店铺档案编辑页上传并保存主图后,店铺设置页重新读取店铺详情时 `coverImageUrls` 始终为空,导致页面继续显示旧封面或空封面。
|
||||
- 根本原因:`ShopServiceImpl.convertToVO()` 只回填了 `coverImageFileId`,没有把封面文件 ID 查询为可访问图片 URL;设置页依赖 `coverImageUrls` 渲染主图。
|
||||
- 处理方式:在 `ShopServiceImpl.getShopById()` 的详情缓存加载链路中批量查询封面和店铺图片文件,并使用现有对象存储 URL 转换逻辑填充 `ShopVO.coverImageUrls`、`imageUrls`;无图片 ID 时不发起对象存储查询。
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
|
||||
- 影响范围:影响店铺详情回显及复用店铺详情的管理端/用户端读取链路;不改变图片上传接口、店铺图片数据库字段和保存 payload。
|
||||
- 验证方式:`ShopServiceImplTest` 定向测试 4/4 通过;店务小程序 JS 语法检查、WXSS/WXML BOM 检查、微信开发者工具 CLI `preview` 和 GitNexus staged 变更检测通过。
|
||||
|
||||
@@ -575,3 +575,15 @@
|
||||
以后避免:小程序固定底部操作条从单按钮改成双按钮时,必须检查全局按钮宽度约束;提交前同时核对 WXML 是否有按钮、WXSS 是否让按钮处于可视范围。
|
||||
|
||||
验证方式:静态检查目标页 WXML 只保留保存按钮,WXSS 覆盖全局宽度;运行 JS 语法检查、WXSS BOM 检查、`git diff --check` 和微信开发者工具 CLI `preview`。
|
||||
|
||||
## 2026-07-24 店铺详情图片字段必须完成文件 ID 到 URL 的回显转换
|
||||
|
||||
问题:店铺档案页上传主图并保存后,店铺设置页重新进入仍显示旧主图或空封面。
|
||||
|
||||
原因:后端店铺详情 VO 只回填 `coverImageFileId`,没有根据对象存储文件 ID 填充前端实际渲染使用的 `coverImageUrls`;保存成功不等于图片回显链路完整。
|
||||
|
||||
处理方式:在店铺详情缓存加载链路中批量读取封面和店铺图片文件,并通过统一对象存储 URL 转换器回填 `coverImageUrls`、`imageUrls`;无文件 ID 时跳过对象存储查询。
|
||||
|
||||
以后避免:涉及图片设置时必须沿“上传 -> 保存文件 ID -> 清理详情缓存 -> 重新读取 -> URL 回显 -> 页面渲染”完整链路验证,不能只检查上传接口返回成功。
|
||||
|
||||
验证方式:服务层测试覆盖封面文件 ID 能转换为 URL;保存后重新加载店铺详情确认 URL 非空;同时执行前端编译和 GitNexus 变更检测。
|
||||
|
||||
Reference in New Issue
Block a user