优化布局

This commit is contained in:
supernijia
2026-07-24 13:26:37 +08:00
parent bca1335dc6
commit f1b7a7aae8
8 changed files with 192 additions and 43 deletions
@@ -152,6 +152,20 @@ public class ShopManageService {
return vo;
}
/**
* 查询匹配业务允许使用的后台店铺;不存在时返回统一中文业务错误。
*/
public ShopManageEntity requireShopByName(String shopName) {
String normalizedShopName = normalizeRequired(shopName, "店铺名称不能为空");
ShopManageEntity entity = shopManageMapper.selectOne(new LambdaQueryWrapper<ShopManageEntity>()
.eq(ShopManageEntity::getShopName, normalizedShopName)
.last("limit 1"));
if (entity == null) {
throw new BusinessException("后台店铺管理中未找到店铺:" + normalizedShopName + ",请先添加店铺信息");
}
return entity;
}
public String findMallNameByShopName(String shopName) {
String normalizedShopName = normalizeRequired(shopName, "shopName required");
ShopManageEntity entity = shopManageMapper.selectOne(new LambdaQueryWrapper<ShopManageEntity>()
@@ -1,6 +1,7 @@
package com.nanri.aiimage.modules.ziniao.service;
import com.nanri.aiimage.common.exception.BusinessException;
import com.nanri.aiimage.modules.shopkey.service.ShopManageService;
import com.nanri.aiimage.modules.ziniao.model.vo.ZiniaoShopMatchResultVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -11,9 +12,10 @@ public class ZiniaoShopSwitchService {
private final ZiniaoAuthService ziniaoAuthService;
private final ZiniaoShopIndexService ziniaoShopIndexService;
private final ShopManageService shopManageService;
public ZiniaoShopMatchResultVo matchStoreByNameAcrossStaff(String targetShopName, Long preferUserId) {
String normalizedShopName = normalizeShopName(targetShopName);
String normalizedShopName = requireManagedShopName(targetShopName);
if (normalizedShopName.isBlank()) {
return emptyMatchResult();
}
@@ -31,11 +33,15 @@ public class ZiniaoShopSwitchService {
}
public ZiniaoShopMatchResultVo findIndexedStoreByName(String targetShopName) {
return ziniaoShopIndexService.findIndexedStoreByName(targetShopName);
return findIndexedStoreByName(targetShopName, true);
}
public ZiniaoShopMatchResultVo findIndexedStoreByName(String targetShopName, boolean buildOpenStoreUrl) {
return ziniaoShopIndexService.findIndexedStoreByName(targetShopName, buildOpenStoreUrl);
String normalizedShopName = requireManagedShopName(targetShopName);
if (normalizedShopName.isBlank()) {
return emptyMatchResult();
}
return ziniaoShopIndexService.findIndexedStoreByName(normalizedShopName, buildOpenStoreUrl);
}
public ZiniaoShopMatchResultVo emptyMatchResult() {
@@ -53,6 +59,14 @@ public class ZiniaoShopSwitchService {
return value.replace(" ", " ").trim();
}
private String requireManagedShopName(String targetShopName) {
String normalizedShopName = normalizeShopName(targetShopName);
if (!normalizedShopName.isBlank()) {
shopManageService.requireShopByName(normalizedShopName);
}
return normalizedShopName;
}
public boolean isSkippableMatchError(BusinessException ex) {
String message = ex == null ? null : ex.getMessage();
if (message == null || message.isBlank()) {