优化
This commit is contained in:
@@ -35,7 +35,23 @@ func (r *auditRecorderRepo) CreateError(ctx context.Context, v *biz.ErrorRecord)
|
||||
return r.data.gormDB.WithContext(ctx).Create(&errorRecordPO{Form: v.Form, Info: v.Info, Level: v.Level, RequestID: v.RequestID, TraceID: v.TraceID, Solution: v.Solution, Status: v.Status}).Error
|
||||
}
|
||||
func (r *auditQueryRepo) UpdateError(ctx context.Context, v *biz.ErrorRecord) error {
|
||||
return r.data.gormDB.WithContext(ctx).Model(&errorRecordPO{}).Where("id = ?", v.ID).Updates(map[string]any{"form": v.Form, "info": v.Info, "level": v.Level, "solution": v.Solution, "status": v.Status}).Error
|
||||
updates := make(map[string]any, 5)
|
||||
if v.Form != "" {
|
||||
updates["form"] = v.Form
|
||||
}
|
||||
if v.Info != "" {
|
||||
updates["info"] = v.Info
|
||||
}
|
||||
if v.Level != "" {
|
||||
updates["level"] = v.Level
|
||||
}
|
||||
if v.Solution != "" {
|
||||
updates["solution"] = v.Solution
|
||||
}
|
||||
if v.Status != "" {
|
||||
updates["status"] = v.Status
|
||||
}
|
||||
return r.data.gormDB.WithContext(ctx).Model(&errorRecordPO{}).Where("id = ?", v.ID).Updates(updates).Error
|
||||
}
|
||||
func (r *auditQueryRepo) DeleteErrors(ctx context.Context, ids []uint) error {
|
||||
return r.data.gormDB.WithContext(ctx).Delete(&errorRecordPO{}, ids).Error
|
||||
|
||||
Reference in New Issue
Block a user