refactor(terminology): rename user-facing tenant labels to workspace
Align product copy, API docs, Swagger descriptions, and i18n strings with workspace terminology while keeping internal tenant identifiers and headers unchanged for API compatibility.
This commit is contained in:
@@ -73,23 +73,23 @@ type updateMemberRoleRequest struct {
|
||||
func parseTenantIDFromPath(c *gin.Context) (uint64, bool) {
|
||||
raw := strings.TrimSpace(c.Param("id"))
|
||||
if raw == "" {
|
||||
c.Error(apperrors.NewValidationError("tenant id is required"))
|
||||
c.Error(apperrors.NewValidationError("workspace id is required"))
|
||||
return 0, false
|
||||
}
|
||||
v, err := strconv.ParseUint(raw, 10, 64)
|
||||
if err != nil || v == 0 {
|
||||
c.Error(apperrors.NewValidationError("tenant id must be a positive integer"))
|
||||
c.Error(apperrors.NewValidationError("workspace id must be a positive integer"))
|
||||
return 0, false
|
||||
}
|
||||
return v, true
|
||||
}
|
||||
|
||||
// ListMembers godoc
|
||||
// @Summary 列出租户成员
|
||||
// @Description 分页返回当前租户内 active 成员(含每位成员的角色、邮箱、头像);支持 q 按邮箱/用户名筛选
|
||||
// @Tags 租户成员
|
||||
// @Summary 列出空间成员
|
||||
// @Description 分页返回当前空间内 active 成员(含每位成员的角色、邮箱、头像);支持 q 按邮箱/用户名筛选
|
||||
// @Tags 空间成员
|
||||
// @Produce json
|
||||
// @Param id path string true "租户 ID"
|
||||
// @Param id path string true "空间 ID"
|
||||
// @Param q query string false "按邮箱/用户名模糊筛选"
|
||||
// @Param page query int false "页码(从 1 起)" default(1)
|
||||
// @Param page_size query int false "每页数量(最大 100)" default(20)
|
||||
@@ -162,15 +162,15 @@ func (h *TenantMemberHandler) ListMembers(c *gin.Context) {
|
||||
}
|
||||
|
||||
// AddMember godoc
|
||||
// @Summary 直接添加租户成员(直加路径)
|
||||
// @Summary 直接添加空间成员(直加路径)
|
||||
// @Description
|
||||
//
|
||||
// Owner 通过 email 直接把用户作为 active 成员添加进当前租户。
|
||||
// Owner 通过 email 直接把用户作为 active 成员添加进当前空间。
|
||||
//
|
||||
// 这是【直加路径】,被加入的用户没有任何确认机会就出现在租户里——
|
||||
// 这是【直加路径】,被加入的用户没有任何确认机会就出现在空间里——
|
||||
// 保留它是为了三类不需要走邀请确认的场景:
|
||||
// 1. 自动化脚本 / 平台运维 / 数据迁移;
|
||||
// 2. 跨租户超管 (CanAccessAllTenants) 的批量编排;
|
||||
// 2. 跨空间超管 (CanAccessAllTenants) 的批量编排;
|
||||
// 3. 对接外部 IdP 时由身份源单向同步成员。
|
||||
//
|
||||
// 所有由 UI 触发的「邀请伙伴加入」交互应改走
|
||||
@@ -178,10 +178,10 @@ func (h *TenantMemberHandler) ListMembers(c *gin.Context) {
|
||||
// 人在 /me/invitations 主动接受后再写 tenant_members 行(PR #1303 后续)。
|
||||
// 这条路径与 invitations 路径共存而不互相替代。
|
||||
//
|
||||
// @Tags 租户成员
|
||||
// @Tags 空间成员
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "租户 ID"
|
||||
// @Param id path string true "空间 ID"
|
||||
// @Param request body addMemberRequest true "邀请请求"
|
||||
// @Success 201 {object} map[string]interface{}
|
||||
// @Security Bearer
|
||||
@@ -271,12 +271,12 @@ func (h *TenantMemberHandler) AddMember(c *gin.Context) {
|
||||
}
|
||||
|
||||
// UpdateMemberRole godoc
|
||||
// @Summary 修改租户成员角色
|
||||
// @Description Owner 修改某位成员在当前租户内的角色;不能将最后一位 Owner 降级
|
||||
// @Tags 租户成员
|
||||
// @Summary 修改空间成员角色
|
||||
// @Description Owner 修改某位成员在当前空间内的角色;不能将最后一位 Owner 降级
|
||||
// @Tags 空间成员
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "租户 ID"
|
||||
// @Param id path string true "空间 ID"
|
||||
// @Param user_id path string true "用户 ID"
|
||||
// @Param request body updateMemberRoleRequest true "目标角色"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
@@ -324,11 +324,11 @@ func (h *TenantMemberHandler) UpdateMemberRole(c *gin.Context) {
|
||||
}
|
||||
|
||||
// RemoveMember godoc
|
||||
// @Summary 移除租户成员
|
||||
// @Description Owner 将某位成员从当前租户中移除(软删除 tenant_members 行);不能移除最后一位 Owner
|
||||
// @Tags 租户成员
|
||||
// @Summary 移除空间成员
|
||||
// @Description Owner 将某位成员从当前空间中移除(软删除 tenant_members 行);不能移除最后一位 Owner
|
||||
// @Tags 空间成员
|
||||
// @Produce json
|
||||
// @Param id path string true "租户 ID"
|
||||
// @Param id path string true "空间 ID"
|
||||
// @Param user_id path string true "用户 ID"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Security Bearer
|
||||
@@ -363,15 +363,15 @@ func (h *TenantMemberHandler) RemoveMember(c *gin.Context) {
|
||||
}
|
||||
|
||||
// LeaveTenant godoc
|
||||
// @Summary 退出当前租户
|
||||
// @Description 调用方主动退出当前租户。等价于以自己的 user_id 调 RemoveMember,
|
||||
// @Summary 退出当前空间
|
||||
// @Description 调用方主动退出当前空间。等价于以自己的 user_id 调 RemoveMember,
|
||||
//
|
||||
// 但不需要 Owner 权限——非 Owner 也可以自助离开。最后一位 Owner 仍然不能离开
|
||||
// (需先把其他成员提升为 Owner),由服务层 ErrLastOwner 拦截。
|
||||
//
|
||||
// @Tags 租户成员
|
||||
// @Tags 空间成员
|
||||
// @Produce json
|
||||
// @Param id path string true "租户 ID"
|
||||
// @Param id path string true "空间 ID"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Security Bearer
|
||||
// @Router /tenants/{id}/leave [post]
|
||||
@@ -390,13 +390,13 @@ func (h *TenantMemberHandler) LeaveTenant(c *gin.Context) {
|
||||
if err := h.memberService.RemoveMember(ctx, caller, tenantID); err != nil {
|
||||
switch {
|
||||
case errors.Is(err, service.ErrMembershipNotFound):
|
||||
c.Error(apperrors.NewNotFoundError("you are not a member of this tenant"))
|
||||
c.Error(apperrors.NewNotFoundError("you are not a member of this workspace"))
|
||||
case errors.Is(err, service.ErrLastOwner):
|
||||
c.Error(apperrors.NewConflictError(err.Error()))
|
||||
default:
|
||||
logger.Errorf(ctx, "LeaveTenant failed: user=%s tenant=%d err=%v",
|
||||
caller, tenantID, err)
|
||||
c.Error(apperrors.NewInternalServerError("failed to leave tenant").WithDetails(err.Error()))
|
||||
c.Error(apperrors.NewInternalServerError("failed to leave workspace").WithDetails(err.Error()))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user