From bc0c5d4fcb915e60f235c90a4ef905cb635db573 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Thu, 6 Jan 2022 19:59:13 +0800 Subject: [PATCH] Refactor code --- .../db/mysql_model/im_mysql_model/user_black_list_model.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go b/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go index 1c7bda90c..cd95aaa95 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go +++ b/pkg/common/db/mysql_model/im_mysql_model/user_black_list_model.go @@ -2,6 +2,7 @@ package im_mysql_model import ( "Open_IM/pkg/common/db" + "Open_IM/pkg/utils" "time" ) @@ -39,9 +40,8 @@ func RemoveBlackList(ownerUserID, blockUserID string) error { if err != nil { return err } - - err = dbConn.Table("blacks").Where("owner_user_id=? and block_user_id=?", ownerUserID, blockUserID).Delete(&db.Black{}).Error - return err + black := db.Black{OwnerUserID: ownerUserID, BlockUserID: blockUserID} + return utils.Wrap(dbConn.Delete(&black).Error, "RemoveBlackList failed") } func GetBlackListByUserID(ownerUserID string) ([]db.Black, error) {