第 5 阶段:纠纷、通知与后台-2

This commit is contained in:
yml
2026-05-22 16:50:33 +08:00
parent 99f9df7bcd
commit aee3455e9a
22 changed files with 519 additions and 36 deletions
@@ -28,9 +28,9 @@ func (h *Handler) List(c *gin.Context) {
}
func (h *Handler) Update(c *gin.Context) {
userID, ok := currentUserID(c)
adminID, ok := currentAdminID(c)
if !ok {
response.Unauthorized(c, "缺少用户上下文")
response.Unauthorized(c, "缺少管理员上下文")
return
}
key := c.Param("key")
@@ -39,7 +39,7 @@ func (h *Handler) Update(c *gin.Context) {
response.BadRequest(c, "配置值不能为空")
return
}
item, err := h.service.Update(userID, key, req, AuditMeta{
item, err := h.service.Update(adminID, key, req, AuditMeta{
IP: c.ClientIP(),
UserAgent: c.GetHeader("User-Agent"),
})
@@ -50,13 +50,13 @@ func (h *Handler) Update(c *gin.Context) {
response.OK(c, item)
}
func currentUserID(c *gin.Context) (uint64, bool) {
value, ok := c.Get(middleware.ContextUserID)
func currentAdminID(c *gin.Context) (uint64, bool) {
value, ok := c.Get(middleware.ContextAdminID)
if !ok {
return 0, false
}
userID, ok := value.(uint64)
return userID, ok
adminID, ok := value.(uint64)
return adminID, ok
}
func writeConfigError(c *gin.Context, err error) {