Documentation
¶
Index ¶
- func EnsureDefaultCategory(ctx *config.Context, uid, spaceID string) error
- func EnsureProjectSidebarSection(ctx *config.Context, uid, spaceID, projectID string) error
- func HideProjectSidebarSection(ctx *config.Context, uid, spaceID, projectID string) error
- type Category
- type CategoryModel
- type SidebarSectionModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDefaultCategory ¶
EnsureDefaultCategory 为 (uid, spaceID) 组合幂等地确保默认分类存在。
背景(GH octo-server#1228):Phase 1 遗漏 — 创建 space / 加入 space 时未自动创建默认 分类,导致新建空间 GET /v1/spaces/{id}/categories 返回 [],前端无法渲染会话列表。
并发安全:依赖表 group_category 上的唯一索引 uk_uid_space_is_default,insertDefaultCategory 使用 INSERT IGNORE,多次调用 / 并发调用均安全。
调用方应将其视为非关键路径(catch error 后以 warn 记录、不中断业务),list 端还有 兜底补偿;因此本函数不包装 transaction,直接调用 db 层。
func EnsureProjectSidebarSection ¶ added in v1.19.0
EnsureProjectSidebarSection is the best-effort hook registered into modules/project. It only creates a personal ordering entry; the sidebar read predicate remains the authority for visibility and requires an active Project seat. A pin hook must not be used to widen that authorization boundary.
func HideProjectSidebarSection ¶ added in v1.19.0
HideProjectSidebarSection records an explicit unpin without deleting the ordering row. Re-pinning can therefore restore the Project at its previous position, while status=2 keeps it out of the shared section order.
Types ¶
type CategoryModel ¶
type CategoryModel struct {
CategoryID string
SpaceID string
UID string
Name string
Sort int
Status int
IsDefault *int
db.BaseModel
}
CategoryModel 群组类别(用户个人视图)
type SidebarSectionModel ¶ added in v1.19.0
type SidebarSectionModel struct {
ID int64
UID string
SpaceID string
SectionType int
RefID string
Sort int
Status int
CreatedAt time.Time
UpdatedAt time.Time
}
SidebarSectionModel is the single per-user order for category and Project entries in one Space. The timestamps deliberately stay application-written UTC values; see the migration for why MySQL timestamp defaults are forbidden here.