fix: 修复客服权限与收件箱配置问题

This commit is contained in:
Rogee
2026-08-08 19:52:18 +08:00
parent dc2a6577bf
commit 518f9c5d6b
20 changed files with 385 additions and 70 deletions
@@ -63,7 +63,20 @@ func (h *InboxHandler) List(c *gin.Context) {
perPage := getPageSize(c)
offset := (page - 1) * perPage
inboxes, _, svcErr := h.svc.ListByAccount(c.Request.Context(), accountID, offset, perPage)
var (
inboxes []model.Inbox
svcErr error
)
if getRole(c) == "administrator" {
inboxes, _, svcErr = h.svc.ListByAccount(c.Request.Context(), accountID, offset, perPage)
} else {
userID := getUserID(c)
if userID == 0 {
response.AbortWithStatusError(c, http.StatusUnauthorized, response.ErrUnauthorized, "current user is required")
return
}
inboxes, _, svcErr = h.svc.ListByAccountAndUser(c.Request.Context(), accountID, userID, offset, perPage)
}
if svcErr != nil {
c.JSON(http.StatusUnprocessableEntity, gin.H{"error": "failed to list inboxes"})
return