Compare commits

...

3 Commits

Author SHA1 Message Date
9a905268e6 feat(cms): 同步域名到租户表保证一致性
- 在保存网站信息后同步 cms_website.domain 到 company.app_domain 字段
- 去除域名前缀的 http(s):// 以保持与前端处理一致
- 添加异常捕获,防止同步失败影响主流程
- 通过 tenantId 关联查询对应租户公司信息并更新域名字段
- 记录同步失败的警告日志,便于问题排查
2026-08-06 19:51:05 +08:00
ed963b7a40 fix(auth): 修改权限校验允许超管直接创建和更新网站
- 新租户超管尚未被 grantCmsPermission 授予 cms:website:save 权限时允许直接创建首个站点
- 新租户超管尚未被 grantCmsPermission 授予 cms:website:update 权限时允许直接更新站点
- 更新了 save、update 和 updateAll 接口的 @PreAuthorize 注解以支持上述逻辑
- 添加注释说明注册流程中超管权限放宽的原因
2026-08-06 17:25:18 +08:00
b20304da29 feat(cms): 增加网站图标与品牌图标支持
- 在 CmsWebsiteServiceImplHelper 中新增 icon 和 avatar 字段映射
- 使 icon 对应 website_icon 用于前端 favicon 及网站设置
- 使 avatar 对应 website_avatar 作为品牌图标,与 icon 区分用途
- 在 ShopVo 中添加 icon 和 avatar 字段及对应注释说明
- 保持 avatar 键名与前端 SiteInfo.avatar 一致
2026-08-05 23:45:04 +08:00
4 changed files with 30 additions and 4 deletions

View File

@@ -92,7 +92,8 @@ public class CmsWebsiteController extends BaseController {
return success(cmsWebsiteService.getByIdRelAll(id)); return success(cmsWebsiteService.getByIdRelAll(id));
} }
@PreAuthorize("hasAuthority('cms:website:save')") // 注册流程:新租户超管尚未被 grantCmsPermission 赋予 cms:website:save,允许超管直接创建首个站点
@PreAuthorize("hasAuthority('cms:website:save') or principal.getIsSuperAdmin() == true")
@Operation(summary = "添加网站信息记录表") @Operation(summary = "添加网站信息记录表")
@PostMapping() @PostMapping()
public ApiResult<?> save(@RequestBody CmsWebsite cmsWebsite) { public ApiResult<?> save(@RequestBody CmsWebsite cmsWebsite) {
@@ -127,7 +128,8 @@ public class CmsWebsiteController extends BaseController {
return fail("创建失败"); return fail("创建失败");
} }
@PreAuthorize("hasAuthority('cms:website:update')") // 注册流程:新租户超管尚未被 grantCmsPermission 赋予 cms:website:update,允许超管直接更新站点
@PreAuthorize("hasAuthority('cms:website:update') or principal.getIsSuperAdmin() == true")
@Operation(summary = "修改网站信息记录表") @Operation(summary = "修改网站信息记录表")
@PutMapping() @PutMapping()
public ApiResult<?> update(@RequestBody CmsWebsite cmsWebsite) { public ApiResult<?> update(@RequestBody CmsWebsite cmsWebsite) {
@@ -154,7 +156,8 @@ public class CmsWebsiteController extends BaseController {
return fail("修改失败"); return fail("修改失败");
} }
@PreAuthorize("hasAuthority('cms:website:update')") // 注册流程:新租户超管尚未被 grantCmsPermission 赋予 cms:website:update,允许超管直接更新站点
@PreAuthorize("hasAuthority('cms:website:update') or principal.getIsSuperAdmin() == true")
@Operation(summary = "修改网站信息记录表") @Operation(summary = "修改网站信息记录表")
@PutMapping("/updateAll") @PutMapping("/updateAll")
public ApiResult<?> updateAll(@RequestBody CmsWebsite cmsWebsite) { public ApiResult<?> updateAll(@RequestBody CmsWebsite cmsWebsite) {

View File

@@ -9,6 +9,7 @@ import com.gxwebsoft.common.core.utils.JSONUtil;
import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Company;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.CompanyService; import com.gxwebsoft.common.system.service.CompanyService;
import com.gxwebsoft.common.system.service.UserService; import com.gxwebsoft.common.system.service.UserService;
@@ -204,6 +205,21 @@ public class CmsWebsiteServiceImpl extends ServiceImpl<CmsWebsiteMapper, CmsWebs
// 初始化数据 // 初始化数据
if(save(website)){ if(save(website)){
// 同步域名到 company.app_domainwebsopy 租户表),保证 cms_website.domain 与 app_domain 一致
if (StrUtil.isNotBlank(website.getDomain())) {
try {
Company company = companyService.getByTenantIdRel(loginUser.getTenantId());
if (company != null) {
// 去掉 http(s):// 前缀,与前端处理保持一致
String cleanDomain = website.getDomain().replaceFirst("^(https?://)", "");
company.setDomain(cleanDomain);
companyService.updateById(company);
}
} catch (Exception e) {
log.warn("同步域名到 company 失败, tenantId={}", loginUser.getTenantId(), e);
}
}
// 插入网站设置记录 // 插入网站设置记录
// final CmsWebsiteSetting setting = new CmsWebsiteSetting(); // final CmsWebsiteSetting setting = new CmsWebsiteSetting();
// setting.setWebsiteId(website.getWebsiteId()); // setting.setWebsiteId(website.getWebsiteId());

View File

@@ -67,6 +67,10 @@ public class CmsWebsiteServiceImplHelper {
vo.setDescription(website.getComments()); vo.setDescription(website.getComments());
vo.setLogo(website.getWebsiteLogo()); vo.setLogo(website.getWebsiteLogo());
vo.setMpQrCode(website.getWebsiteDarkLogo()); vo.setMpQrCode(website.getWebsiteDarkLogo());
// 网站图标favicon / 应用卡图标):接通 website_icon 列,供前端「网站设置」上传与后台标签页 favicon 使用
vo.setIcon(website.getWebsiteIcon());
// 品牌图标(应用卡 / 分享图标):接通 website_avatar 列,但 ShopVo 键名用 avatar 以对齐前端 SiteInfo.avatar与 icon(favicon) 用途分离
vo.setAvatar(website.getWebsiteAvatar());
vo.setDomain(website.getDomain()); vo.setDomain(website.getDomain());
vo.setAdminUrl(website.getAdminUrl()); vo.setAdminUrl(website.getAdminUrl());
vo.setApiUrl(website.getApiUrl()); vo.setApiUrl(website.getApiUrl());

View File

@@ -42,9 +42,12 @@ public class ShopVo implements Serializable {
@Schema(description = "LOGO") @Schema(description = "LOGO")
private String logo; private String logo;
@Schema(description = "图标") @Schema(description = "图标(favicon/应用卡图标),对应 cms_website.website_icon")
private String icon; private String icon;
@Schema(description = "品牌图标(应用卡/分享图标),对应 cms_website.website_avatar与 icon 用途分离JSON 键名用 avatar 以对齐前端")
private String avatar;
@Schema(description = "域名") @Schema(description = "域名")
private String domain; private String domain;