feat: 智能助手增加引用功能

This commit is contained in:
2026-09-19 23:43:57 +08:00
parent 67c661fd46
commit 02e7c4b881
9 changed files with 389 additions and 235 deletions
@@ -275,7 +275,7 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopPO> implements
// 有系统文件 id 则覆盖;否则用渠道外链 logo_url(与商品 mainImage 口径一致)
if (shop.getLogoImageId() != null) {
String accessUrl = sysFileService.getFileAccessUrl(shop.getLogoImageId());
String accessUrl = sysFileService.resolveAccessUrl(shop.getLogoImageId());
if (accessUrl != null && !accessUrl.isBlank()) {
shopVO.setLogo(accessUrl);
}
@@ -124,7 +124,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
// logo:有 fileId 时同步冗余 URL
if (createCompanyDTO.getLogoImageId() != null) {
company.setLogoImageId(createCompanyDTO.getLogoImageId());
company.setLogo(sysFileService.getFileAccessUrl(createCompanyDTO.getLogoImageId()));
company.setLogo(sysFileService.resolveAccessUrl(createCompanyDTO.getLogoImageId()));
}
// 设置默认值
@@ -224,7 +224,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
// logo:有 fileId 时同步冗余 URL
if (updateCompanyDTO.getLogoImageId() != null) {
company.setLogoImageId(updateCompanyDTO.getLogoImageId());
company.setLogo(sysFileService.getFileAccessUrl(updateCompanyDTO.getLogoImageId()));
company.setLogo(sysFileService.resolveAccessUrl(updateCompanyDTO.getLogoImageId()));
}
// 设置公司ID(必须在updateById之前设置)
@@ -425,7 +425,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, CompanyPO> im
// 有系统文件 id 则覆盖 logo URL
if (company.getLogoImageId() != null) {
String accessUrl = sysFileService.getFileAccessUrl(company.getLogoImageId());
String accessUrl = sysFileService.resolveAccessUrl(company.getLogoImageId());
if (accessUrl != null && !accessUrl.isBlank()) {
companyVO.setLogo(accessUrl);
}
@@ -62,13 +62,21 @@ public interface SysFileService {
List<SysFileVO> batchCreateOssFiles(BatchCreateOssFileDTO dto);
/**
* 通过文件ID获取文件访问URL
* 通过文件ID获取文件访问URL。会向存储探测文件是否存在,仅用于单独取地址。
*
* @param fileId 文件ID
* @return 文件访问URL
*/
String getFileAccessUrl(Long fileId);
/**
* 按文件记录拼接访问地址,不探测存储。记录缺失或已删除时返回 null。
*
* @param fileId 文件ID
* @return 访问地址,无法拼接时为 null
*/
String resolveAccessUrl(Long fileId);
/**
* 分页获取当前公司的文件列表
*
@@ -497,6 +497,18 @@ public class SysFileServiceImpl extends ServiceImpl<SysFileMapper, SysFilePO> im
return accessUrl;
}
@Override
public String resolveAccessUrl(Long fileId) {
if (fileId == null) {
return null;
}
SysFilePO sysFile = this.getById(fileId);
if (sysFile == null || sysFile.getDeleteTime() != null) {
return null;
}
return SysFileUtils.getFileAccessUrl(sysFile.getStoragePath(), sysFile.getStorageType());
}
/**
* 转换为VO
*/
@@ -238,7 +238,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
// 处理头像图片ID
if (updateUserInfoDTO.getAvatarImageId() != null) {
user.setAvatarImageId(updateUserInfoDTO.getAvatarImageId());
user.setAvatar(sysFileService.getFileAccessUrl(updateUserInfoDTO.getAvatarImageId()));
user.setAvatar(sysFileService.resolveAccessUrl(updateUserInfoDTO.getAvatarImageId()));
}
if (StringUtils.hasText(updateUserInfoDTO.getPhone())) {