完善日志和审计链路
This commit is contained in:
@@ -110,13 +110,21 @@ func (h *Handler) adminAction(c *gin.Context, fn func(uint64, uint64, AdminActio
|
||||
response.BadRequest(c, "操作原因不能为空")
|
||||
return
|
||||
}
|
||||
if err := fn(adminID, id, req, AuditMeta{IP: c.ClientIP(), UserAgent: c.GetHeader("User-Agent")}); err != nil {
|
||||
if err := fn(adminID, id, req, auditMeta(c)); err != nil {
|
||||
writeOrderError(c, err)
|
||||
return
|
||||
}
|
||||
response.OK(c, okData)
|
||||
}
|
||||
|
||||
func auditMeta(c *gin.Context) AuditMeta {
|
||||
return AuditMeta{
|
||||
IP: c.ClientIP(),
|
||||
UserAgent: c.GetHeader("User-Agent"),
|
||||
RequestID: middleware.GetRequestID(c),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Handler) Detail(c *gin.Context) {
|
||||
userID, ok := currentUserID(c)
|
||||
if !ok {
|
||||
@@ -375,7 +383,6 @@ func parseID(c *gin.Context) (uint64, bool) {
|
||||
}
|
||||
|
||||
func writeOrderError(c *gin.Context, err error) {
|
||||
println("DEBUG ORDER ERROR:", err.Error())
|
||||
switch {
|
||||
case errors.Is(err, ErrDependencyUnavailable):
|
||||
response.ServiceUnavailable(c, "数据库未连接")
|
||||
|
||||
Reference in New Issue
Block a user