Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
*.log
*.out
*.http
.DS_Store
.DS_Store
treehole
treehole.exe
2 changes: 1 addition & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3822,7 +3822,7 @@ const docTemplate = `{
}
},
"frozen": {
"description": "冻结帖子,如果冻结则发帖不会更新 UpdatedAt",
"description": "冻结状态,仅管理员可见",
"type": "boolean"
},
"good": {
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3815,7 +3815,7 @@
}
},
"frozen": {
"description": "冻结帖子,如果冻结则发帖不会更新 UpdatedAt",
"description": "冻结状态,仅管理员可见",
"type": "boolean"
},
"good": {
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ definitions:
type: array
type: object
frozen:
description: 冻结帖子,如果冻结则发帖不会更新 UpdatedAt
description: 冻结状态,仅管理员可见
type: boolean
good:
type: boolean
Expand Down
14 changes: 13 additions & 1 deletion models/hole.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Hole struct {
Locked bool `json:"locked" gorm:"not null;default:false"`

// 冻结帖子,如果冻结则发帖不会更新 UpdatedAt
Frozen bool `json:"frozen" gorm:"not null;default:false"`
Frozen bool `json:"-" gorm:"not null;default:false"`

Good bool `json:"good" gorm:"not null;default:false"`

Expand Down Expand Up @@ -73,6 +73,9 @@ type Hole struct {
// 兼容旧版 id
HoleID int `json:"hole_id" gorm:"-:all"`

// 冻结状态,仅管理员可见
FrozenFrontend *bool `json:"frozen,omitempty" gorm:"-:all"`

// 返回给前端的楼层列表,包括首楼、尾楼和预加载的前 n 个楼层
HoleFloor struct {
FirstFloor *Floor `json:"first_floor"` // 首楼
Expand Down Expand Up @@ -274,6 +277,15 @@ func (holes Holes) Preprocess(c *fiber.Ctx) error {
return err
}

// Set FrozenFrontend field for admin users only
// If there's an error getting user info, silently skip (safe default: don't show frozen field)
user, err := GetCurrLoginUser(c)
if err == nil && user.IsAdmin {
for _, hole := range holes {
hole.FrozenFrontend = &hole.Frozen
}
}

//user, err := GetUser(c)
//if err != nil {
// return err
Expand Down
Loading